mascot-vis 4.3.1 → 4.4.1

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.
@@ -1,4 +1,4 @@
1
- // version: 4.3.1
2
- "use strict";function t(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function e(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function n(n){let i,s,o;function a(t,e,n=0,r=t.length){if(n<r){if(0!==i(e,e))return r;do{const i=n+r>>>1;s(t[i],e)<0?n=i+1:r=i}while(n<r)}return n}return 2!==n.length?(i=t,s=(e,r)=>t(n(e),r),o=(t,e)=>n(t)-e):(i=n===t||n===e?n:r,s=n,o=n),{left:a,center:function(t,e,n=0,r=t.length){const i=a(t,e,n,r-1);return i>n&&o(t[i-1],e)>-o(t[i],e)?i-1:i},right:function(t,e,n=0,r=t.length){if(n<r){if(0!==i(e,e))return r;do{const i=n+r>>>1;s(t[i],e)<=0?n=i+1:r=i}while(n<r)}return n}}}function r(){return 0}function i(t){return null===t?NaN:+t}const s=n(t),o=s.right,a=s.left,l=n(i).center;const c=h(p),u=h(function(t){const e=p(t);return(t,n,r,i,s)=>{e(t,n,(r<<=2)+0,(i<<=2)+0,s<<=2),e(t,n,r+1,i+1,s),e(t,n,r+2,i+2,s),e(t,n,r+3,i+3,s)}});function h(t){return function(e,n,r=n){if(!((n=+n)>=0))throw new RangeError("invalid rx");if(!((r=+r)>=0))throw new RangeError("invalid ry");let{data:i,width:s,height:o}=e;if(!((s=Math.floor(s))>=0))throw new RangeError("invalid width");if(!((o=Math.floor(void 0!==o?o:i.length/s))>=0))throw new RangeError("invalid height");if(!s||!o||!n&&!r)return e;const a=n&&t(n),l=r&&t(r),c=i.slice();return a&&l?(f(a,c,i,s,o),f(a,i,c,s,o),f(a,c,i,s,o),d(l,i,c,s,o),d(l,c,i,s,o),d(l,i,c,s,o)):a?(f(a,i,c,s,o),f(a,c,i,s,o),f(a,i,c,s,o)):l&&(d(l,i,c,s,o),d(l,c,i,s,o),d(l,i,c,s,o)),e}}function f(t,e,n,r,i){for(let s=0,o=r*i;s<o;)t(e,n,s,s+=r,1)}function d(t,e,n,r,i){for(let s=0,o=r*i;s<r;++s)t(e,n,s,s+o,r)}function p(t){const e=Math.floor(t);if(e===t)return function(t){const e=2*t+1;return(n,r,i,s,o)=>{if(!((s-=o)>=i))return;let a=t*r[i];const l=o*t;for(let t=i,e=i+l;t<e;t+=o)a+=r[Math.min(s,t)];for(let t=i,c=s;t<=c;t+=o)a+=r[Math.min(s,t+l)],n[t]=a/e,a-=r[Math.max(i,t-l)]}}(t);const n=t-e,r=2*t+1;return(t,i,s,o,a)=>{if(!((o-=a)>=s))return;let l=e*i[s];const c=a*e,u=c+a;for(let t=s,e=s+c;t<e;t+=a)l+=i[Math.min(o,t)];for(let e=s,h=o;e<=h;e+=a)l+=i[Math.min(o,e+c)],t[e]=(l+n*(i[Math.max(s,e-u)]+i[Math.min(o,e+u)]))/r,l-=i[Math.max(s,e-c)]}}function _(t,e){let n=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&++n;else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(i=+i)>=i&&++n}return n}function g(t){return 0|t.length}function y(t){return!(t>0)}function m(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function b(t,e){let n,r=0,i=0,s=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(n=e-i,i+=n/++r,s+=n*(e-i));else{let o=-1;for(let a of t)null!=(a=e(a,++o,t))&&(a=+a)>=a&&(n=a-i,i+=n/++r,s+=n*(a-i))}if(r>1)return s/(r-1)}function v(t,e){const n=b(t,e);return n?Math.sqrt(n):n}function x(t,e){let n,r;if(void 0===e)for(const e of t)null!=e&&(void 0===n?e>=e&&(n=r=e):(n>e&&(n=e),r<e&&(r=e)));else{let i=-1;for(let s of t)null!=(s=e(s,++i,t))&&(void 0===n?s>=s&&(n=r=s):(n>s&&(n=s),r<s&&(r=s)))}return[n,r]}class w{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const e=this._partials;let n=0;for(let r=0;r<this._n&&r<32;r++){const i=e[r],s=t+i,o=Math.abs(t)<Math.abs(i)?t-(s-i):i-(s-t);o&&(e[n++]=o),t=s}return e[n]=t,this._n=n+1,this}valueOf(){const t=this._partials;let e,n,r,i=this._n,s=0;if(i>0){for(s=t[--i];i>0&&(e=s,n=t[--i],s=e+n,r=n-(s-e),!r););i>0&&(r<0&&t[i-1]<0||r>0&&t[i-1]>0)&&(n=2*r,e=s+n,n==e-s&&(s=e))}return s}}class E extends Map{constructor(t,e=k){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(S(this,t))}has(t){return super.has(S(this,t))}set(t,e){return super.set(T(this,t),e)}delete(t){return super.delete(C(this,t))}}class A extends Set{constructor(t,e=k){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const e of t)this.add(e)}has(t){return super.has(S(this,t))}add(t){return super.add(T(this,t))}delete(t){return super.delete(C(this,t))}}function S({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function T({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function C({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function k(t){return null!==t&&"object"==typeof t?t.valueOf():t}function R(t){return t}function M(t,...e){return D(t,R,R,e)}function O(t,...e){return D(t,Array.from,R,e)}function N(t,e){for(let n=1,r=e.length;n<r;++n)t=t.flatMap(t=>t.pop().map(([e,n])=>[...t,e,n]));return t}function I(t,e,...n){return D(t,R,e,n)}function P(t,e,...n){return D(t,Array.from,e,n)}function L(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function D(t,e,n,r){return function t(i,s){if(s>=r.length)return n(i);const o=new E,a=r[s++];let l=-1;for(const t of i){const e=a(t,++l,i),n=o.get(e);n?n.push(t):o.set(e,[t])}for(const[e,n]of o)o.set(e,t(n,s));return e(o)}(t,0)}function V(t,e){return Array.from(e,e=>t[e])}function B(t,...e){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");t=Array.from(t);let[n]=e;if(n&&2!==n.length||e.length>1){const r=Uint32Array.from(t,(t,e)=>e);return e.length>1?(e=e.map(e=>t.map(e)),r.sort((t,n)=>{for(const r of e){const e=G(r[t],r[n]);if(e)return e}})):(n=t.map(n),r.sort((t,e)=>G(n[t],n[e]))),V(t,r)}return t.sort(z(n))}function z(e=t){if(e===t)return G;if("function"!=typeof e)throw new TypeError("compare is not a function");return(t,n)=>{const r=e(t,n);return r||0===r?r:(0===e(n,n))-(0===e(t,t))}}function G(t,e){return(null==t||!(t>=t))-(null==e||!(e>=e))||(t<e?-1:t>e?1:0)}var F=Array.prototype.slice;function j(t){return()=>t}const U=Math.sqrt(50),Y=Math.sqrt(10),H=Math.sqrt(2);function W(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),o=s>=U?10:s>=Y?5:s>=H?2:1;let a,l,c;return i<0?(c=Math.pow(10,-i)/o,a=Math.round(t*c),l=Math.round(e*c),a/c<t&&++a,l/c>e&&--l,c=-c):(c=Math.pow(10,i)*o,a=Math.round(t/c),l=Math.round(e/c),a*c<t&&++a,l*c>e&&--l),l<a&&.5<=n&&n<2?W(t,e,2*n):[a,l,c]}function q(t,e,n){if(!((n=+n)>0))return[];if((t=+t)===(e=+e))return[t];const r=e<t,[i,s,o]=r?W(e,t,n):W(t,e,n);if(!(s>=i))return[];const a=s-i+1,l=new Array(a);if(r)if(o<0)for(let t=0;t<a;++t)l[t]=(s-t)/-o;else for(let t=0;t<a;++t)l[t]=(s-t)*o;else if(o<0)for(let t=0;t<a;++t)l[t]=(i+t)/-o;else for(let t=0;t<a;++t)l[t]=(i+t)*o;return l}function $(t,e,n){return W(t=+t,e=+e,n=+n)[2]}function X(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?$(e,t,n):$(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function K(t,e,n){let r;for(;;){const i=$(t,e,n);if(i===r||0===i||!isFinite(i))return[t,e];i>0?(t=Math.floor(t/i)*i,e=Math.ceil(e/i)*i):i<0&&(t=Math.ceil(t*i)/i,e=Math.floor(e*i)/i),r=i}}function Z(t){return Math.max(1,Math.ceil(Math.log(_(t))/Math.LN2)+1)}function J(){var t=R,e=x,n=Z;function r(r){Array.isArray(r)||(r=Array.from(r));var i,s,a,l=r.length,c=new Array(l);for(i=0;i<l;++i)c[i]=t(r[i],i,r);var u=e(c),h=u[0],f=u[1],d=n(c,h,f);if(!Array.isArray(d)){const t=f,n=+d;if(e===x&&([h,f]=K(h,f,n)),(d=q(h,f,n))[0]<=h&&(a=$(h,f,n)),d[d.length-1]>=f)if(t>=f&&e===x){const t=$(h,f,n);isFinite(t)&&(t>0?f=(Math.floor(f/t)+1)*t:t<0&&(f=(Math.ceil(f*-t)+1)/-t))}else d.pop()}for(var p=d.length,_=0,g=p;d[_]<=h;)++_;for(;d[g-1]>f;)--g;(_||g<p)&&(d=d.slice(_,g),p=g-_);var y,m=new Array(p+1);for(i=0;i<=p;++i)(y=m[i]=[]).x0=i>0?d[i-1]:h,y.x1=i<p?d[i]:f;if(isFinite(a)){if(a>0)for(i=0;i<l;++i)null!=(s=c[i])&&h<=s&&s<=f&&m[Math.min(p,Math.floor((s-h)/a))].push(r[i]);else if(a<0)for(i=0;i<l;++i)if(null!=(s=c[i])&&h<=s&&s<=f){const t=Math.floor((h-s)*a);m[Math.min(p,t+(d[t]<=s))].push(r[i])}}else for(i=0;i<l;++i)null!=(s=c[i])&&h<=s&&s<=f&&m[o(d,s,0,p)].push(r[i]);return m}return r.value=function(e){return arguments.length?(t="function"==typeof e?e:j(e),r):t},r.domain=function(t){return arguments.length?(e="function"==typeof t?t:j([t[0],t[1]]),r):e},r.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:j(Array.isArray(t)?F.call(t):t),r):n},r}function Q(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n<e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n<i||void 0===n&&i>=i)&&(n=i)}return n}function tt(t,e){let n,r=-1,i=-1;if(void 0===e)for(const e of t)++i,null!=e&&(n<e||void 0===n&&e>=e)&&(n=e,r=i);else for(let s of t)null!=(s=e(s,++i,t))&&(n<s||void 0===n&&s>=s)&&(n=s,r=i);return r}function et(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n>e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n>i||void 0===n&&i>=i)&&(n=i)}return n}function nt(t,e){let n,r=-1,i=-1;if(void 0===e)for(const e of t)++i,null!=e&&(n>e||void 0===n&&e>=e)&&(n=e,r=i);else for(let s of t)null!=(s=e(s,++i,t))&&(n>s||void 0===n&&s>=s)&&(n=s,r=i);return r}function rt(t,e,n=0,r=1/0,i){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(i=void 0===i?G:z(i);r>n;){if(r-n>600){const s=r-n+1,o=e-n+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);rt(t,e,Math.max(n,Math.floor(e-o*l/s+c)),Math.min(r,Math.floor(e+(s-o)*l/s+c)),i)}const s=t[e];let o=n,a=r;for(it(t,n,e),i(t[r],s)>0&&it(t,n,r);o<a;){for(it(t,o,a),++o,--a;i(t[o],s)<0;)++o;for(;i(t[a],s)>0;)--a}0===i(t[n],s)?it(t,n,a):(++a,it(t,a,r)),a<=e&&(n=a+1),e<=a&&(r=a-1)}return t}function it(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function st(e,n=t){let r,i=!1;if(1===n.length){let s;for(const o of e){const e=n(o);(i?t(e,s)>0:0===t(e,e))&&(r=o,s=e,i=!0)}}else for(const t of e)(i?n(t,r)>0:0===n(t,t))&&(r=t,i=!0);return r}function ot(t,e,n){if(t=Float64Array.from(function*(t,e){if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(yield e);else{let n=-1;for(let r of t)null!=(r=e(r,++n,t))&&(r=+r)>=r&&(yield r)}}(t,n)),(r=t.length)&&!isNaN(e=+e)){if(e<=0||r<2)return et(t);if(e>=1)return Q(t);var r,i=(r-1)*e,s=Math.floor(i),o=Q(rt(t,s).subarray(0,s+1));return o+(et(t.subarray(s+1))-o)*(i-s)}}function at(t,e,n=i){if((r=t.length)&&!isNaN(e=+e)){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,s=(r-1)*e,o=Math.floor(s),a=+n(t[o],o,t);return a+(+n(t[o+1],o+1,t)-a)*(s-o)}}function lt(t,e,n=i){if(!isNaN(e=+e)){if(r=Float64Array.from(t,(e,r)=>i(n(t[r],r,t))),e<=0)return nt(r);if(e>=1)return tt(r);var r,s=Uint32Array.from(t,(t,e)=>e),o=r.length-1,a=Math.floor(o*e);return rt(s,a,0,o,(t,e)=>G(r[t],r[e])),(a=st(s.subarray(0,a+1),t=>r[t]))>=0?a:-1}}function ct(t,e){let n=0,r=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(++n,r+=e);else{let i=-1;for(let s of t)null!=(s=e(s,++i,t))&&(s=+s)>=s&&(++n,r+=s)}if(n)return r/n}function ut(t,e){return ot(t,.5,e)}function ht(t){return Array.from(function*(t){for(const e of t)yield*e}(t))}function ft(t,e){return[t,e]}function dt(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((e-t)/n)),s=new Array(i);++r<i;)s[r]=t+r*n;return s}function pt(e,n=t){if(1===n.length)return nt(e,n);let r,i=-1,s=-1;for(const t of e)++s,(i<0?0===n(t,t):n(t,r)<0)&&(r=t,i=s);return i}var _t=gt(Math.random);function gt(t){return function(e,n=0,r=e.length){let i=r-(n=+n);for(;i;){const r=t()*i--|0,s=e[i+n];e[i+n]=e[r+n],e[r+n]=s}return e}}function yt(t,e){let n=0;if(void 0===e)for(let e of t)(e=+e)&&(n+=e);else{let r=-1;for(let i of t)(i=+e(i,++r,t))&&(n+=i)}return n}function mt(t){if(!(i=t.length))return[];for(var e=-1,n=et(t,bt),r=new Array(n);++e<n;)for(var i,s=-1,o=r[e]=new Array(i);++s<i;)o[s]=t[s][e];return r}function bt(t){return t.length}function vt(t){return t instanceof A?t:new A(t)}function xt(t,e){const n=t[Symbol.iterator](),r=new Set;for(const t of e){const e=wt(t);if(r.has(e))continue;let i,s;for(;({value:i,done:s}=n.next());){if(s)return!1;const t=wt(i);if(r.add(t),Object.is(e,t))break}}return!0}function wt(t){return null!==t&&"object"==typeof t?t.valueOf():t}function Et(t){return t}var At=1e-6;function St(t){return"translate("+t+",0)"}function Tt(t){return"translate(0,"+t+")"}function Ct(t){return e=>+t(e)}function kt(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function Rt(){return!this.__axis}function Mt(t,e){var n=[],r=null,i=null,s=6,o=6,a=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,c=1===t||4===t?-1:1,u=4===t||2===t?"x":"y",h=1===t||3===t?St:Tt;function f(f){var d=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,p=null==i?e.tickFormat?e.tickFormat.apply(e,n):Et:i,_=Math.max(s,0)+a,g=e.range(),y=+g[0]+l,m=+g[g.length-1]+l,b=(e.bandwidth?kt:Ct)(e.copy(),l),v=f.selection?f.selection():f,x=v.selectAll(".domain").data([null]),w=v.selectAll(".tick").data(d,e).order(),E=w.exit(),A=w.enter().append("g").attr("class","tick"),S=w.select("line"),T=w.select("text");x=x.merge(x.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),w=w.merge(A),S=S.merge(A.append("line").attr("stroke","currentColor").attr(u+"2",c*s)),T=T.merge(A.append("text").attr("fill","currentColor").attr(u,c*_).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),f!==v&&(x=x.transition(f),w=w.transition(f),S=S.transition(f),T=T.transition(f),E=E.transition(f).attr("opacity",At).attr("transform",function(t){return isFinite(t=b(t))?h(t+l):this.getAttribute("transform")}),A.attr("opacity",At).attr("transform",function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:b(t))+l)})),E.remove(),x.attr("d",4===t||2===t?o?"M"+c*o+","+y+"H"+l+"V"+m+"H"+c*o:"M"+l+","+y+"V"+m:o?"M"+y+","+c*o+"V"+l+"H"+m+"V"+c*o:"M"+y+","+l+"H"+m),w.attr("opacity",1).attr("transform",function(t){return h(b(t)+l)}),S.attr(u+"2",c*s),T.attr(u,c*_).text(p),v.filter(Rt).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),v.each(function(){this.__axis=b})}return f.scale=function(t){return arguments.length?(e=t,f):e},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),f):n.slice()},f.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),f):r&&r.slice()},f.tickFormat=function(t){return arguments.length?(i=t,f):i},f.tickSize=function(t){return arguments.length?(s=o=+t,f):s},f.tickSizeInner=function(t){return arguments.length?(s=+t,f):s},f.tickSizeOuter=function(t){return arguments.length?(o=+t,f):o},f.tickPadding=function(t){return arguments.length?(a=+t,f):a},f.offset=function(t){return arguments.length?(l=+t,f):l},f}var Ot={value:()=>{}};function Nt(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new It(r)}function It(t){this._=t}function Pt(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Lt(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Ot,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}It.prototype=Nt.prototype={constructor:It,on:function(t,e){var n,r,i=this._,s=(r=i,(t+"").trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),o=-1,a=s.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o<a;)if(n=(t=s[o]).type)i[n]=Lt(i[n],t.name,e);else if(null==e)for(n in i)i[n]=Lt(i[n],t.name,null);return this}for(;++o<a;)if((n=(t=s[o]).type)&&(n=Pt(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new It(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),s=0;s<n;++s)i[s]=arguments[s+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=0,n=(r=this._[t]).length;s<n;++s)r[s].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,s=r.length;i<s;++i)r[i].value.apply(e,n)}};var Dt="http://www.w3.org/1999/xhtml",Vt={svg:"http://www.w3.org/2000/svg",xhtml:Dt,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Bt(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Vt.hasOwnProperty(e)?{space:Vt[e],local:t}:t}function zt(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Dt&&e.documentElement.namespaceURI===Dt?e.createElement(t):e.createElementNS(n,t)}}function Gt(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ft(t){var e=Bt(t);return(e.local?Gt:zt)(e)}function jt(){}function Ut(t){return null==t?jt:function(){return this.querySelector(t)}}function Yt(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function Ht(){return[]}function Wt(t){return null==t?Ht:function(){return this.querySelectorAll(t)}}function qt(t){return function(){return this.matches(t)}}function $t(t){return function(e){return e.matches(t)}}var Xt=Array.prototype.find;function Kt(){return this.firstElementChild}var Zt=Array.prototype.filter;function Jt(){return Array.from(this.children)}function Qt(t){return new Array(t.length)}function te(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function ee(t,e,n,r,i,s){for(var o,a=0,l=e.length,c=s.length;a<c;++a)(o=e[a])?(o.__data__=s[a],r[a]=o):n[a]=new te(t,s[a]);for(;a<l;++a)(o=e[a])&&(i[a]=o)}function ne(t,e,n,r,i,s,o){var a,l,c,u=new Map,h=e.length,f=s.length,d=new Array(h);for(a=0;a<h;++a)(l=e[a])&&(d[a]=c=o.call(l,l.__data__,a,e)+"",u.has(c)?i[a]=l:u.set(c,l));for(a=0;a<f;++a)c=o.call(t,s[a],a,s)+"",(l=u.get(c))?(r[a]=l,l.__data__=s[a],u.delete(c)):n[a]=new te(t,s[a]);for(a=0;a<h;++a)(l=e[a])&&u.get(d[a])===l&&(i[a]=l)}function re(t){return t.__data__}function ie(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function se(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function oe(t){return function(){this.removeAttribute(t)}}function ae(t){return function(){this.removeAttributeNS(t.space,t.local)}}function le(t,e){return function(){this.setAttribute(t,e)}}function ce(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ue(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function he(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function fe(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function de(t){return function(){this.style.removeProperty(t)}}function pe(t,e,n){return function(){this.style.setProperty(t,e,n)}}function _e(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ge(t,e){return t.style.getPropertyValue(e)||fe(t).getComputedStyle(t,null).getPropertyValue(e)}function ye(t){return function(){delete this[t]}}function me(t,e){return function(){this[t]=e}}function be(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function ve(t){return t.trim().split(/^|\s+/)}function xe(t){return t.classList||new we(t)}function we(t){this._node=t,this._names=ve(t.getAttribute("class")||"")}function Ee(t,e){for(var n=xe(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function Ae(t,e){for(var n=xe(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function Se(t){return function(){Ee(this,t)}}function Te(t){return function(){Ae(this,t)}}function Ce(t,e){return function(){(e.apply(this,arguments)?Ee:Ae)(this,t)}}function ke(){this.textContent=""}function Re(t){return function(){this.textContent=t}}function Me(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Oe(){this.innerHTML=""}function Ne(t){return function(){this.innerHTML=t}}function Ie(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function Pe(){this.nextSibling&&this.parentNode.appendChild(this)}function Le(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function De(){return null}function Ve(){var t=this.parentNode;t&&t.removeChild(this)}function Be(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function ze(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ge(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,s=e.length;r<s;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function Fe(t,e,n){return function(){var r,i=this.__on,s=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),void(r.value=e);this.addEventListener(t.type,s,n),r={type:t.type,name:t.name,value:e,listener:s,options:n},i?i.push(r):this.__on=[r]}}function je(t,e,n){var r=fe(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Ue(t,e){return function(){return je(this,t,e)}}function Ye(t,e){return function(){return je(this,t,e.apply(this,arguments))}}te.prototype={constructor:te,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)}},we.prototype={add:function(t){this._names.indexOf(t)<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}};var He=[null];function We(t,e){this._groups=t,this._parents=e}function qe(){return new We([[document.documentElement]],He)}function $e(t){return"string"==typeof t?new We([[document.querySelector(t)]],[document.documentElement]):new We([[t]],He)}We.prototype=qe.prototype={constructor:We,select:function(t){"function"!=typeof t&&(t=Ut(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s,o,a=e[i],l=a.length,c=r[i]=new Array(l),u=0;u<l;++u)(s=a[u])&&(o=t.call(s,s.__data__,u,a))&&("__data__"in s&&(o.__data__=s.__data__),c[u]=o);return new We(r,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){return Yt(t.apply(this,arguments))}}(t):Wt(t);for(var e=this._groups,n=e.length,r=[],i=[],s=0;s<n;++s)for(var o,a=e[s],l=a.length,c=0;c<l;++c)(o=a[c])&&(r.push(t.call(o,o.__data__,c,a)),i.push(o));return new We(r,i)},selectChild:function(t){return this.select(null==t?Kt:function(t){return function(){return Xt.call(this.children,t)}}("function"==typeof t?t:$t(t)))},selectChildren:function(t){return this.selectAll(null==t?Jt:function(t){return function(){return Zt.call(this.children,t)}}("function"==typeof t?t:$t(t)))},filter:function(t){"function"!=typeof t&&(t=qt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s,o=e[i],a=o.length,l=r[i]=[],c=0;c<a;++c)(s=o[c])&&t.call(s,s.__data__,c,o)&&l.push(s);return new We(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,re);var n=e?ne:ee,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var s=i.length,o=new Array(s),a=new Array(s),l=new Array(s),c=0;c<s;++c){var u=r[c],h=i[c],f=h.length,d=ie(t.call(u,u&&u.__data__,c,r)),p=d.length,_=a[c]=new Array(p),g=o[c]=new Array(p);n(u,h,_,g,l[c]=new Array(f),d,e);for(var y,m,b=0,v=0;b<p;++b)if(y=_[b]){for(b>=v&&(v=b+1);!(m=g[v])&&++v<p;);y._next=m||null}}return(o=new We(o,r))._enter=a,o._exit=l,o},enter:function(){return new We(this._enter||this._groups.map(Qt),this._parents)},exit:function(){return new We(this._exit||this._groups.map(Qt),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,s=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?s.remove():n(s),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,s=r.length,o=Math.min(i,s),a=new Array(i),l=0;l<o;++l)for(var c,u=n[l],h=r[l],f=u.length,d=a[l]=new Array(f),p=0;p<f;++p)(c=u[p]||h[p])&&(d[p]=c);for(;l<i;++l)a[l]=n[l];return new We(a,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],s=i.length-1,o=i[s];--s>=0;)(r=i[s])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=se);for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var o,a=n[s],l=a.length,c=i[s]=new Array(l),u=0;u<l;++u)(o=a[u])&&(c[u]=o);c.sort(e)}return new We(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,s=r.length;i<s;++i){var o=r[i];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,s=e[n],o=0,a=s.length;o<a;++o)(i=s[o])&&t.call(i,i.__data__,o,s);return this},attr:function(t,e){var n=Bt(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?ae:oe:"function"==typeof e?n.local?he:ue:n.local?ce:le)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?de:"function"==typeof e?_e:pe)(t,e,null==n?"":n)):ge(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?ye:"function"==typeof e?be:me)(t,e)):this.node()[t]},classed:function(t,e){var n=ve(t+"");if(arguments.length<2){for(var r=xe(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?Ce:e?Se:Te)(n,e))},text:function(t){return arguments.length?this.each(null==t?ke:("function"==typeof t?Me:Re)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Oe:("function"==typeof t?Ie:Ne)(t)):this.node().innerHTML},raise:function(){return this.each(Pe)},lower:function(){return this.each(Le)},append:function(t){var e="function"==typeof t?t:Ft(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var n="function"==typeof t?t:Ft(t),r=null==e?De:"function"==typeof e?e:Ut(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(Ve)},clone:function(t){return this.select(t?ze:Be)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,s=function(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),o=s.length;if(!(arguments.length<2)){for(a=e?Fe:Ge,r=0;r<o;++r)this.each(a(s[r],e,n));return this}var a=this.node().__on;if(a)for(var l,c=0,u=a.length;c<u;++c)for(r=0,l=a[c];r<o;++r)if((i=s[r]).type===l.type&&i.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?Ye:Ue)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],s=0,o=i.length;s<o;++s)(r=i[s])&&(yield r)}};var Xe=0;function Ke(){return new Ze}function Ze(){this._="@"+(++Xe).toString(36)}function Je(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Qe(t,e){if(t=Je(t),void 0===e&&(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())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}Ze.prototype=Ke.prototype={constructor:Ze,get:function(t){for(var e=this._;!(e in t);)if(!(t=t.parentNode))return;return t[e]},set:function(t,e){return t[this._]=e},remove:function(t){return this._ in t&&delete t[this._]},toString:function(){return this._}};const tn={passive:!1},en={capture:!0,passive:!1};function nn(t){t.stopImmediatePropagation()}function rn(t){t.preventDefault(),t.stopImmediatePropagation()}function sn(t){var e=t.document.documentElement,n=$e(t).on("dragstart.drag",rn,en);"onselectstart"in e?n.on("selectstart.drag",rn,en):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function on(t,e){var n=t.document.documentElement,r=$e(t).on("dragstart.drag",null);e&&(r.on("click.drag",rn,en),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var an=t=>()=>t;function ln(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:s,x:o,y:a,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:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function cn(t){return!t.ctrlKey&&!t.button}function un(){return this.parentNode}function hn(t,e){return null==e?{x:t.x,y:t.y}:e}function fn(){return navigator.maxTouchPoints||"ontouchstart"in this}function dn(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function pn(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function _n(){}ln.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var gn=.7,yn=1/gn,mn="\\s*([+-]?\\d+)\\s*",bn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",vn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xn=/^#([0-9a-f]{3,8})$/,wn=new RegExp(`^rgb\\(${mn},${mn},${mn}\\)$`),En=new RegExp(`^rgb\\(${vn},${vn},${vn}\\)$`),An=new RegExp(`^rgba\\(${mn},${mn},${mn},${bn}\\)$`),Sn=new RegExp(`^rgba\\(${vn},${vn},${vn},${bn}\\)$`),Tn=new RegExp(`^hsl\\(${bn},${vn},${vn}\\)$`),Cn=new RegExp(`^hsla\\(${bn},${vn},${vn},${bn}\\)$`),kn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Rn(){return this.rgb().formatHex()}function Mn(){return this.rgb().formatRgb()}function On(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=xn.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Nn(e):3===n?new Dn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?In(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?In(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=wn.exec(t))?new Dn(e[1],e[2],e[3],1):(e=En.exec(t))?new Dn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=An.exec(t))?In(e[1],e[2],e[3],e[4]):(e=Sn.exec(t))?In(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Tn.exec(t))?jn(e[1],e[2]/100,e[3]/100,1):(e=Cn.exec(t))?jn(e[1],e[2]/100,e[3]/100,e[4]):kn.hasOwnProperty(t)?Nn(kn[t]):"transparent"===t?new Dn(NaN,NaN,NaN,0):null}function Nn(t){return new Dn(t>>16&255,t>>8&255,255&t,1)}function In(t,e,n,r){return r<=0&&(t=e=n=NaN),new Dn(t,e,n,r)}function Pn(t){return t instanceof _n||(t=On(t)),t?new Dn((t=t.rgb()).r,t.g,t.b,t.opacity):new Dn}function Ln(t,e,n,r){return 1===arguments.length?Pn(t):new Dn(t,e,n,null==r?1:r)}function Dn(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Vn(){return`#${Fn(this.r)}${Fn(this.g)}${Fn(this.b)}`}function Bn(){const t=zn(this.opacity);return`${1===t?"rgb(":"rgba("}${Gn(this.r)}, ${Gn(this.g)}, ${Gn(this.b)}${1===t?")":`, ${t})`}`}function zn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Gn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Fn(t){return((t=Gn(t))<16?"0":"")+t.toString(16)}function jn(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Hn(t,e,n,r)}function Un(t){if(t instanceof Hn)return new Hn(t.h,t.s,t.l,t.opacity);if(t instanceof _n||(t=On(t)),!t)return new Hn;if(t instanceof Hn)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=NaN,a=s-i,l=(s+i)/2;return a?(o=e===s?(n-r)/a+6*(n<r):n===s?(r-e)/a+2:(e-n)/a+4,a/=l<.5?s+i:2-s-i,o*=60):a=l>0&&l<1?0:o,new Hn(o,a,l,t.opacity)}function Yn(t,e,n,r){return 1===arguments.length?Un(t):new Hn(t,e,n,null==r?1:r)}function Hn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Wn(t){return(t=(t||0)%360)<0?t+360:t}function qn(t){return Math.max(0,Math.min(1,t||0))}function $n(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}dn(_n,On,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Rn,formatHex:Rn,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Un(this).formatHsl()},formatRgb:Mn,toString:Mn}),dn(Dn,Ln,pn(_n,{brighter(t){return t=null==t?yn:Math.pow(yn,t),new Dn(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?gn:Math.pow(gn,t),new Dn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dn(Gn(this.r),Gn(this.g),Gn(this.b),zn(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:Vn,formatHex:Vn,formatHex8:function(){return`#${Fn(this.r)}${Fn(this.g)}${Fn(this.b)}${Fn(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Bn,toString:Bn})),dn(Hn,Yn,pn(_n,{brighter(t){return t=null==t?yn:Math.pow(yn,t),new Hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?gn:Math.pow(gn,t),new Hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Dn($n(t>=240?t-240:t+120,i,r),$n(t,i,r),$n(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Hn(Wn(this.h),qn(this.s),qn(this.l),zn(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=zn(this.opacity);return`${1===t?"hsl(":"hsla("}${Wn(this.h)}, ${100*qn(this.s)}%, ${100*qn(this.l)}%${1===t?")":`, ${t})`}`}}));const Xn=Math.PI/180,Kn=180/Math.PI,Zn=.96422,Jn=.82521,Qn=4/29,tr=6/29,er=3*tr*tr,nr=tr*tr*tr;function rr(t){if(t instanceof sr)return new sr(t.l,t.a,t.b,t.opacity);if(t instanceof fr)return dr(t);t instanceof Dn||(t=Pn(t));var e,n,r=cr(t.r),i=cr(t.g),s=cr(t.b),o=or((.2225045*r+.7168786*i+.0606169*s)/1);return r===i&&i===s?e=n=o:(e=or((.4360747*r+.3850649*i+.1430804*s)/Zn),n=or((.0139322*r+.0971045*i+.7141733*s)/Jn)),new sr(116*o-16,500*(e-o),200*(o-n),t.opacity)}function ir(t,e,n,r){return 1===arguments.length?rr(t):new sr(t,e,n,null==r?1:r)}function sr(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}function or(t){return t>nr?Math.pow(t,1/3):t/er+Qn}function ar(t){return t>tr?t*t*t:er*(t-Qn)}function lr(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function cr(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ur(t){if(t instanceof fr)return new fr(t.h,t.c,t.l,t.opacity);if(t instanceof sr||(t=rr(t)),0===t.a&&0===t.b)return new fr(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*Kn;return new fr(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function hr(t,e,n,r){return 1===arguments.length?ur(t):new fr(t,e,n,null==r?1:r)}function fr(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}function dr(t){if(isNaN(t.h))return new sr(t.l,0,0,t.opacity);var e=t.h*Xn;return new sr(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}dn(sr,ir,pn(_n,{brighter(t){return new sr(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker(t){return new sr(this.l-18*(null==t?1:t),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 new Dn(lr(3.1338561*(e=Zn*ar(e))-1.6168667*(t=1*ar(t))-.4906146*(n=Jn*ar(n))),lr(-.9787684*e+1.9161415*t+.033454*n),lr(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}})),dn(fr,hr,pn(_n,{brighter(t){return new fr(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker(t){return new fr(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb(){return dr(this).rgb()}}));var pr=-.14861,_r=1.78277,gr=-.29227,yr=-.90649,mr=1.97294,br=mr*yr,vr=mr*_r,xr=_r*gr-yr*pr;function wr(t,e,n,r){return 1===arguments.length?function(t){if(t instanceof Er)return new Er(t.h,t.s,t.l,t.opacity);t instanceof Dn||(t=Pn(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(xr*r+br*e-vr*n)/(xr+br-vr),s=r-i,o=(mr*(n-i)-gr*s)/yr,a=Math.sqrt(o*o+s*s)/(mr*i*(1-i)),l=a?Math.atan2(o,s)*Kn-120:NaN;return new Er(l<0?l+360:l,a,i,t.opacity)}(t):new Er(t,e,n,null==r?1:r)}function Er(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Ar(t,e,n,r,i){var s=t*t,o=s*t;return((1-3*t+3*s-o)*e+(4-6*s+3*o)*n+(1+3*t+3*s-3*o)*r+o*i)/6}function Sr(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],s=t[r+1],o=r>0?t[r-1]:2*i-s,a=r<e-1?t[r+2]:2*s-i;return Ar((n-r/e)*e,o,i,s,a)}}function Tr(t){var e=t.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*e),i=t[(r+e-1)%e],s=t[r%e],o=t[(r+1)%e],a=t[(r+2)%e];return Ar((n-r/e)*e,i,s,o,a)}}dn(Er,wr,pn(_n,{brighter(t){return t=null==t?yn:Math.pow(yn,t),new Er(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?gn:Math.pow(gn,t),new Er(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=isNaN(this.h)?0:(this.h+120)*Xn,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new Dn(255*(e+n*(pr*r+_r*i)),255*(e+n*(gr*r+yr*i)),255*(e+n*(mr*r)),this.opacity)}}));var Cr=t=>()=>t;function kr(t,e){return function(n){return t+n*e}}function Rr(t,e){var n=e-t;return n?kr(t,n>180||n<-180?n-360*Math.round(n/360):n):Cr(isNaN(t)?e:t)}function Mr(t){return 1===(t=+t)?Or:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):Cr(isNaN(e)?n:e)}}function Or(t,e){var n=e-t;return n?kr(t,n):Cr(isNaN(t)?e:t)}var Nr=function t(e){var n=Mr(e);function r(t,e){var r=n((t=Ln(t)).r,(e=Ln(e)).r),i=n(t.g,e.g),s=n(t.b,e.b),o=Or(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=s(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);function Ir(t){return function(e){var n,r,i=e.length,s=new Array(i),o=new Array(i),a=new Array(i);for(n=0;n<i;++n)r=Ln(e[n]),s[n]=r.r||0,o[n]=r.g||0,a[n]=r.b||0;return s=t(s),o=t(o),a=t(a),r.opacity=1,function(t){return r.r=s(t),r.g=o(t),r.b=a(t),r+""}}}var Pr=Ir(Sr),Lr=Ir(Tr);function Dr(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(s){for(n=0;n<r;++n)i[n]=t[n]*(1-s)+e[n]*s;return i}}function Vr(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Br(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,s=new Array(i),o=new Array(r);for(n=0;n<i;++n)s[n]=Hr(t[n],e[n]);for(;n<r;++n)o[n]=e[n];return function(t){for(n=0;n<i;++n)o[n]=s[n](t);return o}}function zr(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Gr(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Fr(t,e){var n,r={},i={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?r[n]=Hr(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var jr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ur=new RegExp(jr.source,"g");function Yr(t,e){var n,r,i,s=jr.lastIndex=Ur.lastIndex=0,o=-1,a=[],l=[];for(t+="",e+="";(n=jr.exec(t))&&(r=Ur.exec(e));)(i=r.index)>s&&(i=e.slice(s,i),a[o]?a[o]+=i:a[++o]=i),(n=n[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:Gr(n,r)})),s=Ur.lastIndex;return s<e.length&&(i=e.slice(s),a[o]?a[o]+=i:a[++o]=i),a.length<2?l[0]?function(t){return function(e){return t(e)+""}}(l[0].x):function(t){return function(){return t}}(e):(e=l.length,function(t){for(var n,r=0;r<e;++r)a[(n=l[r]).i]=n.x(t);return a.join("")})}function Hr(t,e){var n,r=typeof e;return null==e||"boolean"===r?Cr(e):("number"===r?Gr:"string"===r?(n=On(e))?(e=n,Nr):Yr:e instanceof On?Nr:e instanceof Date?zr:Vr(e)?Dr:Array.isArray(e)?Br:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?Fr:Gr)(t,e)}function Wr(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var qr,$r=180/Math.PI,Xr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Kr(t,e,n,r,i,s){var o,a,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),t*r<e*n&&(t=-t,e=-e,l=-l,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(e,t)*$r,skewX:Math.atan(l)*$r,scaleX:o,scaleY:a}}function Zr(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(s,o){var a=[],l=[];return s=t(s),o=t(o),function(t,r,i,s,o,a){if(t!==i||r!==s){var l=o.push("translate(",null,e,null,n);a.push({i:l-4,x:Gr(t,i)},{i:l-2,x:Gr(r,s)})}else(i||s)&&o.push("translate("+i+e+s+n)}(s.translateX,s.translateY,o.translateX,o.translateY,a,l),function(t,e,n,s){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),s.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Gr(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(s.rotate,o.rotate,a,l),function(t,e,n,s){t!==e?s.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Gr(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(s.skewX,o.skewX,a,l),function(t,e,n,r,s,o){if(t!==n||e!==r){var a=s.push(i(s)+"scale(",null,",",null,")");o.push({i:a-4,x:Gr(t,n)},{i:a-2,x:Gr(e,r)})}else 1===n&&1===r||s.push(i(s)+"scale("+n+","+r+")")}(s.scaleX,s.scaleY,o.scaleX,o.scaleY,a,l),s=o=null,function(t){for(var e,n=-1,r=l.length;++n<r;)a[(e=l[n]).i]=e.x(t);return a.join("")}}}var Jr=Zr(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Xr:Kr(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),Qr=Zr(function(t){return null==t?Xr:(qr||(qr=document.createElementNS("http://www.w3.org/2000/svg","g")),qr.setAttribute("transform",t),(t=qr.transform.baseVal.consolidate())?Kr((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Xr)},", ",")",")");function ti(t){return((t=Math.exp(t))+1/t)/2}var ei=function t(e,n,r){function i(t,i){var s,o,a=t[0],l=t[1],c=t[2],u=i[0],h=i[1],f=i[2],d=u-a,p=h-l,_=d*d+p*p;if(_<1e-12)o=Math.log(f/c)/e,s=function(t){return[a+t*d,l+t*p,c*Math.exp(e*t*o)]};else{var g=Math.sqrt(_),y=(f*f-c*c+r*_)/(2*c*n*g),m=(f*f-c*c-r*_)/(2*f*n*g),b=Math.log(Math.sqrt(y*y+1)-y),v=Math.log(Math.sqrt(m*m+1)-m);o=(v-b)/e,s=function(t){var r=t*o,i=ti(b),s=c/(n*g)*(i*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*r+b)-function(t){return((t=Math.exp(t))-1/t)/2}(b));return[a+s*d,l+s*p,c*i/ti(e*r+b)]}}return s.duration=1e3*o*e/Math.SQRT2,s}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r)},i}(Math.SQRT2,2,4);function ni(t){return function(e,n){var r=t((e=Yn(e)).h,(n=Yn(n)).h),i=Or(e.s,n.s),s=Or(e.l,n.l),o=Or(e.opacity,n.opacity);return function(t){return e.h=r(t),e.s=i(t),e.l=s(t),e.opacity=o(t),e+""}}}var ri=ni(Rr),ii=ni(Or);function si(t){return function(e,n){var r=t((e=hr(e)).h,(n=hr(n)).h),i=Or(e.c,n.c),s=Or(e.l,n.l),o=Or(e.opacity,n.opacity);return function(t){return e.h=r(t),e.c=i(t),e.l=s(t),e.opacity=o(t),e+""}}}var oi=si(Rr),ai=si(Or);function li(t){return function e(n){function r(e,r){var i=t((e=wr(e)).h,(r=wr(r)).h),s=Or(e.s,r.s),o=Or(e.l,r.l),a=Or(e.opacity,r.opacity);return function(t){return e.h=i(t),e.s=s(t),e.l=o(Math.pow(t,n)),e.opacity=a(t),e+""}}return n=+n,r.gamma=e,r}(1)}var ci=li(Rr),ui=li(Or);function hi(t,e){void 0===e&&(e=t,t=Hr);for(var n=0,r=e.length-1,i=e[0],s=new Array(r<0?0:r);n<r;)s[n]=t(i,i=e[++n]);return function(t){var e=Math.max(0,Math.min(r-1,Math.floor(t*=r)));return s[e](t-e)}}var fi,di,pi=0,_i=0,gi=0,yi=0,mi=0,bi=0,vi="object"==typeof performance&&performance.now?performance:Date,xi="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function wi(){return mi||(xi(Ei),mi=vi.now()+bi)}function Ei(){mi=0}function Ai(){this._call=this._time=this._next=null}function Si(t,e,n){var r=new Ai;return r.restart(t,e,n),r}function Ti(){wi(),++pi;for(var t,e=fi;e;)(t=mi-e._time)>=0&&e._call.call(void 0,t),e=e._next;--pi}function Ci(){mi=(yi=vi.now())+bi,pi=_i=0;try{Ti()}finally{pi=0,function(){var t,e,n=fi,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:fi=e);di=t,Ri(r)}(),mi=0}}function ki(){var t=vi.now(),e=t-yi;e>1e3&&(bi-=e,yi=t)}function Ri(t){pi||(_i&&(_i=clearTimeout(_i)),t-mi>24?(t<1/0&&(_i=setTimeout(Ci,t-vi.now()-bi)),gi&&(gi=clearInterval(gi))):(gi||(yi=vi.now(),gi=setInterval(ki,1e3)),pi=1,xi(Ci)))}function Mi(t,e,n){var r=new Ai;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}Ai.prototype=Si.prototype={constructor:Ai,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?wi():+n)+(null==e?0:+e),this._next||di===this||(di?di._next=this:fi=this,di=this),this._call=t,this._time=n,Ri()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ri())}};var Oi=Nt("start","end","cancel","interrupt"),Ni=[];function Ii(t,e,n,r,i,s){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function s(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(s){var c,u,h,f;if(1!==n.state)return l();for(c in i)if((f=i[c]).name===n.name){if(3===f.state)return Mi(o);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[c]):+c<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[c])}if(Mi(function(){3===n.state&&(n.state=4,n.timer.restart(a,n.delay,n.time),a(s))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(h=n.tween.length),c=0,u=-1;c<h;++c)(f=n.tween[c].value.call(t,t.__data__,n.index,n.group))&&(r[++u]=f);r.length=u+1}}function a(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(l),n.state=5,1),s=-1,o=r.length;++s<o;)r[s].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=Si(s,0,n.time)}(t,n,{name:e,index:r,group:i,on:Oi,tween:Ni,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:0})}function Pi(t,e){var n=Di(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function Li(t,e){var n=Di(t,e);if(n.state>3)throw new Error("too late; already running");return n}function Di(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Vi(t,e){var n,r,i,s=t.__transition,o=!0;if(s){for(i in e=null==e?null:e+"",s)(n=s[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete s[i]):o=!1;o&&delete t.__transition}}function Bi(t,e){var n,r;return function(){var i=Li(this,t),s=i.tween;if(s!==n)for(var o=0,a=(r=n=s).length;o<a;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r}}function zi(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var s=Li(this,t),o=s.tween;if(o!==r){i=(r=o).slice();for(var a={name:e,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===e){i[l]=a;break}l===c&&i.push(a)}s.tween=i}}function Gi(t,e,n){var r=t._id;return t.each(function(){var t=Li(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return Di(t,r).value[e]}}function Fi(t,e){var n;return("number"==typeof e?Gr:e instanceof On?Nr:(n=On(e))?(e=n,Nr):Yr)(t,e)}function ji(t){return function(){this.removeAttribute(t)}}function Ui(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Yi(t,e,n){var r,i,s=n+"";return function(){var o=this.getAttribute(t);return o===s?null:o===r?i:i=e(r=o,n)}}function Hi(t,e,n){var r,i,s=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===s?null:o===r?i:i=e(r=o,n)}}function Wi(t,e,n){var r,i,s;return function(){var o,a,l=n(this);if(null!=l)return(o=this.getAttribute(t))===(a=l+"")?null:o===r&&a===i?s:(i=a,s=e(r=o,l));this.removeAttribute(t)}}function qi(t,e,n){var r,i,s;return function(){var o,a,l=n(this);if(null!=l)return(o=this.getAttributeNS(t.space,t.local))===(a=l+"")?null:o===r&&a===i?s:(i=a,s=e(r=o,l));this.removeAttributeNS(t.space,t.local)}}function $i(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Xi(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Ki(t,e){return function(){Pi(this,t).delay=+e.apply(this,arguments)}}function Zi(t,e){return e=+e,function(){Pi(this,t).delay=e}}function Ji(t,e){return function(){Li(this,t).duration=+e.apply(this,arguments)}}function Qi(t,e){return e=+e,function(){Li(this,t).duration=e}}var ts=qe.prototype.constructor;function es(t){return function(){this.style.removeProperty(t)}}var ns=0;function rs(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function is(t){return qe().transition(t)}function ss(){return++ns}var os=qe.prototype;rs.prototype=is.prototype={constructor:rs,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Ut(t));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o<i;++o)for(var a,l,c=r[o],u=c.length,h=s[o]=new Array(u),f=0;f<u;++f)(a=c[f])&&(l=t.call(a,a.__data__,f,c))&&("__data__"in a&&(l.__data__=a.__data__),h[f]=l,Ii(h[f],e,n,f,h,Di(a,n)));return new rs(s,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Wt(t));for(var r=this._groups,i=r.length,s=[],o=[],a=0;a<i;++a)for(var l,c=r[a],u=c.length,h=0;h<u;++h)if(l=c[h]){for(var f,d=t.call(l,l.__data__,h,c),p=Di(l,n),_=0,g=d.length;_<g;++_)(f=d[_])&&Ii(f,e,n,_,d,p);s.push(d),o.push(l)}return new rs(s,o,e,n)},selectChild:os.selectChild,selectChildren:os.selectChildren,filter:function(t){"function"!=typeof t&&(t=qt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s,o=e[i],a=o.length,l=r[i]=[],c=0;c<a;++c)(s=o[c])&&t.call(s,s.__data__,c,o)&&l.push(s);return new rs(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,s=Math.min(r,i),o=new Array(r),a=0;a<s;++a)for(var l,c=e[a],u=n[a],h=c.length,f=o[a]=new Array(h),d=0;d<h;++d)(l=c[d]||u[d])&&(f[d]=l);for(;a<r;++a)o[a]=e[a];return new rs(o,this._parents,this._name,this._id)},selection:function(){return new ts(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=ss(),r=this._groups,i=r.length,s=0;s<i;++s)for(var o,a=r[s],l=a.length,c=0;c<l;++c)if(o=a[c]){var u=Di(o,e);Ii(o,t,n,c,a,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new rs(r,this._parents,t,n)},call:os.call,nodes:os.nodes,node:os.node,size:os.size,empty:os.empty,each:os.each,on:function(t,e){var n=this._id;return arguments.length<2?Di(this.node(),n).on.on(t):this.each(function(t,e,n){var r,i,s=function(t){return(t+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?Pi:Li;return function(){var o=s(this,t),a=o.on;a!==r&&(i=(r=a).copy()).on(e,n),o.on=i}}(n,t,e))},attr:function(t,e){var n=Bt(t),r="transform"===n?Qr:Fi;return this.attrTween(t,"function"==typeof e?(n.local?qi:Wi)(n,r,Gi(this,"attr."+t,e)):null==e?(n.local?Ui:ji)(n):(n.local?Hi:Yi)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=Bt(t);return this.tween(n,(r.local?$i:Xi)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Jr:Fi;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var s=ge(this,t),o=(this.style.removeProperty(t),ge(this,t));return s===o?null:s===n&&o===r?i:i=e(n=s,r=o)}}(t,r)).on("end.style."+t,es(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,s;return function(){var o=ge(this,t),a=n(this),l=a+"";return null==a&&(this.style.removeProperty(t),l=a=ge(this,t)),o===l?null:o===r&&l===i?s:(i=l,s=e(r=o,a))}}(t,r,Gi(this,"style."+t,e))).each(function(t,e){var n,r,i,s,o="style."+e,a="end."+o;return function(){var l=Li(this,t),c=l.on,u=null==l.value[o]?s||(s=es(e)):void 0;c===n&&i===u||(r=(n=c).copy()).on(a,i=u),l.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,s=n+"";return function(){var o=ge(this,t);return o===s?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function s(){var s=e.apply(this,arguments);return s!==i&&(r=(i=s)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,s,n)),r}return s._value=e,s}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Gi(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=Di(this.node(),n).tween,s=0,o=i.length;s<o;++s)if((r=i[s]).name===t)return r.value;return null}return this.each((null==e?Bi:zi)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Ki:Zi)(e,t)):Di(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Ji:Qi)(e,t)):Di(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw new Error;return function(){Li(this,t).ease=e}}(e,t)):Di(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;Li(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(s,o){var a={value:o},l={value:function(){0===--i&&s()}};n.each(function(){var n=Li(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),n.on=e}),0===i&&s()})},[Symbol.iterator]:os[Symbol.iterator]};function as(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}function ls(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var cs=function t(e){function n(t){return Math.pow(t,e)}return e=+e,n.exponent=t,n}(3),us=function t(e){function n(t){return 1-Math.pow(1-t,e)}return e=+e,n.exponent=t,n}(3),hs=function t(e){function n(t){return((t*=2)<=1?Math.pow(t,e):2-Math.pow(2-t,e))/2}return e=+e,n.exponent=t,n}(3),fs=Math.PI,ds=fs/2;function ps(t){return(1-Math.cos(fs*t))/2}function _s(t){return 1.0009775171065494*(Math.pow(2,-10*t)-.0009765625)}function gs(t){return((t*=2)<=1?_s(1-t):2-_s(t-1))/2}function ys(t){return((t*=2)<=1?1-Math.sqrt(1-t*t):Math.sqrt(1-(t-=2)*t)+1)/2}var ms=4/11,bs=6/11,vs=8/11,xs=9/11,ws=10/11,Es=21/22,As=7.5625;function Ss(t){return(t=+t)<ms?As*t*t:t<vs?As*(t-=bs)*t+.75:t<ws?As*(t-=xs)*t+.9375:As*(t-=Es)*t+.984375}var Ts=1.70158,Cs=function t(e){function n(t){return(t=+t)*t*(e*(t-1)+t)}return e=+e,n.overshoot=t,n}(Ts),ks=function t(e){function n(t){return--t*t*((t+1)*e+t)+1}return e=+e,n.overshoot=t,n}(Ts),Rs=function t(e){function n(t){return((t*=2)<1?t*t*((e+1)*t-e):(t-=2)*t*((e+1)*t+e)+2)/2}return e=+e,n.overshoot=t,n}(Ts),Ms=2*Math.PI,Os=function t(e,n){var r=Math.asin(1/(e=Math.max(1,e)))*(n/=Ms);function i(t){return e*_s(- --t)*Math.sin((r-t)/n)}return i.amplitude=function(e){return t(e,n*Ms)},i.period=function(n){return t(e,n)},i}(1,.3),Ns=function t(e,n){var r=Math.asin(1/(e=Math.max(1,e)))*(n/=Ms);function i(t){return 1-e*_s(t=+t)*Math.sin((t+r)/n)}return i.amplitude=function(e){return t(e,n*Ms)},i.period=function(n){return t(e,n)},i}(1,.3),Is=function t(e,n){var r=Math.asin(1/(e=Math.max(1,e)))*(n/=Ms);function i(t){return((t=2*t-1)<0?e*_s(-t)*Math.sin((r-t)/n):2-e*_s(t)*Math.sin((r+t)/n))/2}return i.amplitude=function(e){return t(e,n*Ms)},i.period=function(n){return t(e,n)},i}(1,.3),Ps={time:null,delay:0,duration:250,ease:ls};function Ls(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}qe.prototype.interrupt=function(t){return this.each(function(){Vi(this,t)})},qe.prototype.transition=function(t){var e,n;t instanceof rs?(e=t._id,t=t._name):(e=ss(),(n=Ps).time=wi(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var o,a=r[s],l=a.length,c=0;c<l;++c)(o=a[c])&&Ii(o,t,e,c,a,n||Ls(o,e));return new rs(r,this._parents,t,e)};var Ds=[null];var Vs=t=>()=>t;function Bs(t,{sourceEvent:e,target:n,selection:r,mode:i,dispatch:s}){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:i,enumerable:!0,configurable:!0},_:{value:s}})}function zs(t){t.preventDefault(),t.stopImmediatePropagation()}var Gs={name:"drag"},Fs={name:"space"},js={name:"handle"},Us={name:"center"};const{abs:Ys,max:Hs,min:Ws}=Math;function qs(t){return[+t[0],+t[1]]}function $s(t){return[qs(t[0]),qs(t[1])]}var Xs={name:"x",handles:["w","e"].map(ro),input:function(t,e){return null==t?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},Ks={name:"y",handles:["n","s"].map(ro),input:function(t,e){return null==t?null:[[e[0][0],+t[0]],[e[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},Zs={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(ro),input:function(t){return null==t?null:$s(t)},output:function(t){return t}},Js={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"},Qs={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},to={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},eo={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},no={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function ro(t){return{type:t}}function io(t){return!t.ctrlKey&&!t.button}function so(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function oo(){return navigator.maxTouchPoints||"ontouchstart"in this}function ao(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function lo(t){var e,n=so,r=io,i=oo,s=!0,o=Nt("start","brush","end"),a=6;function l(e){var n=e.property("__brush",_).selectAll(".overlay").data([ro("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Js.overlay).merge(n).each(function(){var t=ao(this).extent;$e(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])}),e.selectAll(".selection").data([ro("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Js.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=e.selectAll(".handle").data(t.handles,function(t){return t.type});r.exit().remove(),r.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return Js[t.type]}),e.each(c).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",f).filter(i).on("touchstart.brush",f).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function c(){var t=$e(this),e=ao(this).selection;e?(t.selectAll(".selection").style("display",null).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1]),t.selectAll(".handle").style("display",null).attr("x",function(t){return"e"===t.type[t.type.length-1]?e[1][0]-a/2:e[0][0]-a/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-a/2:e[0][1]-a/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+a:a}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+a:a})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function u(t,e,n){var r=t.__brush.emitter;return!r||n&&r.clean?new h(t,e,n):r}function h(t,e,n){this.that=t,this.args=e,this.state=t.__brush,this.active=0,this.clean=n}function f(n){if((!e||n.touches)&&r.apply(this,arguments)){var i,o,a,l,h,f,d,p,_,g,y,m=this,b=n.target.__data__.type,v="selection"===(s&&n.metaKey?b="overlay":b)?Gs:s&&n.altKey?Us:js,x=t===Ks?null:eo[b],w=t===Xs?null:no[b],E=ao(m),A=E.extent,S=E.selection,T=A[0][0],C=A[0][1],k=A[1][0],R=A[1][1],M=0,O=0,N=x&&w&&s&&n.shiftKey,I=Array.from(n.touches||[n],t=>{const e=t.identifier;return(t=Qe(t,m)).point0=t.slice(),t.identifier=e,t});Vi(m);var P=u(m,arguments,!0).beforestart();if("overlay"===b){S&&(_=!0);const e=[I[0],I[1]||I[0]];E.selection=S=[[i=t===Ks?T:Ws(e[0][0],e[1][0]),a=t===Xs?C:Ws(e[0][1],e[1][1])],[h=t===Ks?k:Hs(e[0][0],e[1][0]),d=t===Xs?R:Hs(e[0][1],e[1][1])]],I.length>1&&z(n)}else i=S[0][0],a=S[0][1],h=S[1][0],d=S[1][1];o=i,l=a,f=h,p=d;var L=$e(m).attr("pointer-events","none"),D=L.selectAll(".overlay").attr("cursor",Js[b]);if(n.touches)P.moved=B,P.ended=G;else{var V=$e(n.view).on("mousemove.brush",B,!0).on("mouseup.brush",G,!0);s&&V.on("keydown.brush",function(t){switch(t.keyCode){case 16:N=x&&w;break;case 18:v===js&&(x&&(h=f-M*x,i=o+M*x),w&&(d=p-O*w,a=l+O*w),v=Us,z(t));break;case 32:v!==js&&v!==Us||(x<0?h=f-M:x>0&&(i=o-M),w<0?d=p-O:w>0&&(a=l-O),v=Fs,D.attr("cursor",Js.selection),z(t));break;default:return}zs(t)},!0).on("keyup.brush",function(t){switch(t.keyCode){case 16:N&&(g=y=N=!1,z(t));break;case 18:v===Us&&(x<0?h=f:x>0&&(i=o),w<0?d=p:w>0&&(a=l),v=js,z(t));break;case 32:v===Fs&&(t.altKey?(x&&(h=f-M*x,i=o+M*x),w&&(d=p-O*w,a=l+O*w),v=Us):(x<0?h=f:x>0&&(i=o),w<0?d=p:w>0&&(a=l),v=js),D.attr("cursor",Js[b]),z(t));break;default:return}zs(t)},!0),sn(n.view)}c.call(m),P.start(n,v.name)}function B(t){for(const e of t.changedTouches||[t])for(const t of I)t.identifier===e.identifier&&(t.cur=Qe(e,m));if(N&&!g&&!y&&1===I.length){const t=I[0];Ys(t.cur[0]-t[0])>Ys(t.cur[1]-t[1])?y=!0:g=!0}for(const t of I)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);_=!0,zs(t),z(t)}function z(t){const e=I[0],n=e.point0;var r;switch(M=e[0]-n[0],O=e[1]-n[1],v){case Fs:case Gs:x&&(M=Hs(T-i,Ws(k-h,M)),o=i+M,f=h+M),w&&(O=Hs(C-a,Ws(R-d,O)),l=a+O,p=d+O);break;case js:I[1]?(x&&(o=Hs(T,Ws(k,I[0][0])),f=Hs(T,Ws(k,I[1][0])),x=1),w&&(l=Hs(C,Ws(R,I[0][1])),p=Hs(C,Ws(R,I[1][1])),w=1)):(x<0?(M=Hs(T-i,Ws(k-i,M)),o=i+M,f=h):x>0&&(M=Hs(T-h,Ws(k-h,M)),o=i,f=h+M),w<0?(O=Hs(C-a,Ws(R-a,O)),l=a+O,p=d):w>0&&(O=Hs(C-d,Ws(R-d,O)),l=a,p=d+O));break;case Us:x&&(o=Hs(T,Ws(k,i-M*x)),f=Hs(T,Ws(k,h+M*x))),w&&(l=Hs(C,Ws(R,a-O*w)),p=Hs(C,Ws(R,d+O*w)))}f<o&&(x*=-1,r=i,i=h,h=r,r=o,o=f,f=r,b in Qs&&D.attr("cursor",Js[b=Qs[b]])),p<l&&(w*=-1,r=a,a=d,d=r,r=l,l=p,p=r,b in to&&D.attr("cursor",Js[b=to[b]])),E.selection&&(S=E.selection),g&&(o=S[0][0],f=S[1][0]),y&&(l=S[0][1],p=S[1][1]),S[0][0]===o&&S[0][1]===l&&S[1][0]===f&&S[1][1]===p||(E.selection=[[o,l],[f,p]],c.call(m),P.brush(t,v.name))}function G(t){if(function(t){t.stopImmediatePropagation()}(t),t.touches){if(t.touches.length)return;e&&clearTimeout(e),e=setTimeout(function(){e=null},500)}else on(t.view,_),V.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);L.attr("pointer-events","all"),D.attr("cursor",Js.overlay),E.selection&&(S=E.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(S)&&(E.selection=null,c.call(m)),P.end(t,v.name)}}function d(t){u(this,arguments).moved(t)}function p(t){u(this,arguments).ended(t)}function _(){var e=this.__brush||{selection:null};return e.extent=$s(n.apply(this,arguments)),e.dim=t,e}return l.move=function(e,n,r){e.tween?e.on("start.brush",function(t){u(this,arguments).beforestart().start(t)}).on("interrupt.brush end.brush",function(t){u(this,arguments).end(t)}).tween("brush",function(){var e=this,r=e.__brush,i=u(e,arguments),s=r.selection,o=t.input("function"==typeof n?n.apply(this,arguments):n,r.extent),a=Hr(s,o);function l(t){r.selection=1===t&&null===o?null:a(t),c.call(e),i.brush()}return null!==s&&null!==o?l:l(1)}):e.each(function(){var e=this,i=arguments,s=e.__brush,o=t.input("function"==typeof n?n.apply(e,i):n,s.extent),a=u(e,i).beforestart();Vi(e),s.selection=null===o?null:o,c.call(e),a.start(r).brush(r).end(r)})},l.clear=function(t,e){l.move(t,null,e)},h.prototype={beforestart:function(){return 1===++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(t,e){return this.starting?(this.starting=!1,this.emit("start",t,e)):this.emit("brush",t),this},brush:function(t,e){return this.emit("brush",t,e),this},end:function(t,e){return 0===--this.active&&(delete this.state.emitter,this.emit("end",t,e)),this},emit:function(e,n,r){var i=$e(this.that).datum();o.call(e,this.that,new Bs(e,{sourceEvent:n,target:l,selection:t.output(this.state.selection),mode:r,dispatch:o}),i)}},l.extent=function(t){return arguments.length?(n="function"==typeof t?t:Vs($s(t)),l):n},l.filter=function(t){return arguments.length?(r="function"==typeof t?t:Vs(!!t),l):r},l.touchable=function(t){return arguments.length?(i="function"==typeof t?t:Vs(!!t),l):i},l.handleSize=function(t){return arguments.length?(a=+t,l):a},l.keyModifiers=function(t){return arguments.length?(s=!!t,l):s},l.on=function(){var t=o.on.apply(o,arguments);return t===o?l:t},l}var co=Math.abs,uo=Math.cos,ho=Math.sin,fo=Math.PI,po=fo/2,_o=2*fo,go=Math.max,yo=1e-12;function mo(t,e){return Array.from({length:e-t},(e,n)=>t+n)}function bo(t,e){var n=0,r=null,i=null,s=null;function o(o){var a,l=o.length,c=new Array(l),u=mo(0,l),h=new Array(l*l),f=new Array(l),d=0;o=Float64Array.from({length:l*l},e?(t,e)=>o[e%l][e/l|0]:(t,e)=>o[e/l|0][e%l]);for(let e=0;e<l;++e){let n=0;for(let r=0;r<l;++r)n+=o[e*l+r]+t*o[r*l+e];d+=c[e]=n}a=(d=go(0,_o-n*l)/d)?n:_o/l;{let e=0;r&&u.sort((t,e)=>r(c[t],c[e]));for(const n of u){const r=e;if(t){const t=mo(1+~l,l).filter(t=>t<0?o[~t*l+n]:o[n*l+t]);i&&t.sort((t,e)=>i(t<0?-o[~t*l+n]:o[n*l+t],e<0?-o[~e*l+n]:o[n*l+e]));for(const r of t)if(r<0){(h[~r*l+n]||(h[~r*l+n]={source:null,target:null})).target={index:n,startAngle:e,endAngle:e+=o[~r*l+n]*d,value:o[~r*l+n]}}else{(h[n*l+r]||(h[n*l+r]={source:null,target:null})).source={index:n,startAngle:e,endAngle:e+=o[n*l+r]*d,value:o[n*l+r]}}f[n]={index:n,startAngle:r,endAngle:e,value:c[n]}}else{const t=mo(0,l).filter(t=>o[n*l+t]||o[t*l+n]);i&&t.sort((t,e)=>i(o[n*l+t],o[n*l+e]));for(const r of t){let t;if(n<r?(t=h[n*l+r]||(h[n*l+r]={source:null,target:null}),t.source={index:n,startAngle:e,endAngle:e+=o[n*l+r]*d,value:o[n*l+r]}):(t=h[r*l+n]||(h[r*l+n]={source:null,target:null}),t.target={index:n,startAngle:e,endAngle:e+=o[n*l+r]*d,value:o[n*l+r]},n===r&&(t.source=t.target)),t.source&&t.target&&t.source.value<t.target.value){const e=t.source;t.source=t.target,t.target=e}}f[n]={index:n,startAngle:r,endAngle:e,value:c[n]}}e+=a}}return(h=Object.values(h)).groups=f,s?h.sort(s):h}return o.padAngle=function(t){return arguments.length?(n=go(0,t),o):n},o.sortGroups=function(t){return arguments.length?(r=t,o):r},o.sortSubgroups=function(t){return arguments.length?(i=t,o):i},o.sortChords=function(t){return arguments.length?(null==t?s=null:(e=t,s=function(t,n){return e(t.source.value+t.target.value,n.source.value+n.target.value)})._=t,o):s&&s._;var e},o}const vo=Math.PI,xo=2*vo,wo=1e-6,Eo=xo-wo;function Ao(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}let So=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?Ao:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Ao;const n=10**e;return function(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=Math.round(arguments[e]*n)/n+t[e]}}(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,n,r){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(t,e,n,r,i,s){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+s}`}arcTo(t,e,n,r,i){if(t=+t,e=+e,n=+n,r=+r,(i=+i)<0)throw new Error(`negative radius: ${i}`);let s=this._x1,o=this._y1,a=n-t,l=r-e,c=s-t,u=o-e,h=c*c+u*u;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(h>wo)if(Math.abs(u*a-l*c)>wo&&i){let f=n-s,d=r-o,p=a*a+l*l,_=f*f+d*d,g=Math.sqrt(p),y=Math.sqrt(h),m=i*Math.tan((vo-Math.acos((p+h-_)/(2*g*y)))/2),b=m/y,v=m/g;Math.abs(b-1)>wo&&this._append`L${t+b*c},${e+b*u}`,this._append`A${i},${i},0,0,${+(u*f>c*d)},${this._x1=t+v*a},${this._y1=e+v*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,s){if(t=+t,e=+e,s=!!s,(n=+n)<0)throw new Error(`negative radius: ${n}`);let o=n*Math.cos(r),a=n*Math.sin(r),l=t+o,c=e+a,u=1^s,h=s?r-i:i-r;null===this._x1?this._append`M${l},${c}`:(Math.abs(this._x1-l)>wo||Math.abs(this._y1-c)>wo)&&this._append`L${l},${c}`,n&&(h<0&&(h=h%xo+xo),h>Eo?this._append`A${n},${n},0,1,${u},${t-o},${e-a}A${n},${n},0,1,${u},${this._x1=l},${this._y1=c}`:h>wo&&this._append`A${n},${n},0,${+(h>=vo)},${u},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};function To(){return new So}To.prototype=So.prototype;var Co=Array.prototype.slice;function ko(t){return function(){return t}}function Ro(t){return t.source}function Mo(t){return t.target}function Oo(t){return t.radius}function No(t){return t.startAngle}function Io(t){return t.endAngle}function Po(){return 0}function Lo(){return 10}function Do(t){var e=Ro,n=Mo,r=Oo,i=Oo,s=No,o=Io,a=Po,l=null;function c(){var c,u=e.apply(this,arguments),h=n.apply(this,arguments),f=a.apply(this,arguments)/2,d=Co.call(arguments),p=+r.apply(this,(d[0]=u,d)),_=s.apply(this,d)-po,g=o.apply(this,d)-po,y=+i.apply(this,(d[0]=h,d)),m=s.apply(this,d)-po,b=o.apply(this,d)-po;if(l||(l=c=To()),f>yo&&(co(g-_)>2*f+yo?g>_?(_+=f,g-=f):(_-=f,g+=f):_=g=(_+g)/2,co(b-m)>2*f+yo?b>m?(m+=f,b-=f):(m-=f,b+=f):m=b=(m+b)/2),l.moveTo(p*uo(_),p*ho(_)),l.arc(0,0,p,_,g),_!==m||g!==b)if(t){var v=y-+t.apply(this,arguments),x=(m+b)/2;l.quadraticCurveTo(0,0,v*uo(m),v*ho(m)),l.lineTo(y*uo(x),y*ho(x)),l.lineTo(v*uo(b),v*ho(b))}else l.quadraticCurveTo(0,0,y*uo(m),y*ho(m)),l.arc(0,0,y,m,b);if(l.quadraticCurveTo(0,0,p*uo(_),p*ho(_)),l.closePath(),c)return l=null,c+""||null}return t&&(c.headRadius=function(e){return arguments.length?(t="function"==typeof e?e:ko(+e),c):t}),c.radius=function(t){return arguments.length?(r=i="function"==typeof t?t:ko(+t),c):r},c.sourceRadius=function(t){return arguments.length?(r="function"==typeof t?t:ko(+t),c):r},c.targetRadius=function(t){return arguments.length?(i="function"==typeof t?t:ko(+t),c):i},c.startAngle=function(t){return arguments.length?(s="function"==typeof t?t:ko(+t),c):s},c.endAngle=function(t){return arguments.length?(o="function"==typeof t?t:ko(+t),c):o},c.padAngle=function(t){return arguments.length?(a="function"==typeof t?t:ko(+t),c):a},c.source=function(t){return arguments.length?(e=t,c):e},c.target=function(t){return arguments.length?(n=t,c):n},c.context=function(t){return arguments.length?(l=null==t?null:t,c):l},c}var Vo=Array.prototype.slice;function Bo(t,e){return t-e}var zo=t=>()=>t;function Go(t,e){for(var n,r=-1,i=e.length;++r<i;)if(n=Fo(t,e[r]))return n;return 0}function Fo(t,e){for(var n=e[0],r=e[1],i=-1,s=0,o=t.length,a=o-1;s<o;a=s++){var l=t[s],c=l[0],u=l[1],h=t[a],f=h[0],d=h[1];if(jo(l,h,e))return 0;u>r!=d>r&&n<(f-c)*(r-u)/(d-u)+c&&(i=-i)}return i}function jo(t,e,n){var r,i,s,o;return function(t,e,n){return(e[0]-t[0])*(n[1]-t[1])===(n[0]-t[0])*(e[1]-t[1])}(t,e,n)&&(i=t[r=+(t[0]===e[0])],s=n[r],o=e[r],i<=s&&s<=o||o<=s&&s<=i)}function Uo(){}var Yo=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Ho(){var t=1,e=1,n=Z,r=a;function i(t){var e=n(t);if(Array.isArray(e))e=e.slice().sort(Bo);else{const n=x(t,Wo);for(e=q(...K(n[0],n[1],e),e);e[e.length-1]>=n[1];)e.pop();for(;e[1]<n[0];)e.shift()}return e.map(e=>s(t,e))}function s(n,i){const s=null==i?NaN:+i;if(isNaN(s))throw new Error(`invalid value: ${i}`);var a=[],l=[];return function(n,r,i){var s,a,l,c,u,h,f=new Array,d=new Array;s=a=-1,c=qo(n[0],r),Yo[c<<1].forEach(p);for(;++s<t-1;)l=c,c=qo(n[s+1],r),Yo[l|c<<1].forEach(p);Yo[c|0].forEach(p);for(;++a<e-1;){for(s=-1,c=qo(n[a*t+t],r),u=qo(n[a*t],r),Yo[c<<1|u<<2].forEach(p);++s<t-1;)l=c,c=qo(n[a*t+t+s+1],r),h=u,u=qo(n[a*t+s+1],r),Yo[l|c<<1|u<<2|h<<3].forEach(p);Yo[c|u<<3].forEach(p)}s=-1,u=n[a*t]>=r,Yo[u<<2].forEach(p);for(;++s<t-1;)h=u,u=qo(n[a*t+s+1],r),Yo[u<<2|h<<3].forEach(p);function p(t){var e,n,r=[t[0][0]+s,t[0][1]+a],l=[t[1][0]+s,t[1][1]+a],c=o(r),u=o(l);(e=d[c])?(n=f[u])?(delete d[e.end],delete f[n.start],e===n?(e.ring.push(l),i(e.ring)):f[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete d[e.end],e.ring.push(l),d[e.end=u]=e):(e=f[u])?(n=d[c])?(delete f[e.start],delete d[n.end],e===n?(e.ring.push(l),i(e.ring)):f[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete f[e.start],e.ring.unshift(r),f[e.start=c]=e):f[c]=d[u]={start:c,end:u,ring:[r,l]}}Yo[u<<3].forEach(p)}(n,s,function(t){r(t,n,s),function(t){for(var e=0,n=t.length,r=t[n-1][1]*t[0][0]-t[n-1][0]*t[0][1];++e<n;)r+=t[e-1][1]*t[e][0]-t[e-1][0]*t[e][1];return r}(t)>0?a.push([t]):l.push(t)}),l.forEach(function(t){for(var e,n=0,r=a.length;n<r;++n)if(-1!==Go((e=a[n])[0],t))return void e.push(t)}),{type:"MultiPolygon",value:i,coordinates:a}}function o(e){return 2*e[0]+e[1]*(t+1)*4}function a(n,r,i){n.forEach(function(n){var s=n[0],o=n[1],a=0|s,l=0|o,c=$o(r[l*t+a]);s>0&&s<t&&a===s&&(n[0]=Xo(s,$o(r[l*t+a-1]),c,i)),o>0&&o<e&&l===o&&(n[1]=Xo(o,$o(r[(l-1)*t+a]),c,i))})}return i.contour=s,i.size=function(n){if(!arguments.length)return[t,e];var r=Math.floor(n[0]),s=Math.floor(n[1]);if(!(r>=0&&s>=0))throw new Error("invalid size");return t=r,e=s,i},i.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:Array.isArray(t)?zo(Vo.call(t)):zo(t),i):n},i.smooth=function(t){return arguments.length?(r=t?a:Uo,i):r===a},i}function Wo(t){return isFinite(t)?t:NaN}function qo(t,e){return null!=t&&+t>=e}function $o(t){return null==t||isNaN(t=+t)?-1/0:t}function Xo(t,e,n,r){const i=r-e,s=n-e,o=isFinite(i)||isFinite(s)?i/s:Math.sign(i)/Math.sign(s);return isNaN(o)?t:t+o-.5}function Ko(t){return t[0]}function Zo(t){return t[1]}function Jo(){return 1}const Qo=134217729;function ta(t,e,n,r,i){let s,o,a,l,c=e[0],u=r[0],h=0,f=0;u>c==u>-c?(s=c,c=e[++h]):(s=u,u=r[++f]);let d=0;if(h<t&&f<n)for(u>c==u>-c?(o=c+s,a=s-(o-c),c=e[++h]):(o=u+s,a=s-(o-u),u=r[++f]),s=o,0!==a&&(i[d++]=a);h<t&&f<n;)u>c==u>-c?(o=s+c,l=o-s,a=s-(o-l)+(c-l),c=e[++h]):(o=s+u,l=o-s,a=s-(o-l)+(u-l),u=r[++f]),s=o,0!==a&&(i[d++]=a);for(;h<t;)o=s+c,l=o-s,a=s-(o-l)+(c-l),c=e[++h],s=o,0!==a&&(i[d++]=a);for(;f<n;)o=s+u,l=o-s,a=s-(o-l)+(u-l),u=r[++f],s=o,0!==a&&(i[d++]=a);return 0===s&&0!==d||(i[d++]=s),d}function ea(t){return new Float64Array(t)}const na=ea(4),ra=ea(8),ia=ea(12),sa=ea(16),oa=ea(4);function aa(t,e,n,r,i,s){const o=(e-s)*(n-i),a=(t-i)*(r-s),l=o-a,c=Math.abs(o+a);return Math.abs(l)>=33306690738754716e-32*c?l:-function(t,e,n,r,i,s,o){let a,l,c,u,h,f,d,p,_,g,y,m,b,v,x,w,E,A;const S=t-i,T=n-i,C=e-s,k=r-s;v=S*k,f=Qo*S,d=f-(f-S),p=S-d,f=Qo*k,_=f-(f-k),g=k-_,x=p*g-(v-d*_-p*_-d*g),w=C*T,f=Qo*C,d=f-(f-C),p=C-d,f=Qo*T,_=f-(f-T),g=T-_,E=p*g-(w-d*_-p*_-d*g),y=x-E,h=x-y,na[0]=x-(y+h)+(h-E),m=v+y,h=m-v,b=v-(m-h)+(y-h),y=b-w,h=b-y,na[1]=b-(y+h)+(h-w),A=m+y,h=A-m,na[2]=m-(A-h)+(y-h),na[3]=A;let R=function(t,e){let n=e[0];for(let r=1;r<t;r++)n+=e[r];return n}(4,na),M=22204460492503146e-32*o;if(R>=M||-R>=M)return R;if(h=t-S,a=t-(S+h)+(h-i),h=n-T,c=n-(T+h)+(h-i),h=e-C,l=e-(C+h)+(h-s),h=r-k,u=r-(k+h)+(h-s),0===a&&0===l&&0===c&&0===u)return R;if(M=11093356479670487e-47*o+33306690738754706e-32*Math.abs(R),R+=S*u+k*a-(C*c+T*l),R>=M||-R>=M)return R;v=a*k,f=Qo*a,d=f-(f-a),p=a-d,f=Qo*k,_=f-(f-k),g=k-_,x=p*g-(v-d*_-p*_-d*g),w=l*T,f=Qo*l,d=f-(f-l),p=l-d,f=Qo*T,_=f-(f-T),g=T-_,E=p*g-(w-d*_-p*_-d*g),y=x-E,h=x-y,oa[0]=x-(y+h)+(h-E),m=v+y,h=m-v,b=v-(m-h)+(y-h),y=b-w,h=b-y,oa[1]=b-(y+h)+(h-w),A=m+y,h=A-m,oa[2]=m-(A-h)+(y-h),oa[3]=A;const O=ta(4,na,4,oa,ra);v=S*u,f=Qo*S,d=f-(f-S),p=S-d,f=Qo*u,_=f-(f-u),g=u-_,x=p*g-(v-d*_-p*_-d*g),w=C*c,f=Qo*C,d=f-(f-C),p=C-d,f=Qo*c,_=f-(f-c),g=c-_,E=p*g-(w-d*_-p*_-d*g),y=x-E,h=x-y,oa[0]=x-(y+h)+(h-E),m=v+y,h=m-v,b=v-(m-h)+(y-h),y=b-w,h=b-y,oa[1]=b-(y+h)+(h-w),A=m+y,h=A-m,oa[2]=m-(A-h)+(y-h),oa[3]=A;const N=ta(O,ra,4,oa,ia);v=a*u,f=Qo*a,d=f-(f-a),p=a-d,f=Qo*u,_=f-(f-u),g=u-_,x=p*g-(v-d*_-p*_-d*g),w=l*c,f=Qo*l,d=f-(f-l),p=l-d,f=Qo*c,_=f-(f-c),g=c-_,E=p*g-(w-d*_-p*_-d*g),y=x-E,h=x-y,oa[0]=x-(y+h)+(h-E),m=v+y,h=m-v,b=v-(m-h)+(y-h),y=b-w,h=b-y,oa[1]=b-(y+h)+(h-w),A=m+y,h=A-m,oa[2]=m-(A-h)+(y-h),oa[3]=A;const I=ta(N,ia,4,oa,sa);return sa[I-1]}(t,e,n,r,i,s,c)}const la=Math.pow(2,-52),ca=new Uint32Array(512);class ua{static from(t,e=ga,n=ya){const r=t.length,i=new Float64Array(2*r);for(let s=0;s<r;s++){const r=t[s];i[2*s]=e(r),i[2*s+1]=n(r)}return new ua(i)}constructor(t){const e=t.length>>1;if(e>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;const n=Math.max(2*e-5,0);this._triangles=new Uint32Array(3*n),this._halfedges=new Int32Array(3*n),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:n,_hullTri:r,_hullHash:i}=this,s=t.length>>1;let o=1/0,a=1/0,l=-1/0,c=-1/0;for(let e=0;e<s;e++){const n=t[2*e],r=t[2*e+1];n<o&&(o=n),r<a&&(a=r),n>l&&(l=n),r>c&&(c=r),this._ids[e]=e}const u=(o+l)/2,h=(a+c)/2;let f,d,p;for(let e=0,n=1/0;e<s;e++){const r=ha(u,h,t[2*e],t[2*e+1]);r<n&&(f=e,n=r)}const _=t[2*f],g=t[2*f+1];for(let e=0,n=1/0;e<s;e++){if(e===f)continue;const r=ha(_,g,t[2*e],t[2*e+1]);r<n&&r>0&&(d=e,n=r)}let y=t[2*d],m=t[2*d+1],b=1/0;for(let e=0;e<s;e++){if(e===f||e===d)continue;const n=da(_,g,y,m,t[2*e],t[2*e+1]);n<b&&(p=e,b=n)}let v=t[2*p],x=t[2*p+1];if(b===1/0){for(let e=0;e<s;e++)this._dists[e]=t[2*e]-t[0]||t[2*e+1]-t[1];pa(this._ids,this._dists,0,s-1);const e=new Uint32Array(s);let n=0;for(let t=0,r=-1/0;t<s;t++){const i=this._ids[t],s=this._dists[i];s>r&&(e[n++]=i,r=s)}return this.hull=e.subarray(0,n),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(aa(_,g,y,m,v,x)<0){const t=d,e=y,n=m;d=p,y=v,m=x,p=t,v=e,x=n}const w=function(t,e,n,r,i,s){const o=n-t,a=r-e,l=i-t,c=s-e,u=o*o+a*a,h=l*l+c*c,f=.5/(o*c-a*l),d=t+(c*u-a*h)*f,p=e+(o*h-l*u)*f;return{x:d,y:p}}(_,g,y,m,v,x);this._cx=w.x,this._cy=w.y;for(let e=0;e<s;e++)this._dists[e]=ha(t[2*e],t[2*e+1],w.x,w.y);pa(this._ids,this._dists,0,s-1),this._hullStart=f;let E=3;n[f]=e[p]=d,n[d]=e[f]=p,n[p]=e[d]=f,r[f]=0,r[d]=1,r[p]=2,i.fill(-1),i[this._hashKey(_,g)]=f,i[this._hashKey(y,m)]=d,i[this._hashKey(v,x)]=p,this.trianglesLen=0,this._addTriangle(f,d,p,-1,-1,-1);for(let s,o,a=0;a<this._ids.length;a++){const l=this._ids[a],c=t[2*l],u=t[2*l+1];if(a>0&&Math.abs(c-s)<=la&&Math.abs(u-o)<=la)continue;if(s=c,o=u,l===f||l===d||l===p)continue;let h=0;for(let t=0,e=this._hashKey(c,u);t<this._hashSize&&(h=i[(e+t)%this._hashSize],-1===h||h===n[h]);t++);h=e[h];let _,g=h;for(;_=n[g],aa(c,u,t[2*g],t[2*g+1],t[2*_],t[2*_+1])>=0;)if(g=_,g===h){g=-1;break}if(-1===g)continue;let y=this._addTriangle(g,l,n[g],-1,-1,r[g]);r[l]=this._legalize(y+2),r[g]=y,E++;let m=n[g];for(;_=n[m],aa(c,u,t[2*m],t[2*m+1],t[2*_],t[2*_+1])<0;)y=this._addTriangle(m,l,_,r[l],-1,r[m]),r[l]=this._legalize(y+2),n[m]=m,E--,m=_;if(g===h)for(;_=e[g],aa(c,u,t[2*_],t[2*_+1],t[2*g],t[2*g+1])<0;)y=this._addTriangle(_,l,g,-1,r[g],r[_]),this._legalize(y+2),r[_]=y,n[g]=g,E--,g=_;this._hullStart=e[l]=g,n[g]=e[m]=l,n[l]=m,i[this._hashKey(c,u)]=l,i[this._hashKey(t[2*g],t[2*g+1])]=g}this.hull=new Uint32Array(E);for(let t=0,e=this._hullStart;t<E;t++)this.hull[t]=e,e=n[e];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(function(t,e){const n=t/(Math.abs(t)+Math.abs(e));return(e>0?3-n:1+n)/4}(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:n,coords:r}=this;let i=0,s=0;for(;;){const o=n[t],a=t-t%3;if(s=a+(t+2)%3,-1===o){if(0===i)break;t=ca[--i];continue}const l=o-o%3,c=a+(t+1)%3,u=l+(o+2)%3,h=e[s],f=e[t],d=e[c],p=e[u];if(fa(r[2*h],r[2*h+1],r[2*f],r[2*f+1],r[2*d],r[2*d+1],r[2*p],r[2*p+1])){e[t]=p,e[o]=h;const r=n[u];if(-1===r){let e=this._hullStart;do{if(this._hullTri[e]===u){this._hullTri[e]=t;break}e=this._hullPrev[e]}while(e!==this._hullStart)}this._link(t,r),this._link(o,n[s]),this._link(s,u);const a=l+(o+1)%3;i<ca.length&&(ca[i++]=a)}else{if(0===i)break;t=ca[--i]}}return s}_link(t,e){this._halfedges[t]=e,-1!==e&&(this._halfedges[e]=t)}_addTriangle(t,e,n,r,i,s){const o=this.trianglesLen;return this._triangles[o]=t,this._triangles[o+1]=e,this._triangles[o+2]=n,this._link(o,r),this._link(o+1,i),this._link(o+2,s),this.trianglesLen+=3,o}}function ha(t,e,n,r){const i=t-n,s=e-r;return i*i+s*s}function fa(t,e,n,r,i,s,o,a){const l=t-o,c=e-a,u=n-o,h=r-a,f=i-o,d=s-a,p=u*u+h*h,_=f*f+d*d;return l*(h*_-p*d)-c*(u*_-p*f)+(l*l+c*c)*(u*d-h*f)<0}function da(t,e,n,r,i,s){const o=n-t,a=r-e,l=i-t,c=s-e,u=o*o+a*a,h=l*l+c*c,f=.5/(o*c-a*l),d=(c*u-a*h)*f,p=(o*h-l*u)*f;return d*d+p*p}function pa(t,e,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){const r=t[i],s=e[r];let o=i-1;for(;o>=n&&e[t[o]]>s;)t[o+1]=t[o--];t[o+1]=r}else{let i=n+1,s=r;_a(t,n+r>>1,i),e[t[n]]>e[t[r]]&&_a(t,n,r),e[t[i]]>e[t[r]]&&_a(t,i,r),e[t[n]]>e[t[i]]&&_a(t,n,i);const o=t[i],a=e[o];for(;;){do{i++}while(e[t[i]]<a);do{s--}while(e[t[s]]>a);if(s<i)break;_a(t,i,s)}t[n+1]=t[s],t[s]=o,r-i+1>=s-n?(pa(t,e,i,r),pa(t,e,n,s-1)):(pa(t,e,n,s-1),pa(t,e,i,r))}}function _a(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function ga(t){return t[0]}function ya(t){return t[1]}const ma=1e-6;let ba=class{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(t,e){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(t,e){this._+=`L${this._x1=+t},${this._y1=+e}`}arc(t,e,n){const r=(t=+t)+(n=+n),i=e=+e;if(n<0)throw new Error("negative radius");null===this._x1?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>ma||Math.abs(this._y1-i)>ma)&&(this._+="L"+r+","+i),n&&(this._+=`A${n},${n},0,1,1,${t-n},${e}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(t,e,n,r){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${+n}v${+r}h${-n}Z`}value(){return this._||null}},va=class{constructor(){this._=[]}moveTo(t,e){this._.push([t,e])}closePath(){this._.push(this._[0].slice())}lineTo(t,e){this._.push([t,e])}value(){return this._.length?this._:null}};class xa{constructor(t,[e,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(e=+e)&&(i=+i)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=t,this._circumcenters=new Float64Array(2*t.points.length),this.vectors=new Float64Array(2*t.points.length),this.xmax=r,this.xmin=e,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:t,hull:e,triangles:n},vectors:r}=this;let i,s;const o=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r,a,l=0,c=0,u=n.length;l<u;l+=3,c+=2){const u=2*n[l],h=2*n[l+1],f=2*n[l+2],d=t[u],p=t[u+1],_=t[h],g=t[h+1],y=t[f],m=t[f+1],b=_-d,v=g-p,x=y-d,w=m-p,E=2*(b*w-v*x);if(Math.abs(E)<1e-9){if(void 0===i){i=s=0;for(const n of e)i+=t[2*n],s+=t[2*n+1];i/=e.length,s/=e.length}const n=1e9*Math.sign((i-d)*w-(s-p)*x);r=(d+y)/2-n*w,a=(p+m)/2+n*x}else{const t=1/E,e=b*b+v*v,n=x*x+w*w;r=d+(w*e-v*n)*t,a=p+(b*n-x*e)*t}o[c]=r,o[c+1]=a}let a,l,c,u=e[e.length-1],h=4*u,f=t[2*u],d=t[2*u+1];r.fill(0);for(let n=0;n<e.length;++n)u=e[n],a=h,l=f,c=d,h=4*u,f=t[2*u],d=t[2*u+1],r[a+2]=r[h]=c-d,r[a+3]=r[h+1]=f-l}render(t){const e=null==t?t=new ba:void 0,{delaunay:{halfedges:n,inedges:r,hull:i},circumcenters:s,vectors:o}=this;if(i.length<=1)return null;for(let e=0,r=n.length;e<r;++e){const r=n[e];if(r<e)continue;const i=2*Math.floor(e/3),o=2*Math.floor(r/3),a=s[i],l=s[i+1],c=s[o],u=s[o+1];this._renderSegment(a,l,c,u,t)}let a,l=i[i.length-1];for(let e=0;e<i.length;++e){a=l,l=i[e];const n=2*Math.floor(r[l]/3),c=s[n],u=s[n+1],h=4*a,f=this._project(c,u,o[h+2],o[h+3]);f&&this._renderSegment(c,u,f[0],f[1],t)}return e&&e.value()}renderBounds(t){const e=null==t?t=new ba:void 0;return t.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),e&&e.value()}renderCell(t,e){const n=null==e?e=new ba:void 0,r=this._clip(t);if(null===r||!r.length)return;e.moveTo(r[0],r[1]);let i=r.length;for(;r[0]===r[i-2]&&r[1]===r[i-1]&&i>1;)i-=2;for(let t=2;t<i;t+=2)r[t]===r[t-2]&&r[t+1]===r[t-1]||e.lineTo(r[t],r[t+1]);return e.closePath(),n&&n.value()}*cellPolygons(){const{delaunay:{points:t}}=this;for(let e=0,n=t.length/2;e<n;++e){const t=this.cellPolygon(e);t&&(t.index=e,yield t)}}cellPolygon(t){const e=new va;return this.renderCell(t,e),e.value()}_renderSegment(t,e,n,r,i){let s;const o=this._regioncode(t,e),a=this._regioncode(n,r);0===o&&0===a?(i.moveTo(t,e),i.lineTo(n,r)):(s=this._clipSegment(t,e,n,r,o,a))&&(i.moveTo(s[0],s[1]),i.lineTo(s[2],s[3]))}contains(t,e,n){return(e=+e)==e&&(n=+n)==n&&this.delaunay._step(t,e,n)===t}*neighbors(t){const e=this._clip(t);if(e)for(const n of this.delaunay.neighbors(t)){const t=this._clip(n);if(t)t:for(let r=0,i=e.length;r<i;r+=2)for(let s=0,o=t.length;s<o;s+=2)if(e[r]===t[s]&&e[r+1]===t[s+1]&&e[(r+2)%i]===t[(s+o-2)%o]&&e[(r+3)%i]===t[(s+o-1)%o]){yield n;break t}}}_cell(t){const{circumcenters:e,delaunay:{inedges:n,halfedges:r,triangles:i}}=this,s=n[t];if(-1===s)return null;const o=[];let a=s;do{const n=Math.floor(a/3);if(o.push(e[2*n],e[2*n+1]),a=a%3==2?a-2:a+1,i[a]!==t)break;a=r[a]}while(a!==s&&-1!==a);return o}_clip(t){if(0===t&&1===this.delaunay.hull.length)return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];const e=this._cell(t);if(null===e)return null;const{vectors:n}=this,r=4*t;return this._simplify(n[r]||n[r+1]?this._clipInfinite(t,e,n[r],n[r+1],n[r+2],n[r+3]):this._clipFinite(t,e))}_clipFinite(t,e){const n=e.length;let r,i,s,o,a=null,l=e[n-2],c=e[n-1],u=this._regioncode(l,c),h=0;for(let f=0;f<n;f+=2)if(r=l,i=c,l=e[f],c=e[f+1],s=u,u=this._regioncode(l,c),0===s&&0===u)o=h,h=0,a?a.push(l,c):a=[l,c];else{let e,n,f,d,p;if(0===s){if(null===(e=this._clipSegment(r,i,l,c,s,u)))continue;[n,f,d,p]=e}else{if(null===(e=this._clipSegment(l,c,r,i,u,s)))continue;[d,p,n,f]=e,o=h,h=this._edgecode(n,f),o&&h&&this._edge(t,o,h,a,a.length),a?a.push(n,f):a=[n,f]}o=h,h=this._edgecode(d,p),o&&h&&this._edge(t,o,h,a,a.length),a?a.push(d,p):a=[d,p]}if(a)o=h,h=this._edgecode(a[0],a[1]),o&&h&&this._edge(t,o,h,a,a.length);else if(this.contains(t,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return a}_clipSegment(t,e,n,r,i,s){const o=i<s;for(o&&([t,e,n,r,i,s]=[n,r,t,e,s,i]);;){if(0===i&&0===s)return o?[n,r,t,e]:[t,e,n,r];if(i&s)return null;let a,l,c=i||s;8&c?(a=t+(n-t)*(this.ymax-e)/(r-e),l=this.ymax):4&c?(a=t+(n-t)*(this.ymin-e)/(r-e),l=this.ymin):2&c?(l=e+(r-e)*(this.xmax-t)/(n-t),a=this.xmax):(l=e+(r-e)*(this.xmin-t)/(n-t),a=this.xmin),i?(t=a,e=l,i=this._regioncode(t,e)):(n=a,r=l,s=this._regioncode(n,r))}}_clipInfinite(t,e,n,r,i,s){let o,a=Array.from(e);if((o=this._project(a[0],a[1],n,r))&&a.unshift(o[0],o[1]),(o=this._project(a[a.length-2],a[a.length-1],i,s))&&a.push(o[0],o[1]),a=this._clipFinite(t,a))for(let e,n=0,r=a.length,i=this._edgecode(a[r-2],a[r-1]);n<r;n+=2)e=i,i=this._edgecode(a[n],a[n+1]),e&&i&&(n=this._edge(t,e,i,a,n),r=a.length);else this.contains(t,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(a=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return a}_edge(t,e,n,r,i){for(;e!==n;){let n,s;switch(e){case 5:e=4;continue;case 4:e=6,n=this.xmax,s=this.ymin;break;case 6:e=2;continue;case 2:e=10,n=this.xmax,s=this.ymax;break;case 10:e=8;continue;case 8:e=9,n=this.xmin,s=this.ymax;break;case 9:e=1;continue;case 1:e=5,n=this.xmin,s=this.ymin}r[i]===n&&r[i+1]===s||!this.contains(t,n,s)||(r.splice(i,0,n,s),i+=2)}return i}_project(t,e,n,r){let i,s,o,a=1/0;if(r<0){if(e<=this.ymin)return null;(i=(this.ymin-e)/r)<a&&(o=this.ymin,s=t+(a=i)*n)}else if(r>0){if(e>=this.ymax)return null;(i=(this.ymax-e)/r)<a&&(o=this.ymax,s=t+(a=i)*n)}if(n>0){if(t>=this.xmax)return null;(i=(this.xmax-t)/n)<a&&(s=this.xmax,o=e+(a=i)*r)}else if(n<0){if(t<=this.xmin)return null;(i=(this.xmin-t)/n)<a&&(s=this.xmin,o=e+(a=i)*r)}return[s,o]}_edgecode(t,e){return(t===this.xmin?1:t===this.xmax?2:0)|(e===this.ymin?4:e===this.ymax?8:0)}_regioncode(t,e){return(t<this.xmin?1:t>this.xmax?2:0)|(e<this.ymin?4:e>this.ymax?8:0)}_simplify(t){if(t&&t.length>4){for(let e=0;e<t.length;e+=2){const n=(e+2)%t.length,r=(e+4)%t.length;(t[e]===t[n]&&t[n]===t[r]||t[e+1]===t[n+1]&&t[n+1]===t[r+1])&&(t.splice(n,2),e-=2)}t.length||(t=null)}return t}}const wa=2*Math.PI,Ea=Math.pow;function Aa(t){return t[0]}function Sa(t){return t[1]}function Ta(t,e,n){return[t+Math.sin(t+e)*n,e+Math.cos(t-e)*n]}class Ca{static from(t,e=Aa,n=Sa,r){return new Ca("length"in t?function(t,e,n,r){const i=t.length,s=new Float64Array(2*i);for(let o=0;o<i;++o){const i=t[o];s[2*o]=e.call(r,i,o,t),s[2*o+1]=n.call(r,i,o,t)}return s}(t,e,n,r):Float64Array.from(function*(t,e,n,r){let i=0;for(const s of t)yield e.call(r,s,i,t),yield n.call(r,s,i,t),++i}(t,e,n,r)))}constructor(t){this._delaunator=new ua(t),this.inedges=new Int32Array(t.length/2),this._hullIndex=new Int32Array(t.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const t=this._delaunator,e=this.points;if(t.hull&&t.hull.length>2&&function(t){const{triangles:e,coords:n}=t;for(let t=0;t<e.length;t+=3){const r=2*e[t],i=2*e[t+1],s=2*e[t+2];if((n[s]-n[r])*(n[i+1]-n[r+1])-(n[i]-n[r])*(n[s+1]-n[r+1])>1e-10)return!1}return!0}(t)){this.collinear=Int32Array.from({length:e.length/2},(t,e)=>e).sort((t,n)=>e[2*t]-e[2*n]||e[2*t+1]-e[2*n+1]);const t=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[e[2*t],e[2*t+1],e[2*n],e[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let t=0,n=e.length/2;t<n;++t){const n=Ta(e[2*t],e[2*t+1],i);e[2*t]=n[0],e[2*t+1]=n[1]}this._delaunator=new ua(e)}else delete this.collinear;const n=this.halfedges=this._delaunator.halfedges,r=this.hull=this._delaunator.hull,i=this.triangles=this._delaunator.triangles,s=this.inedges.fill(-1),o=this._hullIndex.fill(-1);for(let t=0,e=n.length;t<e;++t){const e=i[t%3==2?t-2:t+1];-1!==n[t]&&-1!==s[e]||(s[e]=t)}for(let t=0,e=r.length;t<e;++t)o[r[t]]=t;r.length<=2&&r.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],s[r[0]]=1,2===r.length&&(s[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(t){return new xa(this,t)}*neighbors(t){const{inedges:e,hull:n,_hullIndex:r,halfedges:i,triangles:s,collinear:o}=this;if(o){const e=o.indexOf(t);return e>0&&(yield o[e-1]),void(e<o.length-1&&(yield o[e+1]))}const a=e[t];if(-1===a)return;let l=a,c=-1;do{if(yield c=s[l],l=l%3==2?l-2:l+1,s[l]!==t)return;if(l=i[l],-1===l){const e=n[(r[t]+1)%n.length];return void(e!==c&&(yield e))}}while(l!==a)}find(t,e,n=0){if((t=+t)!=t||(e=+e)!=e)return-1;const r=n;let i;for(;(i=this._step(n,t,e))>=0&&i!==n&&i!==r;)n=i;return i}_step(t,e,n){const{inedges:r,hull:i,_hullIndex:s,halfedges:o,triangles:a,points:l}=this;if(-1===r[t]||!l.length)return(t+1)%(l.length>>1);let c=t,u=Ea(e-l[2*t],2)+Ea(n-l[2*t+1],2);const h=r[t];let f=h;do{let r=a[f];const h=Ea(e-l[2*r],2)+Ea(n-l[2*r+1],2);if(h<u&&(u=h,c=r),f=f%3==2?f-2:f+1,a[f]!==t)break;if(f=o[f],-1===f){if(f=i[(s[t]+1)%i.length],f!==r&&Ea(e-l[2*f],2)+Ea(n-l[2*f+1],2)<u)return f;break}}while(f!==h);return c}render(t){const e=null==t?t=new ba:void 0,{points:n,halfedges:r,triangles:i}=this;for(let e=0,s=r.length;e<s;++e){const s=r[e];if(s<e)continue;const o=2*i[e],a=2*i[s];t.moveTo(n[o],n[o+1]),t.lineTo(n[a],n[a+1])}return this.renderHull(t),e&&e.value()}renderPoints(t,e){void 0!==e||t&&"function"==typeof t.moveTo||(e=t,t=null),e=null==e?2:+e;const n=null==t?t=new ba:void 0,{points:r}=this;for(let n=0,i=r.length;n<i;n+=2){const i=r[n],s=r[n+1];t.moveTo(i+e,s),t.arc(i,s,e,0,wa)}return n&&n.value()}renderHull(t){const e=null==t?t=new ba:void 0,{hull:n,points:r}=this,i=2*n[0],s=n.length;t.moveTo(r[i],r[i+1]);for(let e=1;e<s;++e){const i=2*n[e];t.lineTo(r[i],r[i+1])}return t.closePath(),e&&e.value()}hullPolygon(){const t=new va;return this.renderHull(t),t.value()}renderTriangle(t,e){const n=null==e?e=new ba:void 0,{points:r,triangles:i}=this,s=2*i[t*=3],o=2*i[t+1],a=2*i[t+2];return e.moveTo(r[s],r[s+1]),e.lineTo(r[o],r[o+1]),e.lineTo(r[a],r[a+1]),e.closePath(),n&&n.value()}*trianglePolygons(){const{triangles:t}=this;for(let e=0,n=t.length/3;e<n;++e)yield this.trianglePolygon(e)}trianglePolygon(t){const e=new va;return this.renderTriangle(t,e),e.value()}}var ka={},Ra={};function Ma(t){return new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'}).join(",")+"}")}function Oa(t){var e=Object.create(null),n=[];return t.forEach(function(t){for(var r in t)r in e||n.push(e[r]=r)}),n}function Na(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function Ia(t){var e,n=t.getUTCHours(),r=t.getUTCMinutes(),i=t.getUTCSeconds(),s=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":((e=t.getUTCFullYear())<0?"-"+Na(-e,6):e>9999?"+"+Na(e,6):Na(e,4))+"-"+Na(t.getUTCMonth()+1,2)+"-"+Na(t.getUTCDate(),2)+(s?"T"+Na(n,2)+":"+Na(r,2)+":"+Na(i,2)+"."+Na(s,3)+"Z":i?"T"+Na(n,2)+":"+Na(r,2)+":"+Na(i,2)+"Z":r||n?"T"+Na(n,2)+":"+Na(r,2)+"Z":"")}function Pa(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],s=t.length,o=0,a=0,l=s<=0,c=!1;function u(){if(l)return Ra;if(c)return c=!1,ka;var e,r,i=o;if(34===t.charCodeAt(i)){for(;o++<s&&34!==t.charCodeAt(o)||34===t.charCodeAt(++o););return(e=o)>=s?l=!0:10===(r=t.charCodeAt(o++))?c=!0:13===r&&(c=!0,10===t.charCodeAt(o)&&++o),t.slice(i+1,e-1).replace(/""/g,'"')}for(;o<s;){if(10===(r=t.charCodeAt(e=o++)))c=!0;else if(13===r)c=!0,10===t.charCodeAt(o)&&++o;else if(r!==n)continue;return t.slice(i,e)}return l=!0,t.slice(i,s)}for(10===t.charCodeAt(s-1)&&--s,13===t.charCodeAt(s-1)&&--s;(r=u())!==Ra;){for(var h=[];r!==ka&&r!==Ra;)h.push(r),r=u();e&&null==(h=e(h,a++))||i.push(h)}return i}function i(e,n){return e.map(function(e){return n.map(function(t){return o(e[t])}).join(t)})}function s(e){return e.map(o).join(t)}function o(t){return null==t?"":t instanceof Date?Ia(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,s=r(t,function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=Ma(t);return function(r,i){return e(n(r),i,t)}}(t,e):Ma(t)});return s.columns=i||[],s},parseRows:r,format:function(e,n){return null==n&&(n=Oa(e)),[n.map(o).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=Oa(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(s).join("\n")},formatRow:s,formatValue:o}}var La=Pa(","),Da=La.parse,Va=La.parseRows,Ba=La.format,za=La.formatBody,Ga=La.formatRows,Fa=La.formatRow,ja=La.formatValue,Ua=Pa("\t"),Ya=Ua.parse,Ha=Ua.parseRows,Wa=Ua.format,qa=Ua.formatBody,$a=Ua.formatRows,Xa=Ua.formatRow,Ka=Ua.formatValue;function Za(t){for(var e in t){var n,r,i=t[e].trim();if(i)if("true"===i)i=!0;else if("false"===i)i=!1;else if("NaN"===i)i=NaN;else if(isNaN(n=+i)){if(!(r=i.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;Ja&&r[4]&&!r[7]&&(i=i.replace(/-/g,"/").replace(/T/," ")),i=new Date(i)}else i=n;else i=null;t[e]=i}return t}const Ja=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();function Qa(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.blob()}function tl(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.arrayBuffer()}function el(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.text()}function nl(t,e){return fetch(t,e).then(el)}function rl(t){return function(e,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=void 0),nl(e,n).then(function(e){return t(e,r)})}}var il=rl(Da),sl=rl(Ya);function ol(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);if(204!==t.status&&205!==t.status)return t.json()}function al(t){return(e,n)=>nl(e,n).then(e=>(new DOMParser).parseFromString(e,t))}var ll=al("application/xml"),cl=al("text/html"),ul=al("image/svg+xml");function hl(t,e){var n,r=1;function i(){var i,s,o=n.length,a=0,l=0;for(i=0;i<o;++i)a+=(s=n[i]).x,l+=s.y;for(a=(a/o-t)*r,l=(l/o-e)*r,i=0;i<o;++i)(s=n[i]).x-=a,s.y-=l}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function fl(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,s,o,a,l,c,u,h,f,d=t._root,p={data:r},_=t._x0,g=t._y0,y=t._x1,m=t._y1;if(!d)return t._root=p,t;for(;d.length;)if((c=e>=(s=(_+y)/2))?_=s:y=s,(u=n>=(o=(g+m)/2))?g=o:m=o,i=d,!(d=d[h=u<<1|c]))return i[h]=p,t;if(a=+t._x.call(null,d.data),l=+t._y.call(null,d.data),e===a&&n===l)return p.next=d,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(c=e>=(s=(_+y)/2))?_=s:y=s,(u=n>=(o=(g+m)/2))?g=o:m=o}while((h=u<<1|c)==(f=(l>=o)<<1|a>=s));return i[f]=d,i[h]=p,t}function dl(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function pl(t){return t[0]}function _l(t){return t[1]}function gl(t,e,n){var r=new yl(null==e?pl:e,null==n?_l:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function yl(t,e,n,r,i,s){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=s,this._root=void 0}function ml(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var bl=gl.prototype=yl.prototype;function vl(t){return function(){return t}}function xl(t){return 1e-6*(t()-.5)}function wl(t){return t.x+t.vx}function El(t){return t.y+t.vy}function Al(t){return t.index}function Sl(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Tl(t){var e,n,r,i,s,o,a=Al,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=vl(30),u=1;function h(r){for(var i=0,a=t.length;i<u;++i)for(var l,c,h,f,d,p,_,g=0;g<a;++g)c=(l=t[g]).source,f=(h=l.target).x+h.vx-c.x-c.vx||xl(o),d=h.y+h.vy-c.y-c.vy||xl(o),f*=p=((p=Math.sqrt(f*f+d*d))-n[g])/p*r*e[g],d*=p,h.vx-=f*(_=s[g]),h.vy-=d*_,c.vx+=f*(_=1-_),c.vy+=d*_}function f(){if(r){var o,l,c=r.length,u=t.length,h=new Map(r.map((t,e)=>[a(t,e,r),t]));for(o=0,i=new Array(c);o<u;++o)(l=t[o]).index=o,"object"!=typeof l.source&&(l.source=Sl(h,l.source)),"object"!=typeof l.target&&(l.target=Sl(h,l.target)),i[l.source.index]=(i[l.source.index]||0)+1,i[l.target.index]=(i[l.target.index]||0)+1;for(o=0,s=new Array(u);o<u;++o)l=t[o],s[o]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(u),d(),n=new Array(u),p()}}function d(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+c(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,o=e,f()},h.links=function(e){return arguments.length?(t=e,f(),h):t},h.id=function(t){return arguments.length?(a=t,h):a},h.iterations=function(t){return arguments.length?(u=+t,h):u},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:vl(+t),d(),h):l},h.distance=function(t){return arguments.length?(c="function"==typeof t?t:vl(+t),p(),h):c},h}bl.copy=function(){var t,e,n=new yl(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=ml(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=ml(e));return n},bl.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return fl(this.cover(e,n),e,n,t)},bl.addAll=function(t){var e,n,r,i,s=t.length,o=new Array(s),a=new Array(s),l=1/0,c=1/0,u=-1/0,h=-1/0;for(n=0;n<s;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(o[n]=r,a[n]=i,r<l&&(l=r),r>u&&(u=r),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<s;++n)fl(this,o[n],a[n],t[n]);return this},bl.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,s=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,s=(r=Math.floor(e))+1;else{for(var o,a,l=i-n||1,c=this._root;n>t||t>=i||r>e||e>=s;)switch(a=(e<r)<<1|t<n,(o=new Array(4))[a]=c,c=o,l*=2,a){case 0:i=n+l,s=r+l;break;case 1:n=i-l,s=r+l;break;case 2:i=n+l,r=s-l;break;case 3:n=i-l,r=s-l}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=r,this._x1=i,this._y1=s,this},bl.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},bl.extent=function(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]]},bl.find=function(t,e,n){var r,i,s,o,a,l,c,u=this._x0,h=this._y0,f=this._x1,d=this._y1,p=[],_=this._root;for(_&&p.push(new dl(_,u,h,f,d)),null==n?n=1/0:(u=t-n,h=e-n,f=t+n,d=e+n,n*=n);l=p.pop();)if(!(!(_=l.node)||(i=l.x0)>f||(s=l.y0)>d||(o=l.x1)<u||(a=l.y1)<h))if(_.length){var g=(i+o)/2,y=(s+a)/2;p.push(new dl(_[3],g,y,o,a),new dl(_[2],i,y,g,a),new dl(_[1],g,s,o,y),new dl(_[0],i,s,g,y)),(c=(e>=y)<<1|t>=g)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=l)}else{var m=t-+this._x.call(null,_.data),b=e-+this._y.call(null,_.data),v=m*m+b*b;if(v<n){var x=Math.sqrt(n=v);u=t-x,h=e-x,f=t+x,d=e+x,r=_.data}}return r},bl.remove=function(t){if(isNaN(s=+this._x.call(null,t))||isNaN(o=+this._y.call(null,t)))return this;var e,n,r,i,s,o,a,l,c,u,h,f,d=this._root,p=this._x0,_=this._y0,g=this._x1,y=this._y1;if(!d)return this;if(d.length)for(;;){if((c=s>=(a=(p+g)/2))?p=a:g=a,(u=o>=(l=(_+y)/2))?_=l:y=l,e=d,!(d=d[h=u<<1|c]))return this;if(!d.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,f=h)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(n?n[f]=d:this._root=d),this):(this._root=i,this)},bl.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},bl.root=function(){return this._root},bl.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},bl.visit=function(t){var e,n,r,i,s,o,a=[],l=this._root;for(l&&a.push(new dl(l,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,s=e.x1,o=e.y1)&&l.length){var c=(r+s)/2,u=(i+o)/2;(n=l[3])&&a.push(new dl(n,c,u,s,o)),(n=l[2])&&a.push(new dl(n,r,u,c,o)),(n=l[1])&&a.push(new dl(n,c,i,s,u)),(n=l[0])&&a.push(new dl(n,r,i,c,u))}return this},bl.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new dl(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var s,o=e.x0,a=e.y0,l=e.x1,c=e.y1,u=(o+l)/2,h=(a+c)/2;(s=i[0])&&n.push(new dl(s,o,a,u,h)),(s=i[1])&&n.push(new dl(s,u,a,l,h)),(s=i[2])&&n.push(new dl(s,o,h,u,c)),(s=i[3])&&n.push(new dl(s,u,h,l,c))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},bl.x=function(t){return arguments.length?(this._x=t,this):this._x},bl.y=function(t){return arguments.length?(this._y=t,this):this._y};const Cl=4294967296;function kl(t){return t.x}function Rl(t){return t.y}var Ml=Math.PI*(3-Math.sqrt(5));function Ol(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),s=0,o=.6,a=new Map,l=Si(h),c=Nt("tick","end"),u=function(){let t=1;return()=>(t=(1664525*t+1013904223)%Cl)/Cl}();function h(){f(),c.call("tick",e),n<r&&(l.stop(),c.call("end",e))}function f(r){var l,c,u=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(s-n)*i,a.forEach(function(t){t(n)}),l=0;l<u;++l)null==(c=t[l]).fx?c.x+=c.vx*=o:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=o:(c.y=c.fy,c.vy=0);return e}function d(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),s=n*Ml;e.x=i*Math.cos(s),e.y=i*Math.sin(s)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,u),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,d(),a.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(s=+t,e):s},velocityDecay:function(t){return arguments.length?(o=1-t,e):1-o},randomSource:function(t){return arguments.length?(u=t,a.forEach(p),e):u},force:function(t,n){return arguments.length>1?(null==n?a.delete(t):a.set(t,p(n)),e):a.get(t)},find:function(e,n,r){var i,s,o,a,l,c=0,u=t.length;for(null==r?r=1/0:r*=r,c=0;c<u;++c)(o=(i=e-(a=t[c]).x)*i+(s=n-a.y)*s)<r&&(l=a,r=o);return l},on:function(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t)}}}function Nl(){var t,e,n,r,i,s=vl(-30),o=1,a=1/0,l=.81;function c(n){var i,s=t.length,o=gl(t,kl,Rl).visitAfter(h);for(r=n,i=0;i<s;++i)e=t[i],o.visit(f)}function u(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+s(n,e,t)}}function h(t){var e,n,r,s,o,a=0,l=0;if(t.length){for(r=s=o=0;o<4;++o)(e=t[o])&&(n=Math.abs(e.value))&&(a+=e.value,l+=n,r+=n*e.x,s+=n*e.y);t.x=r/l,t.y=s/l}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=i[e.data.index]}while(e=e.next)}t.value=a}function f(t,s,c,u){if(!t.value)return!0;var h=t.x-e.x,f=t.y-e.y,d=u-s,p=h*h+f*f;if(d*d/l<p)return p<a&&(0===h&&(p+=(h=xl(n))*h),0===f&&(p+=(f=xl(n))*f),p<o&&(p=Math.sqrt(o*p)),e.vx+=h*t.value*r/p,e.vy+=f*t.value*r/p),!0;if(!(t.length||p>=a)){(t.data!==e||t.next)&&(0===h&&(p+=(h=xl(n))*h),0===f&&(p+=(f=xl(n))*f),p<o&&(p=Math.sqrt(o*p)));do{t.data!==e&&(d=i[t.data.index]*r/p,e.vx+=h*d,e.vy+=f*d)}while(t=t.next)}}return c.initialize=function(e,r){t=e,n=r,u()},c.strength=function(t){return arguments.length?(s="function"==typeof t?t:vl(+t),u(),c):s},c.distanceMin=function(t){return arguments.length?(o=t*t,c):Math.sqrt(o)},c.distanceMax=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.theta=function(t){return arguments.length?(l=t*t,c):Math.sqrt(l)},c}function Il(t){var e,n,r,i=vl(.1);function s(t){for(var i,s=0,o=e.length;s<o;++s)(i=e[s]).vx+=(r[s]-i.x)*n[s]*t}function o(){if(e){var s,o=e.length;for(n=new Array(o),r=new Array(o),s=0;s<o;++s)n[s]=isNaN(r[s]=+t(e[s],s,e))?0:+i(e[s],s,e)}}return"function"!=typeof t&&(t=vl(null==t?0:+t)),s.initialize=function(t){e=t,o()},s.strength=function(t){return arguments.length?(i="function"==typeof t?t:vl(+t),o(),s):i},s.x=function(e){return arguments.length?(t="function"==typeof e?e:vl(+e),o(),s):t},s}function Pl(t){var e,n,r,i=vl(.1);function s(t){for(var i,s=0,o=e.length;s<o;++s)(i=e[s]).vy+=(r[s]-i.y)*n[s]*t}function o(){if(e){var s,o=e.length;for(n=new Array(o),r=new Array(o),s=0;s<o;++s)n[s]=isNaN(r[s]=+t(e[s],s,e))?0:+i(e[s],s,e)}}return"function"!=typeof t&&(t=vl(null==t?0:+t)),s.initialize=function(t){e=t,o()},s.strength=function(t){return arguments.length?(i="function"==typeof t?t:vl(+t),o(),s):i},s.y=function(e){return arguments.length?(t="function"==typeof e?e:vl(+e),o(),s):t},s}function Ll(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 Dl(t){return(t=Ll(Math.abs(t)))?t[1]:NaN}var Vl,Bl=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function zl(t){if(!(e=Bl.exec(t)))throw new Error("invalid format: "+t);var e;return new Gl({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]})}function Gl(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Fl(t,e){var n=Ll(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}zl.prototype=Gl.prototype,Gl.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var jl={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,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)=>Fl(100*t,e),r:Fl,s:function(t,e){var n=Ll(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(Vl=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return s===o?r:s>o?r+new Array(s-o+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+Ll(t,Math.max(0,e+s-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Ul(t){return t}var Yl,Hl,Wl,ql=Array.prototype.map,$l=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Xl(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Ul:(e=ql.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,s=[],o=0,a=e[0],l=0;i>0&&a>0&&(l+a+1>r&&(a=Math.max(1,r-l)),s.push(t.substring(i-=a,i+a)),!((l+=a+1)>r));)a=e[o=(o+1)%e.length];return s.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",s=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",a=void 0===t.numerals?Ul:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(ql.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",c=void 0===t.minus?"−":t.minus+"",u=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=zl(t)).fill,n=t.align,h=t.sign,f=t.symbol,d=t.zero,p=t.width,_=t.comma,g=t.precision,y=t.trim,m=t.type;"n"===m?(_=!0,m="g"):jl[m]||(void 0===g&&(g=12),y=!0,m="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var b="$"===f?i:"#"===f&&/[boxX]/.test(m)?"0"+m.toLowerCase():"",v="$"===f?s:/[%p]/.test(m)?l:"",x=jl[m],w=/[defgprs%]/.test(m);function E(t){var i,s,l,f=b,E=v;if("c"===m)E=x(t)+E,t="";else{var A=(t=+t)<0||1/t<0;if(t=isNaN(t)?u:x(Math.abs(t),g),y&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),A&&0===+t&&"+"!==h&&(A=!1),f=(A?"("===h?h:c:"-"===h||"("===h?"":h)+f,E=("s"===m?$l[8+Vl/3]:"")+E+(A&&"("===h?")":""),w)for(i=-1,s=t.length;++i<s;)if(48>(l=t.charCodeAt(i))||l>57){E=(46===l?o+t.slice(i+1):t.slice(i))+E,t=t.slice(0,i);break}}_&&!d&&(t=r(t,1/0));var S=f.length+t.length+E.length,T=S<p?new Array(p-S+1).join(e):"";switch(_&&d&&(t=r(T+t,T.length?p-E.length:1/0),T=""),n){case"<":t=f+t+E+T;break;case"=":t=f+T+t+E;break;case"^":t=T.slice(0,S=T.length>>1)+f+t+E+T.slice(S);break;default:t=T+f+t+E}return a(t)}return g=void 0===g?6:/[gprs]/.test(m)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),E.toString=function(){return t+""},E}return{format:h,formatPrefix:function(t,e){var n=h(((t=zl(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Dl(e)/3))),i=Math.pow(10,-r),s=$l[8+r/3];return function(t){return n(i*t)+s}}}}function Kl(t){return Yl=Xl(t),Hl=Yl.format,Wl=Yl.formatPrefix,Yl}function Zl(t){return Math.max(0,-Dl(Math.abs(t)))}function Jl(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Dl(e)/3)))-Dl(Math.abs(t)))}function Ql(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Dl(e)-Dl(t))+1}Kl({thousands:",",grouping:[3],currency:["$",""]});var tc=1e-6,ec=1e-12,nc=Math.PI,rc=nc/2,ic=nc/4,sc=2*nc,oc=180/nc,ac=nc/180,lc=Math.abs,cc=Math.atan,uc=Math.atan2,hc=Math.cos,fc=Math.ceil,dc=Math.exp,pc=Math.hypot,_c=Math.log,gc=Math.pow,yc=Math.sin,mc=Math.sign||function(t){return t>0?1:t<0?-1:0},bc=Math.sqrt,vc=Math.tan;function xc(t){return t>1?0:t<-1?nc:Math.acos(t)}function wc(t){return t>1?rc:t<-1?-rc:Math.asin(t)}function Ec(t){return(t=yc(t/2))*t}function Ac(){}function Sc(t,e){t&&Cc.hasOwnProperty(t.type)&&Cc[t.type](t,e)}var Tc={Feature:function(t,e){Sc(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;)Sc(n[r].geometry,e)}},Cc={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)t=n[r],e.point(t[0],t[1],t[2])},LineString:function(t,e){kc(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)kc(n[r],e,0)},Polygon:function(t,e){Rc(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)Rc(n[r],e)},GeometryCollection:function(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;)Sc(n[r],e)}};function kc(t,e,n){var r,i=-1,s=t.length-n;for(e.lineStart();++i<s;)r=t[i],e.point(r[0],r[1],r[2]);e.lineEnd()}function Rc(t,e){var n=-1,r=t.length;for(e.polygonStart();++n<r;)kc(t[n],e,1);e.polygonEnd()}function Mc(t,e){t&&Tc.hasOwnProperty(t.type)?Tc[t.type](t,e):Sc(t,e)}var Oc,Nc,Ic,Pc,Lc,Dc,Vc,Bc,zc,Gc,Fc,jc,Uc,Yc,Hc,Wc,qc=new w,$c=new w,Xc={point:Ac,lineStart:Ac,lineEnd:Ac,polygonStart:function(){qc=new w,Xc.lineStart=Kc,Xc.lineEnd=Zc},polygonEnd:function(){var t=+qc;$c.add(t<0?sc+t:t),this.lineStart=this.lineEnd=this.point=Ac},sphere:function(){$c.add(sc)}};function Kc(){Xc.point=Jc}function Zc(){Qc(Oc,Nc)}function Jc(t,e){Xc.point=Qc,Oc=t,Nc=e,Ic=t*=ac,Pc=hc(e=(e*=ac)/2+ic),Lc=yc(e)}function Qc(t,e){var n=(t*=ac)-Ic,r=n>=0?1:-1,i=r*n,s=hc(e=(e*=ac)/2+ic),o=yc(e),a=Lc*o,l=Pc*s+a*hc(i),c=a*r*yc(i);qc.add(uc(c,l)),Ic=t,Pc=s,Lc=o}function tu(t){return[uc(t[1],t[0]),wc(t[2])]}function eu(t){var e=t[0],n=t[1],r=hc(n);return[r*hc(e),r*yc(e),yc(n)]}function nu(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ru(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function iu(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function su(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function ou(t){var e=bc(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}var au,lu,cu,uu,hu,fu,du,pu,_u,gu,yu,mu,bu,vu,xu,wu,Eu={point:Au,lineStart:Tu,lineEnd:Cu,polygonStart:function(){Eu.point=ku,Eu.lineStart=Ru,Eu.lineEnd=Mu,Yc=new w,Xc.polygonStart()},polygonEnd:function(){Xc.polygonEnd(),Eu.point=Au,Eu.lineStart=Tu,Eu.lineEnd=Cu,qc<0?(Dc=-(Bc=180),Vc=-(zc=90)):Yc>tc?zc=90:Yc<-1e-6&&(Vc=-90),Wc[0]=Dc,Wc[1]=Bc},sphere:function(){Dc=-(Bc=180),Vc=-(zc=90)}};function Au(t,e){Hc.push(Wc=[Dc=t,Bc=t]),e<Vc&&(Vc=e),e>zc&&(zc=e)}function Su(t,e){var n=eu([t*ac,e*ac]);if(Uc){var r=ru(Uc,n),i=ru([r[1],-r[0],0],r);ou(i),i=tu(i);var s,o=t-Gc,a=o>0?1:-1,l=i[0]*oc*a,c=lc(o)>180;c^(a*Gc<l&&l<a*t)?(s=i[1]*oc)>zc&&(zc=s):c^(a*Gc<(l=(l+360)%360-180)&&l<a*t)?(s=-i[1]*oc)<Vc&&(Vc=s):(e<Vc&&(Vc=e),e>zc&&(zc=e)),c?t<Gc?Ou(Dc,t)>Ou(Dc,Bc)&&(Bc=t):Ou(t,Bc)>Ou(Dc,Bc)&&(Dc=t):Bc>=Dc?(t<Dc&&(Dc=t),t>Bc&&(Bc=t)):t>Gc?Ou(Dc,t)>Ou(Dc,Bc)&&(Bc=t):Ou(t,Bc)>Ou(Dc,Bc)&&(Dc=t)}else Hc.push(Wc=[Dc=t,Bc=t]);e<Vc&&(Vc=e),e>zc&&(zc=e),Uc=n,Gc=t}function Tu(){Eu.point=Su}function Cu(){Wc[0]=Dc,Wc[1]=Bc,Eu.point=Au,Uc=null}function ku(t,e){if(Uc){var n=t-Gc;Yc.add(lc(n)>180?n+(n>0?360:-360):n)}else Fc=t,jc=e;Xc.point(t,e),Su(t,e)}function Ru(){Xc.lineStart()}function Mu(){ku(Fc,jc),Xc.lineEnd(),lc(Yc)>tc&&(Dc=-(Bc=180)),Wc[0]=Dc,Wc[1]=Bc,Uc=null}function Ou(t,e){return(e-=t)<0?e+360:e}function Nu(t,e){return t[0]-e[0]}function Iu(t,e){return t[0]<=t[1]?t[0]<=e&&e<=t[1]:e<t[0]||t[1]<e}var Pu={sphere:Ac,point:Lu,lineStart:Vu,lineEnd:Gu,polygonStart:function(){Pu.lineStart=Fu,Pu.lineEnd=ju},polygonEnd:function(){Pu.lineStart=Vu,Pu.lineEnd=Gu}};function Lu(t,e){t*=ac;var n=hc(e*=ac);Du(n*hc(t),n*yc(t),yc(e))}function Du(t,e,n){++au,cu+=(t-cu)/au,uu+=(e-uu)/au,hu+=(n-hu)/au}function Vu(){Pu.point=Bu}function Bu(t,e){t*=ac;var n=hc(e*=ac);vu=n*hc(t),xu=n*yc(t),wu=yc(e),Pu.point=zu,Du(vu,xu,wu)}function zu(t,e){t*=ac;var n=hc(e*=ac),r=n*hc(t),i=n*yc(t),s=yc(e),o=uc(bc((o=xu*s-wu*i)*o+(o=wu*r-vu*s)*o+(o=vu*i-xu*r)*o),vu*r+xu*i+wu*s);lu+=o,fu+=o*(vu+(vu=r)),du+=o*(xu+(xu=i)),pu+=o*(wu+(wu=s)),Du(vu,xu,wu)}function Gu(){Pu.point=Lu}function Fu(){Pu.point=Uu}function ju(){Yu(mu,bu),Pu.point=Lu}function Uu(t,e){mu=t,bu=e,t*=ac,e*=ac,Pu.point=Yu;var n=hc(e);vu=n*hc(t),xu=n*yc(t),wu=yc(e),Du(vu,xu,wu)}function Yu(t,e){t*=ac;var n=hc(e*=ac),r=n*hc(t),i=n*yc(t),s=yc(e),o=xu*s-wu*i,a=wu*r-vu*s,l=vu*i-xu*r,c=pc(o,a,l),u=wc(c),h=c&&-u/c;_u.add(h*o),gu.add(h*a),yu.add(h*l),lu+=u,fu+=u*(vu+(vu=r)),du+=u*(xu+(xu=i)),pu+=u*(wu+(wu=s)),Du(vu,xu,wu)}function Hu(t){return function(){return t}}function Wu(t,e){function n(n,r){return n=t(n,r),e(n[0],n[1])}return t.invert&&e.invert&&(n.invert=function(n,r){return(n=e.invert(n,r))&&t.invert(n[0],n[1])}),n}function qu(t,e){return lc(t)>nc&&(t-=Math.round(t/sc)*sc),[t,e]}function $u(t,e,n){return(t%=sc)?e||n?Wu(Ku(t),Zu(e,n)):Ku(t):e||n?Zu(e,n):qu}function Xu(t){return function(e,n){return lc(e+=t)>nc&&(e-=Math.round(e/sc)*sc),[e,n]}}function Ku(t){var e=Xu(t);return e.invert=Xu(-t),e}function Zu(t,e){var n=hc(t),r=yc(t),i=hc(e),s=yc(e);function o(t,e){var o=hc(e),a=hc(t)*o,l=yc(t)*o,c=yc(e),u=c*n+a*r;return[uc(l*i-u*s,a*n-c*r),wc(u*i+l*s)]}return o.invert=function(t,e){var o=hc(e),a=hc(t)*o,l=yc(t)*o,c=yc(e),u=c*i-l*s;return[uc(l*i+c*s,a*n+u*r),wc(u*n-a*r)]},o}function Ju(t){function e(e){return(e=t(e[0]*ac,e[1]*ac))[0]*=oc,e[1]*=oc,e}return t=$u(t[0]*ac,t[1]*ac,t.length>2?t[2]*ac:0),e.invert=function(e){return(e=t.invert(e[0]*ac,e[1]*ac))[0]*=oc,e[1]*=oc,e},e}function Qu(t,e,n,r,i,s){if(n){var o=hc(e),a=yc(e),l=r*n;null==i?(i=e+r*sc,s=e-l/2):(i=th(o,i),s=th(o,s),(r>0?i<s:i>s)&&(i+=r*sc));for(var c,u=i;r>0?u>s:u<s;u-=l)c=tu([o,-a*hc(u),-a*yc(u)]),t.point(c[0],c[1])}}function th(t,e){(e=eu(e))[0]-=t,ou(e);var n=xc(-e[1]);return((-e[2]<0?-n:n)+sc-tc)%sc}function eh(){var t,e=[];return{point:function(e,n,r){t.push([e,n,r])},lineStart:function(){e.push(t=[])},lineEnd:Ac,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function nh(t,e){return lc(t[0]-e[0])<tc&&lc(t[1]-e[1])<tc}function rh(t,e,n,r){this.x=t,this.z=e,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function ih(t,e,n,r,i){var s,o,a=[],l=[];if(t.forEach(function(t){if(!((e=t.length-1)<=0)){var e,n,r=t[0],o=t[e];if(nh(r,o)){if(!r[2]&&!o[2]){for(i.lineStart(),s=0;s<e;++s)i.point((r=t[s])[0],r[1]);return void i.lineEnd()}o[0]+=2e-6}a.push(n=new rh(r,t,null,!0)),l.push(n.o=new rh(r,null,n,!1)),a.push(n=new rh(o,t,null,!1)),l.push(n.o=new rh(o,null,n,!0))}}),a.length){for(l.sort(e),sh(a),sh(l),s=0,o=l.length;s<o;++s)l[s].e=n=!n;for(var c,u,h=a[0];;){for(var f=h,d=!0;f.v;)if((f=f.n)===h)return;c=f.z,i.lineStart();do{if(f.v=f.o.v=!0,f.e){if(d)for(s=0,o=c.length;s<o;++s)i.point((u=c[s])[0],u[1]);else r(f.x,f.n.x,1,i);f=f.n}else{if(d)for(c=f.p.z,s=c.length-1;s>=0;--s)i.point((u=c[s])[0],u[1]);else r(f.x,f.p.x,-1,i);f=f.p}c=(f=f.o).z,d=!d}while(!f.v);i.lineEnd()}}}function sh(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r<e;)i.n=n=t[r],n.p=i,i=n;i.n=n=t[0],n.p=i}}function oh(t){return lc(t[0])<=nc?t[0]:mc(t[0])*((lc(t[0])+nc)%sc-nc)}function ah(t,e){var n=oh(e),r=e[1],i=yc(r),s=[yc(n),-hc(n),0],o=0,a=0,l=new w;1===i?r=rc+tc:-1===i&&(r=-rc-tc);for(var c=0,u=t.length;c<u;++c)if(f=(h=t[c]).length)for(var h,f,d=h[f-1],p=oh(d),_=d[1]/2+ic,g=yc(_),y=hc(_),m=0;m<f;++m,p=v,g=E,y=A,d=b){var b=h[m],v=oh(b),x=b[1]/2+ic,E=yc(x),A=hc(x),S=v-p,T=S>=0?1:-1,C=T*S,k=C>nc,R=g*E;if(l.add(uc(R*T*yc(C),y*A+R*hc(C))),o+=k?S+T*sc:S,k^p>=n^v>=n){var M=ru(eu(d),eu(b));ou(M);var O=ru(s,M);ou(O);var N=(k^S>=0?-1:1)*wc(O[2]);(r>N||r===N&&(M[0]||M[1]))&&(a+=k^S>=0?1:-1)}}return(o<-1e-6||o<tc&&l<-1e-12)^1&a}function lh(t,e,n,r){return function(i){var s,o,a,l=e(i),c=eh(),u=e(c),h=!1,f={point:d,lineStart:_,lineEnd:g,polygonStart:function(){f.point=y,f.lineStart=m,f.lineEnd=b,o=[],s=[]},polygonEnd:function(){f.point=d,f.lineStart=_,f.lineEnd=g,o=ht(o);var t=ah(s,r);o.length?(h||(i.polygonStart(),h=!0),ih(o,uh,t,n,i)):t&&(h||(i.polygonStart(),h=!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),h&&(i.polygonEnd(),h=!1),o=s=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function d(e,n){t(e,n)&&i.point(e,n)}function p(t,e){l.point(t,e)}function _(){f.point=p,l.lineStart()}function g(){f.point=d,l.lineEnd()}function y(t,e){a.push([t,e]),u.point(t,e)}function m(){u.lineStart(),a=[]}function b(){y(a[0][0],a[0][1]),u.lineEnd();var t,e,n,r,l=u.clean(),f=c.result(),d=f.length;if(a.pop(),s.push(a),a=null,d)if(1&l){if((e=(n=f[0]).length-1)>0){for(h||(i.polygonStart(),h=!0),i.lineStart(),t=0;t<e;++t)i.point((r=n[t])[0],r[1]);i.lineEnd()}}else d>1&&2&l&&f.push(f.pop().concat(f.shift())),o.push(f.filter(ch))}return f}}function ch(t){return t.length>1}function uh(t,e){return((t=t.x)[0]<0?t[1]-rc-tc:rc-t[1])-((e=e.x)[0]<0?e[1]-rc-tc:rc-e[1])}qu.invert=qu;var hh=lh(function(){return!0},function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(s,o){var a=s>0?nc:-nc,l=lc(s-n);lc(l-nc)<tc?(t.point(n,r=(r+o)/2>0?rc:-rc),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),t.point(s,r),e=0):i!==a&&l>=nc&&(lc(n-i)<tc&&(n-=i*tc),lc(s-a)<tc&&(s-=a*tc),r=function(t,e,n,r){var i,s,o=yc(t-n);return lc(o)>tc?cc((yc(e)*(s=hc(r))*yc(n)-yc(r)*(i=hc(e))*yc(t))/(i*s*o)):(e+r)/2}(n,r,s,o),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),e=0),t.point(n=s,r=o),i=a},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}},function(t,e,n,r){var i;if(null==t)i=n*rc,r.point(-nc,i),r.point(0,i),r.point(nc,i),r.point(nc,0),r.point(nc,-i),r.point(0,-i),r.point(-nc,-i),r.point(-nc,0),r.point(-nc,i);else if(lc(t[0]-e[0])>tc){var s=t[0]<e[0]?nc:-nc;i=n*s/2,r.point(-s,i),r.point(0,i),r.point(s,i)}else r.point(e[0],e[1])},[-nc,-rc]);function fh(t){var e=hc(t),n=2*ac,r=e>0,i=lc(e)>tc;function s(t,n){return hc(t)*hc(n)>e}function o(t,n,r){var i=[1,0,0],s=ru(eu(t),eu(n)),o=nu(s,s),a=s[0],l=o-a*a;if(!l)return!r&&t;var c=e*o/l,u=-e*a/l,h=ru(i,s),f=su(i,c);iu(f,su(s,u));var d=h,p=nu(f,d),_=nu(d,d),g=p*p-_*(nu(f,f)-1);if(!(g<0)){var y=bc(g),m=su(d,(-p-y)/_);if(iu(m,f),m=tu(m),!r)return m;var b,v=t[0],x=n[0],w=t[1],E=n[1];x<v&&(b=v,v=x,x=b);var A=x-v,S=lc(A-nc)<tc;if(!S&&E<w&&(b=w,w=E,E=b),S||A<tc?S?w+E>0^m[1]<(lc(m[0]-v)<tc?w:E):w<=m[1]&&m[1]<=E:A>nc^(v<=m[0]&&m[0]<=x)){var T=su(d,(-p+y)/_);return iu(T,f),[m,tu(T)]}}}function a(e,n){var i=r?t:nc-t,s=0;return e<-i?s|=1:e>i&&(s|=2),n<-i?s|=4:n>i&&(s|=8),s}return lh(s,function(t){var e,n,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(h,f){var d,p=[h,f],_=s(h,f),g=r?_?0:a(h,f):_?a(h+(h<0?nc:-nc),f):0;if(!e&&(c=l=_)&&t.lineStart(),_!==l&&(!(d=o(e,p))||nh(e,d)||nh(p,d))&&(p[2]=1),_!==l)u=0,_?(t.lineStart(),d=o(p,e),t.point(d[0],d[1])):(d=o(e,p),t.point(d[0],d[1],2),t.lineEnd()),e=d;else if(i&&e&&r^_){var y;g&n||!(y=o(p,e,!0))||(u=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1],3)))}!_||e&&nh(e,p)||t.point(p[0],p[1]),e=p,l=_,n=g},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return u|(c&&l)<<1}}},function(e,r,i,s){Qu(s,t,n,i,e,r)},r?[0,-t]:[-nc,t-nc])}var dh,ph,_h,gh,yh=1e9,mh=-yh;function bh(t,e,n,r){function i(i,s){return t<=i&&i<=n&&e<=s&&s<=r}function s(i,s,a,c){var u=0,h=0;if(null==i||(u=o(i,a))!==(h=o(s,a))||l(i,s)<0^a>0)do{c.point(0===u||3===u?t:n,u>1?r:e)}while((u=(u+a+4)%4)!==h);else c.point(s[0],s[1])}function o(r,i){return lc(r[0]-t)<tc?i>0?0:3:lc(r[0]-n)<tc?i>0?2:1:lc(r[1]-e)<tc?i>0?1:0:i>0?3:2}function a(t,e){return l(t.x,e.x)}function l(t,e){var n=o(t,1),r=o(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(o){var l,c,u,h,f,d,p,_,g,y,m,b=o,v=eh(),x={point:w,lineStart:function(){x.point=E,c&&c.push(u=[]);y=!0,g=!1,p=_=NaN},lineEnd:function(){l&&(E(h,f),d&&g&&v.rejoin(),l.push(v.result()));x.point=w,g&&b.lineEnd()},polygonStart:function(){b=v,l=[],c=[],m=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=c.length;n<i;++n)for(var s,o,a=c[n],l=1,u=a.length,h=a[0],f=h[0],d=h[1];l<u;++l)s=f,o=d,f=(h=a[l])[0],d=h[1],o<=r?d>r&&(f-s)*(r-o)>(d-o)*(t-s)&&++e:d<=r&&(f-s)*(r-o)<(d-o)*(t-s)&&--e;return e}(),n=m&&e,i=(l=ht(l)).length;(n||i)&&(o.polygonStart(),n&&(o.lineStart(),s(null,null,1,o),o.lineEnd()),i&&ih(l,a,e,s,o),o.polygonEnd());b=o,l=c=u=null}};function w(t,e){i(t,e)&&b.point(t,e)}function E(s,o){var a=i(s,o);if(c&&u.push([s,o]),y)h=s,f=o,d=a,y=!1,a&&(b.lineStart(),b.point(s,o));else if(a&&g)b.point(s,o);else{var l=[p=Math.max(mh,Math.min(yh,p)),_=Math.max(mh,Math.min(yh,_))],v=[s=Math.max(mh,Math.min(yh,s)),o=Math.max(mh,Math.min(yh,o))];!function(t,e,n,r,i,s){var o,a=t[0],l=t[1],c=0,u=1,h=e[0]-a,f=e[1]-l;if(o=n-a,h||!(o>0)){if(o/=h,h<0){if(o<c)return;o<u&&(u=o)}else if(h>0){if(o>u)return;o>c&&(c=o)}if(o=i-a,h||!(o<0)){if(o/=h,h<0){if(o>u)return;o>c&&(c=o)}else if(h>0){if(o<c)return;o<u&&(u=o)}if(o=r-l,f||!(o>0)){if(o/=f,f<0){if(o<c)return;o<u&&(u=o)}else if(f>0){if(o>u)return;o>c&&(c=o)}if(o=s-l,f||!(o<0)){if(o/=f,f<0){if(o>u)return;o>c&&(c=o)}else if(f>0){if(o<c)return;o<u&&(u=o)}return c>0&&(t[0]=a+c*h,t[1]=l+c*f),u<1&&(e[0]=a+u*h,e[1]=l+u*f),!0}}}}}(l,v,t,e,n,r)?a&&(b.lineStart(),b.point(s,o),m=!1):(g||(b.lineStart(),b.point(l[0],l[1])),b.point(v[0],v[1]),a||b.lineEnd(),m=!1)}p=s,_=o,g=a}return x}}var vh={sphere:Ac,point:Ac,lineStart:function(){vh.point=wh,vh.lineEnd=xh},lineEnd:Ac,polygonStart:Ac,polygonEnd:Ac};function xh(){vh.point=vh.lineEnd=Ac}function wh(t,e){ph=t*=ac,_h=yc(e*=ac),gh=hc(e),vh.point=Eh}function Eh(t,e){t*=ac;var n=yc(e*=ac),r=hc(e),i=lc(t-ph),s=hc(i),o=r*yc(i),a=gh*n-_h*r*s,l=_h*n+gh*r*s;dh.add(uc(bc(o*o+a*a),l)),ph=t,_h=n,gh=r}function Ah(t){return dh=new w,Mc(t,vh),+dh}var Sh=[null,null],Th={type:"LineString",coordinates:Sh};function Ch(t,e){return Sh[0]=t,Sh[1]=e,Ah(Th)}var kh={Feature:function(t,e){return Mh(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;)if(Mh(n[r].geometry,e))return!0;return!1}},Rh={Sphere:function(){return!0},Point:function(t,e){return Oh(t.coordinates,e)},MultiPoint:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(Oh(n[r],e))return!0;return!1},LineString:function(t,e){return Nh(t.coordinates,e)},MultiLineString:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(Nh(n[r],e))return!0;return!1},Polygon:function(t,e){return Ih(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(Ih(n[r],e))return!0;return!1},GeometryCollection:function(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;)if(Mh(n[r],e))return!0;return!1}};function Mh(t,e){return!(!t||!Rh.hasOwnProperty(t.type))&&Rh[t.type](t,e)}function Oh(t,e){return 0===Ch(t,e)}function Nh(t,e){for(var n,r,i,s=0,o=t.length;s<o;s++){if(0===(r=Ch(t[s],e)))return!0;if(s>0&&(i=Ch(t[s],t[s-1]))>0&&n<=i&&r<=i&&(n+r-i)*(1-Math.pow((n-r)/i,2))<ec*i)return!0;n=r}return!1}function Ih(t,e){return!!ah(t.map(Ph),Lh(e))}function Ph(t){return(t=t.map(Lh)).pop(),t}function Lh(t){return[t[0]*ac,t[1]*ac]}function Dh(t,e,n){var r=dt(t,e-tc,n).concat(e);return function(t){return r.map(function(e){return[t,e]})}}function Vh(t,e,n){var r=dt(t,e-tc,n).concat(e);return function(t){return r.map(function(e){return[e,t]})}}function Bh(){var t,e,n,r,i,s,o,a,l,c,u,h,f=10,d=f,p=90,_=360,g=2.5;function y(){return{type:"MultiLineString",coordinates:m()}}function m(){return dt(fc(r/p)*p,n,p).map(u).concat(dt(fc(a/_)*_,o,_).map(h)).concat(dt(fc(e/f)*f,t,f).filter(function(t){return lc(t%p)>tc}).map(l)).concat(dt(fc(s/d)*d,i,d).filter(function(t){return lc(t%_)>tc}).map(c))}return y.lines=function(){return m().map(function(t){return{type:"LineString",coordinates:t}})},y.outline=function(){return{type:"Polygon",coordinates:[u(r).concat(h(o).slice(1),u(n).reverse().slice(1),h(a).reverse().slice(1))]}},y.extent=function(t){return arguments.length?y.extentMajor(t).extentMinor(t):y.extentMinor()},y.extentMajor=function(t){return arguments.length?(r=+t[0][0],n=+t[1][0],a=+t[0][1],o=+t[1][1],r>n&&(t=r,r=n,n=t),a>o&&(t=a,a=o,o=t),y.precision(g)):[[r,a],[n,o]]},y.extentMinor=function(n){return arguments.length?(e=+n[0][0],t=+n[1][0],s=+n[0][1],i=+n[1][1],e>t&&(n=e,e=t,t=n),s>i&&(n=s,s=i,i=n),y.precision(g)):[[e,s],[t,i]]},y.step=function(t){return arguments.length?y.stepMajor(t).stepMinor(t):y.stepMinor()},y.stepMajor=function(t){return arguments.length?(p=+t[0],_=+t[1],y):[p,_]},y.stepMinor=function(t){return arguments.length?(f=+t[0],d=+t[1],y):[f,d]},y.precision=function(f){return arguments.length?(g=+f,l=Dh(s,i,90),c=Vh(e,t,g),u=Dh(a,o,90),h=Vh(r,n,g),y):g},y.extentMajor([[-180,-89.999999],[180,89.999999]]).extentMinor([[-180,-80.000001],[180,80.000001]])}var zh,Gh,Fh,jh,Uh=t=>t,Yh=new w,Hh=new w,Wh={point:Ac,lineStart:Ac,lineEnd:Ac,polygonStart:function(){Wh.lineStart=qh,Wh.lineEnd=Kh},polygonEnd:function(){Wh.lineStart=Wh.lineEnd=Wh.point=Ac,Yh.add(lc(Hh)),Hh=new w},result:function(){var t=Yh/2;return Yh=new w,t}};function qh(){Wh.point=$h}function $h(t,e){Wh.point=Xh,zh=Fh=t,Gh=jh=e}function Xh(t,e){Hh.add(jh*t-Fh*e),Fh=t,jh=e}function Kh(){Xh(zh,Gh)}var Zh=1/0,Jh=Zh,Qh=-Zh,tf=Qh,ef={point:function(t,e){t<Zh&&(Zh=t);t>Qh&&(Qh=t);e<Jh&&(Jh=e);e>tf&&(tf=e)},lineStart:Ac,lineEnd:Ac,polygonStart:Ac,polygonEnd:Ac,result:function(){var t=[[Zh,Jh],[Qh,tf]];return Qh=tf=-(Jh=Zh=1/0),t}};var nf,rf,sf,of,af=0,lf=0,cf=0,uf=0,hf=0,ff=0,df=0,pf=0,_f=0,gf={point:yf,lineStart:mf,lineEnd:xf,polygonStart:function(){gf.lineStart=wf,gf.lineEnd=Ef},polygonEnd:function(){gf.point=yf,gf.lineStart=mf,gf.lineEnd=xf},result:function(){var t=_f?[df/_f,pf/_f]:ff?[uf/ff,hf/ff]:cf?[af/cf,lf/cf]:[NaN,NaN];return af=lf=cf=uf=hf=ff=df=pf=_f=0,t}};function yf(t,e){af+=t,lf+=e,++cf}function mf(){gf.point=bf}function bf(t,e){gf.point=vf,yf(sf=t,of=e)}function vf(t,e){var n=t-sf,r=e-of,i=bc(n*n+r*r);uf+=i*(sf+t)/2,hf+=i*(of+e)/2,ff+=i,yf(sf=t,of=e)}function xf(){gf.point=yf}function wf(){gf.point=Af}function Ef(){Sf(nf,rf)}function Af(t,e){gf.point=Sf,yf(nf=sf=t,rf=of=e)}function Sf(t,e){var n=t-sf,r=e-of,i=bc(n*n+r*r);uf+=i*(sf+t)/2,hf+=i*(of+e)/2,ff+=i,df+=(i=of*t-sf*e)*(sf+t),pf+=i*(of+e),_f+=3*i,yf(sf=t,of=e)}function Tf(t){this._context=t}Tf.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(t,e){switch(this._point){case 0:this._context.moveTo(t,e),this._point=1;break;case 1:this._context.lineTo(t,e);break;default:this._context.moveTo(t+this._radius,e),this._context.arc(t,e,this._radius,0,sc)}},result:Ac};var Cf,kf,Rf,Mf,Of,Nf=new w,If={point:Ac,lineStart:function(){If.point=Pf},lineEnd:function(){Cf&&Lf(kf,Rf),If.point=Ac},polygonStart:function(){Cf=!0},polygonEnd:function(){Cf=null},result:function(){var t=+Nf;return Nf=new w,t}};function Pf(t,e){If.point=Lf,kf=Mf=t,Rf=Of=e}function Lf(t,e){Mf-=t,Of-=e,Nf.add(bc(Mf*Mf+Of*Of)),Mf=t,Of=e}let Df,Vf,Bf,zf;class Gf{constructor(t){this._append=null==t?Ff:function(t){const e=Math.floor(t);if(!(e>=0))throw new RangeError(`invalid digits: ${t}`);if(e>15)return Ff;if(e!==Df){const t=10**e;Df=e,Vf=function(e){let n=1;this._+=e[0];for(const r=e.length;n<r;++n)this._+=Math.round(arguments[n]*t)/t+e[n]}}return Vf}(t),this._radius=4.5,this._=""}pointRadius(t){return this._radius=+t,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){0===this._line&&(this._+="Z"),this._point=NaN}point(t,e){switch(this._point){case 0:this._append`M${t},${e}`,this._point=1;break;case 1:this._append`L${t},${e}`;break;default:if(this._append`M${t},${e}`,this._radius!==Bf||this._append!==Vf){const t=this._radius,e=this._;this._="",this._append`m0,${t}a${t},${t} 0 1,1 0,${-2*t}a${t},${t} 0 1,1 0,${2*t}z`,Bf=t,Vf=this._append,zf=this._,this._=e}this._+=zf}}result(){const t=this._;return this._="",t.length?t:null}}function Ff(t){let e=1;this._+=t[0];for(const n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function jf(t){return function(e){var n=new Uf;for(var r in t)n[r]=t[r];return n.stream=e,n}}function Uf(){}function Yf(t,e,n){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),Mc(n,t.stream(ef)),e(ef.result()),null!=r&&t.clipExtent(r),t}function Hf(t,e,n){return Yf(t,function(n){var r=e[1][0]-e[0][0],i=e[1][1]-e[0][1],s=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+e[0][0]+(r-s*(n[1][0]+n[0][0]))/2,a=+e[0][1]+(i-s*(n[1][1]+n[0][1]))/2;t.scale(150*s).translate([o,a])},n)}function Wf(t,e,n){return Hf(t,[[0,0],e],n)}function qf(t,e,n){return Yf(t,function(n){var r=+e,i=r/(n[1][0]-n[0][0]),s=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];t.scale(150*i).translate([s,o])},n)}function $f(t,e,n){return Yf(t,function(n){var r=+e,i=r/(n[1][1]-n[0][1]),s=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;t.scale(150*i).translate([s,o])},n)}Uf.prototype={constructor:Uf,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var Xf=hc(30*ac);function Kf(t,e){return+e?function(t,e){function n(r,i,s,o,a,l,c,u,h,f,d,p,_,g){var y=c-r,m=u-i,b=y*y+m*m;if(b>4*e&&_--){var v=o+f,x=a+d,w=l+p,E=bc(v*v+x*x+w*w),A=wc(w/=E),S=lc(lc(w)-1)<tc||lc(s-h)<tc?(s+h)/2:uc(x,v),T=t(S,A),C=T[0],k=T[1],R=C-r,M=k-i,O=m*R-y*M;(O*O/b>e||lc((y*R+m*M)/b-.5)>.3||o*f+a*d+l*p<Xf)&&(n(r,i,s,o,a,l,C,k,S,v/=E,x/=E,w,_,g),g.point(C,k),n(C,k,S,v,x,w,c,u,h,f,d,p,_,g))}}return function(e){var r,i,s,o,a,l,c,u,h,f,d,p,_={point:g,lineStart:y,lineEnd:b,polygonStart:function(){e.polygonStart(),_.lineStart=v},polygonEnd:function(){e.polygonEnd(),_.lineStart=y}};function g(n,r){n=t(n,r),e.point(n[0],n[1])}function y(){u=NaN,_.point=m,e.lineStart()}function m(r,i){var s=eu([r,i]),o=t(r,i);n(u,h,c,f,d,p,u=o[0],h=o[1],c=r,f=s[0],d=s[1],p=s[2],16,e),e.point(u,h)}function b(){_.point=g,e.lineEnd()}function v(){y(),_.point=x,_.lineEnd=w}function x(t,e){m(r=t,e),i=u,s=h,o=f,a=d,l=p,_.point=m}function w(){n(u,h,c,f,d,p,i,s,r,o,a,l,16,e),_.lineEnd=b,b()}return _}}(t,e):function(t){return jf({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}(t)}var Zf=jf({point:function(t,e){this.stream.point(t*ac,e*ac)}});function Jf(t,e,n,r,i,s){if(!s)return function(t,e,n,r,i){function s(s,o){return[e+t*(s*=r),n-t*(o*=i)]}return s.invert=function(s,o){return[(s-e)/t*r,(n-o)/t*i]},s}(t,e,n,r,i);var o=hc(s),a=yc(s),l=o*t,c=a*t,u=o/t,h=a/t,f=(a*n-o*e)/t,d=(a*e+o*n)/t;function p(t,s){return[l*(t*=r)-c*(s*=i)+e,n-c*t-l*s]}return p.invert=function(t,e){return[r*(u*t-h*e+f),i*(d-h*t-u*e)]},p}function Qf(t){return td(function(){return t})()}function td(t){var e,n,r,i,s,o,a,l,c,u,h=150,f=480,d=250,p=0,_=0,g=0,y=0,m=0,b=0,v=1,x=1,w=null,E=hh,A=null,S=Uh,T=.5;function C(t){return l(t[0]*ac,t[1]*ac)}function k(t){return(t=l.invert(t[0],t[1]))&&[t[0]*oc,t[1]*oc]}function R(){var t=Jf(h,0,0,v,x,b).apply(null,e(p,_)),r=Jf(h,f-t[0],d-t[1],v,x,b);return n=$u(g,y,m),a=Wu(e,r),l=Wu(n,a),o=Kf(a,T),M()}function M(){return c=u=null,C}return C.stream=function(t){return c&&u===t?c:c=Zf(function(t){return jf({point:function(e,n){var r=t(e,n);return this.stream.point(r[0],r[1])}})}(n)(E(o(S(u=t)))))},C.preclip=function(t){return arguments.length?(E=t,w=void 0,M()):E},C.postclip=function(t){return arguments.length?(S=t,A=r=i=s=null,M()):S},C.clipAngle=function(t){return arguments.length?(E=+t?fh(w=t*ac):(w=null,hh),M()):w*oc},C.clipExtent=function(t){return arguments.length?(S=null==t?(A=r=i=s=null,Uh):bh(A=+t[0][0],r=+t[0][1],i=+t[1][0],s=+t[1][1]),M()):null==A?null:[[A,r],[i,s]]},C.scale=function(t){return arguments.length?(h=+t,R()):h},C.translate=function(t){return arguments.length?(f=+t[0],d=+t[1],R()):[f,d]},C.center=function(t){return arguments.length?(p=t[0]%360*ac,_=t[1]%360*ac,R()):[p*oc,_*oc]},C.rotate=function(t){return arguments.length?(g=t[0]%360*ac,y=t[1]%360*ac,m=t.length>2?t[2]%360*ac:0,R()):[g*oc,y*oc,m*oc]},C.angle=function(t){return arguments.length?(b=t%360*ac,R()):b*oc},C.reflectX=function(t){return arguments.length?(v=t?-1:1,R()):v<0},C.reflectY=function(t){return arguments.length?(x=t?-1:1,R()):x<0},C.precision=function(t){return arguments.length?(o=Kf(a,T=t*t),M()):bc(T)},C.fitExtent=function(t,e){return Hf(C,t,e)},C.fitSize=function(t,e){return Wf(C,t,e)},C.fitWidth=function(t,e){return qf(C,t,e)},C.fitHeight=function(t,e){return $f(C,t,e)},function(){return e=t.apply(this,arguments),C.invert=e.invert&&k,R()}}function ed(t){var e=0,n=nc/3,r=td(t),i=r(e,n);return i.parallels=function(t){return arguments.length?r(e=t[0]*ac,n=t[1]*ac):[e*oc,n*oc]},i}function nd(t,e){var n=yc(t),r=(n+yc(e))/2;if(lc(r)<tc)return function(t){var e=hc(t);function n(t,n){return[t*e,yc(n)/e]}return n.invert=function(t,n){return[t/e,wc(n*e)]},n}(t);var i=1+n*(2*r-n),s=bc(i)/r;function o(t,e){var n=bc(i-2*r*yc(e))/r;return[n*yc(t*=r),s-n*hc(t)]}return o.invert=function(t,e){var n=s-e,o=uc(t,lc(n))*mc(n);return n*r<0&&(o-=nc*mc(t)*mc(n)),[o/r,wc((i-(t*t+n*n)*r*r)/(2*r))]},o}function rd(){return ed(nd).scale(155.424).center([0,33.6442])}function id(){return rd().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}function sd(t){return function(e,n){var r=hc(e),i=hc(n),s=t(r*i);return s===1/0?[2,0]:[s*i*yc(e),s*yc(n)]}}function od(t){return function(e,n){var r=bc(e*e+n*n),i=t(r),s=yc(i),o=hc(i);return[uc(e*s,r*o),wc(r&&n*s/r)]}}var ad=sd(function(t){return bc(2/(1+t))});ad.invert=od(function(t){return 2*wc(t/2)});var ld=sd(function(t){return(t=xc(t))&&t/yc(t)});function cd(t,e){return[t,_c(vc((rc+e)/2))]}function ud(t){var e,n,r,i=Qf(t),s=i.center,o=i.scale,a=i.translate,l=i.clipExtent,c=null;function u(){var s=nc*o(),a=i(Ju(i.rotate()).invert([0,0]));return l(null==c?[[a[0]-s,a[1]-s],[a[0]+s,a[1]+s]]:t===cd?[[Math.max(a[0]-s,c),e],[Math.min(a[0]+s,n),r]]:[[c,Math.max(a[1]-s,e)],[n,Math.min(a[1]+s,r)]])}return i.scale=function(t){return arguments.length?(o(t),u()):o()},i.translate=function(t){return arguments.length?(a(t),u()):a()},i.center=function(t){return arguments.length?(s(t),u()):s()},i.clipExtent=function(t){return arguments.length?(null==t?c=e=n=r=null:(c=+t[0][0],e=+t[0][1],n=+t[1][0],r=+t[1][1]),u()):null==c?null:[[c,e],[n,r]]},u()}function hd(t){return vc((rc+t)/2)}function fd(t,e){var n=hc(t),r=t===e?yc(t):_c(n/hc(e))/_c(hd(e)/hd(t)),i=n*gc(hd(t),r)/r;if(!r)return cd;function s(t,e){i>0?e<-rc+tc&&(e=-rc+tc):e>rc-tc&&(e=rc-tc);var n=i/gc(hd(e),r);return[n*yc(r*t),i-n*hc(r*t)]}return s.invert=function(t,e){var n=i-e,s=mc(r)*bc(t*t+n*n),o=uc(t,lc(n))*mc(n);return n*r<0&&(o-=nc*mc(t)*mc(n)),[o/r,2*cc(gc(i/s,1/r))-rc]},s}function dd(t,e){return[t,e]}function pd(t,e){var n=hc(t),r=t===e?yc(t):(n-hc(e))/(e-t),i=n/r+t;if(lc(r)<tc)return dd;function s(t,e){var n=i-e,s=r*t;return[n*yc(s),i-n*hc(s)]}return s.invert=function(t,e){var n=i-e,s=uc(t,lc(n))*mc(n);return n*r<0&&(s-=nc*mc(t)*mc(n)),[s/r,i-mc(r)*bc(t*t+n*n)]},s}ld.invert=od(function(t){return t}),cd.invert=function(t,e){return[t,2*cc(dc(e))-rc]},dd.invert=dd;var _d=1.340264,gd=-.081106,yd=893e-6,md=.003796,bd=bc(3)/2;function vd(t,e){var n=wc(bd*yc(e)),r=n*n,i=r*r*r;return[t*hc(n)/(bd*(_d+3*gd*r+i*(7*yd+9*md*r))),n*(_d+gd*r+i*(yd+md*r))]}function xd(t,e){var n=hc(e),r=hc(t)*n;return[n*yc(t)/r,yc(e)/r]}function wd(t,e){var n=e*e,r=n*n;return[t*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791)),e*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))]}function Ed(t,e){return[hc(e)*yc(t),yc(e)]}function Ad(t,e){var n=hc(e),r=1+hc(t)*n;return[n*yc(t)/r,yc(e)/r]}function Sd(t,e){return[_c(vc((rc+e)/2)),-t]}function Td(t,e){return t.parent===e.parent?1:2}function Cd(t,e){return t+e.x}function kd(t,e){return Math.max(t,e.y)}function Rd(){var t=Td,e=1,n=1,r=!1;function i(i){var s,o=0;i.eachAfter(function(e){var n=e.children;n?(e.x=function(t){return t.reduce(Cd,0)/t.length}(n),e.y=function(t){return 1+t.reduce(kd,0)}(n)):(e.x=s?o+=t(e,s):0,e.y=0,s=e)});var a=function(t){for(var e;e=t.children;)t=e[0];return t}(i),l=function(t){for(var e;e=t.children;)t=e[e.length-1];return t}(i),c=a.x-t(a,l)/2,u=l.x+t(l,a)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*e,t.y=(i.y-t.y)*n}:function(t){t.x=(t.x-c)/(u-c)*e,t.y=(1-(i.y?t.y/i.y:1))*n})}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}function Md(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function Od(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=Id)):void 0===e&&(e=Nd);for(var n,r,i,s,o,a=new Dd(t),l=[a];n=l.pop();)if((i=e(n.data))&&(o=(i=Array.from(i)).length))for(n.children=i,s=o-1;s>=0;--s)l.push(r=i[s]=new Dd(i[s])),r.parent=n,r.depth=n.depth+1;return a.eachBefore(Ld)}function Nd(t){return t.children}function Id(t){return Array.isArray(t)?t[1]:null}function Pd(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Ld(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Dd(t){this.data=t,this.depth=this.height=0,this.parent=null}function Vd(t){return null==t?null:Bd(t)}function Bd(t){if("function"!=typeof t)throw new Error;return t}function zd(){return 0}function Gd(t){return function(){return t}}vd.invert=function(t,e){for(var n,r=e,i=r*r,s=i*i*i,o=0;o<12&&(s=(i=(r-=n=(r*(_d+gd*i+s*(yd+md*i))-e)/(_d+3*gd*i+s*(7*yd+9*md*i)))*r)*i*i,!(lc(n)<ec));++o);return[bd*t*(_d+3*gd*i+s*(7*yd+9*md*i))/hc(r),wc(yc(r)/bd)]},xd.invert=od(cc),wd.invert=function(t,e){var n,r=e,i=25;do{var s=r*r,o=s*s;r-=n=(r*(1.007226+s*(.015085+o*(.028874*s-.044475-.005916*o)))-e)/(1.007226+s*(.045255+o*(.259866*s-.311325-.005916*11*o)))}while(lc(n)>tc&&--i>0);return[t/(.8707+(s=r*r)*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979)),r]},Ed.invert=od(wc),Ad.invert=od(function(t){return 2*cc(t)}),Sd.invert=function(t,e){return[-e,2*cc(dc(t))-rc]},Dd.prototype=Od.prototype={constructor:Dd,count:function(){return this.eachAfter(Md)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,s=this,o=[s],a=[],l=-1;s=o.pop();)if(a.push(s),n=s.children)for(r=0,i=n.length;r<i;++r)o.push(n[r]);for(;s=a.pop();)t.call(e,s,++l,this);return this},eachBefore:function(t,e){for(var n,r,i=this,s=[i],o=-1;i=s.pop();)if(t.call(e,i,++o,this),n=i.children)for(r=n.length-1;r>=0;--r)s.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n})},sort:function(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t},links:function(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e},copy:function(){return Od(this).eachBefore(Pd)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,s=[i];do{for(t=s.reverse(),s=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)s.push(e[n])}while(s.length)}};const Fd=4294967296;function jd(){let t=1;return()=>(t=(1664525*t+1013904223)%Fd)/Fd}function Ud(t,e){for(var n,r,i=0,s=(t=function(t,e){let n,r,i=t.length;for(;i;)r=e()*i--|0,n=t[i],t[i]=t[r],t[r]=n;return t}(Array.from(t),e)).length,o=[];i<s;)n=t[i],r&&Wd(r,n)?++i:(r=$d(o=Yd(o,n)),i=0);return r}function Yd(t,e){var n,r;if(qd(e,t))return[e];for(n=0;n<t.length;++n)if(Hd(e,t[n])&&qd(Xd(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(Hd(Xd(t[n],t[r]),e)&&Hd(Xd(t[n],e),t[r])&&Hd(Xd(t[r],e),t[n])&&qd(Kd(t[n],t[r],e),t))return[t[n],t[r],e];throw new Error}function Hd(t,e){var n=t.r-e.r,r=e.x-t.x,i=e.y-t.y;return n<0||n*n<r*r+i*i}function Wd(t,e){var n=t.r-e.r+1e-9*Math.max(t.r,e.r,1),r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function qd(t,e){for(var n=0;n<e.length;++n)if(!Wd(t,e[n]))return!1;return!0}function $d(t){switch(t.length){case 1:return function(t){return{x:t.x,y:t.y,r:t.r}}(t[0]);case 2:return Xd(t[0],t[1]);case 3:return Kd(t[0],t[1],t[2])}}function Xd(t,e){var n=t.x,r=t.y,i=t.r,s=e.x,o=e.y,a=e.r,l=s-n,c=o-r,u=a-i,h=Math.sqrt(l*l+c*c);return{x:(n+s+l/h*u)/2,y:(r+o+c/h*u)/2,r:(h+i+a)/2}}function Kd(t,e,n){var r=t.x,i=t.y,s=t.r,o=e.x,a=e.y,l=e.r,c=n.x,u=n.y,h=n.r,f=r-o,d=r-c,p=i-a,_=i-u,g=l-s,y=h-s,m=r*r+i*i-s*s,b=m-o*o-a*a+l*l,v=m-c*c-u*u+h*h,x=d*p-f*_,w=(p*v-_*b)/(2*x)-r,E=(_*g-p*y)/x,A=(d*b-f*v)/(2*x)-i,S=(f*y-d*g)/x,T=E*E+S*S-1,C=2*(s+w*E+A*S),k=w*w+A*A-s*s,R=-(Math.abs(T)>1e-6?(C+Math.sqrt(C*C-4*T*k))/(2*T):k/C);return{x:r+w+E*R,y:i+A+S*R,r:R}}function Zd(t,e,n){var r,i,s,o,a=t.x-e.x,l=t.y-e.y,c=a*a+l*l;c?(i=e.r+n.r,i*=i,o=t.r+n.r,i>(o*=o)?(r=(c+o-i)/(2*c),s=Math.sqrt(Math.max(0,o/c-r*r)),n.x=t.x-r*a-s*l,n.y=t.y-r*l+s*a):(r=(c+i-o)/(2*c),s=Math.sqrt(Math.max(0,i/c-r*r)),n.x=e.x+r*a-s*l,n.y=e.y+r*l+s*a)):(n.x=e.x+n.r,n.y=e.y)}function Jd(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function Qd(t){var e=t._,n=t.next._,r=e.r+n.r,i=(e.x*n.r+n.x*e.r)/r,s=(e.y*n.r+n.y*e.r)/r;return i*i+s*s}function tp(t){this._=t,this.next=null,this.previous=null}function ep(t,e){if(!(s=(t=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(t)).length))return 0;var n,r,i,s,o,a,l,c,u,h,f;if((n=t[0]).x=0,n.y=0,!(s>1))return n.r;if(r=t[1],n.x=-r.r,r.x=n.r,r.y=0,!(s>2))return n.r+r.r;Zd(r,n,i=t[2]),n=new tp(n),r=new tp(r),i=new tp(i),n.next=i.previous=r,r.next=n.previous=i,i.next=r.previous=n;t:for(l=3;l<s;++l){Zd(n._,r._,i=t[l]),i=new tp(i),c=r.next,u=n.previous,h=r._.r,f=n._.r;do{if(h<=f){if(Jd(c._,i._)){r=c,n.next=r,r.previous=n,--l;continue t}h+=c._.r,c=c.next}else{if(Jd(u._,i._)){(n=u).next=r,r.previous=n,--l;continue t}f+=u._.r,u=u.previous}}while(c!==u.next);for(i.previous=n,i.next=r,n.next=r.previous=r=i,o=Qd(n);(i=i.next)!==r;)(a=Qd(i))<o&&(n=i,o=a);r=n.next}for(n=[r._],i=r;(i=i.next)!==r;)n.push(i._);for(i=Ud(n,e),l=0;l<s;++l)(n=t[l]).x-=i.x,n.y-=i.y;return i.r}function np(t){return Math.sqrt(t.value)}function rp(){var t=null,e=1,n=1,r=zd;function i(i){const s=jd();return i.x=e/2,i.y=n/2,t?i.eachBefore(ip(t)).eachAfter(sp(r,.5,s)).eachBefore(op(1)):i.eachBefore(ip(np)).eachAfter(sp(zd,1,s)).eachAfter(sp(r,i.r/Math.min(e,n),s)).eachBefore(op(Math.min(e,n)/(2*i.r))),i}return i.radius=function(e){return arguments.length?(t=Vd(e),i):t},i.size=function(t){return arguments.length?(e=+t[0],n=+t[1],i):[e,n]},i.padding=function(t){return arguments.length?(r="function"==typeof t?t:Gd(+t),i):r},i}function ip(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0))}}function sp(t,e,n){return function(r){if(i=r.children){var i,s,o,a=i.length,l=t(r)*e||0;if(l)for(s=0;s<a;++s)i[s].r+=l;if(o=ep(i,n),l)for(s=0;s<a;++s)i[s].r-=l;r.r=o+l}}}function op(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 ap(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 lp(t,e,n,r,i){for(var s,o=t.children,a=-1,l=o.length,c=t.value&&(r-e)/t.value;++a<l;)(s=o[a]).y0=n,s.y1=i,s.x0=e,s.x1=e+=s.value*c}var cp={depth:-1},up={},hp={};function fp(t){return t.id}function dp(t){return t.parentId}function pp(t){let e=t.length;if(e<2)return"";for(;--e>1&&!_p(t,e););return t.slice(0,e)}function _p(t,e){if("/"===t[e]){let n=0;for(;e>0&&"\\"===t[--e];)++n;if(!(1&n))return!0}return!1}function gp(t,e){return t.parent===e.parent?1:2}function yp(t){var e=t.children;return e?e[0]:t.t}function mp(t){var e=t.children;return e?e[e.length-1]:t.t}function bp(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 vp(t,e,n){return t.a.parent===e.parent?t.a:n}function xp(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}function wp(){var t=gp,e=1,n=1,r=null;function i(i){var l=function(t){for(var e,n,r,i,s,o=new xp(t,0),a=[o];e=a.pop();)if(r=e._.children)for(e.children=new Array(s=r.length),i=s-1;i>=0;--i)a.push(n=e.children[i]=new xp(r[i],i)),n.parent=e;return(o.parent=new xp(null,0)).children=[o],o}(i);if(l.eachAfter(s),l.parent.m=-l.z,l.eachBefore(o),r)i.eachBefore(a);else{var c=i,u=i,h=i;i.eachBefore(function(t){t.x<c.x&&(c=t),t.x>u.x&&(u=t),t.depth>h.depth&&(h=t)});var f=c===u?1:t(c,u)/2,d=f-c.x,p=e/(u.x+f+d),_=n/(h.depth||1);i.eachBefore(function(t){t.x=(t.x+d)*p,t.y=t.depth*_})}return i}function s(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){!function(t){for(var e,n=0,r=0,i=t.children,s=i.length;--s>=0;)(e=i[s]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}(e);var s=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-s):e.z=s}else i&&(e.z=i.z+t(e._,i._));e.parent.A=function(e,n,r){if(n){for(var i,s=e,o=e,a=n,l=s.parent.children[0],c=s.m,u=o.m,h=a.m,f=l.m;a=mp(a),s=yp(s),a&&s;)l=yp(l),(o=mp(o)).a=e,(i=a.z+h-s.z-c+t(a._,s._))>0&&(bp(vp(a,e,r),e,i),c+=i,u+=i),h+=a.m,c+=s.m,f+=l.m,u+=o.m;a&&!mp(o)&&(o.t=a,o.m+=h-u),s&&!yp(l)&&(l.t=s,l.m+=c-f,r=e)}return r}(e,i,e.parent.A||r[0])}function o(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function a(t){t.x*=e,t.y=t.depth*n}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}function Ep(t,e,n,r,i){for(var s,o=t.children,a=-1,l=o.length,c=t.value&&(i-n)/t.value;++a<l;)(s=o[a]).x0=e,s.x1=r,s.y0=n,s.y1=n+=s.value*c}xp.prototype=Object.create(Dd.prototype);var Ap=(1+Math.sqrt(5))/2;function Sp(t,e,n,r,i,s){for(var o,a,l,c,u,h,f,d,p,_,g,y=[],m=e.children,b=0,v=0,x=m.length,w=e.value;b<x;){l=i-n,c=s-r;do{u=m[v++].value}while(!u&&v<x);for(h=f=u,g=u*u*(_=Math.max(c/l,l/c)/(w*t)),p=Math.max(f/g,g/h);v<x;++v){if(u+=a=m[v].value,a<h&&(h=a),a>f&&(f=a),g=u*u*_,(d=Math.max(f/g,g/h))>p){u-=a;break}p=d}y.push(o={value:u,dice:l<c,children:m.slice(b,v)}),o.dice?lp(o,n,r,i,w?r+=c*u/w:s):Ep(o,n,r,w?n+=l*u/w:i,s),w-=u,b=v}return y}var Tp=function t(e){function n(t,n,r,i,s){Sp(e,t,n,r,i,s)}return n.ratio=function(e){return t((e=+e)>1?e:1)},n}(Ap);function Cp(){var t=Tp,e=!1,n=1,r=1,i=[0],s=zd,o=zd,a=zd,l=zd,c=zd;function u(t){return t.x0=t.y0=0,t.x1=n,t.y1=r,t.eachBefore(h),i=[0],e&&t.eachBefore(ap),t}function h(e){var n=i[e.depth],r=e.x0+n,u=e.y0+n,h=e.x1-n,f=e.y1-n;h<r&&(r=h=(r+h)/2),f<u&&(u=f=(u+f)/2),e.x0=r,e.y0=u,e.x1=h,e.y1=f,e.children&&(n=i[e.depth+1]=s(e)/2,r+=c(e)-n,u+=o(e)-n,(h-=a(e)-n)<r&&(r=h=(r+h)/2),(f-=l(e)-n)<u&&(u=f=(u+f)/2),t(e,r,u,h,f))}return u.round=function(t){return arguments.length?(e=!!t,u):e},u.size=function(t){return arguments.length?(n=+t[0],r=+t[1],u):[n,r]},u.tile=function(e){return arguments.length?(t=Bd(e),u):t},u.padding=function(t){return arguments.length?u.paddingInner(t).paddingOuter(t):u.paddingInner()},u.paddingInner=function(t){return arguments.length?(s="function"==typeof t?t:Gd(+t),u):s},u.paddingOuter=function(t){return arguments.length?u.paddingTop(t).paddingRight(t).paddingBottom(t).paddingLeft(t):u.paddingTop()},u.paddingTop=function(t){return arguments.length?(o="function"==typeof t?t:Gd(+t),u):o},u.paddingRight=function(t){return arguments.length?(a="function"==typeof t?t:Gd(+t),u):a},u.paddingBottom=function(t){return arguments.length?(l="function"==typeof t?t:Gd(+t),u):l},u.paddingLeft=function(t){return arguments.length?(c="function"==typeof t?t:Gd(+t),u):c},u}var kp=function t(e){function n(t,n,r,i,s){if((o=t._squarify)&&o.ratio===e)for(var o,a,l,c,u,h=-1,f=o.length,d=t.value;++h<f;){for(l=(a=o[h]).children,c=a.value=0,u=l.length;c<u;++c)a.value+=l[c].value;a.dice?lp(a,n,r,i,d?r+=(s-r)*a.value/d:s):Ep(a,n,r,d?n+=(i-n)*a.value/d:i,s),d-=a.value}else t._squarify=o=Sp(e,t,n,r,i,s),o.ratio=e}return n.ratio=function(e){return t((e=+e)>1?e:1)},n}(Ap);function Rp(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function Mp(t,e){return t[0]-e[0]||t[1]-e[1]}function Op(t){const e=t.length,n=[0,1];let r,i=2;for(r=2;r<e;++r){for(;i>1&&Rp(t[n[i-2]],t[n[i-1]],t[r])<=0;)--i;n[i++]=r}return n.slice(0,i)}var Np=Math.random,Ip=function t(e){function n(t,n){return t=null==t?0:+t,n=null==n?1:+n,1===arguments.length?(n=t,t=0):n-=t,function(){return e()*n+t}}return n.source=t,n}(Np),Pp=function t(e){function n(t,n){return arguments.length<2&&(n=t,t=0),t=Math.floor(t),n=Math.floor(n)-t,function(){return Math.floor(e()*n+t)}}return n.source=t,n}(Np),Lp=function t(e){function n(t,n){var r,i;return t=null==t?0:+t,n=null==n?1:+n,function(){var s;if(null!=r)s=r,r=null;else do{r=2*e()-1,s=2*e()-1,i=r*r+s*s}while(!i||i>1);return t+n*s*Math.sqrt(-2*Math.log(i)/i)}}return n.source=t,n}(Np),Dp=function t(e){var n=Lp.source(e);function r(){var t=n.apply(this,arguments);return function(){return Math.exp(t())}}return r.source=t,r}(Np),Vp=function t(e){function n(t){return(t=+t)<=0?()=>0:function(){for(var n=0,r=t;r>1;--r)n+=e();return n+r*e()}}return n.source=t,n}(Np),Bp=function t(e){var n=Vp.source(e);function r(t){if(0===(t=+t))return e;var r=n(t);return function(){return r()/t}}return r.source=t,r}(Np),zp=function t(e){function n(t){return function(){return-Math.log1p(-e())/t}}return n.source=t,n}(Np),Gp=function t(e){function n(t){if((t=+t)<0)throw new RangeError("invalid alpha");return t=1/-t,function(){return Math.pow(1-e(),t)}}return n.source=t,n}(Np),Fp=function t(e){function n(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return function(){return Math.floor(e()+t)}}return n.source=t,n}(Np),jp=function t(e){function n(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return 0===t?()=>1/0:1===t?()=>1:(t=Math.log1p(-t),function(){return 1+Math.floor(Math.log1p(-e())/t)})}return n.source=t,n}(Np),Up=function t(e){var n=Lp.source(e)();function r(t,r){if((t=+t)<0)throw new RangeError("invalid k");if(0===t)return()=>0;if(r=null==r?1:+r,1===t)return()=>-Math.log1p(-e())*r;var i=(t<1?t+1:t)-1/3,s=1/(3*Math.sqrt(i)),o=t<1?()=>Math.pow(e(),1/t):()=>1;return function(){do{do{var t=n(),a=1+s*t}while(a<=0);a*=a*a;var l=1-e()}while(l>=1-.0331*t*t*t*t&&Math.log(l)>=.5*t*t+i*(1-a+Math.log(a)));return i*a*o()*r}}return r.source=t,r}(Np),Yp=function t(e){var n=Up.source(e);function r(t,e){var r=n(t),i=n(e);return function(){var t=r();return 0===t?0:t/(t+i())}}return r.source=t,r}(Np),Hp=function t(e){var n=jp.source(e),r=Yp.source(e);function i(t,e){return t=+t,(e=+e)>=1?()=>t:e<=0?()=>0:function(){for(var i=0,s=t,o=e;s*o>16&&s*(1-o)>16;){var a=Math.floor((s+1)*o),l=r(a,s-a+1)();l<=o?(i+=a,s-=a,o=(o-l)/(1-l)):(s=a-1,o/=l)}for(var c=o<.5,u=n(c?o:1-o),h=u(),f=0;h<=s;++f)h+=u();return i+(c?f:s-f)}}return i.source=t,i}(Np),Wp=function t(e){function n(t,n,r){var i;return 0===(t=+t)?i=t=>-Math.log(t):(t=1/t,i=e=>Math.pow(e,t)),n=null==n?0:+n,r=null==r?1:+r,function(){return n+r*i(-Math.log1p(-e()))}}return n.source=t,n}(Np),qp=function t(e){function n(t,n){return t=null==t?0:+t,n=null==n?1:+n,function(){return t+n*Math.tan(Math.PI*e())}}return n.source=t,n}(Np),$p=function t(e){function n(t,n){return t=null==t?0:+t,n=null==n?1:+n,function(){var r=e();return t+n*Math.log(r/(1-r))}}return n.source=t,n}(Np),Xp=function t(e){var n=Up.source(e),r=Hp.source(e);function i(t){return function(){for(var i=0,s=t;s>16;){var o=Math.floor(.875*s),a=n(o)();if(a>s)return i+r(o-1,s/a)();i+=o,s-=a}for(var l=-Math.log1p(-e()),c=0;l<=s;++c)l-=Math.log1p(-e());return i+c}}return i.source=t,i}(Np);const Kp=1/4294967296;function Zp(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Jp(t,e){switch(arguments.length){case 0:break;case 1:"function"==typeof t?this.interpolator(t):this.range(t);break;default:this.domain(t),"function"==typeof e?this.interpolator(e):this.range(e)}return this}const Qp=Symbol("implicit");function t_(){var t=new E,e=[],n=[],r=Qp;function i(i){let s=t.get(i);if(void 0===s){if(r!==Qp)return r;t.set(i,s=e.push(i)-1)}return n[s%n.length]}return i.domain=function(n){if(!arguments.length)return e.slice();e=[],t=new E;for(const r of n)t.has(r)||t.set(r,e.push(r)-1);return i},i.range=function(t){return arguments.length?(n=Array.from(t),i):n.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return t_(e,n).unknown(r)},Zp.apply(i,arguments),i}function e_(){var t,e,n=t_().unknown(void 0),r=n.domain,i=n.range,s=0,o=1,a=!1,l=0,c=0,u=.5;function h(){var n=r().length,h=o<s,f=h?o:s,d=h?s:o;t=(d-f)/Math.max(1,n-l+2*c),a&&(t=Math.floor(t)),f+=(d-f-t*(n-l))*u,e=t*(1-l),a&&(f=Math.round(f),e=Math.round(e));var p=dt(n).map(function(e){return f+t*e});return i(h?p.reverse():p)}return delete n.unknown,n.domain=function(t){return arguments.length?(r(t),h()):r()},n.range=function(t){return arguments.length?([s,o]=t,s=+s,o=+o,h()):[s,o]},n.rangeRound=function(t){return[s,o]=t,s=+s,o=+o,a=!0,h()},n.bandwidth=function(){return e},n.step=function(){return t},n.round=function(t){return arguments.length?(a=!!t,h()):a},n.padding=function(t){return arguments.length?(l=Math.min(1,c=+t),h()):l},n.paddingInner=function(t){return arguments.length?(l=Math.min(1,t),h()):l},n.paddingOuter=function(t){return arguments.length?(c=+t,h()):c},n.align=function(t){return arguments.length?(u=Math.max(0,Math.min(1,t)),h()):u},n.copy=function(){return e_(r(),[s,o]).round(a).paddingInner(l).paddingOuter(c).align(u)},Zp.apply(h(),arguments)}function n_(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return n_(e())},t}function r_(){return n_(e_.apply(null,arguments).paddingInner(1))}function i_(t){return+t}var s_=[0,1];function o_(t){return t}function a_(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function l_(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=a_(i,r),s=n(o,s)):(r=a_(r,i),s=n(s,o)),function(t){return s(r(t))}}function c_(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),a=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++a<r;)i[a]=a_(t[a],t[a+1]),s[a]=n(e[a],e[a+1]);return function(e){var n=o(t,e,1,r)-1;return s[n](i[n](e))}}function u_(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function h_(){var t,e,n,r,i,s,o=s_,a=s_,l=Hr,c=o_;function u(){var t=Math.min(o.length,a.length);return c!==o_&&(c=function(t,e){var n;return t>e&&(n=t,t=e,e=n),function(n){return Math.max(t,Math.min(e,n))}}(o[0],o[t-1])),r=t>2?c_:l_,i=s=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(o.map(t),a,l)))(t(c(e)))}return h.invert=function(n){return c(e((s||(s=r(a,o.map(t),Gr)))(n)))},h.domain=function(t){return arguments.length?(o=Array.from(t,i_),u()):o.slice()},h.range=function(t){return arguments.length?(a=Array.from(t),u()):a.slice()},h.rangeRound=function(t){return a=Array.from(t),l=Wr,u()},h.clamp=function(t){return arguments.length?(c=!!t||o_,u()):c!==o_},h.interpolate=function(t){return arguments.length?(l=t,u()):l},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,u()}}function f_(){return h_()(o_,o_)}function d_(t,e,n,r){var i,s=X(t,e,n);switch((r=zl(null==r?",f":r)).type){case"s":var o=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=Jl(s,o))||(r.precision=i),Wl(r,o);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=Ql(s,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=Zl(s))||(r.precision=i-2*("%"===r.type))}return Hl(r)}function p_(t){var e=t.domain;return t.ticks=function(t){var n=e();return q(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return d_(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,s=e(),o=0,a=s.length-1,l=s[o],c=s[a],u=10;for(c<l&&(i=l,l=c,c=i,i=o,o=a,a=i);u-- >0;){if((i=$(l,c,n))===r)return s[o]=l,s[a]=c,e(s);if(i>0)l=Math.floor(l/i)*i,c=Math.ceil(c/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,c=Math.floor(c*i)/i}r=i}return t},t}function __(){var t=f_();return t.copy=function(){return u_(t,__())},Zp.apply(t,arguments),p_(t)}function g_(t,e){var n,r=0,i=(t=t.slice()).length-1,s=t[r],o=t[i];return o<s&&(n=r,r=i,i=n,n=s,s=o,o=n),t[r]=e.floor(s),t[i]=e.ceil(o),t}function y_(t){return Math.log(t)}function m_(t){return Math.exp(t)}function b_(t){return-Math.log(-t)}function v_(t){return-Math.exp(-t)}function x_(t){return isFinite(t)?+("1e"+t):t<0?0:t}function w_(t){return(e,n)=>-t(-e,n)}function E_(t){const e=t(y_,m_),n=e.domain;let r,i,s=10;function o(){return r=function(t){return t===Math.E?Math.log:10===t&&Math.log10||2===t&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}(s),i=function(t){return 10===t?x_:t===Math.E?Math.exp:e=>Math.pow(t,e)}(s),n()[0]<0?(r=w_(r),i=w_(i),t(b_,v_)):t(y_,m_),e}return e.base=function(t){return arguments.length?(s=+t,o()):s},e.domain=function(t){return arguments.length?(n(t),o()):n()},e.ticks=t=>{const e=n();let o=e[0],a=e[e.length-1];const l=a<o;l&&([o,a]=[a,o]);let c,u,h=r(o),f=r(a);const d=null==t?10:+t;let p=[];if(!(s%1)&&f-h<d){if(h=Math.floor(h),f=Math.ceil(f),o>0){for(;h<=f;++h)for(c=1;c<s;++c)if(u=h<0?c/i(-h):c*i(h),!(u<o)){if(u>a)break;p.push(u)}}else for(;h<=f;++h)for(c=s-1;c>=1;--c)if(u=h>0?c/i(-h):c*i(h),!(u<o)){if(u>a)break;p.push(u)}2*p.length<d&&(p=q(o,a,d))}else p=q(h,f,Math.min(f-h,d)).map(i);return l?p.reverse():p},e.tickFormat=(t,n)=>{if(null==t&&(t=10),null==n&&(n=10===s?"s":","),"function"!=typeof n&&(s%1||null!=(n=zl(n)).precision||(n.trim=!0),n=Hl(n)),t===1/0)return n;const o=Math.max(1,s*t/e.ticks().length);return t=>{let e=t/i(Math.round(r(t)));return e*s<s-.5&&(e*=s),e<=o?n(t):""}},e.nice=()=>n(g_(n(),{floor:t=>i(Math.floor(r(t))),ceil:t=>i(Math.ceil(r(t)))})),e}function A_(){const t=E_(h_()).domain([1,10]);return t.copy=()=>u_(t,A_()).base(t.base()),Zp.apply(t,arguments),t}function S_(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function T_(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function C_(t){var e=1,n=t(S_(e),T_(e));return n.constant=function(n){return arguments.length?t(S_(e=+n),T_(e)):e},p_(n)}function k_(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function R_(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function M_(t){return t<0?-t*t:t*t}function O_(t){var e=t(o_,o_),n=1;return e.exponent=function(e){return arguments.length?1===(n=+e)?t(o_,o_):.5===n?t(R_,M_):t(k_(n),k_(1/n)):n},p_(e)}function N_(){var t=O_(h_());return t.copy=function(){return u_(t,N_()).exponent(t.exponent())},Zp.apply(t,arguments),t}function I_(t){return Math.sign(t)*t*t}const P_=new Date,L_=new Date;function D_(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=e=>(t(e=new Date(+e)),e),i.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),i.round=t=>{const e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=(t,n)=>(e(t=new Date(+t),null==n?1:Math.floor(n)),t),i.range=(n,r,s)=>{const o=[];if(n=i.ceil(n),s=null==s?1:Math.floor(s),!(n<r&&s>0))return o;let a;do{o.push(a=new Date(+n)),e(n,s),t(n)}while(a<n&&n<r);return o},i.filter=n=>D_(e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)},(t,r)=>{if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}),n&&(i.count=(e,r)=>(P_.setTime(+e),L_.setTime(+r),t(P_),t(L_),Math.floor(n(P_,L_))),i.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?e=>r(e)%t===0:e=>i.count(0,e)%t===0):i:null)),i}const V_=D_(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);V_.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?D_(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):V_:null);const B_=V_.range,z_=1e3,G_=6e4,F_=36e5,j_=864e5,U_=6048e5,Y_=2592e6,H_=31536e6,W_=D_(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*z_)},(t,e)=>(e-t)/z_,t=>t.getUTCSeconds()),q_=W_.range,$_=D_(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*z_)},(t,e)=>{t.setTime(+t+e*G_)},(t,e)=>(e-t)/G_,t=>t.getMinutes()),X_=$_.range,K_=D_(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*G_)},(t,e)=>(e-t)/G_,t=>t.getUTCMinutes()),Z_=K_.range,J_=D_(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*z_-t.getMinutes()*G_)},(t,e)=>{t.setTime(+t+e*F_)},(t,e)=>(e-t)/F_,t=>t.getHours()),Q_=J_.range,tg=D_(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*F_)},(t,e)=>(e-t)/F_,t=>t.getUTCHours()),eg=tg.range,ng=D_(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*G_)/j_,t=>t.getDate()-1),rg=ng.range,ig=D_(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/j_,t=>t.getUTCDate()-1),sg=ig.range,og=D_(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/j_,t=>Math.floor(t/j_)),ag=og.range;function lg(t){return D_(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+7*e)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*G_)/U_)}const cg=lg(0),ug=lg(1),hg=lg(2),fg=lg(3),dg=lg(4),pg=lg(5),_g=lg(6),gg=cg.range,yg=ug.range,mg=hg.range,bg=fg.range,vg=dg.range,xg=pg.range,wg=_g.range;function Eg(t){return D_(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)},(t,e)=>(e-t)/U_)}const Ag=Eg(0),Sg=Eg(1),Tg=Eg(2),Cg=Eg(3),kg=Eg(4),Rg=Eg(5),Mg=Eg(6),Og=Ag.range,Ng=Sg.range,Ig=Tg.range,Pg=Cg.range,Lg=kg.range,Dg=Rg.range,Vg=Mg.range,Bg=D_(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear()),t=>t.getMonth()),zg=Bg.range,Gg=D_(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear()),t=>t.getUTCMonth()),Fg=Gg.range,jg=D_(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());jg.every=t=>isFinite(t=Math.floor(t))&&t>0?D_(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)}):null;const Ug=jg.range,Yg=D_(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());Yg.every=t=>isFinite(t=Math.floor(t))&&t>0?D_(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)}):null;const Hg=Yg.range;function Wg(t,e,r,i,s,o){const a=[[W_,1,z_],[W_,5,5e3],[W_,15,15e3],[W_,30,3e4],[o,1,G_],[o,5,3e5],[o,15,9e5],[o,30,18e5],[s,1,F_],[s,3,108e5],[s,6,216e5],[s,12,432e5],[i,1,j_],[i,2,1728e5],[r,1,U_],[e,1,Y_],[e,3,7776e6],[t,1,H_]];function l(e,r,i){const s=Math.abs(r-e)/i,o=n(([,,t])=>t).right(a,s);if(o===a.length)return t.every(X(e/H_,r/H_,i));if(0===o)return V_.every(Math.max(X(e,r,i),1));const[l,c]=a[s/a[o-1][2]<a[o][2]/s?o-1:o];return l.every(c)}return[function(t,e,n){const r=e<t;r&&([t,e]=[e,t]);const i=n&&"function"==typeof n.range?n:l(t,e,n),s=i?i.range(t,+e+1):[];return r?s.reverse():s},l]}const[qg,$g]=Wg(Yg,Gg,Ag,og,tg,K_),[Xg,Kg]=Wg(jg,Bg,cg,ng,J_,$_);function Zg(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 Jg(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 Qg(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function ty(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,o=t.shortDays,a=t.months,l=t.shortMonths,c=fy(i),u=dy(i),h=fy(s),f=dy(s),d=fy(o),p=dy(o),_=fy(a),g=dy(a),y=fy(l),m=dy(l),b={a:function(t){return o[t.getDay()]},A:function(t){return s[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return a[t.getMonth()]},c:null,d:Py,e:Py,f:zy,g:Ky,G:Jy,H:Ly,I:Dy,j:Vy,L:By,m:Gy,M:Fy,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:xm,s:wm,S:jy,u:Uy,U:Yy,V:Wy,w:qy,W:$y,x:null,X:null,y:Xy,Y:Zy,Z:Qy,"%":vm},v={a:function(t){return o[t.getUTCDay()]},A:function(t){return s[t.getUTCDay()]},b:function(t){return l[t.getUTCMonth()]},B:function(t){return a[t.getUTCMonth()]},c:null,d:tm,e:tm,f:sm,g:gm,G:mm,H:em,I:nm,j:rm,L:im,m:om,M:am,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:xm,s:wm,S:lm,u:cm,U:um,V:fm,w:dm,W:pm,x:null,X:null,y:_m,Y:ym,Z:bm,"%":vm},x={a:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.w=f.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=y.exec(e.slice(n));return r?(t.m=m.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=_.exec(e.slice(n));return r?(t.m=g.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return A(t,e,n,r)},d:Ay,e:Ay,f:My,g:vy,G:by,H:Ty,I:Ty,j:Sy,L:Ry,m:Ey,M:Cy,p:function(t,e,n){var r=c.exec(e.slice(n));return r?(t.p=u.get(r[0].toLowerCase()),n+r[0].length):-1},q:wy,Q:Ny,s:Iy,S:ky,u:_y,U:gy,V:yy,w:py,W:my,x:function(t,e,r){return A(t,n,e,r)},X:function(t,e,n){return A(t,r,e,n)},y:vy,Y:by,Z:xy,"%":Oy};function w(t,e){return function(n){var r,i,s,o=[],a=-1,l=0,c=t.length;for(n instanceof Date||(n=new Date(+n));++a<c;)37===t.charCodeAt(a)&&(o.push(t.slice(l,a)),null!=(i=oy[r=t.charAt(++a)])?r=t.charAt(++a):i="e"===r?" ":"0",(s=e[r])&&(r=s(n,i)),o.push(r),l=a+1);return o.push(t.slice(l,a)),o.join("")}}function E(t,e){return function(n){var r,i,s=Qg(1900,void 0,1);if(A(s,t,n+="",0)!=n.length)return null;if("Q"in s)return new Date(s.Q);if("s"in s)return new Date(1e3*s.s+("L"in s?s.L:0));if(e&&!("Z"in s)&&(s.Z=0),"p"in s&&(s.H=s.H%12+12*s.p),void 0===s.m&&(s.m="q"in s?s.q:0),"V"in s){if(s.V<1||s.V>53)return null;"w"in s||(s.w=1),"Z"in s?(i=(r=Jg(Qg(s.y,0,1))).getUTCDay(),r=i>4||0===i?Sg.ceil(r):Sg(r),r=ig.offset(r,7*(s.V-1)),s.y=r.getUTCFullYear(),s.m=r.getUTCMonth(),s.d=r.getUTCDate()+(s.w+6)%7):(i=(r=Zg(Qg(s.y,0,1))).getDay(),r=i>4||0===i?ug.ceil(r):ug(r),r=ng.offset(r,7*(s.V-1)),s.y=r.getFullYear(),s.m=r.getMonth(),s.d=r.getDate()+(s.w+6)%7)}else("W"in s||"U"in s)&&("w"in s||(s.w="u"in s?s.u%7:"W"in s?1:0),i="Z"in s?Jg(Qg(s.y,0,1)).getUTCDay():Zg(Qg(s.y,0,1)).getDay(),s.m=0,s.d="W"in s?(s.w+6)%7+7*s.W-(i+5)%7:s.w+7*s.U-(i+6)%7);return"Z"in s?(s.H+=s.Z/100|0,s.M+=s.Z%100,Jg(s)):Zg(s)}}function A(t,e,n,r){for(var i,s,o=0,a=e.length,l=n.length;o<a;){if(r>=l)return-1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(s=x[i in oy?e.charAt(o++):i])||(r=s(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return b.x=w(n,b),b.X=w(r,b),b.c=w(e,b),v.x=w(n,v),v.X=w(r,v),v.c=w(e,v),{format:function(t){var e=w(t+="",b);return e.toString=function(){return t},e},parse:function(t){var e=E(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=w(t+="",v);return e.toString=function(){return t},e},utcParse:function(t){var e=E(t+="",!0);return e.toString=function(){return t},e}}}var ey,ny,ry,iy,sy,oy={"-":"",_:" ",0:"0"},ay=/^\s*\d+/,ly=/^%/,cy=/[\\^$*+?|[\]().{}]/g;function uy(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function hy(t){return t.replace(cy,"\\$&")}function fy(t){return new RegExp("^(?:"+t.map(hy).join("|")+")","i")}function dy(t){return new Map(t.map((t,e)=>[t.toLowerCase(),e]))}function py(t,e,n){var r=ay.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function _y(t,e,n){var r=ay.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function gy(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function yy(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function my(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function by(t,e,n){var r=ay.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function vy(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function xy(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 wy(t,e,n){var r=ay.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function Ey(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Ay(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Sy(t,e,n){var r=ay.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Ty(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Cy(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ky(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Ry(t,e,n){var r=ay.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function My(t,e,n){var r=ay.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Oy(t,e,n){var r=ly.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Ny(t,e,n){var r=ay.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Iy(t,e,n){var r=ay.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function Py(t,e){return uy(t.getDate(),e,2)}function Ly(t,e){return uy(t.getHours(),e,2)}function Dy(t,e){return uy(t.getHours()%12||12,e,2)}function Vy(t,e){return uy(1+ng.count(jg(t),t),e,3)}function By(t,e){return uy(t.getMilliseconds(),e,3)}function zy(t,e){return By(t,e)+"000"}function Gy(t,e){return uy(t.getMonth()+1,e,2)}function Fy(t,e){return uy(t.getMinutes(),e,2)}function jy(t,e){return uy(t.getSeconds(),e,2)}function Uy(t){var e=t.getDay();return 0===e?7:e}function Yy(t,e){return uy(cg.count(jg(t)-1,t),e,2)}function Hy(t){var e=t.getDay();return e>=4||0===e?dg(t):dg.ceil(t)}function Wy(t,e){return t=Hy(t),uy(dg.count(jg(t),t)+(4===jg(t).getDay()),e,2)}function qy(t){return t.getDay()}function $y(t,e){return uy(ug.count(jg(t)-1,t),e,2)}function Xy(t,e){return uy(t.getFullYear()%100,e,2)}function Ky(t,e){return uy((t=Hy(t)).getFullYear()%100,e,2)}function Zy(t,e){return uy(t.getFullYear()%1e4,e,4)}function Jy(t,e){var n=t.getDay();return uy((t=n>=4||0===n?dg(t):dg.ceil(t)).getFullYear()%1e4,e,4)}function Qy(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+uy(e/60|0,"0",2)+uy(e%60,"0",2)}function tm(t,e){return uy(t.getUTCDate(),e,2)}function em(t,e){return uy(t.getUTCHours(),e,2)}function nm(t,e){return uy(t.getUTCHours()%12||12,e,2)}function rm(t,e){return uy(1+ig.count(Yg(t),t),e,3)}function im(t,e){return uy(t.getUTCMilliseconds(),e,3)}function sm(t,e){return im(t,e)+"000"}function om(t,e){return uy(t.getUTCMonth()+1,e,2)}function am(t,e){return uy(t.getUTCMinutes(),e,2)}function lm(t,e){return uy(t.getUTCSeconds(),e,2)}function cm(t){var e=t.getUTCDay();return 0===e?7:e}function um(t,e){return uy(Ag.count(Yg(t)-1,t),e,2)}function hm(t){var e=t.getUTCDay();return e>=4||0===e?kg(t):kg.ceil(t)}function fm(t,e){return t=hm(t),uy(kg.count(Yg(t),t)+(4===Yg(t).getUTCDay()),e,2)}function dm(t){return t.getUTCDay()}function pm(t,e){return uy(Sg.count(Yg(t)-1,t),e,2)}function _m(t,e){return uy(t.getUTCFullYear()%100,e,2)}function gm(t,e){return uy((t=hm(t)).getUTCFullYear()%100,e,2)}function ym(t,e){return uy(t.getUTCFullYear()%1e4,e,4)}function mm(t,e){var n=t.getUTCDay();return uy((t=n>=4||0===n?kg(t):kg.ceil(t)).getUTCFullYear()%1e4,e,4)}function bm(){return"+0000"}function vm(){return"%"}function xm(t){return+t}function wm(t){return Math.floor(+t/1e3)}function Em(t){return ey=ty(t),ny=ey.format,ry=ey.parse,iy=ey.utcFormat,sy=ey.utcParse,ey}Em({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"]});var Am="%Y-%m-%dT%H:%M:%S.%LZ";var Sm=Date.prototype.toISOString?function(t){return t.toISOString()}:iy(Am);var Tm=+new Date("2000-01-01T00:00:00.000Z")?function(t){var e=new Date(t);return isNaN(e)?null:e}:sy(Am);function Cm(t){return new Date(t)}function km(t){return t instanceof Date?+t:+new Date(+t)}function Rm(t,e,n,r,i,s,o,a,l,c){var u=f_(),h=u.invert,f=u.domain,d=c(".%L"),p=c(":%S"),_=c("%I:%M"),g=c("%I %p"),y=c("%a %d"),m=c("%b %d"),b=c("%B"),v=c("%Y");function x(t){return(l(t)<t?d:a(t)<t?p:o(t)<t?_:s(t)<t?g:r(t)<t?i(t)<t?y:m:n(t)<t?b:v)(t)}return u.invert=function(t){return new Date(h(t))},u.domain=function(t){return arguments.length?f(Array.from(t,km)):f().map(Cm)},u.ticks=function(e){var n=f();return t(n[0],n[n.length-1],null==e?10:e)},u.tickFormat=function(t,e){return null==e?x:c(e)},u.nice=function(t){var n=f();return t&&"function"==typeof t.range||(t=e(n[0],n[n.length-1],null==t?10:t)),t?f(g_(n,t)):u},u.copy=function(){return u_(u,Rm(t,e,n,r,i,s,o,a,l,c))},u}function Mm(){return Zp.apply(Rm(Xg,Kg,jg,Bg,cg,ng,J_,$_,W_,ny).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Om(){var t,e,n,r,i,s=0,o=1,a=o_,l=!1;function c(e){return null==e||isNaN(e=+e)?i:a(0===n?.5:(e=(r(e)-t)*n,l?Math.max(0,Math.min(1,e)):e))}function u(t){return function(e){var n,r;return arguments.length?([n,r]=e,a=t(n,r),c):[a(0),a(1)]}}return c.domain=function(i){return arguments.length?([s,o]=i,t=r(s=+s),e=r(o=+o),n=t===e?0:1/(e-t),c):[s,o]},c.clamp=function(t){return arguments.length?(l=!!t,c):l},c.interpolator=function(t){return arguments.length?(a=t,c):a},c.range=u(Hr),c.rangeRound=u(Wr),c.unknown=function(t){return arguments.length?(i=t,c):i},function(i){return r=i,t=i(s),e=i(o),n=t===e?0:1/(e-t),c}}function Nm(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function Im(){var t=p_(Om()(o_));return t.copy=function(){return Nm(t,Im())},Jp.apply(t,arguments)}function Pm(){var t=O_(Om());return t.copy=function(){return Nm(t,Pm()).exponent(t.exponent())},Jp.apply(t,arguments)}function Lm(){var t,e,n,r,i,s,o,a=0,l=.5,c=1,u=1,h=o_,f=!1;function d(t){return isNaN(t=+t)?o:(t=.5+((t=+s(t))-e)*(u*t<u*e?r:i),h(f?Math.max(0,Math.min(1,t)):t))}function p(t){return function(e){var n,r,i;return arguments.length?([n,r,i]=e,h=hi(t,[n,r,i]),d):[h(0),h(.5),h(1)]}}return d.domain=function(o){return arguments.length?([a,l,c]=o,t=s(a=+a),e=s(l=+l),n=s(c=+c),r=t===e?0:.5/(e-t),i=e===n?0:.5/(n-e),u=e<t?-1:1,d):[a,l,c]},d.clamp=function(t){return arguments.length?(f=!!t,d):f},d.interpolator=function(t){return arguments.length?(h=t,d):h},d.range=p(Hr),d.rangeRound=p(Wr),d.unknown=function(t){return arguments.length?(o=t,d):o},function(o){return s=o,t=o(a),e=o(l),n=o(c),r=t===e?0:.5/(e-t),i=e===n?0:.5/(n-e),u=e<t?-1:1,d}}function Dm(){var t=O_(Lm());return t.copy=function(){return Nm(t,Dm()).exponent(t.exponent())},Jp.apply(t,arguments)}function Vm(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(6*r,6*++r);return n}var Bm=Vm("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),zm=Vm("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"),Gm=Vm("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"),Fm=Vm("4269d0efb118ff725c6cc5b03ca951ff8ab7a463f297bbf59c6b4e9498a0"),jm=Vm("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),Um=Vm("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"),Ym=Vm("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"),Hm=Vm("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"),Wm=Vm("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"),qm=Vm("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"),$m=Vm("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"),Xm=t=>Pr(t[t.length-1]),Km=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(Vm),Zm=Xm(Km),Jm=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(Vm),Qm=Xm(Jm),tb=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(Vm),eb=Xm(tb),nb=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(Vm),rb=Xm(nb),ib=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(Vm),sb=Xm(ib),ob=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(Vm),ab=Xm(ob),lb=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(Vm),cb=Xm(lb),ub=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(Vm),hb=Xm(ub),fb=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(Vm),db=Xm(fb),pb=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(Vm),_b=Xm(pb),gb=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(Vm),yb=Xm(gb),mb=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(Vm),bb=Xm(mb),vb=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(Vm),xb=Xm(vb),wb=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(Vm),Eb=Xm(wb),Ab=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(Vm),Sb=Xm(Ab),Tb=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(Vm),Cb=Xm(Tb),kb=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(Vm),Rb=Xm(kb),Mb=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(Vm),Ob=Xm(Mb),Nb=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(Vm),Ib=Xm(Nb),Pb=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(Vm),Lb=Xm(Pb),Db=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(Vm),Vb=Xm(Db),Bb=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(Vm),zb=Xm(Bb),Gb=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(Vm),Fb=Xm(Gb),jb=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Vm),Ub=Xm(jb),Yb=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(Vm),Hb=Xm(Yb),Wb=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(Vm),qb=Xm(Wb),$b=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(Vm),Xb=Xm($b);var Kb=ui(wr(300,.5,0),wr(-240,.5,1)),Zb=ui(wr(-100,.75,.35),wr(80,1.5,.8)),Jb=ui(wr(260,.75,.35),wr(80,1.5,.8)),Qb=wr();var tv=Ln(),ev=Math.PI/3,nv=2*Math.PI/3;function rv(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))))+")"}function iv(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}var sv=iv(Vm("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),ov=iv(Vm("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),av=iv(Vm("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),lv=iv(Vm("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function cv(t){return function(){return t}}const uv=Math.abs,hv=Math.atan2,fv=Math.cos,dv=Math.max,pv=Math.min,_v=Math.sin,gv=Math.sqrt,yv=1e-12,mv=Math.PI,bv=mv/2,vv=2*mv;function xv(t){return t>=1?bv:t<=-1?-bv:Math.asin(t)}function wv(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(null==n)e=null;else{const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new So(e)}function Ev(t){return t.innerRadius}function Av(t){return t.outerRadius}function Sv(t){return t.startAngle}function Tv(t){return t.endAngle}function Cv(t){return t&&t.padAngle}function kv(t,e,n,r,i,s,o){var a=t-n,l=e-r,c=(o?s:-s)/gv(a*a+l*l),u=c*l,h=-c*a,f=t+u,d=e+h,p=n+u,_=r+h,g=(f+p)/2,y=(d+_)/2,m=p-f,b=_-d,v=m*m+b*b,x=i-s,w=f*_-p*d,E=(b<0?-1:1)*gv(dv(0,x*x*v-w*w)),A=(w*b-m*E)/v,S=(-w*m-b*E)/v,T=(w*b+m*E)/v,C=(-w*m+b*E)/v,k=A-g,R=S-y,M=T-g,O=C-y;return k*k+R*R>M*M+O*O&&(A=T,S=C),{cx:A,cy:S,x01:-u,y01:-h,x11:A*(i/x-1),y11:S*(i/x-1)}}var Rv=Array.prototype.slice;function Mv(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function Ov(t){this._context=t}function Nv(t){return new Ov(t)}function Iv(t){return t[0]}function Pv(t){return t[1]}function Lv(t,e){var n=cv(!0),r=null,i=Nv,s=null,o=wv(a);function a(a){var l,c,u,h=(a=Mv(a)).length,f=!1;for(null==r&&(s=i(u=o())),l=0;l<=h;++l)!(l<h&&n(c=a[l],l,a))===f&&((f=!f)?s.lineStart():s.lineEnd()),f&&s.point(+t(c,l,a),+e(c,l,a));if(u)return s=null,u+""||null}return t="function"==typeof t?t:void 0===t?Iv:cv(t),e="function"==typeof e?e:void 0===e?Pv:cv(e),a.x=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),a):t},a.y=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),a):e},a.defined=function(t){return arguments.length?(n="function"==typeof t?t:cv(!!t),a):n},a.curve=function(t){return arguments.length?(i=t,null!=r&&(s=i(r)),a):i},a.context=function(t){return arguments.length?(null==t?r=s=null:s=i(r=t),a):r},a}function Dv(t,e,n){var r=null,i=cv(!0),s=null,o=Nv,a=null,l=wv(c);function c(c){var u,h,f,d,p,_=(c=Mv(c)).length,g=!1,y=new Array(_),m=new Array(_);for(null==s&&(a=o(p=l())),u=0;u<=_;++u){if(!(u<_&&i(d=c[u],u,c))===g)if(g=!g)h=u,a.areaStart(),a.lineStart();else{for(a.lineEnd(),a.lineStart(),f=u-1;f>=h;--f)a.point(y[f],m[f]);a.lineEnd(),a.areaEnd()}g&&(y[u]=+t(d,u,c),m[u]=+e(d,u,c),a.point(r?+r(d,u,c):y[u],n?+n(d,u,c):m[u]))}if(p)return a=null,p+""||null}function u(){return Lv().defined(i).curve(o).context(s)}return t="function"==typeof t?t:void 0===t?Iv:cv(+t),e="function"==typeof e?e:cv(void 0===e?0:+e),n="function"==typeof n?n:void 0===n?Pv:cv(+n),c.x=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),r=null,c):t},c.x0=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),c):t},c.x1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:cv(+t),c):r},c.y=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),n=null,c):e},c.y0=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),c):e},c.y1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:cv(+t),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(t){return arguments.length?(i="function"==typeof t?t:cv(!!t),c):i},c.curve=function(t){return arguments.length?(o=t,null!=s&&(a=o(s)),c):o},c.context=function(t){return arguments.length?(null==t?s=a=null:a=o(s=t),c):s},c}function Vv(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function Bv(t){return t}Ov.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&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)}}};var zv=Fv(Nv);function Gv(t){this._curve=t}function Fv(t){function e(e){return new Gv(t(e))}return e._curve=t,e}function jv(t){var e=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(t){return arguments.length?e(Fv(t)):e()._curve},t}function Uv(){return jv(Lv().curve(zv))}function Yv(){var t=Dv().curve(zv),e=t.curve,n=t.lineX0,r=t.lineX1,i=t.lineY0,s=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return jv(n())},delete t.lineX0,t.lineEndAngle=function(){return jv(r())},delete t.lineX1,t.lineInnerRadius=function(){return jv(i())},delete t.lineY0,t.lineOuterRadius=function(){return jv(s())},delete t.lineY1,t.curve=function(t){return arguments.length?e(Fv(t)):e()._curve},t}function Hv(t,e){return[(e=+e)*Math.cos(t-=Math.PI/2),e*Math.sin(t)]}Gv.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(t,e){this._curve.point(e*Math.sin(t),e*-Math.cos(t))}};class Wv{constructor(t,e){this._context=t,this._x=e}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line}point(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._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,e,t,e):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+e)/2,t,this._y0,t,e)}this._x0=t,this._y0=e}}class qv{constructor(t){this._context=t}lineStart(){this._point=0}lineEnd(){}point(t,e){if(t=+t,e=+e,0===this._point)this._point=1;else{const n=Hv(this._x0,this._y0),r=Hv(this._x0,this._y0=(this._y0+e)/2),i=Hv(t,this._y0),s=Hv(t,e);this._context.moveTo(...n),this._context.bezierCurveTo(...r,...i,...s)}this._x0=t,this._y0=e}}function $v(t){return new Wv(t,!0)}function Xv(t){return new Wv(t,!1)}function Kv(t){return new qv(t)}function Zv(t){return t.source}function Jv(t){return t.target}function Qv(t){let e=Zv,n=Jv,r=Iv,i=Pv,s=null,o=null,a=wv(l);function l(){let l;const c=Rv.call(arguments),u=e.apply(this,c),h=n.apply(this,c);if(null==s&&(o=t(l=a())),o.lineStart(),c[0]=u,o.point(+r.apply(this,c),+i.apply(this,c)),c[0]=h,o.point(+r.apply(this,c),+i.apply(this,c)),o.lineEnd(),l)return o=null,l+""||null}return l.source=function(t){return arguments.length?(e=t,l):e},l.target=function(t){return arguments.length?(n=t,l):n},l.x=function(t){return arguments.length?(r="function"==typeof t?t:cv(+t),l):r},l.y=function(t){return arguments.length?(i="function"==typeof t?t:cv(+t),l):i},l.context=function(e){return arguments.length?(null==e?s=o=null:o=t(s=e),l):s},l}function tx(){return Qv($v)}function ex(){return Qv(Xv)}function nx(){const t=Qv(Kv);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t}const rx=gv(3);var ix={draw(t,e){const n=.59436*gv(e+pv(e/28,.75)),r=n/2,i=r*rx;t.moveTo(0,n),t.lineTo(0,-n),t.moveTo(-i,-r),t.lineTo(i,r),t.moveTo(-i,r),t.lineTo(i,-r)}},sx={draw(t,e){const n=gv(e/mv);t.moveTo(n,0),t.arc(0,0,n,0,vv)}},ox={draw(t,e){const n=gv(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}};const ax=gv(1/3),lx=2*ax;var cx={draw(t,e){const n=gv(e/lx),r=n*ax;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},ux={draw(t,e){const n=.62625*gv(e);t.moveTo(0,-n),t.lineTo(n,0),t.lineTo(0,n),t.lineTo(-n,0),t.closePath()}},hx={draw(t,e){const n=.87559*gv(e-pv(e/7,2));t.moveTo(-n,0),t.lineTo(n,0),t.moveTo(0,n),t.lineTo(0,-n)}},fx={draw(t,e){const n=gv(e),r=-n/2;t.rect(r,r,n,n)}},dx={draw(t,e){const n=.4431*gv(e);t.moveTo(n,n),t.lineTo(n,-n),t.lineTo(-n,-n),t.lineTo(-n,n),t.closePath()}};const px=_v(mv/10)/_v(7*mv/10),_x=_v(vv/10)*px,gx=-fv(vv/10)*px;var yx={draw(t,e){const n=gv(.8908130915292852*e),r=_x*n,i=gx*n;t.moveTo(0,-n),t.lineTo(r,i);for(let e=1;e<5;++e){const s=vv*e/5,o=fv(s),a=_v(s);t.lineTo(a*n,-o*n),t.lineTo(o*r-a*i,a*r+o*i)}t.closePath()}};const mx=gv(3);var bx={draw(t,e){const n=-gv(e/(3*mx));t.moveTo(0,2*n),t.lineTo(-mx*n,-n),t.lineTo(mx*n,-n),t.closePath()}};const vx=gv(3);var xx={draw(t,e){const n=.6824*gv(e),r=n/2,i=n*vx/2;t.moveTo(0,-n),t.lineTo(i,r),t.lineTo(-i,r),t.closePath()}};const wx=-.5,Ex=gv(3)/2,Ax=1/gv(12),Sx=3*(Ax/2+1);var Tx={draw(t,e){const n=gv(e/Sx),r=n/2,i=n*Ax,s=r,o=n*Ax+n,a=-s,l=o;t.moveTo(r,i),t.lineTo(s,o),t.lineTo(a,l),t.lineTo(wx*r-Ex*i,Ex*r+wx*i),t.lineTo(wx*s-Ex*o,Ex*s+wx*o),t.lineTo(wx*a-Ex*l,Ex*a+wx*l),t.lineTo(wx*r+Ex*i,wx*i-Ex*r),t.lineTo(wx*s+Ex*o,wx*o-Ex*s),t.lineTo(wx*a+Ex*l,wx*l-Ex*a),t.closePath()}},Cx={draw(t,e){const n=.6189*gv(e-pv(e/6,1.7));t.moveTo(-n,-n),t.lineTo(n,n),t.moveTo(-n,n),t.lineTo(n,-n)}};const kx=[sx,ox,cx,fx,yx,bx,Tx],Rx=[sx,hx,Cx,xx,ix,dx,ux];function Mx(){}function Ox(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 Nx(t){this._context=t}function Ix(t){return new Nx(t)}function Px(t){this._context=t}function Lx(t){this._context=t}function Dx(t,e){this._basis=new Nx(t),this._beta=e}Nx.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:Ox(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&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:Ox(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},Px.prototype={areaStart:Mx,areaEnd:Mx,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:Ox(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},Lx.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(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Ox(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},Dx.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,e=this._y,n=t.length-1;if(n>0)for(var r,i=t[0],s=e[0],o=t[n]-i,a=e[n]-s,l=-1;++l<=n;)r=l/n,this._basis.point(this._beta*t[l]+(1-this._beta)*(i+r*o),this._beta*e[l]+(1-this._beta)*(s+r*a));this._x=this._y=null,this._basis.lineEnd()},point:function(t,e){this._x.push(+t),this._y.push(+e)}};var Vx=function t(e){function n(t){return 1===e?new Nx(t):new Dx(t,e)}return n.beta=function(e){return t(+e)},n}(.85);function Bx(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 zx(t,e){this._context=t,this._k=(1-e)/6}zx.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:Bx(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&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:Bx(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var Gx=function t(e){function n(t){return new zx(t,e)}return n.tension=function(e){return t(+e)},n}(0);function Fx(t,e){this._context=t,this._k=(1-e)/6}Fx.prototype={areaStart:Mx,areaEnd:Mx,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:Bx(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var jx=function t(e){function n(t){return new Fx(t,e)}return n.tension=function(e){return t(+e)},n}(0);function Ux(t,e){this._context=t,this._k=(1-e)/6}Ux.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(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Bx(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var Yx=function t(e){function n(t){return new Ux(t,e)}return n.tension=function(e){return t(+e)},n}(0);function Hx(t,e,n){var r=t._x1,i=t._y1,s=t._x2,o=t._y2;if(t._l01_a>yv){var a=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*a-t._x0*t._l12_2a+t._x2*t._l01_2a)/l,i=(i*a-t._y0*t._l12_2a+t._y2*t._l01_2a)/l}if(t._l23_a>yv){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);s=(s*c+t._x1*t._l23_2a-e*t._l12_2a)/u,o=(o*c+t._y1*t._l23_2a-n*t._l12_2a)/u}t._context.bezierCurveTo(r,i,s,o,t._x2,t._y2)}function Wx(t,e){this._context=t,this._alpha=e}Wx.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)}(this._line||0!==this._line&&1===this._point)&&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:Hx(this,t,e)}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}};var qx=function t(e){function n(t){return e?new Wx(t,e):new zx(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);function $x(t,e){this._context=t,this._alpha=e}$x.prototype={areaStart:Mx,areaEnd:Mx,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=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 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},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._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:Hx(this,t,e)}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}};var Xx=function t(e){function n(t){return e?new $x(t,e):new Fx(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);function Kx(t,e){this._context=t,this._alpha=e}Kx.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(){(this._line||0!==this._line&&3===this._point)&&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;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Hx(this,t,e)}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}};var Zx=function t(e){function n(t){return e?new Kx(t,e):new Ux(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);function Jx(t){this._context=t}function Qx(t){return t<0?-1:1}function tw(t,e,n){var r=t._x1-t._x0,i=e-t._x1,s=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),a=(s*i+o*r)/(r+i);return(Qx(s)+Qx(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(a))||0}function ew(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function nw(t,e,n){var r=t._x0,i=t._y0,s=t._x1,o=t._y1,a=(s-r)/3;t._context.bezierCurveTo(r+a,i+a*e,s-a,o-a*n,s,o)}function rw(t){this._context=t}function iw(t){this._context=new sw(t)}function sw(t){this._context=t}function ow(t){this._context=t}function aw(t){var e,n,r=t.length-1,i=new Array(r),s=new Array(r),o=new Array(r);for(i[0]=0,s[0]=2,o[0]=t[0]+2*t[1],e=1;e<r-1;++e)i[e]=1,s[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[r-1]=2,s[r-1]=7,o[r-1]=8*t[r-1]+t[r],e=1;e<r;++e)n=i[e]/s[e-1],s[e]-=n,o[e]-=n*o[e-1];for(i[r-1]=o[r-1]/s[r-1],e=r-2;e>=0;--e)i[e]=(o[e]-i[e+1])/s[e];for(s[r-1]=(t[r]+i[r-1])/2,e=0;e<r-1;++e)s[e]=2*t[e+1]-i[e+1];return[i,s]}function lw(t){return new ow(t)}function cw(t,e){this._context=t,this._t=e}function uw(t){return new cw(t,.5)}function hw(t,e){if((i=t.length)>1)for(var n,r,i,s=1,o=t[e[0]],a=o.length;s<i;++s)for(r=o,o=t[e[s]],n=0;n<a;++n)o[n][1]+=o[n][0]=isNaN(r[n][1])?r[n][0]:r[n][1]}function fw(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function dw(t,e){return t[e]}function pw(t){const e=[];return e.key=t,e}function _w(t){var e=t.map(gw);return fw(t).sort(function(t,n){return e[t]-e[n]})}function gw(t){for(var e,n=-1,r=0,i=t.length,s=-1/0;++n<i;)(e=+t[n][1])>s&&(s=e,r=n);return r}function yw(t){var e=t.map(mw);return fw(t).sort(function(t,n){return e[t]-e[n]})}function mw(t){for(var e,n=0,r=-1,i=t.length;++r<i;)(e=+t[r][1])&&(n+=e);return n}Jx.prototype={areaStart:Mx,areaEnd:Mx,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e))}},rw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:nw(this,this._t0,ew(this,this._t0))}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(e=+e,(t=+t)!==this._x1||e!==this._y1){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,nw(this,ew(this,n=tw(this,t,e)),n);break;default:nw(this,this._t0,n=tw(this,t,e))}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}},(iw.prototype=Object.create(rw.prototype)).point=function(t,e){rw.prototype.point.call(this,e,t)},sw.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,s){this._context.bezierCurveTo(e,t,r,n,s,i)}},ow.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]),2===n)this._context.lineTo(t[1],e[1]);else for(var r=aw(t),i=aw(e),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],t[o],e[o]);(this._line||0!==this._line&&1===n)&&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)}},cw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,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:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}}this._x=t,this._y=e}};var bw=t=>()=>t;function vw(t,{sourceEvent:e,target:n,transform:r,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},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function xw(t,e,n){this.k=t,this.x=e,this.y=n}xw.prototype={constructor:xw,scale:function(t){return 1===t?this:new xw(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new xw(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+")"}};var ww=new xw(1,0,0);function Ew(t){for(;!t.__zoom;)if(!(t=t.parentNode))return ww;return t.__zoom}function Aw(t){t.stopImmediatePropagation()}function Sw(t){t.preventDefault(),t.stopImmediatePropagation()}function Tw(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Cw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function kw(){return this.__zoom||ww}function Rw(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Mw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ow(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],s=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}Ew.prototype=xw.prototype;var Nw=Object.freeze({__proto__:null,Adder:w,Delaunay:Ca,FormatSpecifier:Gl,InternMap:E,InternSet:A,Node:Dd,Path:So,Voronoi:xa,ZoomTransform:xw,active:function(t,e){var n,r,i=t.__transition;if(i)for(r in e=null==e?null:e+"",i)if((n=i[r]).state>1&&n.name===e)return new rs([[t]],Ds,e,+r);return null},arc:function(){var t=Ev,e=Av,n=cv(0),r=null,i=Sv,s=Tv,o=Cv,a=null,l=wv(c);function c(){var c,u,h=+t.apply(this,arguments),f=+e.apply(this,arguments),d=i.apply(this,arguments)-bv,p=s.apply(this,arguments)-bv,_=uv(p-d),g=p>d;if(a||(a=c=l()),f<h&&(u=f,f=h,h=u),f>yv)if(_>vv-yv)a.moveTo(f*fv(d),f*_v(d)),a.arc(0,0,f,d,p,!g),h>yv&&(a.moveTo(h*fv(p),h*_v(p)),a.arc(0,0,h,p,d,g));else{var y,m,b=d,v=p,x=d,w=p,E=_,A=_,S=o.apply(this,arguments)/2,T=S>yv&&(r?+r.apply(this,arguments):gv(h*h+f*f)),C=pv(uv(f-h)/2,+n.apply(this,arguments)),k=C,R=C;if(T>yv){var M=xv(T/h*_v(S)),O=xv(T/f*_v(S));(E-=2*M)>yv?(x+=M*=g?1:-1,w-=M):(E=0,x=w=(d+p)/2),(A-=2*O)>yv?(b+=O*=g?1:-1,v-=O):(A=0,b=v=(d+p)/2)}var N=f*fv(b),I=f*_v(b),P=h*fv(w),L=h*_v(w);if(C>yv){var D,V=f*fv(v),B=f*_v(v),z=h*fv(x),G=h*_v(x);if(_<mv)if(D=function(t,e,n,r,i,s,o,a){var l=n-t,c=r-e,u=o-i,h=a-s,f=h*l-u*c;if(!(f*f<yv))return[t+(f=(u*(e-s)-h*(t-i))/f)*l,e+f*c]}(N,I,z,G,V,B,P,L)){var F=N-D[0],j=I-D[1],U=V-D[0],Y=B-D[1],H=1/_v(function(t){return t>1?0:t<-1?mv:Math.acos(t)}((F*U+j*Y)/(gv(F*F+j*j)*gv(U*U+Y*Y)))/2),W=gv(D[0]*D[0]+D[1]*D[1]);k=pv(C,(h-W)/(H-1)),R=pv(C,(f-W)/(H+1))}else k=R=0}A>yv?R>yv?(y=kv(z,G,N,I,f,R,g),m=kv(V,B,P,L,f,R,g),a.moveTo(y.cx+y.x01,y.cy+y.y01),R<C?a.arc(y.cx,y.cy,R,hv(y.y01,y.x01),hv(m.y01,m.x01),!g):(a.arc(y.cx,y.cy,R,hv(y.y01,y.x01),hv(y.y11,y.x11),!g),a.arc(0,0,f,hv(y.cy+y.y11,y.cx+y.x11),hv(m.cy+m.y11,m.cx+m.x11),!g),a.arc(m.cx,m.cy,R,hv(m.y11,m.x11),hv(m.y01,m.x01),!g))):(a.moveTo(N,I),a.arc(0,0,f,b,v,!g)):a.moveTo(N,I),h>yv&&E>yv?k>yv?(y=kv(P,L,V,B,h,-k,g),m=kv(N,I,z,G,h,-k,g),a.lineTo(y.cx+y.x01,y.cy+y.y01),k<C?a.arc(y.cx,y.cy,k,hv(y.y01,y.x01),hv(m.y01,m.x01),!g):(a.arc(y.cx,y.cy,k,hv(y.y01,y.x01),hv(y.y11,y.x11),!g),a.arc(0,0,h,hv(y.cy+y.y11,y.cx+y.x11),hv(m.cy+m.y11,m.cx+m.x11),g),a.arc(m.cx,m.cy,k,hv(m.y11,m.x11),hv(m.y01,m.x01),!g))):a.arc(0,0,h,w,x,g):a.lineTo(P,L)}else a.moveTo(0,0);if(a.closePath(),c)return a=null,c+""||null}return c.centroid=function(){var n=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +s.apply(this,arguments))/2-mv/2;return[fv(r)*n,_v(r)*n]},c.innerRadius=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),c):t},c.outerRadius=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),c):e},c.cornerRadius=function(t){return arguments.length?(n="function"==typeof t?t:cv(+t),c):n},c.padRadius=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:cv(+t),c):r},c.startAngle=function(t){return arguments.length?(i="function"==typeof t?t:cv(+t),c):i},c.endAngle=function(t){return arguments.length?(s="function"==typeof t?t:cv(+t),c):s},c.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:cv(+t),c):o},c.context=function(t){return arguments.length?(a=null==t?null:t,c):a},c},area:Dv,areaRadial:Yv,ascending:t,autoType:Za,axisBottom:function(t){return Mt(3,t)},axisLeft:function(t){return Mt(4,t)},axisRight:function(t){return Mt(2,t)},axisTop:function(t){return Mt(1,t)},bin:J,bisect:o,bisectCenter:l,bisectLeft:a,bisectRight:o,bisector:n,blob:function(t,e){return fetch(t,e).then(Qa)},blur:function(t,e){if(!((e=+e)>=0))throw new RangeError("invalid r");let n=t.length;if(!((n=Math.floor(n))>=0))throw new RangeError("invalid length");if(!n||!e)return t;const r=p(e),i=t.slice();return r(t,i,0,n,1),r(i,t,0,n,1),r(t,i,0,n,1),t},blur2:c,blurImage:u,brush:function(){return lo(Zs)},brushSelection:function(t){var e=t.__brush;return e?e.dim.output(e.selection):null},brushX:function(){return lo(Xs)},brushY:function(){return lo(Ks)},buffer:function(t,e){return fetch(t,e).then(tl)},chord:function(){return bo(!1,!1)},chordDirected:function(){return bo(!0,!1)},chordTranspose:function(){return bo(!1,!0)},cluster:Rd,color:On,contourDensity:function(){var t=Ko,e=Zo,n=Jo,r=960,i=500,s=20,o=2,a=3*s,l=r+2*a>>o,u=i+2*a>>o,h=zo(20);function f(r){var i=new Float32Array(l*u),h=Math.pow(2,-o),f=-1;for(const s of r){var d=(t(s,++f,r)+a)*h,p=(e(s,f,r)+a)*h,_=+n(s,f,r);if(_&&d>=0&&d<l&&p>=0&&p<u){var g=Math.floor(d),y=Math.floor(p),m=d-g-.5,b=p-y-.5;i[g+y*l]+=(1-m)*(1-b)*_,i[g+1+y*l]+=m*(1-b)*_,i[g+1+(y+1)*l]+=m*b*_,i[g+(y+1)*l]+=(1-m)*b*_}}return c({data:i,width:l,height:u},s*h),i}function d(t){var e=f(t),n=h(e),r=Math.pow(2,2*o);return Array.isArray(n)||(n=q(Number.MIN_VALUE,Q(e)/r,n)),Ho().size([l,u]).thresholds(n.map(t=>t*r))(e).map((t,e)=>(t.value=+n[e],p(t)))}function p(t){return t.coordinates.forEach(_),t}function _(t){t.forEach(g)}function g(t){t.forEach(y)}function y(t){t[0]=t[0]*Math.pow(2,o)-a,t[1]=t[1]*Math.pow(2,o)-a}function m(){return l=r+2*(a=3*s)>>o,u=i+2*a>>o,d}return d.contours=function(t){var e=f(t),n=Ho().size([l,u]),r=Math.pow(2,2*o),i=t=>{t=+t;var i=p(n.contour(e,t*r));return i.value=t,i};return Object.defineProperty(i,"max",{get:()=>Q(e)/r}),i},d.x=function(e){return arguments.length?(t="function"==typeof e?e:zo(+e),d):t},d.y=function(t){return arguments.length?(e="function"==typeof t?t:zo(+t),d):e},d.weight=function(t){return arguments.length?(n="function"==typeof t?t:zo(+t),d):n},d.size=function(t){if(!arguments.length)return[r,i];var e=+t[0],n=+t[1];if(!(e>=0&&n>=0))throw new Error("invalid size");return r=e,i=n,m()},d.cellSize=function(t){if(!arguments.length)return 1<<o;if(!((t=+t)>=1))throw new Error("invalid cell size");return o=Math.floor(Math.log(t)/Math.LN2),m()},d.thresholds=function(t){return arguments.length?(h="function"==typeof t?t:Array.isArray(t)?zo(Vo.call(t)):zo(t),d):h},d.bandwidth=function(t){if(!arguments.length)return Math.sqrt(s*(s+1));if(!((t=+t)>=0))throw new Error("invalid bandwidth");return s=(Math.sqrt(4*t*t+1)-1)/2,m()},d},contours:Ho,count:_,create:function(t){return $e(Ft(t).call(document.documentElement))},creator:Ft,cross:function(...t){const e="function"==typeof t[t.length-1]&&function(t){return e=>t(...e)}(t.pop()),n=(t=t.map(m)).map(g),r=t.length-1,i=new Array(r+1).fill(0),s=[];if(r<0||n.some(y))return s;for(;;){s.push(i.map((e,n)=>t[n][e]));let o=r;for(;++i[o]===n[o];){if(0===o)return e?s.map(e):s;i[o--]=0}}},csv:il,csvFormat:Ba,csvFormatBody:za,csvFormatRow:Fa,csvFormatRows:Ga,csvFormatValue:ja,csvParse:Da,csvParseRows:Va,cubehelix:wr,cumsum:function(t,e){var n=0,r=0;return Float64Array.from(t,void 0===e?t=>n+=+t||0:i=>n+=+e(i,r++,t)||0)},curveBasis:Ix,curveBasisClosed:function(t){return new Px(t)},curveBasisOpen:function(t){return new Lx(t)},curveBumpX:$v,curveBumpY:Xv,curveBundle:Vx,curveCardinal:Gx,curveCardinalClosed:jx,curveCardinalOpen:Yx,curveCatmullRom:qx,curveCatmullRomClosed:Xx,curveCatmullRomOpen:Zx,curveLinear:Nv,curveLinearClosed:function(t){return new Jx(t)},curveMonotoneX:function(t){return new rw(t)},curveMonotoneY:function(t){return new iw(t)},curveNatural:lw,curveStep:uw,curveStepAfter:function(t){return new cw(t,1)},curveStepBefore:function(t){return new cw(t,0)},descending:e,deviation:v,difference:function(t,...e){t=new A(t);for(const n of e)for(const e of n)t.delete(e);return t},disjoint:function(t,e){const n=e[Symbol.iterator](),r=new A;for(const e of t){if(r.has(e))return!1;let t,i;for(;({value:t,done:i}=n.next())&&!i;){if(Object.is(e,t))return!1;r.add(t)}}return!0},dispatch:Nt,drag:function(){var t,e,n,r,i=cn,s=un,o=hn,a=fn,l={},c=Nt("start","drag","end"),u=0,h=0;function f(t){t.on("mousedown.drag",d).filter(a).on("touchstart.drag",g).on("touchmove.drag",y,tn).on("touchend.drag touchcancel.drag",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(o,a){if(!r&&i.call(this,o,a)){var l=b(this,s.call(this,o,a),o,a,"mouse");l&&($e(o.view).on("mousemove.drag",p,en).on("mouseup.drag",_,en),sn(o.view),nn(o),n=!1,t=o.clientX,e=o.clientY,l("start",o))}}function p(r){if(rn(r),!n){var i=r.clientX-t,s=r.clientY-e;n=i*i+s*s>h}l.mouse("drag",r)}function _(t){$e(t.view).on("mousemove.drag mouseup.drag",null),on(t.view,n),rn(t),l.mouse("end",t)}function g(t,e){if(i.call(this,t,e)){var n,r,o=t.changedTouches,a=s.call(this,t,e),l=o.length;for(n=0;n<l;++n)(r=b(this,a,t,e,o[n].identifier,o[n]))&&(nn(t),r("start",t,o[n]))}}function y(t){var e,n,r=t.changedTouches,i=r.length;for(e=0;e<i;++e)(n=l[r[e].identifier])&&(rn(t),n("drag",t,r[e]))}function m(t){var e,n,i=t.changedTouches,s=i.length;for(r&&clearTimeout(r),r=setTimeout(function(){r=null},500),e=0;e<s;++e)(n=l[i[e].identifier])&&(nn(t),n("end",t,i[e]))}function b(t,e,n,r,i,s){var a,h,d,p=c.copy(),_=Qe(s||n,e);if(null!=(d=o.call(t,new ln("beforestart",{sourceEvent:n,target:f,identifier:i,active:u,x:_[0],y:_[1],dx:0,dy:0,dispatch:p}),r)))return a=d.x-_[0]||0,h=d.y-_[1]||0,function n(s,o,c){var g,y=_;switch(s){case"start":l[i]=n,g=u++;break;case"end":delete l[i],--u;case"drag":_=Qe(c||o,e),g=u}p.call(s,t,new ln(s,{sourceEvent:o,subject:d,target:f,identifier:i,active:g,x:_[0]+a,y:_[1]+h,dx:_[0]-y[0],dy:_[1]-y[1],dispatch:p}),r)}}return f.filter=function(t){return arguments.length?(i="function"==typeof t?t:an(!!t),f):i},f.container=function(t){return arguments.length?(s="function"==typeof t?t:an(t),f):s},f.subject=function(t){return arguments.length?(o="function"==typeof t?t:an(t),f):o},f.touchable=function(t){return arguments.length?(a="function"==typeof t?t:an(!!t),f):a},f.on=function(){var t=c.on.apply(c,arguments);return t===c?f:t},f.clickDistance=function(t){return arguments.length?(h=(t=+t)*t,f):Math.sqrt(h)},f},dragDisable:sn,dragEnable:on,dsv:function(t,e,n,r){3===arguments.length&&"function"==typeof n&&(r=n,n=void 0);var i=Pa(t);return nl(e,n).then(function(t){return i.parse(t,r)})},dsvFormat:Pa,easeBack:Rs,easeBackIn:Cs,easeBackInOut:Rs,easeBackOut:ks,easeBounce:Ss,easeBounceIn:function(t){return 1-Ss(1-t)},easeBounceInOut:function(t){return((t*=2)<=1?1-Ss(1-t):Ss(t-1)+1)/2},easeBounceOut:Ss,easeCircle:ys,easeCircleIn:function(t){return 1-Math.sqrt(1-t*t)},easeCircleInOut:ys,easeCircleOut:function(t){return Math.sqrt(1- --t*t)},easeCubic:ls,easeCubicIn:function(t){return t*t*t},easeCubicInOut:ls,easeCubicOut:function(t){return--t*t*t+1},easeElastic:Ns,easeElasticIn:Os,easeElasticInOut:Is,easeElasticOut:Ns,easeExp:gs,easeExpIn:function(t){return _s(1-+t)},easeExpInOut:gs,easeExpOut:function(t){return 1-_s(t)},easeLinear:t=>+t,easePoly:hs,easePolyIn:cs,easePolyInOut:hs,easePolyOut:us,easeQuad:as,easeQuadIn:function(t){return t*t},easeQuadInOut:as,easeQuadOut:function(t){return t*(2-t)},easeSin:ps,easeSinIn:function(t){return 1===+t?1:1-Math.cos(t*ds)},easeSinInOut:ps,easeSinOut:function(t){return Math.sin(t*ds)},every:function(t,e){if("function"!=typeof e)throw new TypeError("test is not a function");let n=-1;for(const r of t)if(!e(r,++n,t))return!1;return!0},extent:x,fcumsum:function(t,e){const n=new w;let r=-1;return Float64Array.from(t,void 0===e?t=>n.add(+t||0):i=>n.add(+e(i,++r,t)||0))},filter:function(t,e){if("function"!=typeof e)throw new TypeError("test is not a function");const n=[];let r=-1;for(const i of t)e(i,++r,t)&&n.push(i);return n},flatGroup:function(t,...e){return N(O(t,...e),e)},flatRollup:function(t,e,...n){return N(P(t,e,...n),n)},forceCenter:hl,forceCollide:function(t){var e,n,r,i=1,s=1;function o(){for(var t,o,l,c,u,h,f,d=e.length,p=0;p<s;++p)for(o=gl(e,wl,El).visitAfter(a),t=0;t<d;++t)l=e[t],h=n[l.index],f=h*h,c=l.x+l.vx,u=l.y+l.vy,o.visit(_);function _(t,e,n,s,o){var a=t.data,d=t.r,p=h+d;if(!a)return e>c+p||s<c-p||n>u+p||o<u-p;if(a.index>l.index){var _=c-a.x-a.vx,g=u-a.y-a.vy,y=_*_+g*g;y<p*p&&(0===_&&(y+=(_=xl(r))*_),0===g&&(y+=(g=xl(r))*g),y=(p-(y=Math.sqrt(y)))/y*i,l.vx+=(_*=y)*(p=(d*=d)/(f+d)),l.vy+=(g*=y)*p,a.vx-=_*(p=1-p),a.vy-=g*p)}}}function a(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function l(){if(e){var r,i,s=e.length;for(n=new Array(s),r=0;r<s;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=vl(null==t?1:+t)),o.initialize=function(t,n){e=t,r=n,l()},o.iterations=function(t){return arguments.length?(s=+t,o):s},o.strength=function(t){return arguments.length?(i=+t,o):i},o.radius=function(e){return arguments.length?(t="function"==typeof e?e:vl(+e),l(),o):t},o},forceLink:Tl,forceManyBody:Nl,forceRadial:function(t,e,n){var r,i,s,o=vl(.1);function a(t){for(var o=0,a=r.length;o<a;++o){var l=r[o],c=l.x-e||1e-6,u=l.y-n||1e-6,h=Math.sqrt(c*c+u*u),f=(s[o]-h)*i[o]*t/h;l.vx+=c*f,l.vy+=u*f}}function l(){if(r){var e,n=r.length;for(i=new Array(n),s=new Array(n),e=0;e<n;++e)s[e]=+t(r[e],e,r),i[e]=isNaN(s[e])?0:+o(r[e],e,r)}}return"function"!=typeof t&&(t=vl(+t)),null==e&&(e=0),null==n&&(n=0),a.initialize=function(t){r=t,l()},a.strength=function(t){return arguments.length?(o="function"==typeof t?t:vl(+t),l(),a):o},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:vl(+e),l(),a):t},a.x=function(t){return arguments.length?(e=+t,a):e},a.y=function(t){return arguments.length?(n=+t,a):n},a},forceSimulation:Ol,forceX:Il,forceY:Pl,get format(){return Hl},formatDefaultLocale:Kl,formatLocale:Xl,get formatPrefix(){return Wl},formatSpecifier:zl,fsum:function(t,e){const n=new w;if(void 0===e)for(let e of t)(e=+e)&&n.add(e);else{let r=-1;for(let i of t)(i=+e(i,++r,t))&&n.add(i)}return+n},geoAlbers:id,geoAlbersUsa:function(){var t,e,n,r,i,s,o=id(),a=rd().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=rd().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(t,e){s=[t,e]}};function u(t){var e=t[0],o=t[1];return s=null,n.point(e,o),s||(r.point(e,o),s)||(i.point(e,o),s)}function h(){return t=e=null,u}return u.invert=function(t){var e=o.scale(),n=o.translate(),r=(t[0]-n[0])/e,i=(t[1]-n[1])/e;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?a:i>=.166&&i<.234&&r>=-.214&&r<-.115?l:o).invert(t)},u.stream=function(n){return t&&e===n?t:(r=[o.stream(e=n),a.stream(n),l.stream(n)],i=r.length,t={point:function(t,e){for(var n=-1;++n<i;)r[n].point(t,e)},sphere:function(){for(var t=-1;++t<i;)r[t].sphere()},lineStart:function(){for(var t=-1;++t<i;)r[t].lineStart()},lineEnd:function(){for(var t=-1;++t<i;)r[t].lineEnd()},polygonStart:function(){for(var t=-1;++t<i;)r[t].polygonStart()},polygonEnd:function(){for(var t=-1;++t<i;)r[t].polygonEnd()}});var r,i},u.precision=function(t){return arguments.length?(o.precision(t),a.precision(t),l.precision(t),h()):o.precision()},u.scale=function(t){return arguments.length?(o.scale(t),a.scale(.35*t),l.scale(t),u.translate(o.translate())):o.scale()},u.translate=function(t){if(!arguments.length)return o.translate();var e=o.scale(),s=+t[0],u=+t[1];return n=o.translate(t).clipExtent([[s-.455*e,u-.238*e],[s+.455*e,u+.238*e]]).stream(c),r=a.translate([s-.307*e,u+.201*e]).clipExtent([[s-.425*e+tc,u+.12*e+tc],[s-.214*e-tc,u+.234*e-tc]]).stream(c),i=l.translate([s-.205*e,u+.212*e]).clipExtent([[s-.214*e+tc,u+.166*e+tc],[s-.115*e-tc,u+.234*e-tc]]).stream(c),h()},u.fitExtent=function(t,e){return Hf(u,t,e)},u.fitSize=function(t,e){return Wf(u,t,e)},u.fitWidth=function(t,e){return qf(u,t,e)},u.fitHeight=function(t,e){return $f(u,t,e)},u.scale(1070)},geoArea:function(t){return $c=new w,Mc(t,Xc),2*$c},geoAzimuthalEqualArea:function(){return Qf(ad).scale(124.75).clipAngle(179.999)},geoAzimuthalEqualAreaRaw:ad,geoAzimuthalEquidistant:function(){return Qf(ld).scale(79.4188).clipAngle(179.999)},geoAzimuthalEquidistantRaw:ld,geoBounds:function(t){var e,n,r,i,s,o,a;if(zc=Bc=-(Dc=Vc=1/0),Hc=[],Mc(t,Eu),n=Hc.length){for(Hc.sort(Nu),e=1,s=[r=Hc[0]];e<n;++e)Iu(r,(i=Hc[e])[0])||Iu(r,i[1])?(Ou(r[0],i[1])>Ou(r[0],r[1])&&(r[1]=i[1]),Ou(i[0],r[1])>Ou(r[0],r[1])&&(r[0]=i[0])):s.push(r=i);for(o=-1/0,e=0,r=s[n=s.length-1];e<=n;r=i,++e)i=s[e],(a=Ou(r[1],i[0]))>o&&(o=a,Dc=i[0],Bc=r[1])}return Hc=Wc=null,Dc===1/0||Vc===1/0?[[NaN,NaN],[NaN,NaN]]:[[Dc,Vc],[Bc,zc]]},geoCentroid:function(t){au=lu=cu=uu=hu=fu=du=pu=0,_u=new w,gu=new w,yu=new w,Mc(t,Pu);var e=+_u,n=+gu,r=+yu,i=pc(e,n,r);return i<ec&&(e=fu,n=du,r=pu,lu<tc&&(e=cu,n=uu,r=hu),(i=pc(e,n,r))<ec)?[NaN,NaN]:[uc(n,e)*oc,wc(r/i)*oc]},geoCircle:function(){var t,e,n=Hu([0,0]),r=Hu(90),i=Hu(2),s={point:function(n,r){t.push(n=e(n,r)),n[0]*=oc,n[1]*=oc}};function o(){var o=n.apply(this,arguments),a=r.apply(this,arguments)*ac,l=i.apply(this,arguments)*ac;return t=[],e=$u(-o[0]*ac,-o[1]*ac,0).invert,Qu(s,a,l,1),o={type:"Polygon",coordinates:[t]},t=e=null,o}return o.center=function(t){return arguments.length?(n="function"==typeof t?t:Hu([+t[0],+t[1]]),o):n},o.radius=function(t){return arguments.length?(r="function"==typeof t?t:Hu(+t),o):r},o.precision=function(t){return arguments.length?(i="function"==typeof t?t:Hu(+t),o):i},o},geoClipAntimeridian:hh,geoClipCircle:fh,geoClipExtent:function(){var t,e,n,r=0,i=0,s=960,o=500;return n={stream:function(n){return t&&e===n?t:t=bh(r,i,s,o)(e=n)},extent:function(a){return arguments.length?(r=+a[0][0],i=+a[0][1],s=+a[1][0],o=+a[1][1],t=e=null,n):[[r,i],[s,o]]}}},geoClipRectangle:bh,geoConicConformal:function(){return ed(fd).scale(109.5).parallels([30,30])},geoConicConformalRaw:fd,geoConicEqualArea:rd,geoConicEqualAreaRaw:nd,geoConicEquidistant:function(){return ed(pd).scale(131.154).center([0,13.9389])},geoConicEquidistantRaw:pd,geoContains:function(t,e){return(t&&kh.hasOwnProperty(t.type)?kh[t.type]:Mh)(t,e)},geoDistance:Ch,geoEqualEarth:function(){return Qf(vd).scale(177.158)},geoEqualEarthRaw:vd,geoEquirectangular:function(){return Qf(dd).scale(152.63)},geoEquirectangularRaw:dd,geoGnomonic:function(){return Qf(xd).scale(144.049).clipAngle(60)},geoGnomonicRaw:xd,geoGraticule:Bh,geoGraticule10:function(){return Bh()()},geoIdentity:function(){var t,e,n,r,i,s,o,a=1,l=0,c=0,u=1,h=1,f=0,d=null,p=1,_=1,g=jf({point:function(t,e){var n=b([t,e]);this.stream.point(n[0],n[1])}}),y=Uh;function m(){return p=a*u,_=a*h,s=o=null,b}function b(n){var r=n[0]*p,i=n[1]*_;if(f){var s=i*t-r*e;r=r*t+i*e,i=s}return[r+l,i+c]}return b.invert=function(n){var r=n[0]-l,i=n[1]-c;if(f){var s=i*t+r*e;r=r*t-i*e,i=s}return[r/p,i/_]},b.stream=function(t){return s&&o===t?s:s=g(y(o=t))},b.postclip=function(t){return arguments.length?(y=t,d=n=r=i=null,m()):y},b.clipExtent=function(t){return arguments.length?(y=null==t?(d=n=r=i=null,Uh):bh(d=+t[0][0],n=+t[0][1],r=+t[1][0],i=+t[1][1]),m()):null==d?null:[[d,n],[r,i]]},b.scale=function(t){return arguments.length?(a=+t,m()):a},b.translate=function(t){return arguments.length?(l=+t[0],c=+t[1],m()):[l,c]},b.angle=function(n){return arguments.length?(e=yc(f=n%360*ac),t=hc(f),m()):f*oc},b.reflectX=function(t){return arguments.length?(u=t?-1:1,m()):u<0},b.reflectY=function(t){return arguments.length?(h=t?-1:1,m()):h<0},b.fitExtent=function(t,e){return Hf(b,t,e)},b.fitSize=function(t,e){return Wf(b,t,e)},b.fitWidth=function(t,e){return qf(b,t,e)},b.fitHeight=function(t,e){return $f(b,t,e)},b},geoInterpolate:function(t,e){var n=t[0]*ac,r=t[1]*ac,i=e[0]*ac,s=e[1]*ac,o=hc(r),a=yc(r),l=hc(s),c=yc(s),u=o*hc(n),h=o*yc(n),f=l*hc(i),d=l*yc(i),p=2*wc(bc(Ec(s-r)+o*l*Ec(i-n))),_=yc(p),g=p?function(t){var e=yc(t*=p)/_,n=yc(p-t)/_,r=n*u+e*f,i=n*h+e*d,s=n*a+e*c;return[uc(i,r)*oc,uc(s,bc(r*r+i*i))*oc]}:function(){return[n*oc,r*oc]};return g.distance=p,g},geoLength:Ah,geoMercator:function(){return ud(cd).scale(961/sc)},geoMercatorRaw:cd,geoNaturalEarth1:function(){return Qf(wd).scale(175.295)},geoNaturalEarth1Raw:wd,geoOrthographic:function(){return Qf(Ed).scale(249.5).clipAngle(90.000001)},geoOrthographicRaw:Ed,geoPath:function(t,e){let n,r,i=3,s=4.5;function o(t){return t&&("function"==typeof s&&r.pointRadius(+s.apply(this,arguments)),Mc(t,n(r))),r.result()}return o.area=function(t){return Mc(t,n(Wh)),Wh.result()},o.measure=function(t){return Mc(t,n(If)),If.result()},o.bounds=function(t){return Mc(t,n(ef)),ef.result()},o.centroid=function(t){return Mc(t,n(gf)),gf.result()},o.projection=function(e){return arguments.length?(n=null==e?(t=null,Uh):(t=e).stream,o):t},o.context=function(t){return arguments.length?(r=null==t?(e=null,new Gf(i)):new Tf(e=t),"function"!=typeof s&&r.pointRadius(s),o):e},o.pointRadius=function(t){return arguments.length?(s="function"==typeof t?t:(r.pointRadius(+t),+t),o):s},o.digits=function(t){if(!arguments.length)return i;if(null==t)i=null;else{const e=Math.floor(t);if(!(e>=0))throw new RangeError(`invalid digits: ${t}`);i=e}return null===e&&(r=new Gf(i)),o},o.projection(t).digits(i).context(e)},geoProjection:Qf,geoProjectionMutator:td,geoRotation:Ju,geoStereographic:function(){return Qf(Ad).scale(250).clipAngle(142)},geoStereographicRaw:Ad,geoStream:Mc,geoTransform:function(t){return{stream:jf(t)}},geoTransverseMercator:function(){var t=ud(Sd),e=t.center,n=t.rotate;return t.center=function(t){return arguments.length?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return arguments.length?n([t[0],t[1],t.length>2?t[2]+90:90]):[(t=n())[0],t[1],t[2]-90]},n([0,0,90]).scale(159.155)},geoTransverseMercatorRaw:Sd,gray:function(t,e){return new sr(t,0,0,null==e?1:e)},greatest:st,greatestIndex:function(e,n=t){if(1===n.length)return tt(e,n);let r,i=-1,s=-1;for(const t of e)++s,(i<0?0===n(t,t):n(t,r)>0)&&(r=t,i=s);return i},group:M,groupSort:function(e,n,r){return(2!==n.length?B(I(e,n,r),([e,n],[r,i])=>t(n,i)||t(e,r)):B(M(e,r),([e,r],[i,s])=>n(r,s)||t(e,i))).map(([t])=>t)},groups:O,hcl:hr,hierarchy:Od,histogram:J,hsl:Yn,html:cl,image:function(t,e){return new Promise(function(n,r){var i=new Image;for(var s in e)i[s]=e[s];i.onerror=r,i.onload=function(){n(i)},i.src=t})},index:function(t,...e){return D(t,R,L,e)},indexes:function(t,...e){return D(t,Array.from,L,e)},interpolate:Hr,interpolateArray:function(t,e){return(Vr(e)?Dr:Br)(t,e)},interpolateBasis:Sr,interpolateBasisClosed:Tr,interpolateBlues:zb,interpolateBrBG:Zm,interpolateBuGn:_b,interpolateBuPu:yb,interpolateCividis:function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-t*(35.34-t*(2381.73-t*(6402.7-t*(7024.72-2710.57*t)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+t*(170.73+t*(52.82-t*(131.46-t*(176.58-67.37*t)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+t*(442.36-t*(2482.43-t*(6167.24-t*(6614.94-2475.67*t)))))))+")"},interpolateCool:Jb,interpolateCubehelix:ci,interpolateCubehelixDefault:Kb,interpolateCubehelixLong:ui,interpolateDate:zr,interpolateDiscrete:function(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}},interpolateGnBu:bb,interpolateGreens:Fb,interpolateGreys:Ub,interpolateHcl:oi,interpolateHclLong:ai,interpolateHsl:ri,interpolateHslLong:ii,interpolateHue:function(t,e){var n=Rr(+t,+e);return function(t){var e=n(t);return e-360*Math.floor(e/360)}},interpolateInferno:av,interpolateLab:function(t,e){var n=Or((t=ir(t)).l,(e=ir(e)).l),r=Or(t.a,e.a),i=Or(t.b,e.b),s=Or(t.opacity,e.opacity);return function(e){return t.l=n(e),t.a=r(e),t.b=i(e),t.opacity=s(e),t+""}},interpolateMagma:ov,interpolateNumber:Gr,interpolateNumberArray:Dr,interpolateObject:Fr,interpolateOrRd:xb,interpolateOranges:Xb,interpolatePRGn:Qm,interpolatePiYG:eb,interpolatePlasma:lv,interpolatePuBu:Sb,interpolatePuBuGn:Eb,interpolatePuOr:rb,interpolatePuRd:Cb,interpolatePurples:Hb,interpolateRainbow:function(t){(t<0||t>1)&&(t-=Math.floor(t));var e=Math.abs(t-.5);return Qb.h=360*t-100,Qb.s=1.5-1.5*e,Qb.l=.8-.9*e,Qb+""},interpolateRdBu:sb,interpolateRdGy:ab,interpolateRdPu:Rb,interpolateRdYlBu:cb,interpolateRdYlGn:hb,interpolateReds:qb,interpolateRgb:Nr,interpolateRgbBasis:Pr,interpolateRgbBasisClosed:Lr,interpolateRound:Wr,interpolateSinebow:function(t){var e;return t=(.5-t)*Math.PI,tv.r=255*(e=Math.sin(t))*e,tv.g=255*(e=Math.sin(t+ev))*e,tv.b=255*(e=Math.sin(t+nv))*e,tv+""},interpolateSpectral:db,interpolateString:Yr,interpolateTransformCss:Jr,interpolateTransformSvg:Qr,interpolateTurbo:rv,interpolateViridis:sv,interpolateWarm:Zb,interpolateYlGn:Ib,interpolateYlGnBu:Ob,interpolateYlOrBr:Lb,interpolateYlOrRd:Vb,interpolateZoom:ei,interrupt:Vi,intersection:function(t,...e){t=new A(t),e=e.map(vt);t:for(const n of t)for(const r of e)if(!r.has(n)){t.delete(n);continue t}return t},interval:function(t,e,n){var r=new Ai,i=e;return null==e?(r.restart(t,e,n),r):(r._restart=r.restart,r.restart=function(t,e,n){e=+e,n=null==n?wi():+n,r._restart(function s(o){o+=i,r._restart(s,i+=e,n),t(o)},e,n)},r.restart(t,e,n),r)},isoFormat:Sm,isoParse:Tm,json:function(t,e){return fetch(t,e).then(ol)},lab:ir,lch:function(t,e,n,r){return 1===arguments.length?ur(t):new fr(n,e,t,null==r?1:r)},least:function(e,n=t){let r,i=!1;if(1===n.length){let s;for(const o of e){const e=n(o);(i?t(e,s)<0:0===t(e,e))&&(r=o,s=e,i=!0)}}else for(const t of e)(i?n(t,r)<0:0===n(t,t))&&(r=t,i=!0);return r},leastIndex:pt,line:Lv,lineRadial:Uv,link:Qv,linkHorizontal:tx,linkRadial:nx,linkVertical:ex,local:Ke,map:function(t,e){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof e)throw new TypeError("mapper is not a function");return Array.from(t,(n,r)=>e(n,r,t))},matcher:qt,max:Q,maxIndex:tt,mean:ct,median:ut,medianIndex:function(t,e){return lt(t,.5,e)},merge:ht,min:et,minIndex:nt,mode:function(t,e){const n=new E;if(void 0===e)for(let e of t)null!=e&&e>=e&&n.set(e,(n.get(e)||0)+1);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&i>=i&&n.set(i,(n.get(i)||0)+1)}let r,i=0;for(const[t,e]of n)e>i&&(i=e,r=t);return r},namespace:Bt,namespaces:Vt,nice:K,now:wi,pack:rp,packEnclose:function(t){return Ud(t,jd())},packSiblings:function(t){return ep(t,jd()),t},pairs:function(t,e=ft){const n=[];let r,i=!1;for(const s of t)i&&n.push(e(r,s)),r=s,i=!0;return n},partition:function(){var t=1,e=1,n=0,r=!1;function i(i){var s=i.height+1;return i.x0=i.y0=n,i.x1=t,i.y1=e/s,i.eachBefore(function(t,e){return function(r){r.children&&lp(r,r.x0,t*(r.depth+1)/e,r.x1,t*(r.depth+2)/e);var i=r.x0,s=r.y0,o=r.x1-n,a=r.y1-n;o<i&&(i=o=(i+o)/2),a<s&&(s=a=(s+a)/2),r.x0=i,r.y0=s,r.x1=o,r.y1=a}}(e,s)),r&&i.eachBefore(ap),i}return i.round=function(t){return arguments.length?(r=!!t,i):r},i.size=function(n){return arguments.length?(t=+n[0],e=+n[1],i):[t,e]},i.padding=function(t){return arguments.length?(n=+t,i):n},i},path:To,pathRound:function(t=3){return new So(+t)},permute:V,pie:function(){var t=Bv,e=Vv,n=null,r=cv(0),i=cv(vv),s=cv(0);function o(o){var a,l,c,u,h,f=(o=Mv(o)).length,d=0,p=new Array(f),_=new Array(f),g=+r.apply(this,arguments),y=Math.min(vv,Math.max(-vv,i.apply(this,arguments)-g)),m=Math.min(Math.abs(y)/f,s.apply(this,arguments)),b=m*(y<0?-1:1);for(a=0;a<f;++a)(h=_[p[a]=a]=+t(o[a],a,o))>0&&(d+=h);for(null!=e?p.sort(function(t,n){return e(_[t],_[n])}):null!=n&&p.sort(function(t,e){return n(o[t],o[e])}),a=0,c=d?(y-f*b)/d:0;a<f;++a,g=u)l=p[a],u=g+((h=_[l])>0?h*c:0)+b,_[l]={data:o[l],index:a,value:h,startAngle:g,endAngle:u,padAngle:m};return _}return o.value=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),o):t},o.sortValues=function(t){return arguments.length?(e=t,n=null,o):e},o.sort=function(t){return arguments.length?(n=t,e=null,o):n},o.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:cv(+t),o):r},o.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:cv(+t),o):i},o.padAngle=function(t){return arguments.length?(s="function"==typeof t?t:cv(+t),o):s},o},piecewise:hi,pointRadial:Hv,pointer:Qe,pointers:function(t,e){return t.target&&(t=Je(t),void 0===e&&(e=t.currentTarget),t=t.touches||[t]),Array.from(t,t=>Qe(t,e))},polygonArea:function(t){for(var e,n=-1,r=t.length,i=t[r-1],s=0;++n<r;)e=i,i=t[n],s+=e[1]*i[0]-e[0]*i[1];return s/2},polygonCentroid:function(t){for(var e,n,r=-1,i=t.length,s=0,o=0,a=t[i-1],l=0;++r<i;)e=a,a=t[r],l+=n=e[0]*a[1]-a[0]*e[1],s+=(e[0]+a[0])*n,o+=(e[1]+a[1])*n;return[s/(l*=3),o/l]},polygonContains:function(t,e){for(var n,r,i=t.length,s=t[i-1],o=e[0],a=e[1],l=s[0],c=s[1],u=!1,h=0;h<i;++h)n=(s=t[h])[0],(r=s[1])>a!=c>a&&o<(l-n)*(a-r)/(c-r)+n&&(u=!u),l=n,c=r;return u},polygonHull:function(t){if((n=t.length)<3)return null;var e,n,r=new Array(n),i=new Array(n);for(e=0;e<n;++e)r[e]=[+t[e][0],+t[e][1],e];for(r.sort(Mp),e=0;e<n;++e)i[e]=[r[e][0],-r[e][1]];var s=Op(r),o=Op(i),a=o[0]===s[0],l=o[o.length-1]===s[s.length-1],c=[];for(e=s.length-1;e>=0;--e)c.push(t[r[s[e]][2]]);for(e=+a;e<o.length-l;++e)c.push(t[r[o[e]][2]]);return c},polygonLength:function(t){for(var e,n,r=-1,i=t.length,s=t[i-1],o=s[0],a=s[1],l=0;++r<i;)e=o,n=a,e-=o=(s=t[r])[0],n-=a=s[1],l+=Math.hypot(e,n);return l},precisionFixed:Zl,precisionPrefix:Jl,precisionRound:Ql,quadtree:gl,quantile:ot,quantileIndex:lt,quantileSorted:at,quantize:function(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t(r/(e-1));return n},quickselect:rt,radialArea:Yv,radialLine:Uv,randomBates:Bp,randomBernoulli:Fp,randomBeta:Yp,randomBinomial:Hp,randomCauchy:qp,randomExponential:zp,randomGamma:Up,randomGeometric:jp,randomInt:Pp,randomIrwinHall:Vp,randomLcg:function(t=Math.random()){let e=0|(0<=t&&t<1?t/Kp:Math.abs(t));return()=>(e=1664525*e+1013904223|0,Kp*(e>>>0))},randomLogNormal:Dp,randomLogistic:$p,randomNormal:Lp,randomPareto:Gp,randomPoisson:Xp,randomUniform:Ip,randomWeibull:Wp,range:dt,rank:function(e,n=t){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");let r=Array.from(e);const i=new Float64Array(r.length);2!==n.length&&(r=r.map(n),n=t);const s=(t,e)=>n(r[t],r[e]);let o,a;return(e=Uint32Array.from(r,(t,e)=>e)).sort(n===t?(t,e)=>G(r[t],r[e]):z(s)),e.forEach((t,e)=>{const n=s(t,void 0===o?t:o);n>=0?((void 0===o||n>0)&&(o=t,a=e),i[t]=a):i[t]=NaN}),i},reduce:function(t,e,n){if("function"!=typeof e)throw new TypeError("reducer is not a function");const r=t[Symbol.iterator]();let i,s,o=-1;if(arguments.length<3){if(({done:i,value:n}=r.next()),i)return;++o}for(;({done:i,value:s}=r.next()),!i;)n=e(n,s,++o,t);return n},reverse:function(t){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(t).reverse()},rgb:Ln,ribbon:function(){return Do()},ribbonArrow:function(){return Do(Lo)},rollup:I,rollups:P,scaleBand:e_,scaleDiverging:function t(){var e=p_(Lm()(o_));return e.copy=function(){return Nm(e,t())},Jp.apply(e,arguments)},scaleDivergingLog:function t(){var e=E_(Lm()).domain([.1,1,10]);return e.copy=function(){return Nm(e,t()).base(e.base())},Jp.apply(e,arguments)},scaleDivergingPow:Dm,scaleDivergingSqrt:function(){return Dm.apply(null,arguments).exponent(.5)},scaleDivergingSymlog:function t(){var e=C_(Lm());return e.copy=function(){return Nm(e,t()).constant(e.constant())},Jp.apply(e,arguments)},scaleIdentity:function t(e){var n;function r(t){return null==t||isNaN(t=+t)?n:t}return r.invert=r,r.domain=r.range=function(t){return arguments.length?(e=Array.from(t,i_),r):e.slice()},r.unknown=function(t){return arguments.length?(n=t,r):n},r.copy=function(){return t(e).unknown(n)},e=arguments.length?Array.from(e,i_):[0,1],p_(r)},scaleImplicit:Qp,scaleLinear:__,scaleLog:A_,scaleOrdinal:t_,scalePoint:r_,scalePow:N_,scaleQuantile:function e(){var n,r=[],i=[],s=[];function a(){var t=0,e=Math.max(1,i.length);for(s=new Array(e-1);++t<e;)s[t-1]=at(r,t/e);return l}function l(t){return null==t||isNaN(t=+t)?n:i[o(s,t)]}return l.invertExtent=function(t){var e=i.indexOf(t);return e<0?[NaN,NaN]:[e>0?s[e-1]:r[0],e<s.length?s[e]:r[r.length-1]]},l.domain=function(e){if(!arguments.length)return r.slice();r=[];for(let t of e)null==t||isNaN(t=+t)||r.push(t);return r.sort(t),a()},l.range=function(t){return arguments.length?(i=Array.from(t),a()):i.slice()},l.unknown=function(t){return arguments.length?(n=t,l):n},l.quantiles=function(){return s.slice()},l.copy=function(){return e().domain(r).range(i).unknown(n)},Zp.apply(l,arguments)},scaleQuantize:function t(){var e,n=0,r=1,i=1,s=[.5],a=[0,1];function l(t){return null!=t&&t<=t?a[o(s,t,0,i)]:e}function c(){var t=-1;for(s=new Array(i);++t<i;)s[t]=((t+1)*r-(t-i)*n)/(i+1);return l}return l.domain=function(t){return arguments.length?([n,r]=t,n=+n,r=+r,c()):[n,r]},l.range=function(t){return arguments.length?(i=(a=Array.from(t)).length-1,c()):a.slice()},l.invertExtent=function(t){var e=a.indexOf(t);return e<0?[NaN,NaN]:e<1?[n,s[0]]:e>=i?[s[i-1],r]:[s[e-1],s[e]]},l.unknown=function(t){return arguments.length?(e=t,l):l},l.thresholds=function(){return s.slice()},l.copy=function(){return t().domain([n,r]).range(a).unknown(e)},Zp.apply(p_(l),arguments)},scaleRadial:function t(){var e,n=f_(),r=[0,1],i=!1;function s(t){var r=function(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}(n(t));return isNaN(r)?e:i?Math.round(r):r}return s.invert=function(t){return n.invert(I_(t))},s.domain=function(t){return arguments.length?(n.domain(t),s):n.domain()},s.range=function(t){return arguments.length?(n.range((r=Array.from(t,i_)).map(I_)),s):r.slice()},s.rangeRound=function(t){return s.range(t).round(!0)},s.round=function(t){return arguments.length?(i=!!t,s):i},s.clamp=function(t){return arguments.length?(n.clamp(t),s):n.clamp()},s.unknown=function(t){return arguments.length?(e=t,s):e},s.copy=function(){return t(n.domain(),r).round(i).clamp(n.clamp()).unknown(e)},Zp.apply(s,arguments),p_(s)},scaleSequential:Im,scaleSequentialLog:function t(){var e=E_(Om()).domain([1,10]);return e.copy=function(){return Nm(e,t()).base(e.base())},Jp.apply(e,arguments)},scaleSequentialPow:Pm,scaleSequentialQuantile:function e(){var n=[],r=o_;function i(t){if(null!=t&&!isNaN(t=+t))return r((o(n,t,1)-1)/(n.length-1))}return i.domain=function(e){if(!arguments.length)return n.slice();n=[];for(let t of e)null==t||isNaN(t=+t)||n.push(t);return n.sort(t),i},i.interpolator=function(t){return arguments.length?(r=t,i):r},i.range=function(){return n.map((t,e)=>r(e/(n.length-1)))},i.quantiles=function(t){return Array.from({length:t+1},(e,r)=>ot(n,r/t))},i.copy=function(){return e(r).domain(n)},Jp.apply(i,arguments)},scaleSequentialSqrt:function(){return Pm.apply(null,arguments).exponent(.5)},scaleSequentialSymlog:function t(){var e=C_(Om());return e.copy=function(){return Nm(e,t()).constant(e.constant())},Jp.apply(e,arguments)},scaleSqrt:function(){return N_.apply(null,arguments).exponent(.5)},scaleSymlog:function t(){var e=C_(h_());return e.copy=function(){return u_(e,t()).constant(e.constant())},Zp.apply(e,arguments)},scaleThreshold:function t(){var e,n=[.5],r=[0,1],i=1;function s(t){return null!=t&&t<=t?r[o(n,t,0,i)]:e}return s.domain=function(t){return arguments.length?(n=Array.from(t),i=Math.min(n.length,r.length-1),s):n.slice()},s.range=function(t){return arguments.length?(r=Array.from(t),i=Math.min(n.length,r.length-1),s):r.slice()},s.invertExtent=function(t){var e=r.indexOf(t);return[n[e-1],n[e]]},s.unknown=function(t){return arguments.length?(e=t,s):e},s.copy=function(){return t().domain(n).range(r).unknown(e)},Zp.apply(s,arguments)},scaleTime:Mm,scaleUtc:function(){return Zp.apply(Rm(qg,$g,Yg,Gg,Ag,ig,tg,K_,W_,iy).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},scan:function(t,e){const n=pt(t,e);return n<0?void 0:n},schemeAccent:zm,schemeBlues:Bb,schemeBrBG:Km,schemeBuGn:pb,schemeBuPu:gb,schemeCategory10:Bm,schemeDark2:Gm,schemeGnBu:mb,schemeGreens:Gb,schemeGreys:jb,schemeObservable10:Fm,schemeOrRd:vb,schemeOranges:$b,schemePRGn:Jm,schemePaired:jm,schemePastel1:Um,schemePastel2:Ym,schemePiYG:tb,schemePuBu:Ab,schemePuBuGn:wb,schemePuOr:nb,schemePuRd:Tb,schemePurples:Yb,schemeRdBu:ib,schemeRdGy:ob,schemeRdPu:kb,schemeRdYlBu:lb,schemeRdYlGn:ub,schemeReds:Wb,schemeSet1:Hm,schemeSet2:Wm,schemeSet3:qm,schemeSpectral:fb,schemeTableau10:$m,schemeYlGn:Nb,schemeYlGnBu:Mb,schemeYlOrBr:Pb,schemeYlOrRd:Db,select:$e,selectAll:function(t){return"string"==typeof t?new We([document.querySelectorAll(t)],[document.documentElement]):new We([Yt(t)],He)},selection:qe,selector:Ut,selectorAll:Wt,shuffle:_t,shuffler:gt,some:function(t,e){if("function"!=typeof e)throw new TypeError("test is not a function");let n=-1;for(const r of t)if(e(r,++n,t))return!0;return!1},sort:B,stack:function(){var t=cv([]),e=fw,n=hw,r=dw;function i(i){var s,o,a=Array.from(t.apply(this,arguments),pw),l=a.length,c=-1;for(const t of i)for(s=0,++c;s<l;++s)(a[s][c]=[0,+r(t,a[s].key,c,i)]).data=t;for(s=0,o=Mv(e(a));s<l;++s)a[o[s]].index=s;return n(a,o),a}return i.keys=function(e){return arguments.length?(t="function"==typeof e?e:cv(Array.from(e)),i):t},i.value=function(t){return arguments.length?(r="function"==typeof t?t:cv(+t),i):r},i.order=function(t){return arguments.length?(e=null==t?fw:"function"==typeof t?t:cv(Array.from(t)),i):e},i.offset=function(t){return arguments.length?(n=null==t?hw:t,i):n},i},stackOffsetDiverging:function(t,e){if((a=t.length)>0)for(var n,r,i,s,o,a,l=0,c=t[e[0]].length;l<c;++l)for(s=o=0,n=0;n<a;++n)(i=(r=t[e[n]][l])[1]-r[0])>0?(r[0]=s,r[1]=s+=i):i<0?(r[1]=o,r[0]=o+=i):(r[0]=0,r[1]=i)},stackOffsetExpand:function(t,e){if((r=t.length)>0){for(var n,r,i,s=0,o=t[0].length;s<o;++s){for(i=n=0;n<r;++n)i+=t[n][s][1]||0;if(i)for(n=0;n<r;++n)t[n][s][1]/=i}hw(t,e)}},stackOffsetNone:hw,stackOffsetSilhouette:function(t,e){if((n=t.length)>0){for(var n,r=0,i=t[e[0]],s=i.length;r<s;++r){for(var o=0,a=0;o<n;++o)a+=t[o][r][1]||0;i[r][1]+=i[r][0]=-a/2}hw(t,e)}},stackOffsetWiggle:function(t,e){if((i=t.length)>0&&(r=(n=t[e[0]]).length)>0){for(var n,r,i,s=0,o=1;o<r;++o){for(var a=0,l=0,c=0;a<i;++a){for(var u=t[e[a]],h=u[o][1]||0,f=(h-(u[o-1][1]||0))/2,d=0;d<a;++d){var p=t[e[d]];f+=(p[o][1]||0)-(p[o-1][1]||0)}l+=h,c+=f*h}n[o-1][1]+=n[o-1][0]=s,l&&(s-=c/l)}n[o-1][1]+=n[o-1][0]=s,hw(t,e)}},stackOrderAppearance:_w,stackOrderAscending:yw,stackOrderDescending:function(t){return yw(t).reverse()},stackOrderInsideOut:function(t){var e,n,r=t.length,i=t.map(mw),s=_w(t),o=0,a=0,l=[],c=[];for(e=0;e<r;++e)n=s[e],o<a?(o+=i[n],l.push(n)):(a+=i[n],c.push(n));return c.reverse().concat(l)},stackOrderNone:fw,stackOrderReverse:function(t){return fw(t).reverse()},stratify:function(){var t,e=fp,n=dp;function r(r){var i,s,o,a,l,c,u,h,f=Array.from(r),d=e,p=n,_=new Map;if(null!=t){const e=f.map((e,n)=>function(t){t=`${t}`;let e=t.length;_p(t,e-1)&&!_p(t,e-2)&&(t=t.slice(0,-1));return"/"===t[0]?t:`/${t}`}(t(e,n,r))),n=e.map(pp),i=new Set(e).add("");for(const t of n)i.has(t)||(i.add(t),e.push(t),n.push(pp(t)),f.push(hp));d=(t,n)=>e[n],p=(t,e)=>n[e]}for(o=0,i=f.length;o<i;++o)s=f[o],c=f[o]=new Dd(s),null!=(u=d(s,o,r))&&(u+="")&&(h=c.id=u,_.set(h,_.has(h)?up:c)),null!=(u=p(s,o,r))&&(u+="")&&(c.parent=u);for(o=0;o<i;++o)if(u=(c=f[o]).parent){if(!(l=_.get(u)))throw new Error("missing: "+u);if(l===up)throw new Error("ambiguous: "+u);l.children?l.children.push(c):l.children=[c],c.parent=l}else{if(a)throw new Error("multiple roots");a=c}if(!a)throw new Error("no root");if(null!=t){for(;a.data===hp&&1===a.children.length;)a=a.children[0],--i;for(let t=f.length-1;t>=0&&(c=f[t]).data===hp;--t)c.data=null}if(a.parent=cp,a.eachBefore(function(t){t.depth=t.parent.depth+1,--i}).eachBefore(Ld),a.parent=null,i>0)throw new Error("cycle");return a}return r.id=function(t){return arguments.length?(e=Vd(t),r):e},r.parentId=function(t){return arguments.length?(n=Vd(t),r):n},r.path=function(e){return arguments.length?(t=Vd(e),r):t},r},style:ge,subset:function(t,e){return xt(e,t)},sum:yt,superset:xt,svg:ul,symbol:function(t,e){let n=null,r=wv(i);function i(){let i;if(n||(n=i=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),i)return n=null,i+""||null}return t="function"==typeof t?t:cv(t||sx),e="function"==typeof e?e:cv(void 0===e?64:+e),i.type=function(e){return arguments.length?(t="function"==typeof e?e:cv(e),i):t},i.size=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),i):e},i.context=function(t){return arguments.length?(n=null==t?null:t,i):n},i},symbolAsterisk:ix,symbolCircle:sx,symbolCross:ox,symbolDiamond:cx,symbolDiamond2:ux,symbolPlus:hx,symbolSquare:fx,symbolSquare2:dx,symbolStar:yx,symbolTimes:Cx,symbolTriangle:bx,symbolTriangle2:xx,symbolWye:Tx,symbolX:Cx,symbols:kx,symbolsFill:kx,symbolsStroke:Rx,text:nl,thresholdFreedmanDiaconis:function(t,e,n){const r=_(t),i=ot(t,.75)-ot(t,.25);return r&&i?Math.ceil((n-e)/(2*i*Math.pow(r,-1/3))):1},thresholdScott:function(t,e,n){const r=_(t),i=v(t);return r&&i?Math.ceil((n-e)*Math.cbrt(r)/(3.49*i)):1},thresholdSturges:Z,tickFormat:d_,tickIncrement:$,tickStep:X,ticks:q,timeDay:ng,timeDays:rg,get timeFormat(){return ny},timeFormatDefaultLocale:Em,timeFormatLocale:ty,timeFriday:pg,timeFridays:xg,timeHour:J_,timeHours:Q_,timeInterval:D_,timeMillisecond:V_,timeMilliseconds:B_,timeMinute:$_,timeMinutes:X_,timeMonday:ug,timeMondays:yg,timeMonth:Bg,timeMonths:zg,get timeParse(){return ry},timeSaturday:_g,timeSaturdays:wg,timeSecond:W_,timeSeconds:q_,timeSunday:cg,timeSundays:gg,timeThursday:dg,timeThursdays:vg,timeTickInterval:Kg,timeTicks:Xg,timeTuesday:hg,timeTuesdays:mg,timeWednesday:fg,timeWednesdays:bg,timeWeek:cg,timeWeeks:gg,timeYear:jg,timeYears:Ug,timeout:Mi,timer:Si,timerFlush:Ti,transition:is,transpose:mt,tree:wp,treemap:Cp,treemapBinary:function(t,e,n,r,i){var s,o,a=t.children,l=a.length,c=new Array(l+1);for(c[0]=o=s=0;s<l;++s)c[s+1]=o+=a[s].value;!function t(e,n,r,i,s,o,l){if(e>=n-1){var u=a[e];return u.x0=i,u.y0=s,u.x1=o,void(u.y1=l)}var h=c[e],f=r/2+h,d=e+1,p=n-1;for(;d<p;){var _=d+p>>>1;c[_]<f?d=_+1:p=_}f-c[d-1]<c[d]-f&&e+1<d&&--d;var g=c[d]-h,y=r-g;if(o-i>l-s){var m=r?(i*y+o*g)/r:o;t(e,d,g,i,s,m,l),t(d,n,y,m,s,o,l)}else{var b=r?(s*y+l*g)/r:l;t(e,d,g,i,s,o,b),t(d,n,y,i,b,o,l)}}(0,l,t.value,e,n,r,i)},treemapDice:lp,treemapResquarify:kp,treemapSlice:Ep,treemapSliceDice:function(t,e,n,r,i){(1&t.depth?Ep:lp)(t,e,n,r,i)},treemapSquarify:Tp,tsv:sl,tsvFormat:Wa,tsvFormatBody:qa,tsvFormatRow:Xa,tsvFormatRows:$a,tsvFormatValue:Ka,tsvParse:Ya,tsvParseRows:Ha,union:function(...t){const e=new A;for(const n of t)for(const t of n)e.add(t);return e},unixDay:og,unixDays:ag,utcDay:ig,utcDays:sg,get utcFormat(){return iy},utcFriday:Rg,utcFridays:Dg,utcHour:tg,utcHours:eg,utcMillisecond:V_,utcMilliseconds:B_,utcMinute:K_,utcMinutes:Z_,utcMonday:Sg,utcMondays:Ng,utcMonth:Gg,utcMonths:Fg,get utcParse(){return sy},utcSaturday:Mg,utcSaturdays:Vg,utcSecond:W_,utcSeconds:q_,utcSunday:Ag,utcSundays:Og,utcThursday:kg,utcThursdays:Lg,utcTickInterval:$g,utcTicks:qg,utcTuesday:Tg,utcTuesdays:Ig,utcWednesday:Cg,utcWednesdays:Pg,utcWeek:Ag,utcWeeks:Og,utcYear:Yg,utcYears:Hg,variance:b,window:fe,xml:ll,zip:function(){return mt(arguments)},zoom:function(){var t,e,n,r=Tw,i=Cw,s=Ow,o=Rw,a=Mw,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,h=ei,f=Nt("start","zoom","end"),d=0,p=10;function _(t){t.property("__zoom",kw).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",E).on("dblclick.zoom",A).filter(a).on("touchstart.zoom",S).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",C).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(t,e){return(e=Math.max(l[0],Math.min(l[1],e)))===t.k?t:new xw(e,t.x,t.y)}function y(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new xw(t.k,r,i)}function m(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function b(t,e,n,r){t.on("start.zoom",function(){v(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){v(this,arguments).event(r).end()}).tween("zoom",function(){var t=this,s=arguments,o=v(t,s).event(r),a=i.apply(t,s),l=null==n?m(a):"function"==typeof n?n.apply(t,s):n,c=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),u=t.__zoom,f="function"==typeof e?e.apply(t,s):e,d=h(u.invert(l).concat(c/u.k),f.invert(l).concat(c/f.k));return function(t){if(1===t)t=f;else{var e=d(t),n=c/e[2];t=new xw(n,l[0]-e[0]*n,l[1]-e[1]*n)}o.zoom(null,t)}})}function v(t,e,n){return!n&&t.__zooming||new x(t,e)}function x(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function w(t,...e){if(r.apply(this,arguments)){var n=v(this,e).event(t),i=this.__zoom,a=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,o.apply(this,arguments)))),u=Qe(t);if(n.wheel)n.mouse[0][0]===u[0]&&n.mouse[0][1]===u[1]||(n.mouse[1]=i.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else{if(i.k===a)return;n.mouse=[u,i.invert(u)],Vi(this),n.start()}Sw(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",s(y(g(i,a),n.mouse[0],n.mouse[1]),n.extent,c))}}function E(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,o=v(this,e,!0).event(t),a=$e(t.view).on("mousemove.zoom",function(t){if(Sw(t),!o.moved){var e=t.clientX-u,n=t.clientY-h;o.moved=e*e+n*n>d}o.event(t).zoom("mouse",s(y(o.that.__zoom,o.mouse[0]=Qe(t,i),o.mouse[1]),o.extent,c))},!0).on("mouseup.zoom",function(t){a.on("mousemove.zoom mouseup.zoom",null),on(t.view,o.moved),Sw(t),o.event(t).end()},!0),l=Qe(t,i),u=t.clientX,h=t.clientY;sn(t.view),Aw(t),o.mouse=[l,this.__zoom.invert(l)],Vi(this),o.start()}}function A(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,o=Qe(t.changedTouches?t.changedTouches[0]:t,this),a=n.invert(o),l=n.k*(t.shiftKey?.5:2),h=s(y(g(n,l),o,a),i.apply(this,e),c);Sw(t),u>0?$e(this).transition().duration(u).call(b,h,o,t):$e(this).call(_.transform,h,o,t)}}function S(n,...i){if(r.apply(this,arguments)){var s,o,a,l,c=n.touches,u=c.length,h=v(this,i,n.changedTouches.length===u).event(n);for(Aw(n),o=0;o<u;++o)l=[l=Qe(a=c[o],this),this.__zoom.invert(l),a.identifier],h.touch0?h.touch1||h.touch0[2]===l[2]||(h.touch1=l,h.taps=0):(h.touch0=l,s=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),s&&(h.taps<2&&(e=l[0],t=setTimeout(function(){t=null},500)),Vi(this),h.start())}}function T(t,...e){if(this.__zooming){var n,r,i,o,a=v(this,e).event(t),l=t.changedTouches,u=l.length;for(Sw(t),n=0;n<u;++n)i=Qe(r=l[n],this),a.touch0&&a.touch0[2]===r.identifier?a.touch0[0]=i:a.touch1&&a.touch1[2]===r.identifier&&(a.touch1[0]=i);if(r=a.that.__zoom,a.touch1){var h=a.touch0[0],f=a.touch0[1],d=a.touch1[0],p=a.touch1[1],_=(_=d[0]-h[0])*_+(_=d[1]-h[1])*_,m=(m=p[0]-f[0])*m+(m=p[1]-f[1])*m;r=g(r,Math.sqrt(_/m)),i=[(h[0]+d[0])/2,(h[1]+d[1])/2],o=[(f[0]+p[0])/2,(f[1]+p[1])/2]}else{if(!a.touch0)return;i=a.touch0[0],o=a.touch0[1]}a.zoom("touch",s(y(r,i,o),a.extent,c))}}function C(t,...r){if(this.__zooming){var i,s,o=v(this,r).event(t),a=t.changedTouches,l=a.length;for(Aw(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<l;++i)s=a[i],o.touch0&&o.touch0[2]===s.identifier?delete o.touch0:o.touch1&&o.touch1[2]===s.identifier&&delete o.touch1;if(o.touch1&&!o.touch0&&(o.touch0=o.touch1,delete o.touch1),o.touch0)o.touch0[1]=this.__zoom.invert(o.touch0[0]);else if(o.end(),2===o.taps&&(s=Qe(s,this),Math.hypot(e[0]-s[0],e[1]-s[1])<p)){var c=$e(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return _.transform=function(t,e,n,r){var i=t.selection?t.selection():t;i.property("__zoom",kw),t!==i?b(t,e,n,r):i.interrupt().each(function(){v(this,arguments).event(r).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},_.scaleBy=function(t,e,n,r){_.scaleTo(t,function(){return this.__zoom.k*("function"==typeof e?e.apply(this,arguments):e)},n,r)},_.scaleTo=function(t,e,n,r){_.transform(t,function(){var t=i.apply(this,arguments),r=this.__zoom,o=null==n?m(t):"function"==typeof n?n.apply(this,arguments):n,a=r.invert(o),l="function"==typeof e?e.apply(this,arguments):e;return s(y(g(r,l),o,a),t,c)},n,r)},_.translateBy=function(t,e,n,r){_.transform(t,function(){return s(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),c)},null,r)},_.translateTo=function(t,e,n,r,o){_.transform(t,function(){var t=i.apply(this,arguments),o=this.__zoom,a=null==r?m(t):"function"==typeof r?r.apply(this,arguments):r;return s(ww.translate(a[0],a[1]).scale(o.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,c)},r,o)},x.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1===++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0===--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var e=$e(this.that).datum();f.call(t,this.that,new vw(t,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:f}),e)}},_.wheelDelta=function(t){return arguments.length?(o="function"==typeof t?t:bw(+t),_):o},_.filter=function(t){return arguments.length?(r="function"==typeof t?t:bw(!!t),_):r},_.touchable=function(t){return arguments.length?(a="function"==typeof t?t:bw(!!t),_):a},_.extent=function(t){return arguments.length?(i="function"==typeof t?t:bw([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),_):i},_.scaleExtent=function(t){return arguments.length?(l[0]=+t[0],l[1]=+t[1],_):[l[0],l[1]]},_.translateExtent=function(t){return arguments.length?(c[0][0]=+t[0][0],c[1][0]=+t[1][0],c[0][1]=+t[0][1],c[1][1]=+t[1][1],_):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},_.constrain=function(t){return arguments.length?(s=t,_):s},_.duration=function(t){return arguments.length?(u=+t,_):u},_.interpolate=function(t){return arguments.length?(h=t,_):h},_.on=function(){var t=f.on.apply(f,arguments);return t===f?_:t},_.clickDistance=function(t){return arguments.length?(d=(t=+t)*t,_):Math.sqrt(d)},_.tapDistance=function(t){return arguments.length?(p=+t,_):p},_},zoomIdentity:ww,zoomTransform:Ew});const Iw=Object.freeze({Rect:"rect",Circle:"circle",Line:"line",Ring:"ring",Path:"path",Image:"image",Symbol:"symbol",SimpleText:"text",RichText:"richText",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord",Arrow:"arrow"}),Pw=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord",Line:"line",Path:"path",Image:"image",Symbol:"symbol",SimpleText:"text",RichText:"richText",Collection:"collection",Group:"group",Composite:"composite",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",Trajectory:"trajectory",LinearGradient:"LinearGradient",PathGradient:"PathGradient",Link:"link",DataTable:"datatable",Layout:"layout",NetworkData:"networkdata",TreeData:"treedata",Arrow:"arrow"}),Lw=Object.freeze({Axis:"axis",Legend:"legend",Gridlines:"gridlines",Trajectory:"trajectory"});function Dw(){return Date.now().toString(36)+"_"+Math.random().toString(36).slice(2)}const Vw=Object.freeze({Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"});function Bw(t){var e=Object.values(Vw);for(let n=0;n<t.length;n++){let r=t[n];if(null!=r){for(let t=0;t<e.length;t++)zw[e[t]](r)||(e.splice(t,1),t-=1);if(1==e.length)return e[0]}}return e[0]}const zw={boolean:function(t){return"true"===t||"false"===t||!0===t||!1===t||"[object Boolean]"==toString.call(t)},integer:function(t){return zw.number(t)&&(t=+t)===~~t},number:function(t){return!isNaN(+t)&&"[object Date]"!=toString.call(t)},date:function(t){let e=new Date(t);return null!=e&&!isNaN(e)},string:function(t){return!0}};function Gw(t,e){let n={};switch(e){case Vw.Boolean:n.trueCount=t.filter(t=>t).length,n.falseCount=t.filter(t=>!t).length;break;case Vw.Date:n.min=et(t),n.max=Q(t),n.extent=[n.min,n.max],n.unique=[...new Set(t)];break;case Vw.String:n.unique=[...new Set(t)];break;default:n.min=et(t),n.max=Q(t),n.extent=[n.min,n.max],n.mean=ct(t),n.median=ut(t),n.unique=[...new Set(t)]}return n}const Fw="max",jw="min",Uw="avg",Yw="mean",Hw="median",Ww="count",qw="percentile 25",$w="percentile 75";function Xw(t,e={},n){return{dataTable:t,filters:Object.assign({},e),rowIds:n?n.slice():void 0}}function Kw(t){if(t)return Xw(t.dataTable,t.filters,t.rowIds)}function Zw(t){return Kw(t)}function Jw(t){if(t)return t.dataTable}function Qw(t){return t&&t.filters||{}}function tE(t){return t?t.rowIds&&t.dataTable?t.dataTable.rows({[_E]:t.rowIds}):t.dataTable?t.dataTable.rows(t.filters):[]:[]}function eE(t){let e=tE(t);return e.length>0?e[0]:{}}function nE(t){return tE(t).length}function rE(t,e){return e in Qw(t)}function iE(t,e){let n=Qw(t);if(e in n)return n[e];let r=tE(t);return r.length>0?r[0][e]:void 0}function sE(t,e){let n=Qw(t);return e in n?[n[e]]:Array.from(new Set(tE(t).map(t=>t[e])))}function oE(t,e,n){let r=tE(t).map(t=>t[e]);switch(n){case Fw:return Q(r);case jw:return et(r);case Uw:case Yw:return ct(r);case Hw:return ut(r);case Ww:return r.length;case qw:return ot(r,.25);case $w:return ot(r,.75);default:return yt(r)}}function aE(t,e,n){let r=Jw(t),i=Object.assign({},Qw(t),{[e]:n});return Xw(r,i,hE(r,i))}function lE(t,e){if(!t)return Zw(e);if(!e)return Zw(t);let n=Jw(t),r=Object.assign({},Qw(t));for(let[t,n]of Object.entries(Qw(e)))t in r&&r[t]!==n?console.warn("Conflict in attribute values when merging dataScope:",t,r[t],n):r[t]=n;return Xw(n,r,hE(n,r))}function cE(t){return Xw(t,{},t.data.map(t=>t[_E]))}function uE(t,e,n=!1){let r=Jw(t),i=Qw(t),s=Object.entries(i).filter(([t])=>t!==e),o=r._attrValueIndexes.get(e),a=[];for(let t of r.unique(e)){let l=o&&o.get(t)?o.get(t):[];s.length>0&&(l=l.filter(t=>s.every(([e,n])=>t[e]==n))),(n||0!==l.length)&&a.push(Xw(r,Object.assign({},i,{[e]:t}),l.map(t=>t[_E])))}return a}function hE(t,e){return t.rows(e).map(t=>t[_E])}class fE{constructor(t,e,n){this._id=Pw.DataTable+Dw(),this.initialize(t,e,n)}initialize(t,e,n){if(this.url=e,this._rawData=JSON.parse(JSON.stringify(t)),this._data=t,this._dataScopeCache=new Map,this._scopeTupleCache=new Map,this._attrValueIndexes=new Map,this._rowIdIndex=new Map,this._dateMap=new Map,this._attributes=0===this._data.length?[]:Object.keys(this._data[0]),this._newAttribute=0,n)this._attrTypes=n;else{this._attrTypes={};for(let t of this._attributes)this._attrTypes[t]=Bw(this.data.map(e=>e[t])),"year"==t.toLowerCase()&&this._attrTypes[t]==Vw.Integer&&(this._attrTypes[t]=Vw.Date)}this._validate(this.data,this._attrTypes),this._attrSummaries={};for(let t of this._attributes)this._attrSummaries[t]=Gw(this.data.map(e=>e[t]),this._attrTypes[t]);this._attributes.indexOf(_E)<0&&this.addAttr(_E,Vw.String,this.data.map((t,e)=>"r"+e)),this._buildAttributeValueIndexes()}clone(){let t=[];for(let e of this._data)t.push(Object.assign({},e));let e=new fE(t,this.url,Object.assign({},this._attrTypes));return e.sourceDataTable=this,e}get id(){return this._id}get name(){return this.url?function(t){var e=t.indexOf("\\")>=0?t.lastIndexOf("\\"):t.lastIndexOf("/"),n=t.substring(e);0!==n.indexOf("\\")&&0!==n.indexOf("/")||(n=n.substring(1));return n}(this.url):this.id}get data(){return this._data}encodable(t){switch(t){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":case"text":return this.measures.concat(this.dimensions);default:return this.measures}}addAttr(t,e,n){this._data.forEach((e,r)=>e[t]=n[r]),t!==_E&&this._rawData.forEach((e,r)=>e[t]=n[r]),this._attrTypes[t]=e,this._attributes.includes(t)||this._attributes.push(t),this._attrSummaries[t]=Gw(n,e),this._clearDataCaches()}type(t){return this._attrTypes[t]}summary(t){return this._attrSummaries[t]}values(t){return this.data.map(e=>e[t])}unique(t){return this._attrSummaries[t].unique}order(t,e){this._attrSummaries[t].unique=e}load(t){this._data=t,this._clearDataCaches(),this.summarize()}rows(t={}){let e=this._getFilterKey(t);if(this._scopeTupleCache.has(e))return this._scopeTupleCache.get(e);let n=Object.entries(t);if(0===n.length)return this._scopeTupleCache.set(e,this.data),this.data;if(1===n.length&&n[0][0]===_E&&Array.isArray(n[0][1])){let t=n[0][1].map(t=>this._rowIdIndex.get(t)).filter(t=>t);return this._scopeTupleCache.set(e,t),t}let r=this.data;for(let[t,e]of n){if(Array.isArray(e)||dE(e))continue;let n=this._getRowsByAttributeValue(t,e);n&&n.length<r.length&&(r=n)}let i=r.filter(t=>n.every(([e,n])=>{if(dE(n)){let r=t[e];return(!("min"in n)||r>=n.min)&&(!("max"in n)||r<=n.max)}return Array.isArray(n)?n.includes(t[e]):t[e]==n}));return this._scopeTupleCache.set(e,i),i}_getRowsByAttributeValue(t,e){let n=this._attrValueIndexes.get(t);return n?n.get(e):void 0}_buildAttributeValueIndexes(){this._attrValueIndexes=new Map,this._rowIdIndex=new Map;for(let t of this._attributes){let e=new Map;for(let n of this.data){let r=n[t];e.has(r)||e.set(r,[]),e.get(r).push(n)}this._attrValueIndexes.set(t,e)}for(let t of this.data)this._rowIdIndex.set(t[_E],t)}_getFilterKey(t={}){return Object.entries(t).sort(([t],[e])=>t.localeCompare(e)).map(([t,e])=>dE(e)?t+":["+(e.min??"-inf")+","+(e.max??"+inf")+"]":t+":"+JSON.stringify(e)).join("|")}_clearDataCaches(){this._dataScopeCache&&this._dataScopeCache.clear(),this._scopeTupleCache&&this._scopeTupleCache.clear(),this._attrValueIndexes&&(this._attrValueIndexes.clear(),this._buildAttributeValueIndexes())}count(){return this.data.length}has(t){return this._attributes.indexOf(t)>=0}parseDate(t,e){let n=ry(e);for(let e of this.data){let r=e[t];null==r||null==r?(r="",e[t]=new Date(1899,11,31).getTime()):e[t]=n(r).getTime(),this._dateMap.set(e[t],r)}this._attrTypes[t]=Vw.Date,this._attrSummaries[t]=Gw(this.data.map(e=>e[t]),Vw.Date),this._clearDataCaches()}raw(t,e){return this.type(t)===Vw.Date?this._dateMap.get(e).toString():e}get dimensions(){let t=[];for(let e in this._attrTypes)this._attrTypes[e]!=Vw.Number&&this._attrTypes[e]!=Vw.Integer&&e!=fE.RowID&&t.push(e);return t.sort((t,e)=>this.unique(t).length-this.unique(e).length),t}get measures(){let t=[];for(let e in this._attrTypes)this._attrTypes[e]!==Vw.Number&&this._attrTypes[e]!==Vw.Integer||e==fE.RowID||t.push(e);return t}attrs(t){if(void 0===t)return this._attributes;let e=[];for(let n in this._attrTypes)this._attrTypes[n]===t&&n!=fE.RowID&&e.push(n);return e}summarize(){for(let t of this._attributes)this._attrSummaries[t]=Gw(this.data.map(e=>e[t]),this._attrTypes[t])}_validate(t,e){for(let n of t)for(let t in e){let r,i=e[t],s=n[t];if(null==n[t]||null==n[t])switch(i){case Vw.Boolean:r=!1;break;case Vw.Date:r=new Date(1899,11,31).getTime();break;case Vw.String:r="";break;default:r=0}else switch(i){case Vw.Boolean:r=s;break;case Vw.Date:r=Number.isInteger(s)&&s<=9999?new Date(s,0).getTime():Number.isInteger(s)?s:new Date(s+"").getTime(),this._dateMap.set(r,s);break;case Vw.String:r=s.toString();break;default:r=s}n[t]=r}}}function dE(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&("min"in t||"max"in t)}function pE(t){return t.dataScope?Jw(t.dataScope):t.parent&&t.parent.dataScope?Jw(t.parent.dataScope):void 0}const _E="mascot_rowId";class gE{constructor(t,e){this._id=Pw.TreeData+Dw(),this.initialize(t,e)}initialize(t,e){this.url=e,this._data=t,this._nodeList=[],this._linkList=[],this._nodeHash={},this._traverse(t,this._nodeList,this._linkList),this._nodeTable=new fE(this._nodeList,"nodes"),this._linkTable=new fE(this._linkList,"links"),this._nodeTable.tree=this,this._linkTable.tree=this}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}_traverse(t,e,n,r=0){let i={};xE in t||(t[xE]="n"+e.length),e.push(i),t._depth=r;for(let s in t)if("children"==s&&t[s]&&t[s].length>0)for(let i of t[s]){let s=this._traverse(i,e,n,r+1);n.push({parent:t[xE],child:s})}else i[s]=t[s];return this._nodeHash[i[xE]]=i,i[xE]}getNodeDataScopeRef(t){return aE(cE(this._nodeTable),_E,t[_E])}getNode(t){return this._nodeHash[t]}getRoot(){return this._nodeTable.data[0]}getChildren(t){let e=t[xE],n=[],r=this._linkTable.data,i=this._nodeTable.data;for(let t in r)if(r[t].parent==e){let e=r[t].child,s=i.findIndex(t=>t[xE]==e);n.push(i[s])}return n}getParent(t){let e=t[xE],n=this._linkTable.data,r=this._nodeTable.data;for(let t in n)if(n[t].child==e){let e=n[t].parent,i=r.findIndex(t=>t[xE]==e);return r[i]}}}function yE(t){return Jw(t.dataScope).tree}class mE{constructor(t,e){this._id=Pw.NetworkData+Dw(),this.initialize(t,e)}initialize(t,e){this.url=e,this._nodeTable=new fE(t.nodes,this._id+"_nodes"),this._linkTable=new fE(t.links,this._id+"_links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._rawNodes=t.nodes,this._rawLinks=t.links,this._nodeHash={};for(let e of t.nodes)this._nodeHash[e[xE]]=e}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodeList(){return this._rawNodes}get linkList(){return this._rawLinks}getNode(t){return this._nodeHash[t]}getLinks(t){let e=t[xE],n=this._rawLinks,r=[];for(let t in n)n[t].target!==e&&n[t].source!==e||r.push(n[t]);return r}buildNodeHierarchy(t){let e={};return e[xE]="root",vE(e,this._rawNodes,t),new gE(e,this.url)}}function bE(t){return Jw(t.dataScope).graph}function vE(t,e,n){if(0===e.length||0===n.length)return;"children"in t||(t.children=[]);let r={};for(let t of e){let e=t[n[0]];e in r||(r[e]=[]),r[e].push(t)}if(1===n.length)for(let e in r){let n={children:r[e]};n[xE]=e,t.children.push(n)}else for(let e in r){let i={};i[xE]=e,t.children.push(i),vE(i,r[e],n.slice(1))}}const xE="id";function wE(t,e){return fetch(e,{method:t}).then(t=>t.ok?t.text():(console.log(t.status),Promise.reject({status:t.status,statusText:t.statusText}))).catch(t=>(console.log(t),Promise.reject({status:t.status,statusText:t.statusText})))}class EE{constructor(t,e,n){this._id="predicate_"+Dw(),this._type=t||AE.POINT,this._variableType=e,this._variableName=n,this._value=void 0}get type(){return this._type}get value(){return this._value}set value(t){this._value=t}get id(){return this._id}get variableType(){return this._variableType}get variableName(){return this._variableName}}const AE=Object.freeze({POINT:"point",INTERVAL:"interval",LIST:"list"});class SE extends EE{constructor(t,e,n){super(t,e,n)}testElement(t){let e;if("attribute"==this._variableType){if(!t.dataScope)return!1;e=t.datum[this._variableName]}else e=t[this._variableName];return this._value[0]<=e&&this._value[1]>=e}testTuple(t){if("attribute"==this._variableType){let e=t[this._variableName];return this._value[0]<=e&&this._value[1]>=e}return!1}}class TE extends EE{constructor(t,e,n){super(t,e,n)}addValue(t){this._value||(this._value=[]),this._value.push(t)}resetValue(){this._value=void 0}testElement(t){if("attribute"==this._variableType){if(!t.dataScope)return!1;let e=Array.from(new Set(t.data.map(t=>t[this._variableName])));return 1===e.length&&this._value.indexOf(e[0])>=0}return this._value.indexOf(t[this._variableName])>=0}testTuple(t){if("attribute"==this._variableType){let e=t[this._variableName];return this._value.indexOf(e)>=0}return!1}}class CE extends EE{constructor(t,e,n){super(t,e,n)}testElement(t){if("attribute"==this._variableType){if(!t.dataScope)return!1;return t.datum[this._variableName]==this._value}return t[this._variableName]==this._value}testTuple(t){if("attribute"==this._variableType){let e=t[this._variableName];return this._value===e}return!1}equals(t){return this.type===t.type&&this.variableName===t.variableName&&this.value===t.value}}function kE(t){let e,n="attribute"in t?"attribute":"property",r=t[n];switch(t.type){case AE.LIST:e=new TE(t.type,n,r);break;case AE.INTERVAL:e=new SE(t.type,n,r);break;case AE.POINT:default:e=new CE(t.type,n,r)}return e.value=t.value,e}function RE(t,e){for(let n of e)if(!n.testElement(t))return!1;return!0}const ME={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.visibility="hidden",this.svg.style.pointerEvents="none",this.svg.setAttribute("aria-hidden","true"),document.body.appendChild(this.svg)),this.svg):null}};function OE(t,e,n,r,i){const s=i*Math.PI/180,o=t-n,a=e-r;return{x:o*Math.cos(s)-a*Math.sin(s)+n,y:o*Math.sin(s)+a*Math.cos(s)+r}}function NE(t,e,n,r){return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-r,2))}const IE=Object.freeze({fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",strokeDash:"stroke-dasharray",opacity:"opacity",fontSize:"font-size",fontFamily:"font-family",fontWeight:"font-weight",visibility:"visibility",cursor:"cursor"});class PE{constructor(t,e,n,r){this._x=t+n/2,this._y=e+r/2,this._width=n,this._height=r}translate(t,e){this._x+=t,this._y+=e}toJSON(){let t={};return t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t}union(t){let e=d3.min([this.left,t.left]),n=d3.min([this.top,t.top]),r=d3.max([this.right,t.right]),i=d3.max([this.bottom,t.bottom]);return new PE(e,n,r-e,i-n)}clone(){return new PE(this.left,this.top,this._width,this._height)}get left(){return this._x-this._width/2}set left(t){this._x=t+this._width/2}get right(){return this._x+this._width/2}set right(t){this._x=t-this._width/2}get top(){return this._y-this._height/2}set top(t){this._y=t+this._height/2}get bottom(){return this._y+this._height/2}set bottom(t){this._y=t-this._height/2}get x(){return this._x}get y(){return this._y}get center(){return this.x}get middle(){return this.y}get width(){return this._width}setWidth(t,e){switch(e){case zE.RIGHT:this._x=this.right-t/2;break;case zE.CENTER:this._width=2*t;break;default:this._x=this.left+t/2}this._width=t}get height(){return this._height}setHeight(t,e){switch(e){case zE.TOP:this._y=this.top+t/2;break;case zE.MIDDLE:this._height=2*t;break;default:this._y=this.bottom-t/2}this._height=t}contains(t,e){return this.left<=t&&this.right>=t&&this.top<=e&&this.bottom>=e}intersects(t){return!(this.right<t.left||this.bottom<t.top||this.left>t.right||this.top>t.bottom)}}function LE(t){let e=t[0].clone();for(let n=1;n<t.length;n++)e=e.union(t[n]);return e}function DE(t){return LE(("vertex"==t[0].type||"segment"==t[0].type?t.map(t=>t.parent):t).map(t=>t.refBounds?t.refBounds:t.bounds))}function VE(t){return LE(("vertex"==t[0].type||"segment"==t[0].type?t.map(t=>t.parent):t).map(t=>t.bounds))}function BE(t){let e=JE(t);for(let t of e)t._updateBounds();let n=[];for(let t of e)t.parent&&!n.includes(t.parent)&&n.push(t.parent);for(let t of n)BE(t)}const zE=Object.freeze({TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",CENTER:"center",MIDDLE:"middle"});class GE{constructor(t){if(this._dataScopeRef=void 0,this._type="type"in t?t.type:Pw.Mark,this._id=t.id?t.id:this._type+"_"+Dw(),this._classId=void 0,this._bounds=void 0,this._rotate=void 0,this._refBounds=void 0,this._dirty=!0,this._clipMask=void 0,this._cursor=void 0,this._styles={},void 0!==t)for(let e in IE)e in t&&(this.styles[e]=t[e])}get scene(){return aA(this)}get datum(){return eE(this._dataScopeRef)}get data(){return tE(this._dataScopeRef)}set strokeColor(t){this.styles.strokeColor!==t&&(this.styles.strokeColor=t,this._dirty=!0)}get strokeColor(){return this.styles.strokeColor}set strokeWidth(t){this.styles.strokeWidth!==t&&(this.styles.strokeWidth=t,this._dirty=!0)}get strokeWidth(){return this.styles.strokeWidth}get strokeDash(){return this.styles.strokeDash}set strokeDash(t){this.styles.strokeDash!==t&&(this.styles.strokeDash=t,this._dirty=!0)}set fillColor(t){this.styles.fillColor!==t&&(this.styles.fillColor=t,this._dirty=!0)}get fillColor(){return this.styles.fillColor}get rotation(){return this._rotate}get cursor(){return this._cursor}get id(){return this._id}set id(t){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}get classId(){return this._classId?this._classId:this._id}set classId(t){this._classId=t}get type(){return this._type}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){return this._refBounds?this._refBounds:this.bounds}set dataScope(t){this._dataScopeRef=Kw(t)}get dataScope(){return this._dataScopeRef}get styles(){return this._styles}set styles(t){this._styles!==t&&(this._styles=t,this._dirty=!0)}set visibility(t){this.styles.visibility!==t&&(this.styles.visibility=t,this._dirty=!0)}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(t){this.styles.opacity!==t&&(this.styles.opacity=t,this._dirty=!0)}get z(){return"z"in this.styles?this.styles.z:0}set z(t){this.styles.z!==t&&(this.styles.z=t,this._dirty=!0)}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t._dataScopeRef=Zw(this._dataScopeRef))}createClipMask(){let t=this._bounds;this._clipMask=new PE(t.left,t.top,t.width,t.height)}get clipMask(){return this._clipMask}}function FE(t){return t instanceof GE&&t.type!==Pw.Gridlines}const jE=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",Symbol:"symbol",SimpleText:"text",RichText:"richText",Polygon:"polygon",BezierCurve:"bezierCurve"});class UE{constructor(){this._refElements=[]}addRefElement(t){this._refElements.push(t)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}}function YE(t){return t instanceof UE}const HE=Object.freeze({GRID:"grid",STACK:"stack",PACKING:"packing",FORCE:"force",DIRECTED:"directedgraph",TIDYTREE:"tidytree",TREEMAP:"treemap",STRATA:"strata",CIRCULAR:"circular",CLUSTER:"cluster",SPIRAL:"spiral"});function WE(t,e){return!!(t.startsWith("h")&&[zE.LEFT,zE.CENTER,zE.RIGHT].indexOf(e)>=0)||(!!(t.startsWith("v")&&[zE.TOP,zE.MIDDLE,zE.BOTTOM].indexOf(e)>=0)||(console.warn("Invalid alignment:",e),!1))}class qE{constructor(t){this._id=t+"_"+Dw(),this._type=t,this._inputVars=[],this._outputVars=[]}run(){}get id(){return this._id}get type(){return this._type}get inputVars(){return this._inputVars}get outputVars(){return this._outputVars}get outputVar(){return this._outputVars[0]}isIsolated(){return 0==this._inputVars.length&&0==this._outputVars.length}}const $E=Object.freeze({CONDUIT:"conduit",ENCODER:"encoder",LAYOUT:"layout",LINK_PLACER:"linkRouter",CONSTRAINT:"constraint",EVAL_BBOX:"evalBBox",EVAL_REFBOUNDS:"evalRefBounds",AFFIXER:"affixer",ALIGNER:"aligner",DATA_EXTRACTOR:"dataExtractor",SCALE_BUILDER:"scaleBuilder",AXIS_PATH_PLACER:"axisPathPlacer",AXIS_TICKS_PLACER:"axisTicksPlacer",AXIS_LABELS_PLACER:"axisLabelsPlacer",AXIS_TITLE_PLACER:"axisTitlePlacer",GRIDLINES_PLACER:"gridlinesPlacer",SPIRAL_TRAJECTORY_PLACER:"spiralTrajectoryPlacer",GRID_LAYOUT:"gridLayout",STACK_LAYOUT:"stackLayout",PACK_LAYOUT:"packLayout",FORCE_LAYOUT:"forceLayout",DIRECTED_LAYOUT:"directedLayout",TIDY_TREE_LAYOUT:"tidyTreeLayout",TREEMAP_LAYOUT:"treemapLayout",STRATA_LAYOUT:"strataLayout",CIRCULAR_LAYOUT:"circularLayout",CLUSTER_LAYOUT:"clusterLayout",SPIRAL_LAYOUT:"spiralLayout",BIN_TRANSFORMER:"binTransformer",FILTER_TRANSFORMER:"filterTransformer",KDE_TRANSFORMER:"kdeTransformer",CUSTOM_TRANSFORMER:"customTransformer",REPOPULATE:"repopulate",TARGET_EVALUATOR:"targetEvaluator",TARGET_UPDATER:"targetUpdater"});class XE{constructor(t){this._id="v_"+Dw(),this._type=t,this._incomings=[],this._outgoings=[],this._undirected=[]}get id(){return this._id}get incomingEdges(){return this._incomings}get outgoingEdges(){return this._outgoings}get undirectedEdges(){return this._undirected}get type(){return this._type}get incomingDataflow(){for(let t of this._incomings)if(t.fromNode&&t.fromNode instanceof qE)return t.fromNode;return null}isIsolated(){return 0==this._incomings.length&&0==this._outgoings.length}}const KE=Object.freeze({CHANNEL:"channel",PROPERTY:"property",STATE:"state",ATTRIBUTE:"attribute",ITEMS:"items",DATASCOPE:"datascope",ATTR_VALUE:"dataValue",BOUNDS:"bounds",SCALE:"scale",CONDITION_RESULT:"conditionResult",AFFIXATION:"affixation",ALIGNMENT:"alignment",EVT_CTX:"evtContext"});class ZE extends Map{constructor(t){super(),this._scene=t}get scene(){return this._scene}var(t){if("string"!=typeof t||0===t.length)throw new Error("state.var(...) expects a non-empty variable name");return{type:"stateVar",key:t,stateContext:this}}set(t,e){const n=this.get(t);return super.set(t,e),n!==e&&(this._scene.depGraph.getVariable(KE.STATE,t,this),this._scene.onChange(KE.STATE,t,this)),this}}function JE(t,e){let n=aA(t);return"vertex"===t.type||"segment"===t.type?function(t,e){let n=aA(t),r=e||n;if("vertex"===t.type){return QE(t,rA(r,[{property:"classId",value:t.parent.classId}],!0))}if("segment"===t.type){return nA(t,rA(r,[{property:"classId",value:t.parent.classId}],!0))}return t.classId?rA(r,[{property:"classId",value:t.classId}]):[t]}(t,e):t.classId?rA(e||n,[{property:"classId",value:t.classId}]):[t]}function QE(t,e){if(!t.classId){if(t.dataScope){let n=t.parent;if(!n)throw new Error("vertex has no parent mark");let r=[];if(n.type!==Pw.Area||t._isAnyVertex)for(let t of e)r=r.concat(t.vertices.filter(t=>t.dataScope));else{let i=n.vertices.indexOf(t)<n.vertices.length/2;for(let t of e){let e=i?t.vertices.slice(0,t.vertices.length/2):t.vertices.slice(t.vertices.length/2);r=r.concat(e.filter(t=>t.dataScope))}}return r}{let n=t.parent;if(!n)throw new Error("vertex has no parent mark");let r=n.vertices.indexOf(t),i=[];for(let t of e)i.push(t.vertices[r]);return i}}}function tA(t,e){return t.id+"_v_"+t._vertices._ids[e]}function eA(t,e){let n=t.parent,r=t._index,i=[];if(t.dataScope)if(n.type!==Pw.Area||t._isAnyVertex)for(let t of e){let e=[];for(let n=0;n<t._vertices.length;n++)t._vertices.hasDataScope(n)&&e.push(n);i.push({parent:t,indices:e})}else{let t=r<n._vertices.length/2;for(let n of e){let e=t?0:n._vertices.length/2,r=t?n._vertices.length/2:n._vertices.length,s=[];for(let t=e;t<r;t++)n._vertices.hasDataScope(t)&&s.push(t);i.push({parent:n,indices:s})}}else for(let t of e)i.push({parent:t,indices:[r]});return i}function nA(t,e){if(t._dataScopeRef){if(!t.parent)throw new Error("segment has no parent mark");let n=[];for(let t of e)n=n.concat(t.segments);return n}{let n=t.parent;if(!n)throw new Error("segment has no parent mark");let r=n.segments.indexOf(t),i=[];for(let t of e)i.push(t.segments[r]);return i}}function rA(t,e,n){let r=[];return oA(t,e?e.map(t=>kE(t)):[],r,n),r}function iA(t,e){let n=t.children.filter(t=>t.type==Pw.Collection);if(0!==n.length)for(let t of n){let n=t;for(;n&&n.dataScope;){if(rE(n.dataScope,e))return n;n=n.children?n.children[0]:void 0}}}function sA(t){return t.type==Pw.Collection?t:t.parent?sA(t.parent):void 0}function oA(t,e,n,r){if(t)if(RE(t,e)&&n.push(t),t.vertices&&r)for(let r of t.vertices.concat(t.segments))RE(r,e)&&n.push(r);else if(t.children&&t.children.length>0)for(let i of t.children)oA(i,e,n,r)}function aA(t){let e;if(e=Array.isArray(t)?t[0]:t,e){if(e instanceof ZE)return e.scene;if(e._scene)return e._scene;for(YE(e)&&e.group&&(e=e.group),e.id.startsWith("encoding_")&&(e=e.element);e;){if(e.type==Pw.Scene)return e;e=e.parent}}}function lA(t){let e=t;for("vertex"!=e.type&&"segment"!=e.type||(e=e.parent);e.parent&&[Pw.Collection,Pw.Glyph].includes(e.parent.type);)e=e.parent;return e}function cA(t,e){let n=[];if(uA(t,n),e){let t={};for(let e of n)t[e.classId]=e;return Object.values(t)}return n}function uA(t,e){if(FE(t))e.push(t);else if(t.children&&!Object.values(Lw).includes(t.type))for(let n of t.children)uA(n,e)}class hA extends XE{constructor(t,e,n){super(t),this._channel=e,this._elem=n}get channel(){return this._channel}get element(){return this._elem}}const fA=Object.freeze({X:"x",Y:"y",WIDTH:"width",HEIGHT:"height",RADIUS:"radius",FILLCOLOR:"fillColor",STROKECOLOR:"strokeColor",FILLGRADIENT:"fillGradient",STROKEGRADIENT:"strokeGradient",TEXT:"text",ANGLE:"angle",THICKNESS:"thickness",AREA:"area",FONTSIZE:"fontSize",POLARRADIUS:"polarRadius",POLARANGLE:"polarAngle",STROKEWIDTH:"strokeWidth",OPACITY:"opacity",VISIBILITY:"visibility",STRENGTH:"strength",SRC:"src",PATH:"path",Z:"z"});class dA extends XE{constructor(t,e,n){super(t),this._property=e,this._elem=n}get property(){return this._property}get element(){return this._elem}}function pA(t){return t in _A?_A[t]:t}const _A=Object.freeze({numCols:"layoutParameter",numRows:"layoutParameter",startCorner:"layoutParameter",direction:"layoutParameter"}),gA=Object.freeze({AXIS_ORIENTATION:"axisOrientation",AXIS_PATH_POSITION:"axisPathPosition",AXIS_TICK_SIZE:"axisTickSize",AXIS_TICK_OFFSET:"axisTickOffset",AXIS_TICKS_POSITION:"axisTicksPosition",AXIS_LABELS_POSITION:"axisLabelsPosition",AXIS_TITLE_POSITION:"axisTitlePosition",AXIS_LABEL_OFFSET:"axisLabelOffset",AXIS_LABEL_FORMAT:"axisLabelFormat",AXIS_FONT_SIZE:"axisFontSize",LEGEND_POSITION:"legendPosition",GRIDLINES_POSITION:"gridlinesPosition",TRAJECTORY_POSITION:"trajectoryPosition",INCLUDE_ZERO:"includeZero",FLIP_SCALE:"flipScale",RANGE_START:"rangeStart",RANGE_EXTENT:"rangeExtent",BASE_LINE:"baseline",LAYOUT_PARAMETER:"layoutParameter",NUM_BINS:"numBins",CHILDREN_ORDER:"childrenOrder",ATTRIBUTE:"attribute"});function yA(t){let e=t?aA(t):void 0;e&&e._clearInteractionCaches&&e._clearInteractionCaches()}function mA(t,e){if(yA(t),e.findVariable(KE.BOUNDS,[t]))return;let n=e.getVariable(KE.BOUNDS,t),r=e.createOneWayDependency($E.EVAL_BBOX);switch(e.connect(r,n),t.type){case Pw.Circle:case Pw.Polygon:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"radius",t),o=e.getVariable(KE.CHANNEL,"area",t);e.connect(s,r),e.connect(n,r),e.connect(i,r),e.connect(o,r);break}case Pw.Area:case Pw.Line:case Pw.BezierCurve:case Pw.Path:case Pw.Image:case Pw.Symbol:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"width",t),o=e.getVariable(KE.CHANNEL,"height",t);e.connect(n,r),e.connect(i,r),e.connect(s,r),e.connect(o,r);break}case Pw.Rect:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"width",t),o=e.getVariable(KE.CHANNEL,"height",t),a=e.getVariable(KE.CHANNEL,"area",t);e.connect(n,r),e.connect(i,r),e.connect(s,r),e.connect(o,r),e.connect(a,r);break}case Pw.SimpleText:case Pw.RichText:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"text",t);e.connect(n,r),e.connect(i,r),e.connect(s,r);break}case Pw.Ring:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"innerRadius",t),o=e.getVariable(KE.CHANNEL,"outerRadius",t);e.connect(n,r),e.connect(i,r),e.connect(s,r),e.connect(o,r);break}case Pw.Pie:case Pw.Arc:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"innerRadius",t),o=e.getVariable(KE.CHANNEL,"outerRadius",t),a=e.getVariable(KE.CHANNEL,"startAngle",t),l=e.getVariable(KE.CHANNEL,"endAngle",t),c=e.getVariable(KE.CHANNEL,"angle",t),u=e.getVariable(KE.CHANNEL,"thickness",t);e.connect(n,r),e.connect(i,r),e.connect(s,r),e.connect(o,r),e.connect(a,r),e.connect(l,r),e.connect(c,r),e.connect(u,r);break}}r.run()}function bA(t,e){if(t.type===Pw.Axis){let n=e.findVariable(KE.PROPERTY,[gA.AXIS_PATH_POSITION,t]).incomingDataflow;console.log(n,t),e.deleteOperator(n),n=e.findVariable(KE.PROPERTY,[gA.AXIS_TICKS_POSITION,t]).incomingDataflow,e.deleteOperator(n),n=e.findVariable(KE.PROPERTY,[gA.AXIS_LABELS_POSITION,t]).incomingDataflow,e.deleteOperator(n),n=e.findVariable(KE.PROPERTY,[gA.AXIS_TITLE_POSITION,t]).incomingDataflow,e.deleteOperator(n)}else if(t.type===Pw.Gridlines){let n=e.findVariable(KE.PROPERTY,[gA.GRIDLINES_POSITION,t]).incomingDataflow;e.deleteOperator(n)}}function vA(t,e){if(yA(t),e.findVariable(KE.BOUNDS,[t]))return;let n=e.getVariable(KE.BOUNDS,t),r=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"width",t),o=e.getVariable(KE.CHANNEL,"height",t),a=e.createOneWayDependency($E.EVAL_BBOX);e.connect(r,a),e.connect(i,a),e.connect(s,a),e.connect(o,a),e.connect(a,n),a.run()}function xA(t,e){yA(t);let n=e.getVariable(KE.BOUNDS,t),r=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"width",t),o=e.getVariable(KE.CHANNEL,"height",t),a=e.createOneWayDependency($E.EVAL_BBOX);e.connect(r,a),e.connect(i,a),e.connect(s,a),e.connect(o,a),e.connect(a,n),a.run()}function wA(t,e,n){yA(t);let r=n.getVariable(KE.BOUNDS,t),i=n.getVariable(KE.BOUNDS,e),s=n.getIncomingDataflowOperator($E.EVAL_BBOX,r),o=i.outgoingEdges.find(t=>t.fromNode===i&&t.toNode===s);if(o&&n.disconnect(i,s,o),t.layout){let r=n.getVariable(KE.CHANNEL,"x",e),i=n.getIncomingDataflowOperator(SA(t.layout.type),r);i&&n.deleteOperator(i)}}function EA(t,e,n){yA(t);let r=n.getVariable(KE.BOUNDS,t),i=n.getVariable(KE.BOUNDS,e),s=n.getIncomingDataflowOperator($E.EVAL_BBOX,r);n.connect(i,s),n.connect(s,r),t.layout&&CA(t,t.layout,n)}function AA(t,e){yA(t);let n=e.getVariable(KE.BOUNDS,t),r=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getIncomingDataflowOperator($E.EVAL_BBOX,n);e.connect(r,s),e.connect(i,s);for(let n of t.children)e.connect(e.getVariable(KE.BOUNDS,n),s);e.connect(s,n),s.run()}function SA(t){switch(t){case HE.GRID:return $E.GRID_LAYOUT;case HE.STACK:return $E.STACK_LAYOUT;case HE.PACKING:return $E.PACK_LAYOUT;case HE.FORCE:return $E.FORCE_LAYOUT;case HE.DIRECTED:return $E.DIRECTED_LAYOUT;case HE.TIDYTREE:return $E.TIDY_TREE_LAYOUT;case HE.TREEMAP:return $E.TREEMAP_LAYOUT;case HE.STRATA:return $E.STRATA_LAYOUT;case HE.CIRCULAR:return $E.CIRCULAR_LAYOUT;case HE.CLUSTER:return $E.CLUSTER_LAYOUT;case HE.SPIRAL:return $E.SPIRAL_LAYOUT}}function TA(t,e,n){let r=n.getVariable(KE.PROPERTY,gA.CHILDREN_ORDER,t),i=n.getOutgoingDataflowOperator(SA(e.type),r);n.deleteOperator(i)}function CA(t,e,n){let r=e?e.type:"none",i=r===HE.TREEMAP?cA(t)[0]:t.children[0];if(!i)return;let s=n.getVariable(KE.CHANNEL,"width",i),o=n.getVariable(KE.CHANNEL,"height",i),a=n.getVariable(KE.PROPERTY,gA.CHILDREN_ORDER,t),l=n.getVariable(KE.CHANNEL,"x",i),c=n.getVariable(KE.CHANNEL,"y",i),u=n.getVariable(KE.CHANNEL,"visibility",i),h=n.getVariable(KE.PROPERTY,gA.LAYOUT_PARAMETER,e),f=n.getOutgoingDataflowOperator(SA(r),a);if(n.connect(s,f),n.connect(o,f),n.connect(a,f),n.connect(h,f),n.connect(u,f),n.connect(f,l),n.connect(f,c),n.disconnectChannelVarFromBBoxOperator(s),n.disconnectChannelVarFromBBoxOperator(o),i.type===Pw.Arc||i.type===Pw.Pie){let t=n.getVariable(KE.CHANNEL,"angle",i),e=n.getVariable(KE.CHANNEL,"thickness",i);n.connect(t,f),n.connect(e,f)}else if(i.type===Pw.Circle){let t=n.getVariable(KE.CHANNEL,"area",i),e=n.getVariable(KE.CHANNEL,"radius",i);n.connect(t,f),n.connect(e,f),n.disconnectChannelVarFromBBoxOperator(t),n.disconnectChannelVarFromBBoxOperator(e)}else if(i.type===Pw.Rect){let t=n.getVariable(KE.CHANNEL,"area",i);n.connect(t,f),n.disconnectChannelVarFromBBoxOperator(t)}if(f.run(),i.links&&kA(i,n),i.children&&i.children[0]){let t=n.getVariable(KE.BOUNDS,i.children[0]),e=n.getVariable(KE.CHANNEL,"x",i).incomingDataflow;e&&n.connect(t,e),n.disconnectChannelVarFromBBoxOperator(t)}}function kA(t,e){let n=t.links[0],r=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"x",n),s=e.getVariable(KE.CHANNEL,"strokeWidth",n),o=e.getVariable(KE.CHANNEL,"strength",n),a=e.createOneWayDependency($E.LINK_PLACER);e.connect(r,a),e.connect(s,a),e.connect(o,a),e.connect(a,i)}function RA(t,e,n){if(!t||"segment"!==t.type)return;let r=pE(t),i=r?n.findVariable(KE.ITEMS,[r]):null;if(i)for(let t of i.outgoingEdges)if(t.isDirected&&t.toNode.type===$E.REPOPULATE)return void n.connect(t.toNode,e)}function MA(t,e,n){let r=t.attribute,i=t.channel,s=t.element,o=e.createOneWayDependency($E.ENCODER);if(["width","height"].includes(t.channel)&&s.type===Pw.Area){let t=e.getVariable(KE.PROPERTY,gA.BASE_LINE,s);e.connect(t,o)}if(n){let r=e.getVariable(KE.ATTR_VALUE,n),a=e.getVariable(KE.SCALE,n),l=e.getVariable(KE.CHANNEL,i,s);e.connect(a,o),e.connect(o,l),r.addLinkedEncoding(t),a.addLinkedEncoding(t);let c=e.getVariable(KE.DATASCOPE,t.element),u=r.incomingDataflow;u&&c&&(e.connect(c,u),RA(t.element,c,e)),r.incomingDataflow.run()}else{let n=e.getVariable(KE.ATTRIBUTE,r,pE(s),t),a=e.getVariable(KE.PROPERTY,gA.INCLUDE_ZERO,t),l=e.getVariable(KE.ATTR_VALUE,t),c=e.getVariable(KE.DATASCOPE,s),u=e.createOneWayDependency($E.DATA_EXTRACTOR);e.connect(n,u),e.connect(a,u),e.connect(c,u),e.connect(u,l),RA(s,c,e),u.run();let h=e.getVariable(KE.PROPERTY,gA.RANGE_START,t),f=e.getVariable(KE.PROPERTY,gA.RANGE_EXTENT,t),d=e.getVariable(KE.PROPERTY,gA.FLIP_SCALE,t),p=e.getVariable(KE.SCALE,t),_=e.createOneWayDependency($E.SCALE_BUILDER);e.connect(h,_),e.connect(f,_),e.connect(d,_),e.connect(l,_),e.connect(_,p),_.run();let g=e.getVariable(KE.CHANNEL,i,s);e.connect(p,o),e.connect(o,g),o.run()}}function OA(t,e){let n=e.getVariable(KE.PROPERTY,gA.AXIS_ORIENTATION,t),r=e.getVariable(KE.BOUNDS,t.elements[0].parent),i=e.getVariable(KE.PROPERTY,gA.AXIS_PATH_POSITION,t),s=e.createOneWayDependency($E.AXIS_PATH_PLACER);e.connect(n,s),e.connect(r,s),e.connect(s,i),s.run();let o=e.getVariable(KE.PROPERTY,gA.AXIS_TICK_OFFSET,t),a=e.getVariable(KE.PROPERTY,gA.AXIS_TICK_SIZE,t),l=e.createOneWayDependency($E.AXIS_TICKS_PLACER),c=e.getVariable(KE.PROPERTY,gA.AXIS_TICKS_POSITION,t);e.connect(i,l),e.connect(o,l),e.connect(a,l),e.connect(l,c),l.run();let u=e.getVariable(KE.PROPERTY,gA.AXIS_LABEL_OFFSET,t),h=e.getVariable(KE.PROPERTY,gA.AXIS_LABEL_FORMAT,t),f=e.getVariable(KE.PROPERTY,gA.AXIS_FONT_SIZE,t),d=e.createOneWayDependency($E.AXIS_LABELS_PLACER),p=e.getVariable(KE.PROPERTY,gA.AXIS_LABELS_POSITION,t);e.connect(i,d),e.connect(u,d),e.connect(h,d),e.connect(f,d),e.connect(d,p),d.run();let _=e.getVariable(KE.PROPERTY,gA.AXIS_TITLE_POSITION,t),g=e.createOneWayDependency($E.AXIS_TITLE_PLACER);e.connect(i,g),e.connect(g,_),g.run();let y=e.getVariable(KE.BOUNDS,t),m=e.getIncomingDataflowOperator($E.EVAL_BBOX,y);e.connect(c,m),e.connect(p,m),e.connect(m,y)}function NA(t,e){let n=e.getVariable(KE.PROPERTY,gA.AXIS_ORIENTATION,t),r=e.getVariable(KE.BOUNDS,lA(t.elements[0])),i=e.getVariable(KE.PROPERTY,gA.AXIS_PATH_POSITION,t),s=e.createOneWayDependency($E.AXIS_PATH_PLACER);e.connect(n,s),e.connect(r,s),e.connect(s,i),s.run();let o=e.getVariable(KE.PROPERTY,gA.AXIS_TICK_OFFSET,t),a=e.getVariable(KE.PROPERTY,gA.AXIS_TICK_SIZE,t),l=e.createOneWayDependency($E.AXIS_TICKS_PLACER),c=e.getVariable(KE.PROPERTY,gA.AXIS_TICKS_POSITION,t);e.connect(i,l),e.connect(o,l),e.connect(a,l),e.connect(l,c),l.run();let u=e.getVariable(KE.PROPERTY,gA.AXIS_LABEL_OFFSET,t),h=e.getVariable(KE.PROPERTY,gA.AXIS_LABEL_FORMAT,t),f=e.getVariable(KE.PROPERTY,gA.AXIS_FONT_SIZE,t),d=e.createOneWayDependency($E.AXIS_LABELS_PLACER),p=e.getVariable(KE.PROPERTY,gA.AXIS_LABELS_POSITION,t);e.connect(i,d),e.connect(u,d),e.connect(h,d),e.connect(f,d),e.connect(d,p),d.run();let _=e.getVariable(KE.PROPERTY,gA.AXIS_TITLE_POSITION,t),g=e.createOneWayDependency($E.AXIS_TITLE_PLACER);e.connect(i,g),e.connect(g,_),g.run();let y=e.getVariable(KE.BOUNDS,t),m=e.getIncomingDataflowOperator($E.EVAL_BBOX,y);e.connect(c,m),e.connect(p,m),e.connect(m,y)}function IA(t,e){let n=e.getVariable(KE.BOUNDS,lA(t.elements[0])),r=e.getVariable(KE.PROPERTY,gA.GRIDLINES_POSITION,t),i=e.createOneWayDependency($E.GRIDLINES_PLACER);e.connect(n,i),e.connect(i,r),i.run();let s=e.getVariable(KE.BOUNDS,t),o=e.getIncomingDataflowOperator($E.EVAL_BBOX,s);e.connect(r,o),e.connect(o,s)}class PA{constructor(){this._id=this.type+Dw(),this._type=Pw.Group,this._dataScopeRef=void 0,this._bounds=void 0,this._layout=void 0,this._children=[],this._sortBy={property:_E,descending:!1},this._z=0}get id(){return this._id}get type(){return this._type}get datum(){return eE(this._dataScopeRef)}get data(){return tE(this._dataScopeRef)}get children(){return this._children}addChild(t){this._children.indexOf(t)>=0||(t.parent&&t.parent.removeChild(t),this._children.push(t),t.parent=this)}addChildAt(t,e){t.parent&&t.parent.removeChild(t),this.children.splice(e,0,t),t.parent=this}removeChild(t){let e=this.children.indexOf(t);e>=0&&(this.children.splice(e,1),t.parent=null)}removeChildAt(t){this.children[t].parent=null,this.children.splice(t,1)}removeAll(){for(let t of this.children)t.parent=null;this._children=[]}get dataScope(){return this._dataScopeRef}set dataScope(t){if(this._dataScopeRef=Kw(t),void 0===this._dataScopeRef)for(let t of this.children)t.dataScope=void 0;else for(let t of this.children)t.dataScope?t.dataScope=lE(t.dataScope,this._dataScopeRef):t.dataScope=this._dataScopeRef}getInternalEncodings(t){if(0==this.children.length)return[];let e=this.children[0],n=this.getScene(),r=Object.keys(n.encodings),i=[];for(;e;){if(e.classId&&i.indexOf(e.classId)<0&&i.push(e.classId),e.type===Pw.Glyph){e.children.forEach(t=>i.push(t.classId));break}if(!e.children)break;e=e.children[0]}let s=[];for(let e of r){let r=e.split("_");for(let o of i)r[0]==o&&n.encodings[e][t]&&s.push(n.encodings[e][t])}return s}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(t){if(this._layout=t,t&&(t.group=this),CA(this,t,this.scene._depGraph),this.children&&this.children.length>0){let t=cA(this,!0);for(let e of t)this.scene.onChange(KE.CHANNEL,"x",e)}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){let t=this.children.map(t=>t.refBounds),e=d3.min(t.map(t=>t.left)),n=d3.min(t.map(t=>t.top)),r=d3.max(t.map(t=>t.right)),i=d3.max(t.map(t=>t.bottom));return new PE(e,n,r-e,i-n)}get x(){return this.bounds.x}get y(){return this.bounds.y}_updateBounds(){let t=this.children;if(t.length>0){this._bounds=t[0].bounds.clone();for(let e=1;e<t.length;e++)"hidden"!=t[e].visibility&&(this._bounds=this._bounds.union(t[e].bounds))}else this._bounds=new PE(0,0,0,0)}set visibility(t){let e="hidden"==t?"hidden":"visible";if(this.visibility!==e){this._visibility="hidden"==t?t:"visible";for(let e of this.children)e.visibility=t}}get visibility(){return this._visibility?this._visibility:"visible"}get z(){return this._z}set z(t){this._z!==t&&(this._z=t)}get scene(){return aA(this)}get sortBy(){return this._sortBy}}class LA extends PA{constructor(t){super(),this._type=Pw.Collection,this._id=t.id?t.id:this._type+"_"+Dw(),this._classId=this.id,this._childrenOrder=void 0,this._clipMask=void 0}get classId(){return this._classId}getSVGPathData(){let t="";for(let e of this.children)if(e.getSVGPathData)t+=e.getSVGPathData();else if(e.bounds){let n=e.bounds;t+=["M",n.left,n.top].join(" "),t+=["L",n.right,n.top].join(" "),t+=["L",n.right,n.bottom].join(" "),t+=["L",n.left,n.bottom,"Z"].join(" ")}return t}createClipMask(){let t=DE(this._children);this._clipMask=new PE(t.left,t.top,t.width,t.height)}get clipMask(){return this._clipMask}}class DA extends PA{constructor(t){if(super(),this._type=Pw.Glyph,this._id=t&&t.id?t.id:this.type+"_"+Dw(),this._classId=this._id,t&&t.children)for(let e of t.children)this.addChild(e)}get classId(){return this._classId}}const VA=Object.freeze({RowFirst:"rowFirst",ColumnFirst:"columnFirst"}),BA=Object.freeze({TopLeft:"topLeft",TopRight:"topRight",BottomLeft:"bottomLeft",BottomRight:"bottomRight"}),zA="horizontal",GA="vertical",FA="angular",jA="radial",UA={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"},YA=Object.freeze({CLOCKWISE:"clockwise",ANTI_CLOCKWISE:"anti-clockwise"}),HA=Object.freeze({INWARD:"inward",OUTWARD:"outward"}),WA=Object.freeze({INWARD:"inward",OUTWARD:"outward",TANGENTIAL_CLOCKWISE:"tangentialClockwise",TANGENTIAL_COUNTERCLOCKWISE:"tangentialCounterClockwise",UPRIGHT:"upright"});class qA{constructor(t,e){this.type="vertex",this.parent=t,this._index=e}_getStored(t){return this.parent._vertices.getProperty(this._index,t)}_setStored(t,e){this._getStored(t)!==e&&(this.parent._vertices.setProperty(this._index,t,e),this.parent._dirty=!0)}get datum(){return this.dataScope?eE(this.dataScope):this.parent.datum}get data(){return this.dataScope?tE(this.dataScope):this.parent.data}get dataScope(){return this.parent._vertices.getDataScopeRef(this._index)}set dataScope(t){this.dataScope!==t&&(this.parent._vertices.setDataScopeRef(this._index,t),this.parent._dirty=!0)}get bounds(){switch(this.shape){case"rect":return new PE(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new PE(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new PE(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this.parent._vertices._ids[this._index]}set polarAngle(t){this._setStored("polarAngle",t)}get polarAngle(){return this._getStored("polarAngle")}get _polarAngle(){return this.polarAngle}set _polarAngle(t){this.polarAngle=t}get scene(){return this.parent.scene}get x(){return this.parent._vertices._xs[this._index]}set x(t){this.parent._vertices._xs[this._index]!==t&&(this.parent._vertices._xs[this._index]=t,this.parent._dirty=!0)}get y(){return this.parent._vertices._ys[this._index]}set y(t){this.parent._vertices._ys[this._index]!==t&&(this.parent._vertices._ys[this._index]=t,this.parent._dirty=!0)}get shape(){return this._getStored("shape")}set shape(t){this._setStored("shape",t)}get width(){return this._getStored("width")}set width(t){this._setStored("width",t)}get height(){return this._getStored("height")}set height(t){this._setStored("height",t)}get radius(){return this._getStored("radius")}set radius(t){this._setStored("radius",t)}get fillColor(){return this._getStored("fillColor")}set fillColor(t){this._setStored("fillColor",t)}get opacity(){return this._getStored("opacity")}set opacity(t){this._setStored("opacity",t)}get strokeWidth(){return this._getStored("strokeWidth")}set strokeWidth(t){this._setStored("strokeWidth",t)}get strokeColor(){return this._getStored("strokeColor")}set strokeColor(t){this._setStored("strokeColor",t)}}qA.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class $A{constructor(t,e,n,r){this.type="segment",this._id=r,this._vertex1Index="number"==typeof t?t:t._index,this._vertex2Index="number"==typeof e?e:e._index,this._dataScopeRef=void 0,this.parent=n}get dataScope(){return this._dataScopeRef?this._dataScopeRef:this.parent.dataScope}set dataScope(t){this._dataScopeRef=Kw(t)}get datum(){return this.dataScope?eE(this.dataScope):this.parent.datum}get data(){return this.dataScope?tE(this.dataScope):this.parent.data}get id(){return this.parent.id+"_s_"+this._id}get vertex1(){return this.parent.vertices[this._vertex1Index]}set vertex1(t){this._vertex1Index="number"==typeof t?t:t._index}get vertex2(){return this.parent.vertices[this._vertex2Index]}set vertex2(t){this._vertex2Index="number"==typeof t?t:t._index}get x(){return(this.parent._vertices._xs[this._vertex1Index]+this.parent._vertices._xs[this._vertex2Index])/2}get y(){return(this.parent._vertices._ys[this._vertex1Index]+this.parent._vertices._ys[this._vertex2Index])/2}get scene(){return this.parent.scene}}class XA{constructor(t){return this._path=t,this.clear(),new Proxy(this,{get:(t,e)=>"length"===e?t.length:e===Symbol.iterator?t[Symbol.iterator].bind(t):XA._isIndex(e)?t.get(Number(e)):t[e],set(t,e,n){if(XA._isIndex(e))return t.replace(Number(e),n),!0;if("string"==typeof e&&"_"===e[0])return t[e]=n,!0;throw new Error("path.vertices is read-only; mutate vertex properties or use path.vertices = [...].")}})}static _isIndex(t){if("string"!=typeof t||""===t)return!1;let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t}static getCoords(t){return Array.isArray(t)?t:[t.x,t.y]}static getId(t){return t&&t.parent&&t.parent._vertices&&void 0!==t._index?t.parent._vertices._ids[t._index]:t?t.id:void 0}static get storageKeys(){return["_ids","_xs","_ys","_dataScopeRefs","_polarAngles","_shapes","_widths","_heights","_radii","_fillColors","_opacities","_strokeWidths","_strokeColors","_refs"]}static get propertyArrays(){return{dataScope:"_dataScopeRefs",polarAngle:"_polarAngles",shape:"_shapes",width:"_widths",height:"_heights",radius:"_radii",fillColor:"_fillColors",opacity:"_opacities",strokeWidth:"_strokeWidths",strokeColor:"_strokeColors"}}get length(){return this._xs.length}clear(){this._ids=[],this._xs=[],this._ys=[],this._dataScopeRefs=[],this._polarAngles=[],this._shapes=[],this._widths=[],this._heights=[],this._radii=[],this._fillColors=[],this._opacities=[],this._strokeWidths=[],this._strokeColors=[],this._refs=[]}get(t){if(!(t<0||t>=this.length))return this._refs[t]||(this._refs[t]=new qA(this._path,t)),this._refs[t]}at(t){return t<0&&(t=this.length+t),this.get(t)}append(t,e){let[n,r]=XA.getCoords(t),i=Array.isArray(t)?void 0:t.dataScope,s=void 0!==e?e:XA.getId(t),o=this.length;return this._ids.push(s),this._xs.push(n),this._ys.push(r),this._dataScopeRefs.push(i?this._copyDataScopeRef(i):void 0),this._polarAngles.push(Array.isArray(t)?void 0:t.polarAngle),this._shapes.push(Array.isArray(t)?void 0:t.shape),this._widths.push(Array.isArray(t)?0:t.width),this._heights.push(Array.isArray(t)?0:t.height),this._radii.push(Array.isArray(t)?0:t.radius),this._fillColors.push(Array.isArray(t)?"#555":t.fillColor),this._opacities.push(Array.isArray(t)?1:t.opacity),this._strokeWidths.push(Array.isArray(t)?0:t.strokeWidth),this._strokeColors.push(Array.isArray(t)?"#aaa":t.strokeColor),this._refs.push(void 0),o}insert(t,e,n,r){let i="number"==typeof e,s=i?[e,n]:XA.getCoords(e),o=s[0],a=s[1],l=i||Array.isArray(e)?void 0:e.dataScope,c=i?r:XA.getId(e);this._ids.splice(t,0,c),this._xs.splice(t,0,o),this._ys.splice(t,0,a),this._dataScopeRefs.splice(t,0,l?this._copyDataScopeRef(l):void 0),this._polarAngles.splice(t,0,i||Array.isArray(e)?void 0:e.polarAngle),this._shapes.splice(t,0,i||Array.isArray(e)?void 0:e.shape),this._widths.splice(t,0,i||Array.isArray(e)?0:e.width),this._heights.splice(t,0,i||Array.isArray(e)?0:e.height),this._radii.splice(t,0,i||Array.isArray(e)?0:e.radius),this._fillColors.splice(t,0,i||Array.isArray(e)?"#555":e.fillColor),this._opacities.splice(t,0,i||Array.isArray(e)?1:e.opacity),this._strokeWidths.splice(t,0,i||Array.isArray(e)?0:e.strokeWidth),this._strokeColors.splice(t,0,i||Array.isArray(e)?"#aaa":e.strokeColor),this._refs.splice(t,0,void 0),this._reindexRefs()}replace(t,e){let[n,r]=XA.getCoords(e),i=Array.isArray(e)?void 0:e.dataScope;this._xs[t]=n,this._ys[t]=r,this._dataScopeRefs[t]=i?this._copyDataScopeRef(i):void 0,this._polarAngles[t]=Array.isArray(e)?void 0:e.polarAngle,this._shapes[t]=Array.isArray(e)?void 0:e.shape,this._widths[t]=Array.isArray(e)?0:e.width,this._heights[t]=Array.isArray(e)?0:e.height,this._radii[t]=Array.isArray(e)?0:e.radius,this._fillColors[t]=Array.isArray(e)?"#555":e.fillColor,this._opacities[t]=Array.isArray(e)?1:e.opacity,this._strokeWidths[t]=Array.isArray(e)?0:e.strokeWidth,this._strokeColors[t]=Array.isArray(e)?"#aaa":e.strokeColor,this._refs[t]=void 0}copyFrom(t){this._ids=t._ids.slice(),this._xs=t._xs.slice(),this._ys=t._ys.slice(),this._dataScopeRefs=t._dataScopeRefs.map(t=>this._copyDataScopeRef(t)),this._polarAngles=t._polarAngles.slice(),this._shapes=t._shapes.slice(),this._widths=t._widths.slice(),this._heights=t._heights.slice(),this._radii=t._radii.slice(),this._fillColors=t._fillColors.slice(),this._opacities=t._opacities.slice(),this._strokeWidths=t._strokeWidths.slice(),this._strokeColors=t._strokeColors.slice(),this._refs=[]}getProperty(t,e){let n=XA.propertyArrays[e];return"dataScope"===e?this.getDataScopeRef(t):n?this[n][t]:void 0}setProperty(t,e,n){let r=XA.propertyArrays[e];r&&("dataScope"===e?this.setDataScopeRef(t,n):this[r][t]=n)}setDataScopeRef(t,e){this._dataScopeRefs[t]=e?this._copyDataScopeRef(e):void 0}getDataScopeRef(t){return this._dataScopeRefs[t]}hasDataScope(t){return!!this._dataScopeRefs[t]}getDataScopeRows(t){let e=this._dataScopeRefs[t];if(e)return tE(e)}getDataScopeAttrVal(t,e){let n=this._dataScopeRefs[t];if(n)return iE(n,e)}getDataScopeAttributeValues(t,e){let n=this._dataScopeRefs[t];return n?sE(n,e):[]}aggregateDataScopeAttribute(t,e,n){return oE(this._dataScopeRefs[t],e,n)}_copyDataScopeRef(t){return t?Kw(t):t}sort(t){let e=Array.from({length:this.length},(t,e)=>e);return e.sort((e,n)=>t(this.get(e),this.get(n))),this._reorder(e),this._path._reindexSegments(),this}reverse(){let t=Array.from({length:this.length},(t,e)=>this.length-e-1);return this._reorder(t),this._path._reindexSegments(),this}splice(t,e,...n){let r=this.slice(t,t+e);for(let n of XA.storageKeys)this[n].splice(t,e);for(let e=0;e<n.length;e++)this.insert(t+e,n[e],void 0);return this._reindexRefs(),this._path._reindexSegments(),r}push(...t){for(let e of t)this.append(e,void 0);return this._path._reindexSegments(),this.length}map(t,e){let n=[];for(let r=0;r<this.length;r++)n.push(t.call(e,this.get(r),r,this));return n}filter(t,e){let n=[];for(let r=0;r<this.length;r++){let i=this.get(r);t.call(e,i,r,this)&&n.push(i)}return n}find(t,e){for(let n=0;n<this.length;n++){let r=this.get(n);if(t.call(e,r,n,this))return r}}forEach(t,e){for(let n=0;n<this.length;n++)t.call(e,this.get(n),n,this)}slice(t,e){return Array.from(this).slice(t,e)}concat(...t){return Array.from(this).concat(...t)}entries(){let t=this;return function*(){for(let e=0;e<t.length;e++)yield[e,t.get(e)]}()}indexOf(t){return t&&t.parent===this._path?t._index:-1}includes(t){return this.indexOf(t)>=0}[Symbol.iterator](){let t=this;return function*(){for(let e=0;e<t.length;e++)yield t.get(e)}()}_reorder(t){for(let e of XA.storageKeys){let n=this[e];this[e]=t.map(t=>n[t])}this._reindexRefs()}_reindexRefs(){for(let t=0;t<this._refs.length;t++)this._refs[t]&&(this._refs[t]._index=t)}}class KA extends GE{constructor(t){super(t),this._type="type"in t?t.type:Pw.Path,this._vertices=new XA(this),this.vertexCounter=0,this._sortBy={},this.segmentCounter=0,this.segments=[],this.anchor=void 0,this.closed="closed"in t&&t.closed,this.curveMode="curveMode"in t?t.curveMode:"linear",this._vxShape=void 0,this._vxWidth=0,this._vxHeight=0,this._vxRadius=0,this._vxFillColor="#555555",this._vxStrokeColor="#aaaaaa",this._vxStrokeWidth=0,this._vxOpacity=1;for(let e of qA.styles)e in t&&(this["_"+e]=t[e]);"vertices"in t&&(this.vertices=t.vertices),this._sourceAnchor="sourceAnchor"in t?t.sourceAnchor:["center","middle"],this._targetAnchor="targetAnchor"in t?t.targetAnchor:["center","middle"],this._sourceOffset="sourceOffset"in t?t.sourceOffset:[0,0],this._targetOffset="targetOffset"in t?t.targetOffset:[0,0],this._strength="strength"in t?t.strength:.85,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}set vertices(t){if(this._vertices.clear(),this.segments=[],this.vertexCounter=0,this.segmentCounter=0,0===t.length)return this._dirty=!0,void(this._bounds=void 0);for(let e=0;e<t.length;e++){let n=XA.getCoords(t[e]),r=XA.getCoords(t[0]);if(e==t.length-1&&n[0]===r[0]&&n[1]===r[1]&&this.type===Pw.Path)continue;let i=Array.isArray(t[e])?this.vertexCounter++:XA.getId(t[e]),s=this._vertices.append(t[e],i);!Array.isArray(t[e])&&"number"==typeof i&&i>=this.vertexCounter&&(this.vertexCounter=i+1);for(let t of qA.styles)if(void 0!==this[t]){let e=t.replace("vx","");this._vertices.setProperty(s,e[0].toLowerCase()+e.slice(1),this[t])}e>0&&this.segments.push(new $A(s-1,s,this,this.segmentCounter++))}let e=XA.getCoords(t[0]),n=XA.getCoords(t[t.length-1]);this._vertices.length>1&&(this.closed||e[0]===n[0]&&e[1]===n[1]||this.type===Pw.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new $A(this._vertices.length-1,0,this,this.segmentCounter++))),this._dirty=!0,this._updateBounds()}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles);for(let e of qA.styles)void 0!==this["_"+e]&&(t["_"+e]=this["_"+e]);this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t.closed=this.closed,t.curveMode=this.curveMode,t.vertexCounter=this.vertexCounter,t._vertices.copyFrom(this._vertices),t.segments=[],t.segmentCounter=0;for(let e=1;e<t._vertices.length;e++)t.segments.push(new $A(e-1,e,t,t.segmentCounter++));t.closed&&t.segments.push(new $A(t._vertices.length-1,0,t,t.segmentCounter++)),t._sourceAnchor=this._sourceAnchor.slice(),t._targetAnchor=this._targetAnchor.slice(),t._sourceOffset=this._sourceOffset.slice(),t._targetOffset=this._targetOffset.slice(),t._beta=this._beta}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get x(){return this.bounds.x}get y(){return this.bounds.y}resize(t,e,n,r){let i=this.bounds,s=0===i.width?1:i.width,o=0===i.height?1:i.height,a=this._vertices._xs,l=this._vertices._ys;if("right"===n)for(let e=0;e<this._vertices.length;e++)a[e]=i.right-t/s*(i.right-a[e]);else for(let e=0;e<this._vertices.length;e++)a[e]=i.left+t/s*(a[e]-i.left);if("top"===r)for(let t=0;t<this._vertices.length;t++)l[t]=i.top+e/o*(l[t]-i.top);else for(let t=0;t<this._vertices.length;t++)l[t]=i.bottom-e/o*(i.bottom-l[t]);this._updateBounds(),this._dirty=!0}_updateBounds(){let t=[],e=[];if(this._d){const n=this._d.match(/[a-zA-Z][^a-zA-Z]*/g),r=" ";n.forEach(n=>{let i=n.slice(1).trim().split(r).map(Number);for(let[n,r]of i.entries())n%2==0?t.push(r):e.push(r)})}else t=this._vertices._xs,e=this._vertices._ys;let n=et(t),r=et(e),i=Q(t),s=Q(e),o=i-n,a=s-r;if(this._bounds=new PE(n,r,o,a),this.type===Pw.Line||this.type===Pw.Path){let t=this.styles.strokeWidth?this.styles.strokeWidth:1;n===i?this._bounds=new PE(n-t/2,r,i-n+t,s-r):r===s&&(this._bounds=new PE(n,r-t/2,i-n,s-r+t))}}addVertex(t,e,n){void 0===n&&(n=this._vertices.length),this._vertices.insert(n,t,e,this.vertexCounter++),this._reindexSegments()}sortVertices(t,e){this._vertices.sort((e,n)=>e[t]-n[t]),e&&this._vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=t,e.vertex2=(t+1)%this._vertices.length}this._dirty=!0}sortVerticesByData(t,e,n){let r;r=n?(e,r)=>n.indexOf(e.datum[t])-n.indexOf(r.datum[t]):(e,n)=>e.datum[t]<n.datum[t]?-1:1,this._vertices.sort(r),e&&this._vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=t,e.vertex2=(t+1)%this._vertices.length}this._dirty=!0}getSVGPathData(){if(this._d)return this._d;if(this._vertices.length<2)return"";let t=To(),e=this._getD3CurveFunction(this.curveMode)(t);e.lineStart();for(let t=0;t<this._vertices.length;t++)e.point(this._vertices._xs[t],this._vertices._ys[t]);return this.closed&&e.point(this._vertices._xs[0],this._vertices._ys[0]),e.lineEnd(),t._}get firstVertex(){return this._vertices[0]}get anyVertex(){return this._anyVertexRef||(this._anyVertexRef=new qA(this,0),this._anyVertexRef._isAnyVertex=!0),this._anyVertexRef}get firstSegment(){return this.segments[0]}get lastVertex(){return this._vertices[this._vertices.length-1]}get lastSegment(){return this.segments[this.segments.length-1]}_reindexSegments(){for(let t=0;t<this.segments.length;t++)this.segments[t].vertex1=t,this.segments[t].vertex2=(t+1)%this._vertices.length}_getD3CurveFunction(t){switch(t){case QA.Natural:return lw;case QA.Basis:return Ix;case QA.BumpX:return $v;case QA.BumpY:return Xv;case QA.Linear:return Nv;case QA.Step:return uw;case QA.CatmullRom:return qx;case QA.Cardinal:return Gx;case QA.Bundle:return Vx.beta(.5);default:return Nv}}get vxShape(){return this._vxShape}get vxWidth(){return this._vxWidth}get vxHeight(){return this._vxHeight}get vxRadius(){return this._vxRadius}get vxFillColor(){return this._vxFillColor}get vxStrokeColor(){return this._vxStrokeColor}get vxStrokeWidth(){return this._vxStrokeWidth}get vxOpacity(){return this._vxOpacity}set vxOpacity(t){this._vxOpacity=t;for(let e of this.vertices)e.opacity=t}get sourceAnchor(){return this._sourceAnchor}get targetAnchor(){return this._targetAnchor}get sourceOffset(){return this._sourceOffset}get targetOffset(){return this._targetOffset}get strength(){return this._strength}set strength(t){this._strength=t,this._dirty=!0}get vertices(){return this._vertices}}function ZA(t,e){const n=ME.getSVG();let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",t.getSVGPathData()),n.appendChild(r);let i=r.getTotalLength();return r.getPointAtLength(i*e)}function JA(t){return t instanceof KA&&t.source&&t.target}const QA={Natural:"natural",Basis:"basis",BumpX:"bumpX",BumpY:"bumpY",Bundle:"bundle",Linear:"linear",Step:"step",CatmullRom:"CatmullRom",Cardinal:"cardinal"};function tS(t,e,n){const r=t.match(/[a-zA-Z][^a-zA-Z]*/g),i=",",s=r.map(t=>{const r=t[0],s=t.slice(1).trim();if("M"===r||"L"===r||"T"===r){const[t,o]=s.split(i).map(Number);return`${r}${t+e} ${o+n}`}if("C"===r){const t=s.split(i).map(Number);return`${r}${t[0]+e} ${t[1]+n} ${t[2]+e} ${t[3]+n} ${t[4]+e} ${t[5]+n}`}if("Q"===r){const t=s.split(i).map(Number);return`${r}${t[0]+e} ${t[1]+n} ${t[2]+e} ${t[3]+n}`}if("A"===r){const t=s.split(i).map(Number);return`${r}${t[0]} ${t[1]} ${t[2]} ${t[3]} ${t[4]} ${t[5]+e} ${t[6]+n}`}return"Z"===r||"z"===r?r:t});return s.join(" ")}class eS extends KA{constructor(t){super(t),this._type=Pw.Arc,this.closed=!0,this._x="x"in t?t.x:100,this._y="y"in t?t.y:100,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200,this._thickness="thickness"in t?t.thickness:this._outerRadius-this._innerRadius,this._startAngle="startAngle"in t?t.startAngle:0,this._endAngle="endAngle"in t?t.endAngle:90,this._sr=nS(this._startAngle),this._er=nS(this._endAngle),this._direction="direction"in t?t.direction:YA.ANTI_CLOCKWISE;let e=this._x+this._innerRadius*Math.cos(this._sr),n=this._y-this._innerRadius*Math.sin(this._sr),r=this._x+this._innerRadius*Math.cos(this._er),i=this._y-this._innerRadius*Math.sin(this._er),s=this._x+this._outerRadius*Math.cos(this._sr),o=this._y-this._outerRadius*Math.sin(this._sr),a=this._x+this._outerRadius*Math.cos(this._er),l=this._y-this._outerRadius*Math.sin(this._er);this.vertices=[[e,n],[s,o],[a,l],[r,i]]}get type(){return 0===this._innerRadius?Pw.Pie:Pw.Arc}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}get direction(){return this._direction}get x(){return this._x}get y(){return this._y}get startAngle(){return this._startAngle}get endAngle(){return this._endAngle}get angle(){return this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle}setAngles(t,e){this._startAngle=t,this._endAngle=e,this._sr=nS(this._startAngle),this._er=nS(this._endAngle),this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._dirty=!0}_updateBounds(){let t=this.vertices.map(t=>t.x),e=this.vertices.map(t=>t.y),n=d3.min(t),r=d3.min(e),i=d3.max(t)-n,s=d3.max(e)-r;this._bounds=new PE(n,r,i,s)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius,t._startAngle=this._startAngle,t._endAngle=this._endAngle,t._thickness=this._thickness,t._direction=this._direction,t._sr=this._sr,t._er=this._er}getSVGPathData(){let t=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,e=t>180?1:0;return["M "+this.vertices[0].x+", "+this.vertices[0].y,"L "+this.vertices[1].x+", "+this.vertices[1].y,"A "+[this._outerRadius,this._outerRadius,t,e,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,t,e,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}}function nS(t){return t*Math.PI/180}function rS(t){return 180*t/Math.PI}function iS(t){return(t%360+360)%360}function sS(t,e,n,r){let i=t-n,s=r-e;return Math.atan2(s,i)*(180/Math.PI)}class oS extends KA{constructor(t){super(t),this._type=Pw.Area,this.closed=!0,this._orientation="orientation"in t?t.orientation:void 0,this._baseline="baseline"in t?t.baseline:void 0,t&&"vertices"in t&&this.segments.push(new $A(this.vertices.length-1,0,this,this.segmentCounter++))}get topLeftVertex(){return this._orientation===zA?this.vertices[0]:this.vertices[this.vertices.length-1]}get bottomLeftVertex(){return this._orientation===zA?this.vertices[this.vertices.length-1]:this.vertices[this.vertices.length/2]}get topRightVertex(){return this._orientation===zA?this.vertices[this.vertices.length/2-1]:this.vertices[0]}get bottomRightVertex(){return this._orientation===zA?this.vertices[this.vertices.length/2]:this.vertices[this.vertices.length/2-1]}get baseline(){return this._baseline}set baseline(t){this._baseline=t,this._dirty=!0}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this._dirty=!0}get firstVertexPair(){return[this.vertices[0],this.vertices[this.vertices.length-1]]}get width(){return this.vertices[this.vertices.length/2].x-this.vertices[0].x}get height(){return this.vertices[this.vertices.length/2].y-this.vertices[0].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}copyPropertiesTo(t){super.copyPropertiesTo(t),t._baseline=this._baseline,t._orientation=this._orientation}getSVGPathData(){return super.getSVGPathData()+" z"}}class aS extends KA{constructor(t){super(t),this._type=Pw.BezierCurve,this._orientation="orientation"in t?t.orientation:zA}get type(){return this._type}get orientation(){return this._orientation}copyPropertiesTo(t){super.copyPropertiesTo(t),t._orientation=this._orientation}getSVGPathData(){if(this._d)return this._d;let t="M ";return t+=this.vertices[0].x+" "+this.vertices[0].y+" ",t+="C "+this.vertices[1].x+" "+this.vertices[1].y+" ",t+=this.vertices[2].x+" "+this.vertices[2].y+" ",t+=this.vertices[3].x+" "+this.vertices[3].y,t}}class lS extends GE{constructor(t){super(t),this._type=Pw.Circle,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._radius="radius"in t?t.radius:100,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}set x(t){this._x=t,this._dirty=!0}set y(t){this._y=t,this._dirty=!0}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}set radius(t){this._radius=t,this._dirty=!0}get area(){return Math.PI*Math.pow(this._radius,2)}_updateBounds(){if(this._rotate){let t=OE(this._x,this._y,this._rotate[1],this._rotate[2],this._rotate[0]);this._bounds=new PE(t.x-this._radius,t.y-this._radius,2*this._radius,2*this._radius)}else this._bounds=new PE(this._x-this._radius,this._y-this._radius,2*this._radius,2*this._radius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._radius=this._radius}getSVGPathData(){return["M",this._x,this._y,"m",-this._radius,", 0 a",this._radius,",",this._radius,"0 1,0",2*this._radius,",0 a",this._radius,",",this._radius,"0 1,0",-2*this._radius,",0"].join(" ")}}let cS=class extends GE{constructor(t){super(t),this._type=Pw.Image,this._src=t.src,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._width="width"in t?t.width:100,this._height="height"in t?t.height:100}get src(){return this._src}set src(t){this._src=t,this._dirty=!0}get width(){return this._width}set width(t){this._width=t,this._updateBounds(),this._dirty=!0}get height(){return this._height}set height(t){this._height=t,this._updateBounds(),this._dirty=!0}resize(t,e){this._width=t,this._height=e,this._dirty=!0,this._updateBounds()}get x(){return this._x}set x(t){this._x=t,this._dirty=!0,this._updateBounds()}get y(){return this._y}set y(t){this._y=t,this._dirty=!0,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new PE(this._x,this._y,this._width,this._height)}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t.src=this._src}},uS=class extends GE{constructor(t){super(t),this._type=Pw.Symbol,this._path=t.path,this._viewBox="viewBox"in t?t.viewBox:[0,0,24,24],this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._width="width"in t?t.width:24,this._height="height"in t?t.height:24}get path(){return this._path}set path(t){this._path=t,this._dirty=!0}get viewBox(){return this._viewBox}set viewBox(t){this._viewBox=t,this._dirty=!0}get width(){return this._width}set width(t){this._width=t,this._updateBounds(),this._dirty=!0}get height(){return this._height}set height(t){this._height=t,this._updateBounds(),this._dirty=!0}resize(t,e){this._width=t,this._height=e,this._dirty=!0,this._updateBounds()}get x(){return this._x}set x(t){this._x=t,this._dirty=!0,this._updateBounds()}get y(){return this._y}set y(t){this._y=t,this._dirty=!0,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new PE(this._x,this._y,this._width,this._height)}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t.path=this._path,t.viewBox=this._viewBox}};class hS extends KA{constructor(t){super(t)}get x1(){return this.vertices[0].x}get y1(){return this.vertices[0].y}get x2(){return this.vertices[1].x}get y2(){return this.vertices[1].y}get x(){return(this.vertices[0].x+this.vertices[1].x)/2}get y(){return(this.vertices[0].y+this.vertices[1].y)/2}set x(t){let e=t-this.x;this.vertices[0].x+=e,this.vertices[1].x+=e,this._dirty=!0}set y(t){let e=t-this.y;this.vertices[0].y+=e,this.vertices[1].y+=e,this._dirty=!0}set x1(t){this.vertices[0].x=t,this._dirty=!0}set x2(t){this.vertices[1].x=t,this._dirty=!0}set y1(t){this.vertices[0].y=t,this._dirty=!0}set y2(t){this.vertices[1].y=t,this._dirty=!0}}const fS="filled",dS="none";class pS extends KA{constructor(t={}){const e="x1"in t?t.x1:0,n="y1"in t?t.y1:0,r="x2"in t?t.x2:100,i="y2"in t?t.y2:0,s=[[e,n],...t.controlPoints||[],[r,i]];super({...t,type:Pw.Arrow,vertices:s}),this._startStyle=t.startStyle??dS,this._startSize=t.startSize??8,this._endStyle=t.endStyle??fS,this._endSize=t.endSize??8}get x1(){return this.vertices[0].x}set x1(t){this.vertices[0].x=t,this._dirty=!0}get y1(){return this.vertices[0].y}set y1(t){this.vertices[0].y=t,this._dirty=!0}get x2(){return this.vertices[this.vertices.length-1].x}set x2(t){this.vertices[this.vertices.length-1].x=t,this._dirty=!0}get y2(){return this.vertices[this.vertices.length-1].y}set y2(t){this.vertices[this.vertices.length-1].y=t,this._dirty=!0}get startStyle(){return this._startStyle}set startStyle(t){this._startStyle=t,this._dirty=!0}get startSize(){return this._startSize}set startSize(t){this._startSize=t,this._dirty=!0}get endStyle(){return this._endStyle}set endStyle(t){this._endStyle=t,this._dirty=!0}get endSize(){return this._endSize}set endSize(t){this._endSize=t,this._dirty=!0}}class _S extends GE{constructor(t){super(t),this._type=Pw.SimpleText,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._text="text"in t?t.text:"",this._anchor="anchor"in t?t.anchor:[zE.CENTER,zE.MIDDLE],this._textPath=void 0,this._textPathOffset="50%","fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),"backgroundColor"in t&&(this._backgroundColor=t.backgroundColor),"borderWidth"in t&&(this._borderWidth=t.borderWidth),"borderColor"in t&&(this._borderColor=t.borderColor),this._rotate="rotate"in t?t.rotate:void 0}hasBackground(){return this._backgroundColor||this._borderStroke||this._borderColor}_updateBounds(){let t,e,n=function(t,e,n){const r=ME.getSVG(),i=document.createElementNS("http://www.w3.org/2000/svg","text");i.setAttribute("font-family",e),i.setAttribute("font-size",n),i.textContent=t,r.appendChild(i);const s=i.getBBox();return r.removeChild(i),{width:s.width,height:s.height}}(this._text,[this.fontWeight,this.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),r=n.width,i=n.height;switch(this._anchor[0]){case zE.LEFT:t=this._x;break;case zE.RIGHT:t=this._x-r;break;case zE.CENTER:t=this._x-r/2;break;default:t=this._x}switch(this._anchor[1]){case zE.TOP:e=this._y;break;case zE.BOTTOM:e=this._y-i;break;case zE.MIDDLE:default:e=this._y-i/2}if(this._rotate&&3===this._rotate.length){let n=[{x:t,y:e},{x:t+r,y:e},{x:t,y:e+i},{x:t+r,y:e+i}].map(t=>OE(t.x,t.y,this._rotate[1],this._rotate[2],this._rotate[0])),s=d3.min(n.map(t=>t.x)),o=d3.max(n.map(t=>t.x)),a=d3.min(n.map(t=>t.y)),l=d3.max(n.map(t=>t.y));this._bounds=new PE(s,a,o-s,l-a)}else this._bounds=new PE(t,e,r,i)}get x(){return this._x}set x(t){this._x=t,this._dirty=!0}get y(){return this._y}set y(t){this._y=t,this._dirty=!0}get text(){return this._text}set text(t){this._text=t,this._dirty=!0}get anchor(){return this._anchor}get fontFamily(){return this.styles.fontFamily}get fontSize(){return this.styles.fontSize}get fontWeight(){return this.styles.fontWeight}set fontWeight(t){this.styles.fontWeight=t,this._dirty=!0}get textPath(){return this._textPath}set textPath(t){this._textPath=t,this._dirty=!0}get textPathOffset(){return this._textPathOffset}set textPathOffset(t){this._textPathOffset=t,this._dirty=!0}get backgroundColor(){return this._backgroundColor?this._backgroundColor:"#fff"}get borderColor(){return this._borderColor?this._borderColor:"#ccc"}get borderWidth(){return this._borderWidth?this._borderWidth:1}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t._x=this._x,t._y=this._y,t._text=this._text,t._anchor=[this._anchor[0],this._anchor[1]],t._backgroundColor=this._backgroundColor,t._borderColor=this._borderColor,t._borderStroke=this._borderStroke}}class gS extends KA{constructor(t){super(t),this._type=Pw.Polygon,this.closed=!0,"x"in t&&(this._x=t.x),"y"in t&&(this._y=t.y),"radius"in t&&(this._radius=t.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}set x(t){this._x=t,this._dirty=!0}set y(t){this._y=t,this._dirty=!0}set radius(t){this._radius=t,this._dirty=!0}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._radius=this._radius}}class yS extends KA{constructor(t){super(t)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}get right(){return this.vertices[1].x}get bottom(){return this.vertices[2].y}get area(){return this.width*this.height}setBounds(t,e,n,r){this.vertices[0].x=t,this.vertices[0].y=e,this.vertices[1].x=t+n,this.vertices[1].y=e,this.vertices[2].x=t+n,this.vertices[2].y=e+r,this.vertices[3].x=t,this.vertices[3].y=e+r,this._dirty=!0}resize(t,e,n,r){t!==this.width&&("right"===n?(this.vertices[1].x=this.refBounds.right,this.vertices[2].x=this.refBounds.right,this.vertices[0].x=this.vertices[1].x-t,this.vertices[3].x=this.vertices[0].x):(this.vertices[0].x=this.refBounds.left,this.vertices[3].x=this.refBounds.left,this.vertices[1].x=this.vertices[0].x+t,this.vertices[2].x=this.vertices[1].x)),e!==this.height&&("top"===r?(this.vertices[0].y=this.refBounds.top,this.vertices[1].y=this.refBounds.top,this.vertices[3].y=this.vertices[0].y+e,this.vertices[2].y=this.vertices[3].y):(this.vertices[2].y=this.refBounds.bottom,this.vertices[3].y=this.refBounds.bottom,this.vertices[0].y=this.vertices[3].y-e,this.vertices[1].y=this.vertices[0].y)),this._dirty=!0}get leftSegment(){return this.segments[3]}get rightSegment(){return this.segments[1]}get topSegment(){return this.segments[0]}get bottomSegment(){return this.segments[2]}}class mS extends KA{constructor(t){super(t),this._type=Pw.Ring,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get x(){return this._x}get y(){return this._y}get thickness(){return this._outerRadius-this._innerRadius}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius}getSVGPathData(){return["M "+this._x+" "+this._y,"m 0, -"+this._outerRadius,"a "+this._outerRadius+","+this._outerRadius+", 0, 1, 0, 1, 0","Z","m 0 "+(this._outerRadius-this._innerRadius),"a "+this._innerRadius+", "+this._innerRadius+", 0, 1, 1, -1, 0","Z"].join(" ")}}class bS extends GE{constructor(t){super(t),this._type=Pw.RichText,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._text="text"in t?t.text:"",this._width="width"in t?t.width:200,this._anchor="anchor"in t?t.anchor:[zE.CENTER,zE.MIDDLE],"fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),"backgroundColor"in t&&(this._backgroundColor=t.backgroundColor),"borderWidth"in t&&(this._borderWidth=t.borderWidth),"borderColor"in t&&(this._borderColor=t.borderColor),this._rotate="rotate"in t?t.rotate:void 0}hasBackground(){return this._backgroundColor||this._borderStroke||this._borderColor}_updateBounds(){let t,e,n=function(t,e,n){const r=ME.getSVG(),i=document.createElementNS("http://www.w3.org/2000/svg","text");i.setAttribute("font-family",e),i.setAttribute("font-size",n),i.textContent=t,r.appendChild(i);const s=i.getBBox();return r.removeChild(i),{width:s.width,height:s.height}}(this._text,[this.fontWeight,this.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),r=n.width,i=n.height;switch(this._anchor[0]){case zE.LEFT:t=this._x;break;case zE.RIGHT:t=this._x-r;break;case zE.CENTER:t=this._x-r/2;break;default:t=this._x}switch(this._anchor[1]){case zE.TOP:e=this._y;break;case zE.BOTTOM:e=this._y-i;break;case zE.MIDDLE:default:e=this._y-i/2}if(this._rotate&&3===this._rotate.length){let n=[{x:t,y:e},{x:t+r,y:e},{x:t,y:e+i},{x:t+r,y:e+i}].map(t=>OE(t.x,t.y,this._rotate[1],this._rotate[2],this._rotate[0])),s=d3.min(n.map(t=>t.x)),o=d3.max(n.map(t=>t.x)),a=d3.min(n.map(t=>t.y)),l=d3.max(n.map(t=>t.y));this._bounds=new PE(s,a,o-s,l-a)}else this._bounds=new PE(t,e,r,i)}get x(){return this._x}get y(){return this._y}set x(t){this._x=t,this._dirty=!0}set y(t){this._y=t,this._dirty=!0}get text(){return this._text}set text(t){this._text=t,this._dirty=!0}get anchor(){return this._anchor}get fontFamily(){return this.styles.fontFamily}get fontSize(){return this.styles.fontSize}get fontWeight(){return this.styles.fontWeight}get textPath(){return this._textPath}set textPath(t){this._textPath=t,this._dirty=!0}get textPathOffset(){return this._textPathOffset}set textPathOffset(t){this._textPathOffset=t,this._dirty=!0}get backgroundColor(){return this._backgroundColor?this._backgroundColor:"#fff"}get borderColor(){return this._borderColor?this._borderColor:"#ccc"}get borderWidth(){return this._borderWidth?this._borderWidth:1}get width(){return this._width}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t._x=this._x,t._y=this._y,t._text=this._text,t._anchor=[this._anchor[0],this._anchor[1]],t._backgroundColor=this._backgroundColor,t._borderColor=this._borderColor,t._borderStroke=this._borderStroke}}class vS{constructor(t){let e=t||{};this._stops=[],this.type=Pw.LinearGradient,this.id=this.type+Dw(),this.x1="x1"in e?e.x1:0,this.x2="x2"in e?e.x2:100,this.y1="y1"in e?e.y1:0,this.y2="y2"in e?e.y2:0}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.x1=this.x1,t.x2=this.x2,t.y1=this.y1,t.y2=this.y2,t.stops=this._stops,t}addStop(t,e,n){this._stops.push({offset:t,color:e,opacity:n})}get stops(){return this._stops}}class xS{constructor(t){this.type=Pw.PathGradient,this.id=this.type+Dw(),this._colors=t?t.slice():[]}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.colors=this._colors.slice(),t}get colors(){return this._colors}set colors(t){this._colors=t}}function wS(t,e,n,r){let i,s=t.domain,o=t.range;switch(t.type){case"linear":case"log":{let a=Math.abs(o[0]-o[1]);i="width"==e||"x"==e?45:30;let l,c=Math.max(2,Math.floor(a/i));if("width"==e||"height"==e){let i=!!r&&(r.elements[0].parent.layout&&r.elements[0].parent.layout.type==HE.STACK);s[1]=t._scale.invert(i?VE(n)[e]:DE(n)[e])}if("log"===t.type){l=[];let e=t._scale.ticks();for(let t of e){let n=Math.log(t)/Math.log(10)+1e-6;Math.abs(n-Math.floor(n))<c/e.length&&l.push(t)}}else l=q(s[0],s[1],c);return l}case"point":{i="width"==e||"x"==e?80:30;let n=Math.floor(t.rangeExtent/s.length),r=Math.ceil(i/n);return"x"==e?s.filter((t,e)=>e%r==0):s}case"band":{i="width"==e||"x"==e?80:30;let n=Math.floor(t.rangeExtent/s.length),r=Math.max(1,Math.ceil(i/n));return s.filter((t,e)=>e%r==0)}case"time":{i="width"==e||"x"==e?80:30;let t,n,r=Math.floor((o[1]-o[0])/i),a=Math.ceil((s[1]-s[0])/r)/1e3,l=[1,60,3600,86400,2628003,31536e3],c=[q_,X_,Q_,rg,zg,Ug];for(let e=0;e<l.length-1;e++)if(a>=l[e]&&a<l[e+1])return t=Math.floor(a/l[e]),n=c[e],n(s[0],s[1],t);return a>l[l.length-1]?(t=Math.floor(a/l[l.length-1]),n=c[l.length-1],n(s[0],s[1],t)):[]}default:return[]}}function ES(t,e){e.removeChild(t)}class AS extends PA{constructor(t){super(),this._type=Pw.Axis,this._id=t.id?t.id:this._type+Dw(),this._attribute=void 0,this._channel=void 0,this._orientation=void 0,this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._textColor="textColor"in t?t.textColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._tickOffset="tickOffset"in t?t.tickOffset:0,this._tickSize="tickSize"in t?t.tickSize:5,this._tickAnchor=t.tickAnchor,this._tickVisible=!("tickVisible"in t)||t.tickVisible,this._pathVisible=!("pathVisible"in t)||t.pathVisible,this._labelVisible=!("labelVisible"in t)||t.labelVisible,this._labelOffset="labelOffset"in t?t.labelOffset:this._tickSize+this._tickOffset+3,this._labelFormat="labelFormat"in t?t.labelFormat:"",this._titleOffset="titleOffset"in t?t.titleOffset:40,this._rotateYTitle=!("rotateTitle"in t&&!t.rotateTitle),this._showTitle=!("titleVisible"in t)||t.titleVisible,this._labelRotation="labelRotation"in t?t.labelRotation:0,this._ticks=new PA,this._ticks._id=this._id+"_ticks",this.addChild(this._ticks),this._labels=new PA,this._labels._id=this._id+"_labels",this.addChild(this._labels),this._title=new _S({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title._id=this.id+"_title",this.addChild(this._title),this._showTitle||(this._title.visibility="hidden"),this._pathPos=void 0,this._args=t}get id(){return this._id}get pathPosition(){return this._pathPos}get pathVisible(){return this._pathVisible}get attribute(){return this._attribute}get channel(){return this._channel}get orientation(){return this._orientation}get ticksVisible(){return this._tickVisible}get labelsVisible(){return this._labelVisible}get tickSize(){return this._tickSize}get tickOffset(){return this._tickOffset}get tickAnchor(){return this._tickAnchor?this._tickAnchor:"x"===this._channel||"width"===this._channel?"center":"middle"}get labelOffset(){return this._labelOffset}get labelFormat(){return this._labelFormat}get labelRotation(){return this._labelRotation}get tickValues(){return this._tickValues}get labelValues(){return this._labelValues}get titleOffset(){return this._titleOffset}get titleVisisble(){return this._showTitle}get boundsWithoutTitle(){let t=this.children.filter(t=>t.type!==Pw.SimpleText),e=t[0].bounds.clone();for(let n=1;n<t.length;n++)"hidden"!=t[n].visibility&&(e=e.union(t[n].bounds));return e}get strokeColor(){return this._strokeColor}get textColor(){return this._textColor}}const SS="top",TS="bottom",CS="left";function kS(t,e,n){if(t&&t.origin)return t.origin;let r=e[0].parent;if(r.type===Pw.Polygon)return[r.x,r.y];throw new Error('Mascot: "polarRadius"/"polarAngle" '+n+' need an explicit {origin: [x, y]} option (passed to encode(), or to gridlines()/axis() themselves) because the encoded shape has no fixed center of its own -- e.g. it came from densify() on a "line" mark rather than a "circle".')}class RS extends AS{constructor(t,e,n,r){if(super(r),this._encoding=t,this._attribute=this._encoding.attribute,this._channel=this._encoding.channel,this._scale=e,this._elems=n,this._flip="flip"in r&&r.flip,this._posArg="x"==this._channel||"width"==this._channel?r.pathY:r.pathX,this._orientation="orientation"in r?r.orientation:"x"===this._channel||"width"==this._channel?TS:CS,this._titleText="title"in r?r.title:this._encoding.sourceAttribute??this._encoding.attribute,this._path="angle"===this._channel||"polarAngle"===this._channel?new lS({strokeColor:this._strokeColor,id:this._id+"_path"}):new KA({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(r),t.dataTable.type(this._attribute)!==Vw.Date||"labelFormat"in r||(this._labelFormat="%m/%d/%y"),"polarRadius"===this._channel&&"rotation"in r){let[t,e]=this.origin;this._rotate=[-r.rotation,t,e]}"polarAngle"===this._channel&&(this._radius="radius"in r?r.radius:100)}get radius(){return this._radius}get origin(){return kS(this._args,this._elems,"axis")}isFlipped(){return this._flip}get elements(){return this._elems}get scale(){return this._scale}get encoding(){return this._encoding}get includeZero(){return this._encoding.includeZero}createTicksLabels(t){"tickValues"in t?(this._tickValues=t.tickValues,this._labelValues="labelValues"in t?t.labelValues:t.tickValues):(this._tickValues=wS(this._scale,this._channel,this._elems,this),this._labelValues="labelValues"in t?t.labelValues:this._tickValues),this._ticks.removeAll();for(let t=0;t<this._tickValues.length;t++){let e=new KA({strokeColor:this._strokeColor,id:this._id+"_tick"+t});this._tickVisible||(e.visibility="hidden"),this._ticks.addChild(e)}this._labels.removeAll();let e,n=this._encoding.dataTable.type(this._attribute);if("labelValues"in t)e=function(t){return t};else switch(n){case Vw.Date:e=iy(this._labelFormat);break;case Vw.String:e=function(t){return t};break;default:e=Hl(this._labelFormat)}for(let[t,n]of this._labelValues.entries()){let r=new _S({text:e(n),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+t});this._labelVisible||(r.visibility="hidden"),this._labels.addChild(r)}this._title._text=this._titleText}}class MS{constructor(t,e){switch(this._id="scale_"+Dw(),this._type=t,e&&(this._args=e),t){case"linear":this._scale=__();break;case"point":this._scale=r_();break;case"band":this._scale=e_().padding(0);break;case"ordinal":this._scale=t_();break;case"ordinalColor":this._scale=t_(Nw[e.scheme]);break;case"power":this._scale=N_().exponent(2);break;case"sqrt":this._scale=N_().exponent(.5);break;case"log":this._scale=A_();break;case"identity":case"time":this._scale=Mm();break;case"sequentialColor":e.scheme?this._scale=Im(Nw[e.scheme]):this._scale=Im()}}get id(){return this._id}get domain(){return this._scale.domain()}set domain(t){this._scale.domain(t)}get range(){return this._scale.range()}set range(t){this._scale.range(t)}get rangeExtent(){let t=this._scale.range();return Math.abs(t[1]-t[0])}set rangeExtent(t){let e=this._scale.range();e[0]<e[1]?this._scale.range([e[0],e[0]+t]):this._scale.range([e[1]+t,e[1]])}get type(){return this._type}map(t){return this._scale(t)}invert(t,e){let n=et(this._scale.range()),r=Q(this._scale.range()),i=t;if(e||(i=Q([n,et([t,r])])),"time"===this._type)return this._scale.invert(i).getTime();if(["point","band","ordinal","ordinalColor"].includes(this._type)){return this._scale.domain().reduce((t,e)=>{let n=this._scale(e);"band"===this._type&&(n+=this._scale.bandwidth()/2);let r=this._scale(t);return"band"===this._type&&(r+=this._scale.bandwidth()/2),Math.abs(n-i)<Math.abs(r-i)?e:t})}return this._scale.invert(i)}}function OS(t){if(t.scaleType)return new MS(t.scaleType);if(t._baseEnc&&t._baseEnc.scales.length>0){let e=t._baseEnc.scales[0];return new MS(e.type,e._args)}if("text"===t.channel||"src"===t.channel||"path"===t.channel)return new MS("ordinal");switch(t.dataTable.type(t.attribute)){case Vw.Boolean:break;case Vw.Date:return new MS("time");case Vw.String:if("count"==t.aggregator)return new MS("linear");if(t.channel.indexOf("Color")>=0||"fillGradient"===t.channel||"strokeGradient"===t.channel){let e={};return e.scheme=t.colorScheme?t.colorScheme:"schemeCategory10",new MS("ordinalColor",e)}return new MS("point");default:return["strokeColor","fillColor","fillGradient","strokeGradient"].indexOf(t.channel)>=0?t.mapping?new MS("linear"):new MS("sequentialColor",{scheme:t.colorScheme}):new MS("linear")}}const NS=["schemeBrBG","schemePRGn","schemePiYG","schemePuOr","schemeRdBu","schemeRdGy","schemeRdYlBu","schemeRdYlGn","schemeSpectral"],IS=["schemeBlues","schemeGreens","schemeGreys","schemeOranges","schemePurples","schemeReds","schemeBuGn","schemeBuPu","schemeGnBu","schemeOrRd","schemePuBuGn","schemePuBu","schemePuRd","schemeRdPu","schemeYlGnBu","schemeYlGn","schemeYlOrBr","schemeYlOrRd"];function PS(t,e){let n=e||aA(t.element);delete n._encodings[BS(t.element)][t.channel],console.log("remove encoding",t.channel,t.attribute),function(t,e){let n=e.findVariable(KE.CHANNEL,[t.channel,t.element]);n||console.warn("cannot find encoding to remove from the dep graph");let r=n.incomingDataflow;e.deleteOperator(r)}(t,n._depGraph);for(let e of t.refElements)ES(e,n),bA(e,n._depGraph);t.clearRefElements()}function LS(t,e){let n=t.scene._encodings[BS(t)],r=[];n&&(r=r.concat(Object.values(n)));{let e=t.scene;for(let n in e._encodings){let i=n.split("_");i.pop(),i.join("_")===t.classId&&(r=r.concat(Object.values(e._encodings[n])))}}return r}function DS(t,e,n){for(let r in n._encodings){let i=n._encodings[r];if(i[e]&&i[e].attribute==t)return i[e]}return null}function VS(t,e){let n=t.scene._encodings[BS(t)];return n&&n[e]?n[e]:null}function BS(t){if(Array.isArray(t))return t.map(t=>BS(t)).join("_");if(t.classId)return t.classId;if("vertex"==t.type&&t._isAnyVertex)return t.parent.classId+"_vAny";if("vertex"==t.type&&t.dataScope){if(t.parent.type===Pw.Area){let e=t._index<t.parent._vertices.length/2;return t.parent.classId+"_v"+(e?0:t.parent._vertices.length-1)}return t.parent.classId+"_v"}return"vertex"==t.type?t.parent.classId+"_v"+t._index:"segment"==t.type&&t._dataScopeRef?t.parent.classId+"_s":"segment"==t.type?t.parent.classId+"_s"+t.parent.segments.indexOf(t):null}function zS(t,e){if(0==t.children.length)return[];let n=aA(t),r=t.type===Pw.Composite?t.children:[t.children[0]],i=Object.keys(n._encodings),s=[];for(let t of r){let e=t;for(;e;){if(e.classId&&s.indexOf(e.classId)<0&&s.push(e.classId),e.type===Pw.Glyph){e.children.forEach(t=>s.push(t.classId));break}if(!e.children)break;e=e.children[0]}}let o=[];for(let t of i)for(let r of s)0===t.indexOf(r)&&n._encodings[t][e]&&o.push(n._encodings[t][e]);return o}function GS(t){let e=VS(t,"y"),n=VS(t,"height");return e||n&&n.scales[0].domain[0]<0}function FS(t){let e=VS(t,"x"),n=VS(t,"width");return e||n&&n.scales[0].domain[0]<0}class jS extends KA{constructor(t,e,n,r,i){super(i),this._type=Pw.Gridlines,this._id=this._type+Dw(),this._attribute=e,this._channel=t,this._scale=n,this._elems=r,this._args=i,"strokeColor"in i||(this.styles.strokeColor="#ddd"),"opacity"in i||(this.styles.opacity=.5),this.updateValues(),this._lines=[]}updateValues(){"values"in this._args?this._values=this._args.values:this._scale?this._values=wS(this._scale,this._channel,this._elems):this._values=this._elems.map(t=>t.datum[this._attribute])}get type(){return this._type}get id(){return this._id}getSVGPathData(){let t="";if("polarRadius"===this._channel)for(let e of this._lines)t+="M "+e.x+" "+e.y+" m -"+e.r+" 0 a "+e.r+" "+e.r+" 0 1 0 "+2*e.r+" 0 a "+e.r+" "+e.r+" 0 1 0 -"+2*e.r+" 0 ";else for(let e of this._lines)t+=["M",e.x1,e.y1].join(" ")+[" L",e.x2,e.y2].join(" ")+" ";return t}_updateBounds(){if("polarRadius"===this._channel){let t=this._lines.map(t=>new PE(t.x-t.r,t.y-t.y,2*t.r,2*t.r));this._bounds=LE(t)}else{let t=this._lines.map(t=>t.x1).concat(this._lines.map(t=>t.x2)),e=this._lines.map(t=>t.y1).concat(this._lines.map(t=>t.y2)),n=d3.min(t),r=d3.max(t),i=d3.min(e),s=d3.max(e);this._bounds=new PE(n,i,r-n,s-i)}}get elements(){return this._elems}get values(){return this._values}get channel(){return this._channel}get attribute(){return this._attribute}get scale(){return this._scale}get origin(){return kS(this._args,this._elems,"gridlines")}get lines(){return this._lines}set lines(t){this._lines=t}}class US{constructor(t,e,n,r,i){this._id="encoding_"+Dw(),this._elem=t,this._channel=e,this._attribute=n,this._table=i.table,this._aggregator=r,this._includeZero=i.includeZero,this._flipScale=i.flipScale,this._mapping=i.mapping,this._preferredRangeExtent=i.rangeExtent,this._preferredRangeStart=i.rangeStart,this._preferredDomain=i.domain,this._preferredRange=i.range,this._preferredOrigin=i.origin,this._scaleType=i.scaleType,this._colorScheme=i.scheme,this._forLegend=i.forLegend,this._sourceAttribute=i.sourceAttribute??null,i.shareScale&&(this._baseEnc=i.shareScale),this._scales=[],this._elemGroups=[],this._elem2scale={},this._refElements=[],["width","height","radius","angle","thickness","polarRadius","strokeWidth","area"].indexOf(this._channel)>=0&&(this._includeZero=!0),this.initialize()}get id(){return this._id}initialize(){if(this._scales=[],this._elemGroups=[],"vertex"===this._elem.type){let t,e=lA(this._elem),n=JE(this._elem.parent);if("x"!==this._channel&&"y"!==this._channel||!e.layout||e.layout.type!=HE.GRID)t=FS(this._elem.parent)||GS(this._elem.parent)?n.map(t=>eA(this._elem,[t])):[eA(this._elem,n)];else{t=("x"===this._channel?e.layout.getElementsByCol(!0,this._elem.parent):e.layout.getElementsByRow(!0,this._elem.parent)).map(t=>eA(this._elem,t))}for(let e of t)this._createScaleForVertexIndices(e)}else if("x"===this._channel||"y"===this._channel){let t=this._elem,e=lA(t);if(e.layout&&e.layout.type==HE.GRID){let n="x"===this._channel?e.layout.getElementsByCol(!0,t):e.layout.getElementsByRow(!0,t);for(let t of n)this._createScaleForElems(t)}else{let t=JE(this._elem);this._createScaleForElems(t)}}else if("angle"===this._channel){let t=JE(this._elem).reduce((t,e)=>{const n=e.parent.id;return t[n]||(t[n]=[]),t[n].push(e),t},{}),e=Object.values(t);for(let t of e)this._createScaleForElems(t)}else{let t=JE(this._elem);this._createScaleForElems(t)}}_createScaleForElems(t){this._elemGroups.push(t);var e=OS(this);this._scales.push(e);for(let n of t)this._elem2scale[n.id]=e}_createScaleForVertexIndices(t){this._elemGroups.push({type:"vertexIndices",groups:t});var e=OS(this);this._scales.push(e);for(let n of t)for(let t of n.indices)this._elem2scale[tA(n.parent,t)]=e}refreshElementMappings(){if(1===this._scales.length)if(this._elem2scale={},"vertex"===this._elem.type){let t=JE(this._elem.parent),e=eA(this._elem,t);this._elemGroups=[{type:"vertexIndices",groups:e}];for(let t of e)for(let e of t.indices)this._elem2scale[tA(t.parent,e)]=this._scales[0]}else{let t=JE(this._elem);this._elemGroups=[t];for(let e of t)this._elem2scale[e.id]=this._scales[0]}}getScale(t){return this._elem2scale[t.id]}getAttrValue(t,e,n){let r=(e?this.getScale(e):this._scales[0]).invert(t,n),i=this._attribute;if(this.dataTable.type(i)===Vw.Date){const t=this.dataTable.values(i).slice().sort((t,e)=>t-e);let e=a(t,r);return e=Math.min(e,t.length-1),e>0&&Math.abs(t[e-1]-r)<Math.abs(t[e]-r)&&e--,t[e]}return r}getChannelValue(t,e){return(e?this.getScale(e):this._scales[0]).map(t)}getElements(t){let e=this._scales.indexOf(t);return this._elemGroups[e]}getNormalizedElements(t){let e=this.getElements(t);return e&&"vertexIndices"===e.type?Array.from(new Set(e.groups.map(t=>t.parent))):e}get elementGroups(){return this._elemGroups}get element(){return this._elem}get channel(){return this._channel}get origin(){return this._preferredOrigin}get attribute(){return this._attribute}get sourceAttribute(){return this._sourceAttribute}set attribute(t){let e=this._attribute;this._attribute=t;for(let e of this._refElements)e instanceof RS?(e._attribute=t,e.createTicksLabels({}),e._titleText&&(e._titleText=this._sourceAttribute??t)):e instanceof jS&&(e._attribute=t,e.updateValues());const n=this._elem.scene._depGraph.getVariable(KE.ATTRIBUTE,e,this.dataTable,this);n&&(n._attribute=t,this._elem.scene.onChange(KE.ATTRIBUTE,t,this.dataTable,this))}get dataTable(){return this._table}get aggregator(){return this._aggregator}hasMultipleScales(){return this._scales.length>0}get scales(){return this._scales}getRangeStart(t){return et(this.getScale(t).range)}getRangeExtent(t){return this.getScale(t).rangeExtent}get domain(){if(1===this._scales.length)return this._scales[0].domain;throw new Error("AttributeEncoding: multiple scales exist, specify element to get domain.")}get rangeExtent(){if(1===this._scales.length)return this._scales[0].rangeExtent;throw new Error("AttributeEncoding: multiple scales exist, specify element to get rangeExtent.")}get scaleType(){return this._scaleType}set scaleType(t){this._scaleType=t}getDomain(t){return this.getScale(t).domain}set domain(t){this._preferredDomain=t;for(let e of this._scales)e._scale.domain(t);for(let t of this._refElements)t instanceof RS&&t.createTicksLabels({});this._elem.scene.onChange(KE.ATTR_VALUE,this)}set rangeExtent(t){let e=t<1?1:Math.round(t);for(let t of this._scales)t.rangeExtent=e;for(let t of this._refElements)t instanceof RS&&t.createTicksLabels({});this._elem.scene.onChange(KE.PROPERTY,gA.RANGE_EXTENT,this)}set includeZero(t){this._includeZero=t;for(let t of this._refElements)t instanceof RS&&t.createTicksLabels({});this._elem.scene.onChange(KE.PROPERTY,gA.INCLUDE_ZERO,this)}get includeZero(){return this._includeZero}set flipScale(t){this._flipScale=t,this._elem.scene.onChange(KE.PROPERTY,gA.FLIP_SCALE,this)}get flipScale(){return this._flipScale}set mapping(t){this._mapping=t}get mapping(){return this._mapping}set colorScheme(t){this._colorScheme=t}get colorScheme(){return this._colorScheme}addRefElement(t){this._refElements.indexOf(t)<0&&this._refElements.push(t)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}zoom(t,e,n,r){let i=r||this._elem,s=this.getDomain(i),o=et(s),a=Q(s),l="log"!==this._scales[0].type,c=this.getAttrValue(e,i,l),u=o-(c-o)*t*n,h=a+(a-c)*t*n;u!==h&&(!l&&u<=0||(this.domain=[u,h]))}}function YS(t,e){let n=function(t){let e=t.parent,n=[];for(;e.type!==Pw.Scene;)n.push(e),e=e.parent;return n}(t);for(let t of n)if(VS(t,e))return!1;return n.length>=2?n[n.length-2]:t}function HS(t,e,n){switch(t.type){case Pw.Rect:case Pw.Path:case Pw.Line:case Pw.Area:!function(t,e,n){for(let r of t.vertices)WS(r,e,n);t._updateBounds(),t._refBounds&&t._refBounds.translate(e,n)}(t,e,n),0===e&&0===n||(t._dirty=!0);break;case Pw.Group:case Pw.Collection:case Pw.Glyph:!function(t,e,n){for(let r of t.children)HS(r,e,n);t._layout&&(void 0!==t._layout._left&&(t._layout._left+=e),void 0!==t._layout._top&&(t._layout._top+=n),t._layout._cellBounds&&t._layout._cellBounds.forEach(t=>t.translate(e,n)));0===e&&0===n||(t._dirty=!0);t._updateBounds(),t._refBounds&&t._refBounds.translate(e,n)}(t,e,n);break;case"segment":!function(t,e,n){WS(t.vertex1,e,n),WS(t.vertex2,e,n)}(t,e,n),0===e&&0===n||(t.parent._dirty=!0);break;case"vertex":WS(t,e,n),0===e&&0===n||(t.parent._dirty=!0);break;default:!function(t,e,n){t._x+=e,t._y+=n,t._updateBounds(),t._refBounds&&t._refBounds.translate(e,n)}(t,e,n),0===e&&0===n||(t._dirty=!0)}}function WS(t,e,n){t.x+=e,t.y+=n}function qS(t,e,n,r={}){let i={channel:e,attribute:n,...r};if("rowId"===i.attribute&&(i.attribute=_E),function(t,e,n){if(!t||!e||!n)throw new Error("encode(elem, channel, attribute) — all three arguments are required");if(!Object.values(fA).includes(e))throw new Error(`Unknown channel "${e}"`);let r=pE(t);if(r&&r.tree){if(n.indexOf(".")>0&&!r.tree.nodeTable.has(n.split(".")[1]))throw new Error(`Data attribute "${n}" does not exist in the data table`)}else if(!r||!r.has(n))throw new Error(`Data attribute "${n}" does not exist in the data table`)}(t,e,n),i.shareScale){let t=i.shareScale;if(t.channel!=i.channel&&t.channel.indexOf("Color")<0&&i.channel.indexOf("Color")<0)throw new Error("Cannot share scales between "+t.channel+" and "+i.channel+" encodings");i.scheme=i.shareScale.colorScheme}!function(t){let e;"vertex"===t.type&&t.parent.type===Pw.Area?e=t.parent:t.type===Pw.Area&&(e=t),e&&!e._refBounds&&JE(e).forEach(t=>t._refBounds=t.bounds.clone())}(t);let s=i.aggregator?i.aggregator:"sum";i.table=pE(t);let o=new US(t,i.channel,i.attribute,s,i),a=t.scene;return a._addAttributeEncoding(o),MA(o,a._depGraph,i.shareScale),i.shareScale?a.onChange(KE.ATTR_VALUE,o):a.onChange(KE.CHANNEL,i.channel,t),o}function $S(t,e,n,r){for(let i=e;i<n;i++)t._vertices._xs[i]=r;t._dirty=!0}function XS(t,e,n,r){for(let i=e;i<n;i++)t._vertices._xs[i]=r(i);t._dirty=!0}function KS(t,e,n,r){for(let i=e;i<n;i++)t._vertices._ys[i]=r;t._dirty=!0}function ZS(t,e,n,r){for(let i=e;i<n;i++)t._vertices._ys[i]=r(i);t._dirty=!0}function JS(t,e,n){return"number"==typeof e?function(t,e){if(!Number.isInteger(e)||e<1)throw new Error("Repeat count must be a positive integer");let n=[];for(let t=0;t<e;t++)n.push({index:t});let r=new fE(n,"from count");return QS(t,r)}(t,e):function(t){if(!t||"object"!=typeof t||Array.isArray(t))return!1;if(t instanceof fE||t instanceof gE||t instanceof mE)return!1;let e=Object.values(t);return e.length>0&&e.every(t=>"number"==typeof t)}(e)?function(t,e){let n=[];for(let t of Object.keys(e)){let r=e[t];if(!Number.isInteger(r)||r<0)throw new Error("Repeat group counts must be non-negative integers: "+t+" = "+r);for(let e=0;e<r;e++)n.push({group:t})}if(0===n.length)throw new Error("Repeat counts must include at least one group with a positive count");let r=new fE(n,"from group counts");return QS(t,r)}(t,e):QS(t,e)}function QS(t,e,n){let r=aA(t),i={};if(i.attribute=i.attribute||_E,function(t,e,n){if(!t||void 0===e)throw new Error("Incomplete information to do repeat. You must specify an element, a categorical data attribute and a data table");if(e instanceof gE||e instanceof mE){if(!Array.isArray(t)||2!==t.length)throw new Error("To repeat with a tree or a network, you need to provide two marks, one for node and one for link")}else e instanceof fE&&function(t,e){if(e.has(t))return!0;if(e.tree&&e.tree.nodeTable.has(t.split(".")[1]))return!0;throw new Error(["Attribute",t,"does not exist in the table",e.name].join(" "))}(n.attribute,e);if(n.layout&&!(n.layout instanceof UE))throw new Error("Invalid layout: "+n.layout)}(t,e,i),e instanceof gE||e instanceof mE){let n=t[0].parent,i=t[1].parent,[s,o]=function(t,e,n,r){let i=e.dataScope?e.dataScope:cE(r.nodeTable),s=uE(i,xE),o=aT(t,{type:Pw.Collection}),a=aT(t,{type:Pw.Collection}),l={};a.dataScope=i,a.addChild(e);for(let t=1;t<s.length;t++){let t=uT(e);a.addChild(t)}a.children.forEach((t,e)=>{t.dataScope=s[e],t.links=[],l[iE(t.dataScope,xE)]=t});let c=n.dataScope?n.dataScope:cE(r.linkTable),u=uE(c,_E);o.dataScope=c,o.addChild(n);for(let t=1;t<u.length;t++){let t=uT(n);o.addChild(t)}o.children.forEach((t,e)=>t.dataScope=u[e]);let h=r instanceof gE?"parent":"source",f=r instanceof gE?"child":"target";for(let t of o.children){let e=iE(t.dataScope,h),n=iE(t.dataScope,f),r=l[e],i=l[n];t.source=r,t.target=i,r.links.push(t),i.links.push(t)}return[a,o]}(r,t[0],t[1],e);return wA(n,t[0],r._depGraph),wA(i,t[1],r._depGraph),vA(s,r._depGraph),vA(o,r._depGraph),EA(s,t[0],r._depGraph),EA(s.parent,s,r._depGraph),EA(o,t[1],r._depGraph),EA(o.parent,o,r._depGraph),[s,o]}if(e instanceof fE){let n=t.parent,s=function(t,e,n,r){let i=r.type(n);if(i!=Vw.String&&i!=Vw.Date&&i!=Vw.Integer)throw new Error("Repeat only works on a string or date attribute: "+n+" is "+i);if(!function(t){if(Array.isArray(t)){if(1===t.length)return tT(t[0]);for(let e of t)if(!FE(e)||e.dataScope)return!1;return!0}return tT(t)}(e))throw new Error("The "+e.type+" is not repeatable");return function(t,e,n,r){let i=e.dataScope?e.dataScope:cE(r),s=uE(i,n),o=aT(t,{type:Pw.Collection});o.dataScope=i,o.addChild(e),e._refBounds||(e._refBounds=e.bounds.clone());for(let t=1;t<s.length;t++){let t=uT(e);o.addChild(t)}return o.children.forEach((t,e)=>t.dataScope=s[e]),o}(t,e,n,r)}(r,t,i.attribute,e);return wA(n,t,r._depGraph),vA(s,r._depGraph),EA(s,t,r._depGraph),EA(s.parent,s,r._depGraph),function(t,e,n,r){let i=r.getVariable(KE.ITEMS,n),s=r.createOneWayDependency($E.REPOPULATE);s._collection=t,s._repeatAttr=e,r.connect(i,s);let o=t.children[0],a=new Set([o,...cA(o)]);for(let t of a)r.connect(s,r.getVariable(KE.DATASCOPE,t))}(s,i.attribute,e,r._depGraph),i.layout&&(s.layout=i.layout),s}}function tT(t){return!(!FE(t)&&t.type!=Pw.Glyph||t.dataScope)||t.type===Pw.Collection&&nE(t.firstChild.dataScope)>1}class eT extends UE{constructor(t){super(),this.type=HE.GRID,this._numCols=t.numCols,this._numRows=t.numRows,this._start="start"in t?t.start:BA.TopLeft,this._direction="direction"in t?t.direction:VA.RowFirst,this._rowGap="rowGap"in t&&void 0!==t.rowGap?t.rowGap:5,this._colGap="colGap"in t&&void 0!==t.colGap?t.colGap:5,this._cellHorzAlignment="horzCellAlignment"in t&&WE("h",t.horzCellAlignment)?t.horzCellAlignment:zE.LEFT,this._cellVertAlignment="vertCellAlignment"in t&&WE("v",t.vertCellAlignment)?t.vertCellAlignment:zE.BOTTOM,this._rowOffset="rowOffset"in t&&void 0!==t.rowOffset?t.rowOffset:0,this._colOffset="colOffset"in t&&void 0!==t.colOffset?t.colOffset:0,this._numCols||this._numRows||(this._numRows=1),this._includeInvisible=!1,this._left=void 0,this._top=void 0,this._cellBounds=void 0,this._grid=void 0}get includeInvisible(){return this._includeInvisible}set includeInvisible(t){this._includeInvisible=t}get cellBounds(){return this._cellBounds}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}set numCols(t){this._numCols=t}set numRows(t){this._numRows=t}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}get rowOffset(){return this._rowOffset}set rowOffset(t){this._rowOffset=t}get colOffset(){return this._colOffset}set colOffset(t){this._colOffset=t}clone(){let t=new eT({numCols:this._numCols,numRows:this._numRows,start:this._start,direction:this._direction,colGap:this._colGap,rowGap:this._rowGap,horzCellAlignment:this._cellHorzAlignment,vertCellAlignment:this._cellVertAlignment,rowOffset:this._rowOffset,colOffset:this._colOffset});return t._includeInvisible=this._includeInvisible,t._left=this._left,t._top=this._top,this._cellBounds&&(t._cellBounds=this._cellBounds.map(t=>t.clone())),t}getElementsByRow(t,e){let n=[],r=this.group.children;for(let e=0;e<this.numRows;e++){let i=this._grid[e].filter(t=>null!=t).map(t=>r[t]);if(t){let t=[];for(let e of i)t=t.concat(cA(e));n.push(t)}else n.push(i)}return e&&(n=this._filterElementsByExample(n,e)),n}getElementsByCol(t,e){let n=[],r=this.group.children,i=this._grid;for(let e=0;e<this.numCols;e++){let s=i.map(t=>t[e]).filter(t=>null!=t).map(t=>r[t]);if(t){let t=[];for(let e of s)t=t.concat(cA(e));n.push(t)}else n.push(s)}return e&&(n=this._filterElementsByExample(n,e)),n}getElementsByCell(t,e){let n=[],r=this.group.children;for(let e=0;e<r.length;e++)if(t){let t=cA(r[e]);n.push(t)}else n.push(r[e]);return e&&(n=this._filterElementsByExample(n,e)),n}_filterElementsByExample(t,e){let n;return"vertex"===e.type?(n=t.map(t=>t.filter(t=>t.classId===e.parent.classId)),n=n.map(t=>QE(e,t))):"segment"===e.type?(n=t.map(t=>t.filter(t=>t.classId===e.parent.classId)),n=n.map(t=>nA(e,t))):n=t.map(t=>t.filter(t=>t.classId===e.classId)),n}getIndex(t){let e=t;for(;e&&e.parent!==this.group;)e=e.parent;return this.group.children.indexOf(e)}getRowCol(t){let e,n;switch(this._direction){case VA.RowFirst:e=Math.floor(t/this.numCols),n=t%this.numCols;break;case VA.ColumnFirst:e=t%this.numRows,n=Math.floor(t/this.numRows);break;default:throw new Error("Invalid fill direction. Use 'row_first' or 'column_first'.")}return this._start.toLowerCase().includes("bottom")&&(e=this.numRows-1-e),this._start.toLowerCase().includes("right")&&(n=this.numCols-1-n),{row:e,col:n}}get startCorner(){return this._start}set startCorner(t){this._start=t}get direction(){return this._direction}set direction(t){this._direction=t}}class nT extends PA{constructor(t,e){super(),this._type=Pw.Axis,this._id=this._type+Dw(),this._enc=t,this._textColor="textColor"in e?e.textColor:"#555",this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._x="x"in e?e.x:100,this._y="y"in e?e.y:100,this._showTitle=!("showTitle"in e)||e.showTitle,this._orientation="orientation"in e?e.orientation:GA,this._numberFormat=e.numberFormat?e.numberFormat:""}get attribute(){return this._enc.attribute}get channel(){return this._enc.channel}get attributeType(){return pE(this._enc.element).getFieldType(this.attribute)}get orientation(){return this._orientation}get textColor(){return this._textColor}}class rT extends nT{constructor(t,e){super(t,e),"numCols"in e||"numRows"in e?(this._numCols=e.numCols,this._numRows=e.numRows):this._orientation===GA?this._numCols=1:this._numRows=1,this._initialize()}_initialize(){let t=this._enc.element.scene,e=this._enc.attribute,n=this._enc.scales[0],r=new fE(n.domain.map(t=>({category:t,value:n.map(t)}))),i=r.unique("category").sort((t,e)=>e.length-t.length)[0],s=this._enc.element,o=s instanceof KA&&s.closed&&"strokeColor"!==this._enc.channel?s.strokeWidth:0;if(this._orientation===GA){let n=0;this._showTitle&&(this.addChild(new _S({fillColor:this._textColor,fontSize:this._fontSize,text:e,x:this._x,y:this._y,anchor:["left","top"]})),n=parseFloat(this._fontSize)+5);let a=t.mark("rect",{top:this._y+2+n,left:this._x,width:10,height:10,strokeWidth:o,strokeColor:s.strokeColor,opacity:s.opacity}),l=t.mark("text",{text:i,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+n+12+o,anchor:["left","bottom"]}),c=JS(t.glyph(a,l),r);qS(l,"text","category",{forLegend:!0}),qS(a,"fillColor","category",{shareScale:this._enc,forLegend:!0}),c.layout=new eT({numCols:this._numCols,numRows:this._numRows}),this.addChild(c)}else{let e=t.mark("rect",{top:this._y,left:this._x,width:10,height:10,strokeWidth:o,strokeColor:s.strokeColor,opacity:s.opacity}),n=t.mark("text",{text:i,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+15,y:this._y,anchor:["left","top"]}),a=JS(t.glyph(e,n),r);qS(n,"text","category",{forLegend:!0}),qS(e,"fillColor","category",{shareScale:this._enc,forLegend:!0}),a.layout=new eT({numCols:this._numCols,numRows:this._numRows,colGap:15}),this.addChild(a)}}}class iT extends nT{constructor(t,e){super(t,e),this._initialize()}_initialize(){let t,e,n,r=this._enc.element.scene,i=this._enc.attribute;if(this._orientation==GA?(t=15,e=300):(t=300,e=15),this._showTitle){let e=r.mark("text",{fillColor:this._textColor,text:i,x:this._x+t/2,y:this._y,anchor:["center","middle"]});this.addChild(e),n=20}else n=0;let s,o=r.mark("rect",{top:this._y+n,left:this._x,width:t,height:e,strokeWidth:0,opacity:this._enc.element.opacity}),a=Object.values(this._enc.attrValues),l=[et(a),Q(a)],c=this._enc.mapping,u=[],h=[],f=Hl(this._numberFormat);if(c){let i=Object.keys(c).map(t=>parseFloat(t)).sort((t,e)=>t-e);this._orientation==GA?(s=new vS({x1:0,y1:100,x2:0,y2:0}),i.forEach(i=>{let o=(i-l[0])/(l[1]-l[0]);s.addStop(100*o,c[i],1);let a=r.mark("line",{x1:this._x+t,x2:this._x+t+5,y1:this._y+e-o*e+n,y2:this._y+e-o*e+n,strokeColor:this._strokeColor});h.push(a);let d=r.mark("text",{fillColor:this._textColor,text:this._numberFormat?f(i):i.toFixed(0),x:this._x+t+5+5,y:this._y+e-o*e+n,anchor:["left","middle"]});u.push(d)})):(s=new vS({x1:0,y1:0,x2:100,y2:0}),i.forEach(i=>{let o=(i-l[0])/(l[1]-l[0]);s.addStop(100*o,c[i],1);let a=r.mark("line",{x1:this._x+o*t,x2:this._x+o*t,y1:this._y+20-5+n,y2:this._y+e+5+n,strokeColor:this._strokeColor});h.push(a);let d=r.mark("text",{fillColor:this._textColor,text:this._numberFormat?f(i):i.toFixed(0),x:this._x+o*t,y:this._y+e+5+n,anchor:["center","top"]});u.push(d)}))}else{let o=this._enc.scales[0].domain,a=pE(this._enc.element),l=a.type(i),c=[],d=l===Vw.Date?a.getUniqueFieldValues(i):[...new Set(Object.values(this._enc.attrValues))];if(d.length<=10)c=d,c.sort((t,e)=>t-e);else if(l===Vw.Date){d.sort((t,e)=>t-e);for(let t=0;t<d.length;t+=Math.ceil(d.length/10))c.push(d[t])}else{let t=(o[1]-o[0])/9;for(let e=0;e<10;e++)c.push(o[0]+e*t)}let p=0,_=Math.abs((c[c.length-1]-c[0])/c.length);for(;_>0&&_<1&&p<10;)_*=10,p++;c=c.map(t=>t.toFixed(p)),this._orientation==GA?(s=new vS({x1:0,y1:100,x2:0,y2:0}),c.forEach(c=>{let d=(c-o[0])/(o[1]-o[0]);s.addStop(100*d,this._enc.scales[0].map(c),1);let p=r.mark("line",{x1:this._x+t,x2:this._x+t+5,y1:this._y+e-d*e+n,y2:this._y+e-d*e+n,strokeColor:this._strokeColor});h.push(p);let _=r.mark("text",{fillColor:this._textColor,text:l===Vw.Date?a.raw(i,c):this._numberFormat?f(c):c,x:this._x+t+5+5,y:this._y+e-d*e+n,anchor:["left","middle"]});u.push(_)})):(s=new vS({x1:0,y1:0,x2:100,y2:0}),c.forEach(c=>{let f=(c-o[0])/(o[1]-o[0]);s.addStop(100*f,this._enc.scales[0].map(c),1);let d=r.mark("line",{x1:this._x+f*t,x2:this._x+f*t,y1:this._y+e+n,y2:this._y+e+5+n,strokeColor:this._strokeColor});h.push(d);let p=r.mark("text",{fillColor:this._textColor,text:l===Vw.Date?a.raw(i,c):c,x:this._x+f*t,y:this._y+e+5+n,anchor:["center","top"]});u.push(p)}))}o.styles.fillColor=s,this.addChild(o);for(let t of u)this.addChild(t);for(let t of h)this.addChild(t)}}class sT extends AS{constructor(t,e,n,r){super(r),this._elems=t,this._attribute=n,this._channel=e,this._posArg="x"==this._channel||"width"==this._channel?r.pathY:r.pathX,this._labelAttribute=r.labelAttribute,this._orientation="orientation"in r?r.orientation:"x"===this._channel||"width"==this._channel?TS:CS,this._titleText="title"in r?r.title:this._attribute,this._path="angle"===this._channel?new lS({strokeColor:this._strokeColor,id:this._id+"_path"}):new KA({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(r),Jw(this._elems[0].dataScope).type(this._attribute)!==Vw.Date||"labelFormat"in r||(this._labelFormat="%m/%d/%y")}get elements(){if(this.layout.type===HE.CLUSTER){const t=new Map(this._elems.map(t=>[t.datum[xE],t]));return this.layout._d3Root.leaves().map(e=>t.get(e.data[xE]))}return this._elems}get layout(){return this._elems[0].parent.layout}createTicksLabels(t){"tickValues"in t?(this._tickValues=t.tickValues,this._labelValues=t.tickValues):(this._tickValues=this.elements.map(t=>t.datum[this._labelAttribute?this._labelAttribute:this._attribute]),this._labelValues=this._tickValues),this._ticks.removeAll();for(let t=0;t<this._tickValues.length;t++){let e=new KA({strokeColor:this._strokeColor,id:this._id+"_tick"+t});this._tickVisible||(e.visibility="hidden"),this._ticks.addChild(e)}let e;switch(this._labels.removeAll(),Jw(this._elems[0].dataScope).type(this._labelAttribute?this._labelAttribute:this._attribute)){case Vw.Date:e=ny(this._labelFormat);break;case Vw.String:e=function(t){return t};break;default:e=Hl(this._labelFormat)}for(let[t,n]of this._labelValues.entries()){let r=new _S({text:e(n),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+t});this._labels.addChild(r)}this._title._text=this._titleText}}class oT extends PA{constructor(t){super(),this._type=Pw.Composite,this._id=t&&t.id?t.id:this._type+Dw()}addChild(t){let e=t.parent;super.addChild(t);let n=aA(t)._depGraph;e&&wA(e,t,n),EA(this,t,n)}}function aT(t,e){let n;switch(e.type){case"collection":n=cT(e);break;case"glyph":n=function(t){let e=new DA(t);return e}(e);break;case"axis":n=function(t){if("encoding"===t.axisType){return new RS(t.enc,t.scale,t.elems,t)}if("layout"===t.axisType){return new sT(t.elems,t.channel,t.attribute,t)}}(e);break;case"legend":n=function(t){let e="string"===t.attrType?new rT(t.enc,t):new iT(t.enc,t);return e}(e);break;case"composite":n=function(t){let e=new oT(t);return e}(e);break;default:n=lT(e)}return t.addChild(n),t._itemMap[n.id]=n,n}function lT(t){let e=null;switch(t.type){case Pw.Circle:e=new lS(t);break;case Pw.Line:var n="x1"in t?t.x1:0,r="y1"in t?t.y1:0,i="x2"in t?t.x2:100,s="y2"in t?t.y2:100;t.vertices=[[n,r],[i,s]],e=new hS(t);break;case Pw.Rect:var o="top"in t?t.top:0,a="left"in t?t.left:0,l="width"in t?t.width:50,c="height"in t?t.height:30;t.vertices=[[a,o],[a+l,o],[a+l,o+c],[a,o+c]],e=new yS(t);break;case Pw.SimpleText:e=new _S(t);break;case Pw.RichText:e=new bS(t);break;case Pw.Image:e=new cS(t);break;case Pw.Symbol:e=new uS(t);break;case Pw.BundledPath:case Pw.Chord:case Pw.Path:e=new KA(t);break;case Pw.Arrow:e=new pS(t);break;case Pw.Area:e=new oS(t);break;case Pw.Ring:e=new mS(t);break;case Pw.Arc:e=new eS(t);break;case Pw.BezierCurve:"vertices"in t||(t.vertices=[[0,100],[20,120],[80,180],[100,200]]),e=new aS(t);break;case Pw.Polygon:e=new gS(t)}return e&&e._updateBounds(),e}function cT(t){return new LA(t)}function uT(t){switch(t.type){case Pw.Collection:return function(t){let e=cT({});for(let n=0;n<t.children.length;n++){let r=t.children[n];e.addChild(uT(r))}if(e._classId=t.classId,t._layout){let n=t._layout.clone();e._layout=n,n.group=e}return e._updateBounds(),t.scene._itemMap[e.id]=e,e}(t);case Pw.Glyph:return function(t){let e=new DA;for(let n of t.children)e.addChild(uT(n));e._classId=t.classId,t.dataScope&&(e.dataScope=t.dataScope);return t.scene._itemMap[e.id]=e,e}(t);default:return function(t){let e=lT({type:t.type});t.copyPropertiesTo(e),e._classId=t.classId,e._bounds=t.bounds.clone(),t._refBounds||(t._refBounds=t.bounds.clone());if(e._refBounds=t._refBounds.clone(),t.vertices)for(let n=0;n<t.vertices.length;n++)t.vertices[n].dataScope&&(e.vertices[n].dataScope=t.vertices[n].dataScope);return t.scene._itemMap[e.id]=e,e}(t)}}class hT extends XE{constructor(t,e){super(t),this._elem=e}get element(){return this._elem}}class fT extends XE{constructor(t,e){super(t),this._item=e}get element(){return this._item}}class dT{constructor(t){this._id=t+"_"+Dw(),this._type=t,this._vars=[],this._edges=[]}get vars(){return this._vars}get edges(){return this._edges}run(){console.log("-",this._type)}}class pT{constructor(t,e,n=!0){this._id="e_"+Dw(),this._fromNode=t,this._toNode=e,this._isDirected=n}get id(){return this._id}get fromNode(){return this._fromNode}get toNode(){return this._toNode}get isDirected(){return this._isDirected}get operator(){return this._fromNode instanceof qE||this._fromNode instanceof dT?this._fromNode:this._toNode}}class _T extends XE{constructor(t,e){super(t),this._encs={},this._encs[e.channel+"_"+BS(e.element)]=e,this._initialized=!1}addLinkedEncoding(t){this._encs[t.channel+"_"+BS(t.element)]=t}getEncoding(t,e){let n=t+"_"+BS(e);return this._encs[n]}get encodings(){return Object.values(this._encs)}get initialized(){return this._initialized}set initialized(t){this._initialized=t}}class gT extends XE{constructor(t,e){super(t),this._encs=[e],this._valueMap={}}addLinkedEncoding(t){this._encs.push(t)}get encodings(){return this._encs}get attrValues(){return this._valueMap}set attrValues(t){this._valueMap=t}}function yT(t){if("number"!=typeof t.radius)throw new Error('Mascot: encode(..., "polarRadius", ...) needs an explicit {rangeExtent: N} (or {range: [...]}) option because the encoded shape has no fixed radius of its own -- e.g. it came from densify() on a "line" mark rather than a "circle".');return t.radius}class mT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof gT),e=this.outputVar,n=e.encodings,r=n[0],i=r.channel,s=r.attribute,o=t.encodings[0].dataTable.type(t.encodings[0].attribute),a=Object.values(t.attrValues);if("angle"===r.channel&&[Pw.Arc,Pw.Pie].indexOf(r.element.type)>=0)for(let e of t.encodings)for(let t of e.scales){let n=e.getElements(t).map(t=>e.attrValues[t.id]);t.domain=r._preferredDomain?r._preferredDomain:e.dataTable.tree?[0,e.dataTable.tree.getRoot()[s]]:this._getDomainForNumbers(n),console.log("domain for",s,t.domain)}else{let e;e=r._preferredDomain?r._preferredDomain:o==Vw.String||"text"===t.encodings[0].channel?this._getDomainForStrings(a):this._getDomainForNumbers(a);for(let n of t.encodings)for(let t of n.scales)t.domain=e.slice()}for(let t=0;t<r.scales.length;t++){let s=r.scales[t],o=r.getElements(s),a=this._buildRange(i,o,r,e);if(a)for(let e of n)e.scales[t].range=a}e.initialized=!0}_getDomainForNumbers(t){let e=this.outputVar.encodings[0],n=[et(t),Q(t)];if(e.includeZero&&n[0]>0&&(n=[0,Q(t)]),e.mapping)n=Object.keys(e.mapping),n=n.map(t=>parseFloat(t)),n.sort((t,e)=>t-e);else if("sequentialColor"===e.scales[0].type){if(n[0]<0&&n[1]>0){let t=Math.max(Math.abs(n[0]),Math.abs(n[1]));n=[-t,t]}}else if("angle"===e.channel){let e=Object.values(t).reduce((t,e)=>t+e,0);n=[0,e]}return n}_getDomainForStrings(t){let e,n=this.outputVar,r=n.encodings[0];return e="count"==n.encodings[0].aggregator?[0,Math.max(...t)]:Array.from(new Set(t)),r.mapping&&(e=Object.keys(r.mapping)),e}_buildRange(t,e,n,r){if(n._preferredRange)return n._preferredRange;if("x"===t)return this._buildXRange(e,n,r);if("y"===t)return this._buildYRange(e,n,r);if(["width","height","radius","area","fontSize","polarRadius","strokeWidth"].includes(t))return this._buildSizeRange(e,n,r);if(t.indexOf("Color")>0||"fillGradient"===t||"strokeGradient"===t)return this._buildColorRange(e,n);if("angle"===t)return this._buildAngleRange(e,n);if("polarAngle"===t)return[0,360];if("thickness"===t)return this._buildThicknessRange(e,n,r);if("src"===t||"path"===t){let t=n.scales[0].domain;return n.mapping?t.map(t=>n.mapping[t+""]):t.slice()}}_buildThicknessRange(t,e,n){let r=t.map(t=>t.outerRadius-t.innerRadius);return[0,n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:Math.max(...r)]}_buildAngleRange(t,e){return[0,360]}_buildColorRange(t,e){if(e.mapping){return e.scales[0].domain.map(t=>e.mapping[t+""])}if("sequentialColor"===e.scales[0].type){let t=this.outputVar,n=e.scales[0].domain;for(let r of t.encodings)if(!e.colorScheme)for(let t of r.scales){let e=t.domain;t._scale=Im(n[0]<0&&n[1]>0?rb:rv),t._scale.domain(e)}}if((NS.indexOf(e.colorScheme)>=0||IS.indexOf(e.colorScheme)>=0)&&"ordinalColor"===e.scales[0].type){let t=this.outputVar,n=e.scales[0].domain;for(let r of t.encodings)for(let t of r.scales){let r=t.domain;t._scale=t_(Nw[e.colorScheme][n.length]),t._scale.domain(r)}}}_buildSizeRange(t,e,n){let r,i;if(r=0,"vertexIndices"===t.type){let r=tA(t.groups[0].parent,t.groups[0].indices[0]);return i=n.initialized?e._elem2scale[r].rangeExtent:e._preferredRangeExtent?e._preferredRangeExtent:Math.max(...this._getVertexIndexSizeValues(t,e.channel)),[0,0+i]}return i=n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:Math.max(...t.map(t=>"radius"===e.channel?t.refBounds.width/2:"strokeWidth"===e.channel?t.strokeWidth:"polarRadius"===e.channel?yT(t.parent):"area"===e.channel?t.type===Pw.Circle?Math.PI*Math.pow(t.radius,2):t.width*t.height:"fontSize"===e.channel?parseFloat(t.fontSize):t.refBounds[e.channel])),[0,0+i]}_getVertexIndexSizeValues(t,e){let n=[];for(let r of t.groups){let t=r.parent._vertices;for(let i of r.indices)n.push("radius"===e?t._radii[i]:"strokeWidth"===e?t._strokeWidths[i]:"polarRadius"===e?yT(r.parent):"width"===e?t._widths[i]:"height"===e?t._heights[i]:0)}return n}_buildXRange(t,e,n){let r,i,s=e.scales[0].type;if("vertexIndices"===t.type){let s=t.groups[0].parent,o=tA(s,t.groups[0].indices[0]),a=s.refBounds?s.refBounds:s.bounds;return r=n.initialized?et(e._elem2scale[o].range):a.left,i=n.initialized?e._elem2scale[o].rangeExtent:e._preferredRangeExtent?e._preferredRangeExtent:a.width,e.flipScale?[r+i,r]:[r,r+i]}switch(t[0].type){case"vertex":case"segment":var o=t[0].parent.refBounds?t[0].parent.refBounds:t[0].parent.bounds;r=n.initialized?e.getRangeStart(t[0]):o.left,i=n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:o.width;break;default:r=n.initialized?e.getRangeStart(t[0]):e._preferredRangeStart?e._preferredRangeStart:lA(t[0]).bounds.left+t[0].bounds.width/2,i="band"===s?t[0].bounds.width*e.scales[0].domain.length:n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:Q([450,Q(t.map(t=>t.bounds.x))-et(t.map(t=>t.bounds.x))])}return e.flipScale?[r+i,r]:[r,r+i]}_buildYRange(t,e,n){let r,i;if(e.scales[0].type,"vertexIndices"===t.type){let s=t.groups[0].parent,o=tA(s,t.groups[0].indices[0]),a=s.refBounds?s.refBounds:s.bounds;return r=n.initialized?et(e._elem2scale[o].range):a.top,i=n.initialized?e._elem2scale[o].rangeExtent:e._preferredRangeExtent?e._preferredRangeExtent:a.height,e.flipScale?[r,r+i]:[r+i,r]}switch(t[0].type){case"vertex":case"segment":var s=t[0].parent.refBounds?t[0].parent.refBounds:t[0].parent.bounds;r=n.initialized?e.getRangeStart(t[0]):s.top,i=n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:s.height;break;default:r=n.initialized?e.getRangeStart(t[0]):lA(t[0]).bounds.top+t[0].bounds.height/2,i=n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:450}return e.flipScale?[r,r+i]:[r+i,r]}}class bT extends qE{constructor(t){super(t)}run(){super.run()}}class vT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof dA&&t.property==gA.AXIS_ORIENTATION).element;t.createTicksLabels(t._args),t instanceof RS?this._runForEncoding(t):t instanceof sT&&this._runForLayout(t),BE(t._path)}_runForLayout(t){let e=t.channel,n=t.elements[0].parent.layout&&t.elements[0].parent.layout.type==HE.STACK?VE(t.elements):DE(t.elements),r=[];if("x"===e){let e=t.orientation===SS?n.top-2:n.bottom+2;t._pathPos=t._posArg?t._posArg:e,r.push([n.left,t._pathPos]),r.push([n.right,t._pathPos]),t._path.vertices=r}else if("y"===e){let e=t.orientation===CS?n.left-2:n.right+2;t._pathPos=t._posArg?t._posArg:e,r.push([t._pathPos,n.top]),r.push([t._pathPos,n.bottom]),t._path.vertices=r}else if("angle"===e){let e=t.elements[0].parent.layout;e.type===HE.CLUSTER&&(t._path._x=e.x,t._path._y=e.y,t._path._radius=e.radius)}}_runForEncoding(t){let e=t.channel,n=t.elements,r=n[0].parent.layout&&n[0].parent.layout.type==HE.STACK?VE(n):DE(n),i=[],s=lA(n[0]);if(s&&s.clipMask&&(r=s.clipMask),"x"===e){let e,s,o=VS(n[0],"y");o?(e=Math.min(...o.getScale(n[0]).range,r.top),s=Math.max(...o.getScale(n[0]).range,r.bottom)):(e=r.top,s=r.bottom);let a=t.orientation===SS?e-2:s+2;t._pathPos=t._posArg?t._posArg:a,i.push([t.scale.range[0],t._pathPos]),i.push([t.scale.range[1],t._pathPos])}else if("width"===e){let e=t.orientation===SS?r.top-2:r.bottom+2;t._pathPos=t._posArg?t._posArg:e,i.push([r.left,t._pathPos]),i.push([r.right,t._pathPos])}else if("polarRadius"===e){let[e,n]=t.origin;t._pathPos=t._posArg?t._posArg:n,i.push([t.scale.range[0]+e,t._pathPos]),i.push([t.scale.range[1]+e,t._pathPos])}else{if("polarAngle"===e){let[e,n]=t.origin;return t._path._x=e,t._path._y=n,void(t._path._radius=t.radius)}if("y"===e){let e,s,o=VS(n[0],"x");o?(e=Math.min(...o.getScale(n[0]).range,r.left),s=Math.max(...o.getScale(n[0]).range,r.right)):(e=r.left,s=r.right);let a=t.orientation===CS?e-2:s+2;t._pathPos=t._posArg?t._posArg:a,i.push([t._pathPos,t.scale.range[0]]),i.push([t._pathPos,t.scale.range[1]])}else if("height"===e){let e=t.orientation===CS?r.left-2:r.right+2;t._pathPos=t._posArg?t._posArg:e,i.push([t._pathPos,r.bottom]),i.push([t._pathPos,r.top])}}t._path.vertices=i}}class xT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof dA&&t.property==gA.AXIS_PATH_POSITION).element;t instanceof RS?this._runForEncoding(t):t instanceof sT&&this._runForLayout(t);let e=[];if("width"===t.channel||"x"===t.channel){let n=t._ticks.children.map(t=>t.vertices[0].x),r=[t._path.vertices[0].x,t._path.vertices[1].x];e.push([d3.min(n.concat(r)),t._path.vertices[0].y]),e.push([d3.max(n.concat(r)),t._path.vertices[0].y]),t._path.vertices=e}else if("height"===t.channel||"y"===t.channel){let n=t._ticks.children.map(t=>t.vertices[0].y),r=[t._path.vertices[0].y,t._path.vertices[1].y];e.push([t._pathPos,d3.min(n.concat(r))]),e.push([t._pathPos,d3.max(n.concat(r))]),t._path.vertices=e}for(let e of t._ticks.children)e._updateBounds();BE(t._ticks)}_runForLayout(t){let e=t.channel;if("x"==e){let e=t.orientation==TS?t._pathPos+t.tickOffset:t._pathPos-t.tickOffset,n=t.orientation==TS?t.tickSize:-t.tickSize;for(let[r,i]of t._ticks.children.entries()){let s=t.elements[r].bounds[t.tickAnchor];i.vertices=[[s,e],[s,e+n]]}}else if("y"===e){let e=t.orientation==CS?t._pathPos-t.tickOffset:t._pathPos+t.tickOffset,n=t.orientation==CS?-t.tickSize:t.tickSize;for(let[r,i]of t._ticks.children.entries()){let s=t.elements[r].bounds[t.tickAnchor];i.vertices=[[e,s],[e+n,s]]}}else if("angle"===e){let e=t.elements[0].parent.layout;if(e.type===HE.CLUSTER){let n=e._d3Root.leaves();const r=new Map(n.map(t=>[t.data[xE],[t.x,t.y]]));for(let[n,i]of t._ticks.children.entries()){let s=t.elements[n].datum[xE],o=rS(r.get(s)[0])-90;i.vertices=[[e.x+r.get(s)[1]+t.elements[n].bounds.width/2,e.y],[e.x+r.get(s)[1]+t.elements[n].bounds.width/2+t.tickSize,e.y]],i._rotate=[o,e.x,e.y]}}}}_runForEncoding(t){let e=t.channel,n=DE(t.elements);if("x"==e){let e=t.orientation==TS?t._pathPos+t.tickOffset:t._pathPos-t.tickOffset,n=t.orientation==TS?t.tickSize:-t.tickSize;for(let[r,i]of t._ticks.children.entries())i.vertices=[[t.scale.map(t._tickValues[r]),e],[t.scale.map(t._tickValues[r]),e+n]]}else if("width"==e){let e=t.orientation==TS?t._pathPos+t.tickOffset:t._pathPos-t.tickOffset,r=t.orientation==TS?t.tickSize:-t.tickSize;if(!!(t.isFlipped()||t.elements[0].type===Pw.Area&&"right"===t.elements[0].baseline))for(let[i,s]of t._ticks.children.entries())s.vertices=[[n.left+t.scale.rangeExtent-t.scale.map(t._tickValues[i]),e],[n.left+t.scale.rangeExtent-t.scale.map(t._tickValues[i]),e+r]];else for(let[i,s]of t._ticks.children.entries())s.vertices=[[t.scale.map(t._tickValues[i])+n.left,e],[t.scale.map(t._tickValues[i])+n.left,e+r]]}else if("y"===e){let e=t.orientation==CS?t._pathPos-t.tickOffset:t._pathPos+t.tickOffset,n=t.orientation==CS?-t.tickSize:t.tickSize;for(let[r,i]of t._ticks.children.entries())i.vertices=[[e,t.scale.map(t._tickValues[r])],[e+n,t.scale.map(t._tickValues[r])]]}else if("height"===e){let e=t.orientation==CS?t._pathPos-t.tickOffset:t._pathPos+t.tickOffset,r=t.orientation==CS?-t.tickSize:t.tickSize;if(!!(t.isFlipped()||t.elements[0].type===Pw.Area&&"top"===t.elements[0].baseline))for(let[i,s]of t._ticks.children.entries())s.vertices=[[e,n.top+t.scale.map(t._tickValues[i])],[e+r,n.top+t.scale.map(t._tickValues[i])]];else for(let[i,s]of t._ticks.children.entries()){let o=n.bottom-t.scale.map(t._tickValues[i]);s.vertices=[[e,o],[e+r,o]]}}else if("polarRadius"===e){let e=t.orientation==TS?t._pathPos+t.tickOffset:t._pathPos-t.tickOffset,n=t.orientation==TS?t.tickSize:-t.tickSize,[r]=t.origin;for(let[i,s]of t._ticks.children.entries())s.vertices=[[r+t.scale.map(t._tickValues[i]),e],[r+t.scale.map(t._tickValues[i]),e+n]]}else if("polarAngle"===e){let[e,n]=t.origin,r=t.radius-t.tickSize/2,i=t.radius+t.tickSize/2;for(let[s,o]of t._ticks.children.entries()){let a=t.scale.map(t._tickValues[s])*Math.PI/180;o.vertices=[[e+r*Math.cos(a),n-r*Math.sin(a)],[e+i*Math.cos(a),n-i*Math.sin(a)]]}}}}class wT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof dA&&t.property==gA.AXIS_PATH_POSITION).element;t instanceof RS?this._runForEncoding(t):t instanceof sT&&this._runForLayout(t);for(let e of t._labels.children)e._updateBounds();BE(t._labels)}_runForLayout(t){let e=t.channel;if("x"==e){let e=t.orientation==TS?t.labelOffset:-t.labelOffset,n=t.orientation==TS?[zE.CENTER,zE.TOP]:[zE.CENTER,zE.BOTTOM];for(let[r,i]of t._labels.children.entries()){let s=t.elements[r].bounds;i.x=s[t.tickAnchor],i._y=t._pathPos+e,i._anchor=n,t._labelRotation&&(i._rotate=[t._labelRotation,i.x,i.y],i._anchor=[zE.RIGHT,zE.MIDDLE])}}else if("y"===e){let e=t.orientation==CS?-t.labelOffset:t.labelOffset,n=t.orientation==CS?[zE.RIGHT,zE.MIDDLE]:[zE.LEFT,zE.MIDDLE];for(let[r,i]of t._labels.children.entries()){let s=t.elements[r].bounds;i.x=t._pathPos+e,i._y=t.tickAnchor==zE.MIDDLE?s.y:s[t.tickAnchor],i._anchor=n,t._labelRotation&&(i._rotate=[t._labelRotation,i.x,i.y],i._anchor=[zE.RIGHT,n[1]])}}else if("angle"===e){let e=t.elements[0].parent.layout;if(e.type===HE.CLUSTER){let n=e._d3Root.leaves();const r=new Map(n.map(t=>[t.data[xE],[t.x,t.y]]));let i=5;for(let[n,s]of t._labels.children.entries()){let o=t.elements[n].datum[xE];if(r.get(o)[0]<Math.PI){let a=rS(r.get(o)[0])-90;s._anchor=[zE.LEFT,zE.MIDDLE],s.x=e.x+r.get(o)[1]+t.elements[n].bounds.width/2+i,s._y=e.y,s._rotate=[a,e.x,e.y]}else{let a=rS(r.get(o)[0])+90;s._anchor=[zE.RIGHT,zE.MIDDLE],s.x=e.x-r.get(o)[1]-t.elements[n].bounds.width/2-i,s._y=e.y,s._rotate=[a,e.x,e.y]}}}}}_runForEncoding(t){let e=t.channel,n=DE(t.elements);if("x"==e){let e=t.orientation==TS?t.labelOffset:-t.labelOffset,n=t.orientation==TS?[zE.CENTER,zE.TOP]:[zE.CENTER,zE.BOTTOM];for(let[r,i]of t._labels.children.entries())i.x=t.scale.map(t.labelValues[r]),i._y=t._pathPos+e,i._anchor=n,t._labelRotation&&(i._rotate=[t._labelRotation,i.x,i.y],i._anchor=[zE.RIGHT,n[1]])}else if("width"===e){let e=t.orientation==TS?t.labelOffset:-t.labelOffset,r=t.orientation==TS?[zE.CENTER,zE.TOP]:[zE.CENTER,zE.BOTTOM],i=!!(t.isFlipped()||t.elements[0].type===Pw.Area&&"right"===t.elements[0].baseline);for(let[s,o]of t._labels.children.entries())o.x=i?n.left+t.scale.rangeExtent-t.scale.map(t.labelValues[s]):t.scale.map(t.labelValues[s])+n.left,o._y=t._pathPos+e,o._anchor=r,t._labelRotation&&(o._rotate=[t._labelRotation,o.x,o.y],o._anchor=[zE.RIGHT,r[1]])}else if("y"===e){let e=t.orientation==CS?-t.labelOffset:t.labelOffset,n=t.orientation==CS?[zE.RIGHT,zE.MIDDLE]:[zE.LEFT,zE.MIDDLE];for(let[r,i]of t._labels.children.entries())i.x=t._pathPos+e,i._y=t.scale.map(t.labelValues[r]),i._anchor=n,t._labelRotation&&(i._rotate=[t._labelRotation,i.x,i.y],i._anchor=[zE.RIGHT,n[1]])}else if("height"===e){let e=t.orientation==CS?-t.labelOffset:t.labelOffset,r=t.orientation==CS?[zE.RIGHT,zE.MIDDLE]:[zE.LEFT,zE.MIDDLE],i=t.elements[0].type===Pw.Area&&"top"===t.elements[0].baseline;for(let[s,o]of t._labels.children.entries())o.x=t._pathPos+e,o._y=i?n.top+t.scale.map(t.labelValues[s]):n.bottom-t.scale.map(t.labelValues[s]),o._anchor=r,t._labelRotation&&(o._rotate=[t._labelRotation,o.x,o.y],o._anchor=[zE.RIGHT,r[1]])}else if("polarRadius"==e){let e=t.orientation==TS?t.labelOffset:-t.labelOffset,n=t.orientation==TS?[zE.CENTER,zE.TOP]:[zE.CENTER,zE.BOTTOM],[r]=t.origin;for(let[i,s]of t._labels.children.entries())s.x=r+t.scale.map(t.labelValues[i]),s._y=t._pathPos+e,s._anchor=n,t._labelRotation&&(s._rotate=[t._labelRotation,s.x,s.y],s._anchor=[zE.RIGHT,n[1]])}else if("polarAngle"===e){let[e,n]=t.origin,r=t.radius+t.labelOffset;for(let[i,s]of t._labels.children.entries()){let o=t.scale.map(t.tickValues[i])*Math.PI/180;s.x=e+r*Math.cos(o),s._y=n-r*Math.sin(o),s._anchor=[zE.CENTER,zE.MIDDLE],t._labelRotation&&(s._rotate=[t._labelRotation,s.x,s.y])}}}}function ET(t,e){let n=t.getElements(e);return n&&"vertexIndices"===n.type?n.groups[0].parent:n[0]}class AT extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)return;let n=e._includeInvisible?t.children:t.children.filter(t=>"hidden"!==t.visibility);this.fillGrid(t,e,n),this.computeCellBounds(t,e,n),this.placeElements(t,e,n)}let n=cA(t,!0);for(let t of n)BE(t)}placeElements(t,e,n){let r=zS(t,"x"),i=zS(t,"y");for(let n=0;n<t.children.length;n++){let r=t.children[n],i=e.cellBounds[n];if(!i)continue;let s=0,o=0;switch(e._cellHorzAlignment){case zE.LEFT:s=i.left-r.refBounds.left;break;case zE.CENTER:s=i.x-r.refBounds.x;break;case zE.RIGHT:s=i.right-r.refBounds.right}switch(e._cellVertAlignment){case zE.TOP:o=i.top-r.refBounds.top;break;case zE.MIDDLE:o=i.y-r.refBounds.y;break;case zE.BOTTOM:o=i.bottom-r.refBounds.bottom}HS(r,s,o)}if(r.length>0)for(let t of r)for(let n of t.scales){let r=ET(t,n),i=e.getIndex(r);if(i<0||!e.cellBounds[i])continue;let s="point"===n.type?e.cellBounds[i].left+r.bounds.width/2:e.cellBounds[i].left,o=s+n.rangeExtent;n.range=n.range[0]<n.range[1]?[s,o]:[o,s]}if(i.length>0)for(let t of i)for(let n of t.scales){let r=ET(t,n),i=e.getIndex(r);if(i<0||!e.cellBounds[i])continue;let s="point"===n.type?e.cellBounds[i].top+r.bounds.height/2:e.cellBounds[i].top,o=s+n.rangeExtent;n.range=n.range[0]<n.range[1]?[s,o]:[o,s]}}fillGrid(t,e,n){let r=n.length,i=e._numCols?e._numCols:e._numRows?Math.ceil(r/e._numRows):1,s=e._numRows?e._numRows:Math.ceil(r/i);e._grid=new Array(s).fill(null).map(()=>new Array(i).fill(null));for(let o=0;o<r;o++){let r,a;switch(e._direction){case VA.RowFirst:r=Math.floor(o/i),a=o%i;break;case VA.ColumnFirst:r=o%s,a=Math.floor(o/s);break;default:throw new Error("Invalid fill direction. Use 'row_first' or 'column_first'.")}e._start.toLowerCase().includes("bottom")&&(r=s-1-r),e._start.toLowerCase().includes("right")&&(a=i-1-a);let l=t.children.indexOf(n[o]);e._grid[r][a]=l}}computeCellBounds(t,e,n){let r=n.map(t=>t.refBounds?t.refBounds:t.bounds),i=e._colGap,s=e._rowGap;if(void 0===e._left){let t=r.map(t=>t.left),n=r.map(t=>t.top);e._left=d3.min(t),e._top=d3.min(n)}let o=r.map(t=>t.width),a=r.map(t=>t.height),l=d3.max(o),c=d3.max(a);e._cellBounds=new Array(t.children.length).fill(null);let u=e._grid.length,h=u>0&&e._grid[0]?e._grid[0].length:0,f=e._rowOffset||0,d=e._colOffset||0;for(let n=0;n<u;n++)for(let r=0;r<h;r++){let o=e._grid[n][r];if(null==o||o>=t.children.length)continue;let a=e._left+(l+i)*r+(n%2==1?f:0),u=e._top+(c+s)*n+(r%2==1?d:0);e._cellBounds[o]=new PE(a,u,l,c)}}}function ST(t,e,n,r){return[n*Math.cos(nS(r))+t,e-n*Math.sin(nS(r))]}function TT(t,e,n,r){switch(e){case"x":kT(t,n);break;case"y":RT(t,n);break;case"width":!function(t,e){t.resize(e,t.height)}(t,n);break;case"height":!function(t,e){t.resize(t.width,e)}(t,n);break;case"radius":t.radius=n;break;case"strength":t._strength=n;break;case"area":t.type===Pw.Circle?t.radius=Math.sqrt(n/Math.PI):t.type===Pw.Rect&&t.resize(Math.sqrt(n),Math.sqrt(n)),t._updateBounds();break;case"text":t._text=n;break;case"curveMode":t.curveMode=n;break;case"baseline":t.baseline=n;break;case"angle":[Pw.Arc,Pw.Pie].includes(t.type)&&function(t,e){t._endAngle=iS(t._startAngle+e),t._sr=nS(t._startAngle),t._er=nS(t._endAngle),t.vertices[0].x=t._x+t._innerRadius*Math.cos(t._sr),t.vertices[0].y=t._y-t._innerRadius*Math.sin(t._sr),t.vertices[1].x=t._x+t._outerRadius*Math.cos(t._sr),t.vertices[1].y=t._y-t._outerRadius*Math.sin(t._sr),t.vertices[2].x=t._x+t._outerRadius*Math.cos(t._er),t.vertices[2].y=t._y-t._outerRadius*Math.sin(t._er),t.vertices[3].x=t._x+t._innerRadius*Math.cos(t._er),t.vertices[3].y=t._y-t._innerRadius*Math.sin(t._er)}(t,n);break;case"startAngle":!function(t,e){let n=t.angle;t._startAngle=e,t._endAngle=iS(t._startAngle+n),t._sr=nS(t._startAngle),t._er=nS(t._endAngle),t.vertices[0].x=t._x+t._innerRadius*Math.cos(t._sr),t.vertices[0].y=t._y-t._innerRadius*Math.sin(t._sr),t.vertices[1].x=t._x+t._outerRadius*Math.cos(t._sr),t.vertices[1].y=t._y-t._outerRadius*Math.sin(t._sr),t.vertices[2].x=t._x+t._outerRadius*Math.cos(t._er),t.vertices[2].y=t._y-t._outerRadius*Math.sin(t._er),t.vertices[3].x=t._x+t._innerRadius*Math.cos(t._er),t.vertices[3].y=t._y-t._innerRadius*Math.sin(t._er)}(t,n);break;case"thickness":!function(t,e){CT(t,t._innerRadius+e)}(t,n);break;case"innerRadius":!function(t,e){t._innerRadius=e,t.vertices[0].x=t._x+t._innerRadius*Math.cos(t._sr),t.vertices[0].y=t._y-t._innerRadius*Math.sin(t._sr),t.vertices[3].x=t._x+t._innerRadius*Math.cos(t._er),t.vertices[3].y=t._y-t._innerRadius*Math.sin(t._er)}(t,n);break;case"outerRadius":CT(t,n);break;case"polarAngle":
1
+ // version: 4.4.1
2
+ "use strict";function t(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function e(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function n(n){let i,s,o;function a(t,e,n=0,r=t.length){if(n<r){if(0!==i(e,e))return r;do{const i=n+r>>>1;s(t[i],e)<0?n=i+1:r=i}while(n<r)}return n}return 2!==n.length?(i=t,s=(e,r)=>t(n(e),r),o=(t,e)=>n(t)-e):(i=n===t||n===e?n:r,s=n,o=n),{left:a,center:function(t,e,n=0,r=t.length){const i=a(t,e,n,r-1);return i>n&&o(t[i-1],e)>-o(t[i],e)?i-1:i},right:function(t,e,n=0,r=t.length){if(n<r){if(0!==i(e,e))return r;do{const i=n+r>>>1;s(t[i],e)<=0?n=i+1:r=i}while(n<r)}return n}}}function r(){return 0}function i(t){return null===t?NaN:+t}const s=n(t),o=s.right,a=s.left,l=n(i).center;const c=h(p),u=h(function(t){const e=p(t);return(t,n,r,i,s)=>{e(t,n,(r<<=2)+0,(i<<=2)+0,s<<=2),e(t,n,r+1,i+1,s),e(t,n,r+2,i+2,s),e(t,n,r+3,i+3,s)}});function h(t){return function(e,n,r=n){if(!((n=+n)>=0))throw new RangeError("invalid rx");if(!((r=+r)>=0))throw new RangeError("invalid ry");let{data:i,width:s,height:o}=e;if(!((s=Math.floor(s))>=0))throw new RangeError("invalid width");if(!((o=Math.floor(void 0!==o?o:i.length/s))>=0))throw new RangeError("invalid height");if(!s||!o||!n&&!r)return e;const a=n&&t(n),l=r&&t(r),c=i.slice();return a&&l?(f(a,c,i,s,o),f(a,i,c,s,o),f(a,c,i,s,o),d(l,i,c,s,o),d(l,c,i,s,o),d(l,i,c,s,o)):a?(f(a,i,c,s,o),f(a,c,i,s,o),f(a,i,c,s,o)):l&&(d(l,i,c,s,o),d(l,c,i,s,o),d(l,i,c,s,o)),e}}function f(t,e,n,r,i){for(let s=0,o=r*i;s<o;)t(e,n,s,s+=r,1)}function d(t,e,n,r,i){for(let s=0,o=r*i;s<r;++s)t(e,n,s,s+o,r)}function p(t){const e=Math.floor(t);if(e===t)return function(t){const e=2*t+1;return(n,r,i,s,o)=>{if(!((s-=o)>=i))return;let a=t*r[i];const l=o*t;for(let t=i,e=i+l;t<e;t+=o)a+=r[Math.min(s,t)];for(let t=i,c=s;t<=c;t+=o)a+=r[Math.min(s,t+l)],n[t]=a/e,a-=r[Math.max(i,t-l)]}}(t);const n=t-e,r=2*t+1;return(t,i,s,o,a)=>{if(!((o-=a)>=s))return;let l=e*i[s];const c=a*e,u=c+a;for(let t=s,e=s+c;t<e;t+=a)l+=i[Math.min(o,t)];for(let e=s,h=o;e<=h;e+=a)l+=i[Math.min(o,e+c)],t[e]=(l+n*(i[Math.max(s,e-u)]+i[Math.min(o,e+u)]))/r,l-=i[Math.max(s,e-c)]}}function _(t,e){let n=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&++n;else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(i=+i)>=i&&++n}return n}function g(t){return 0|t.length}function y(t){return!(t>0)}function m(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function b(t,e){let n,r=0,i=0,s=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(n=e-i,i+=n/++r,s+=n*(e-i));else{let o=-1;for(let a of t)null!=(a=e(a,++o,t))&&(a=+a)>=a&&(n=a-i,i+=n/++r,s+=n*(a-i))}if(r>1)return s/(r-1)}function v(t,e){const n=b(t,e);return n?Math.sqrt(n):n}function x(t,e){let n,r;if(void 0===e)for(const e of t)null!=e&&(void 0===n?e>=e&&(n=r=e):(n>e&&(n=e),r<e&&(r=e)));else{let i=-1;for(let s of t)null!=(s=e(s,++i,t))&&(void 0===n?s>=s&&(n=r=s):(n>s&&(n=s),r<s&&(r=s)))}return[n,r]}class w{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const e=this._partials;let n=0;for(let r=0;r<this._n&&r<32;r++){const i=e[r],s=t+i,o=Math.abs(t)<Math.abs(i)?t-(s-i):i-(s-t);o&&(e[n++]=o),t=s}return e[n]=t,this._n=n+1,this}valueOf(){const t=this._partials;let e,n,r,i=this._n,s=0;if(i>0){for(s=t[--i];i>0&&(e=s,n=t[--i],s=e+n,r=n-(s-e),!r););i>0&&(r<0&&t[i-1]<0||r>0&&t[i-1]>0)&&(n=2*r,e=s+n,n==e-s&&(s=e))}return s}}class E extends Map{constructor(t,e=k){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(S(this,t))}has(t){return super.has(S(this,t))}set(t,e){return super.set(T(this,t),e)}delete(t){return super.delete(C(this,t))}}class A extends Set{constructor(t,e=k){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const e of t)this.add(e)}has(t){return super.has(S(this,t))}add(t){return super.add(T(this,t))}delete(t){return super.delete(C(this,t))}}function S({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function T({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function C({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function k(t){return null!==t&&"object"==typeof t?t.valueOf():t}function R(t){return t}function M(t,...e){return D(t,R,R,e)}function O(t,...e){return D(t,Array.from,R,e)}function N(t,e){for(let n=1,r=e.length;n<r;++n)t=t.flatMap(t=>t.pop().map(([e,n])=>[...t,e,n]));return t}function I(t,e,...n){return D(t,R,e,n)}function P(t,e,...n){return D(t,Array.from,e,n)}function L(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function D(t,e,n,r){return function t(i,s){if(s>=r.length)return n(i);const o=new E,a=r[s++];let l=-1;for(const t of i){const e=a(t,++l,i),n=o.get(e);n?n.push(t):o.set(e,[t])}for(const[e,n]of o)o.set(e,t(n,s));return e(o)}(t,0)}function V(t,e){return Array.from(e,e=>t[e])}function B(t,...e){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");t=Array.from(t);let[n]=e;if(n&&2!==n.length||e.length>1){const r=Uint32Array.from(t,(t,e)=>e);return e.length>1?(e=e.map(e=>t.map(e)),r.sort((t,n)=>{for(const r of e){const e=G(r[t],r[n]);if(e)return e}})):(n=t.map(n),r.sort((t,e)=>G(n[t],n[e]))),V(t,r)}return t.sort(z(n))}function z(e=t){if(e===t)return G;if("function"!=typeof e)throw new TypeError("compare is not a function");return(t,n)=>{const r=e(t,n);return r||0===r?r:(0===e(n,n))-(0===e(t,t))}}function G(t,e){return(null==t||!(t>=t))-(null==e||!(e>=e))||(t<e?-1:t>e?1:0)}var F=Array.prototype.slice;function j(t){return()=>t}const U=Math.sqrt(50),Y=Math.sqrt(10),H=Math.sqrt(2);function W(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),o=s>=U?10:s>=Y?5:s>=H?2:1;let a,l,c;return i<0?(c=Math.pow(10,-i)/o,a=Math.round(t*c),l=Math.round(e*c),a/c<t&&++a,l/c>e&&--l,c=-c):(c=Math.pow(10,i)*o,a=Math.round(t/c),l=Math.round(e/c),a*c<t&&++a,l*c>e&&--l),l<a&&.5<=n&&n<2?W(t,e,2*n):[a,l,c]}function q(t,e,n){if(!((n=+n)>0))return[];if((t=+t)===(e=+e))return[t];const r=e<t,[i,s,o]=r?W(e,t,n):W(t,e,n);if(!(s>=i))return[];const a=s-i+1,l=new Array(a);if(r)if(o<0)for(let t=0;t<a;++t)l[t]=(s-t)/-o;else for(let t=0;t<a;++t)l[t]=(s-t)*o;else if(o<0)for(let t=0;t<a;++t)l[t]=(i+t)/-o;else for(let t=0;t<a;++t)l[t]=(i+t)*o;return l}function $(t,e,n){return W(t=+t,e=+e,n=+n)[2]}function X(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?$(e,t,n):$(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function K(t,e,n){let r;for(;;){const i=$(t,e,n);if(i===r||0===i||!isFinite(i))return[t,e];i>0?(t=Math.floor(t/i)*i,e=Math.ceil(e/i)*i):i<0&&(t=Math.ceil(t*i)/i,e=Math.floor(e*i)/i),r=i}}function Z(t){return Math.max(1,Math.ceil(Math.log(_(t))/Math.LN2)+1)}function J(){var t=R,e=x,n=Z;function r(r){Array.isArray(r)||(r=Array.from(r));var i,s,a,l=r.length,c=new Array(l);for(i=0;i<l;++i)c[i]=t(r[i],i,r);var u=e(c),h=u[0],f=u[1],d=n(c,h,f);if(!Array.isArray(d)){const t=f,n=+d;if(e===x&&([h,f]=K(h,f,n)),(d=q(h,f,n))[0]<=h&&(a=$(h,f,n)),d[d.length-1]>=f)if(t>=f&&e===x){const t=$(h,f,n);isFinite(t)&&(t>0?f=(Math.floor(f/t)+1)*t:t<0&&(f=(Math.ceil(f*-t)+1)/-t))}else d.pop()}for(var p=d.length,_=0,g=p;d[_]<=h;)++_;for(;d[g-1]>f;)--g;(_||g<p)&&(d=d.slice(_,g),p=g-_);var y,m=new Array(p+1);for(i=0;i<=p;++i)(y=m[i]=[]).x0=i>0?d[i-1]:h,y.x1=i<p?d[i]:f;if(isFinite(a)){if(a>0)for(i=0;i<l;++i)null!=(s=c[i])&&h<=s&&s<=f&&m[Math.min(p,Math.floor((s-h)/a))].push(r[i]);else if(a<0)for(i=0;i<l;++i)if(null!=(s=c[i])&&h<=s&&s<=f){const t=Math.floor((h-s)*a);m[Math.min(p,t+(d[t]<=s))].push(r[i])}}else for(i=0;i<l;++i)null!=(s=c[i])&&h<=s&&s<=f&&m[o(d,s,0,p)].push(r[i]);return m}return r.value=function(e){return arguments.length?(t="function"==typeof e?e:j(e),r):t},r.domain=function(t){return arguments.length?(e="function"==typeof t?t:j([t[0],t[1]]),r):e},r.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:j(Array.isArray(t)?F.call(t):t),r):n},r}function Q(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n<e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n<i||void 0===n&&i>=i)&&(n=i)}return n}function tt(t,e){let n,r=-1,i=-1;if(void 0===e)for(const e of t)++i,null!=e&&(n<e||void 0===n&&e>=e)&&(n=e,r=i);else for(let s of t)null!=(s=e(s,++i,t))&&(n<s||void 0===n&&s>=s)&&(n=s,r=i);return r}function et(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n>e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n>i||void 0===n&&i>=i)&&(n=i)}return n}function nt(t,e){let n,r=-1,i=-1;if(void 0===e)for(const e of t)++i,null!=e&&(n>e||void 0===n&&e>=e)&&(n=e,r=i);else for(let s of t)null!=(s=e(s,++i,t))&&(n>s||void 0===n&&s>=s)&&(n=s,r=i);return r}function rt(t,e,n=0,r=1/0,i){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(i=void 0===i?G:z(i);r>n;){if(r-n>600){const s=r-n+1,o=e-n+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);rt(t,e,Math.max(n,Math.floor(e-o*l/s+c)),Math.min(r,Math.floor(e+(s-o)*l/s+c)),i)}const s=t[e];let o=n,a=r;for(it(t,n,e),i(t[r],s)>0&&it(t,n,r);o<a;){for(it(t,o,a),++o,--a;i(t[o],s)<0;)++o;for(;i(t[a],s)>0;)--a}0===i(t[n],s)?it(t,n,a):(++a,it(t,a,r)),a<=e&&(n=a+1),e<=a&&(r=a-1)}return t}function it(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function st(e,n=t){let r,i=!1;if(1===n.length){let s;for(const o of e){const e=n(o);(i?t(e,s)>0:0===t(e,e))&&(r=o,s=e,i=!0)}}else for(const t of e)(i?n(t,r)>0:0===n(t,t))&&(r=t,i=!0);return r}function ot(t,e,n){if(t=Float64Array.from(function*(t,e){if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(yield e);else{let n=-1;for(let r of t)null!=(r=e(r,++n,t))&&(r=+r)>=r&&(yield r)}}(t,n)),(r=t.length)&&!isNaN(e=+e)){if(e<=0||r<2)return et(t);if(e>=1)return Q(t);var r,i=(r-1)*e,s=Math.floor(i),o=Q(rt(t,s).subarray(0,s+1));return o+(et(t.subarray(s+1))-o)*(i-s)}}function at(t,e,n=i){if((r=t.length)&&!isNaN(e=+e)){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,s=(r-1)*e,o=Math.floor(s),a=+n(t[o],o,t);return a+(+n(t[o+1],o+1,t)-a)*(s-o)}}function lt(t,e,n=i){if(!isNaN(e=+e)){if(r=Float64Array.from(t,(e,r)=>i(n(t[r],r,t))),e<=0)return nt(r);if(e>=1)return tt(r);var r,s=Uint32Array.from(t,(t,e)=>e),o=r.length-1,a=Math.floor(o*e);return rt(s,a,0,o,(t,e)=>G(r[t],r[e])),(a=st(s.subarray(0,a+1),t=>r[t]))>=0?a:-1}}function ct(t,e){let n=0,r=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(++n,r+=e);else{let i=-1;for(let s of t)null!=(s=e(s,++i,t))&&(s=+s)>=s&&(++n,r+=s)}if(n)return r/n}function ut(t,e){return ot(t,.5,e)}function ht(t){return Array.from(function*(t){for(const e of t)yield*e}(t))}function ft(t,e){return[t,e]}function dt(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((e-t)/n)),s=new Array(i);++r<i;)s[r]=t+r*n;return s}function pt(e,n=t){if(1===n.length)return nt(e,n);let r,i=-1,s=-1;for(const t of e)++s,(i<0?0===n(t,t):n(t,r)<0)&&(r=t,i=s);return i}var _t=gt(Math.random);function gt(t){return function(e,n=0,r=e.length){let i=r-(n=+n);for(;i;){const r=t()*i--|0,s=e[i+n];e[i+n]=e[r+n],e[r+n]=s}return e}}function yt(t,e){let n=0;if(void 0===e)for(let e of t)(e=+e)&&(n+=e);else{let r=-1;for(let i of t)(i=+e(i,++r,t))&&(n+=i)}return n}function mt(t){if(!(i=t.length))return[];for(var e=-1,n=et(t,bt),r=new Array(n);++e<n;)for(var i,s=-1,o=r[e]=new Array(i);++s<i;)o[s]=t[s][e];return r}function bt(t){return t.length}function vt(t){return t instanceof A?t:new A(t)}function xt(t,e){const n=t[Symbol.iterator](),r=new Set;for(const t of e){const e=wt(t);if(r.has(e))continue;let i,s;for(;({value:i,done:s}=n.next());){if(s)return!1;const t=wt(i);if(r.add(t),Object.is(e,t))break}}return!0}function wt(t){return null!==t&&"object"==typeof t?t.valueOf():t}function Et(t){return t}var At=1e-6;function St(t){return"translate("+t+",0)"}function Tt(t){return"translate(0,"+t+")"}function Ct(t){return e=>+t(e)}function kt(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function Rt(){return!this.__axis}function Mt(t,e){var n=[],r=null,i=null,s=6,o=6,a=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,c=1===t||4===t?-1:1,u=4===t||2===t?"x":"y",h=1===t||3===t?St:Tt;function f(f){var d=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,p=null==i?e.tickFormat?e.tickFormat.apply(e,n):Et:i,_=Math.max(s,0)+a,g=e.range(),y=+g[0]+l,m=+g[g.length-1]+l,b=(e.bandwidth?kt:Ct)(e.copy(),l),v=f.selection?f.selection():f,x=v.selectAll(".domain").data([null]),w=v.selectAll(".tick").data(d,e).order(),E=w.exit(),A=w.enter().append("g").attr("class","tick"),S=w.select("line"),T=w.select("text");x=x.merge(x.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),w=w.merge(A),S=S.merge(A.append("line").attr("stroke","currentColor").attr(u+"2",c*s)),T=T.merge(A.append("text").attr("fill","currentColor").attr(u,c*_).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),f!==v&&(x=x.transition(f),w=w.transition(f),S=S.transition(f),T=T.transition(f),E=E.transition(f).attr("opacity",At).attr("transform",function(t){return isFinite(t=b(t))?h(t+l):this.getAttribute("transform")}),A.attr("opacity",At).attr("transform",function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:b(t))+l)})),E.remove(),x.attr("d",4===t||2===t?o?"M"+c*o+","+y+"H"+l+"V"+m+"H"+c*o:"M"+l+","+y+"V"+m:o?"M"+y+","+c*o+"V"+l+"H"+m+"V"+c*o:"M"+y+","+l+"H"+m),w.attr("opacity",1).attr("transform",function(t){return h(b(t)+l)}),S.attr(u+"2",c*s),T.attr(u,c*_).text(p),v.filter(Rt).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),v.each(function(){this.__axis=b})}return f.scale=function(t){return arguments.length?(e=t,f):e},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),f):n.slice()},f.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),f):r&&r.slice()},f.tickFormat=function(t){return arguments.length?(i=t,f):i},f.tickSize=function(t){return arguments.length?(s=o=+t,f):s},f.tickSizeInner=function(t){return arguments.length?(s=+t,f):s},f.tickSizeOuter=function(t){return arguments.length?(o=+t,f):o},f.tickPadding=function(t){return arguments.length?(a=+t,f):a},f.offset=function(t){return arguments.length?(l=+t,f):l},f}var Ot={value:()=>{}};function Nt(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new It(r)}function It(t){this._=t}function Pt(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Lt(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Ot,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}It.prototype=Nt.prototype={constructor:It,on:function(t,e){var n,r,i=this._,s=(r=i,(t+"").trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),o=-1,a=s.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o<a;)if(n=(t=s[o]).type)i[n]=Lt(i[n],t.name,e);else if(null==e)for(n in i)i[n]=Lt(i[n],t.name,null);return this}for(;++o<a;)if((n=(t=s[o]).type)&&(n=Pt(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new It(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),s=0;s<n;++s)i[s]=arguments[s+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=0,n=(r=this._[t]).length;s<n;++s)r[s].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,s=r.length;i<s;++i)r[i].value.apply(e,n)}};var Dt="http://www.w3.org/1999/xhtml",Vt={svg:"http://www.w3.org/2000/svg",xhtml:Dt,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Bt(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Vt.hasOwnProperty(e)?{space:Vt[e],local:t}:t}function zt(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Dt&&e.documentElement.namespaceURI===Dt?e.createElement(t):e.createElementNS(n,t)}}function Gt(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ft(t){var e=Bt(t);return(e.local?Gt:zt)(e)}function jt(){}function Ut(t){return null==t?jt:function(){return this.querySelector(t)}}function Yt(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function Ht(){return[]}function Wt(t){return null==t?Ht:function(){return this.querySelectorAll(t)}}function qt(t){return function(){return this.matches(t)}}function $t(t){return function(e){return e.matches(t)}}var Xt=Array.prototype.find;function Kt(){return this.firstElementChild}var Zt=Array.prototype.filter;function Jt(){return Array.from(this.children)}function Qt(t){return new Array(t.length)}function te(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function ee(t,e,n,r,i,s){for(var o,a=0,l=e.length,c=s.length;a<c;++a)(o=e[a])?(o.__data__=s[a],r[a]=o):n[a]=new te(t,s[a]);for(;a<l;++a)(o=e[a])&&(i[a]=o)}function ne(t,e,n,r,i,s,o){var a,l,c,u=new Map,h=e.length,f=s.length,d=new Array(h);for(a=0;a<h;++a)(l=e[a])&&(d[a]=c=o.call(l,l.__data__,a,e)+"",u.has(c)?i[a]=l:u.set(c,l));for(a=0;a<f;++a)c=o.call(t,s[a],a,s)+"",(l=u.get(c))?(r[a]=l,l.__data__=s[a],u.delete(c)):n[a]=new te(t,s[a]);for(a=0;a<h;++a)(l=e[a])&&u.get(d[a])===l&&(i[a]=l)}function re(t){return t.__data__}function ie(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function se(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function oe(t){return function(){this.removeAttribute(t)}}function ae(t){return function(){this.removeAttributeNS(t.space,t.local)}}function le(t,e){return function(){this.setAttribute(t,e)}}function ce(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ue(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function he(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function fe(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function de(t){return function(){this.style.removeProperty(t)}}function pe(t,e,n){return function(){this.style.setProperty(t,e,n)}}function _e(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ge(t,e){return t.style.getPropertyValue(e)||fe(t).getComputedStyle(t,null).getPropertyValue(e)}function ye(t){return function(){delete this[t]}}function me(t,e){return function(){this[t]=e}}function be(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function ve(t){return t.trim().split(/^|\s+/)}function xe(t){return t.classList||new we(t)}function we(t){this._node=t,this._names=ve(t.getAttribute("class")||"")}function Ee(t,e){for(var n=xe(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function Ae(t,e){for(var n=xe(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function Se(t){return function(){Ee(this,t)}}function Te(t){return function(){Ae(this,t)}}function Ce(t,e){return function(){(e.apply(this,arguments)?Ee:Ae)(this,t)}}function ke(){this.textContent=""}function Re(t){return function(){this.textContent=t}}function Me(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Oe(){this.innerHTML=""}function Ne(t){return function(){this.innerHTML=t}}function Ie(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function Pe(){this.nextSibling&&this.parentNode.appendChild(this)}function Le(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function De(){return null}function Ve(){var t=this.parentNode;t&&t.removeChild(this)}function Be(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function ze(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ge(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,s=e.length;r<s;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function Fe(t,e,n){return function(){var r,i=this.__on,s=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),void(r.value=e);this.addEventListener(t.type,s,n),r={type:t.type,name:t.name,value:e,listener:s,options:n},i?i.push(r):this.__on=[r]}}function je(t,e,n){var r=fe(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Ue(t,e){return function(){return je(this,t,e)}}function Ye(t,e){return function(){return je(this,t,e.apply(this,arguments))}}te.prototype={constructor:te,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)}},we.prototype={add:function(t){this._names.indexOf(t)<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}};var He=[null];function We(t,e){this._groups=t,this._parents=e}function qe(){return new We([[document.documentElement]],He)}function $e(t){return"string"==typeof t?new We([[document.querySelector(t)]],[document.documentElement]):new We([[t]],He)}We.prototype=qe.prototype={constructor:We,select:function(t){"function"!=typeof t&&(t=Ut(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s,o,a=e[i],l=a.length,c=r[i]=new Array(l),u=0;u<l;++u)(s=a[u])&&(o=t.call(s,s.__data__,u,a))&&("__data__"in s&&(o.__data__=s.__data__),c[u]=o);return new We(r,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){return Yt(t.apply(this,arguments))}}(t):Wt(t);for(var e=this._groups,n=e.length,r=[],i=[],s=0;s<n;++s)for(var o,a=e[s],l=a.length,c=0;c<l;++c)(o=a[c])&&(r.push(t.call(o,o.__data__,c,a)),i.push(o));return new We(r,i)},selectChild:function(t){return this.select(null==t?Kt:function(t){return function(){return Xt.call(this.children,t)}}("function"==typeof t?t:$t(t)))},selectChildren:function(t){return this.selectAll(null==t?Jt:function(t){return function(){return Zt.call(this.children,t)}}("function"==typeof t?t:$t(t)))},filter:function(t){"function"!=typeof t&&(t=qt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s,o=e[i],a=o.length,l=r[i]=[],c=0;c<a;++c)(s=o[c])&&t.call(s,s.__data__,c,o)&&l.push(s);return new We(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,re);var n=e?ne:ee,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var s=i.length,o=new Array(s),a=new Array(s),l=new Array(s),c=0;c<s;++c){var u=r[c],h=i[c],f=h.length,d=ie(t.call(u,u&&u.__data__,c,r)),p=d.length,_=a[c]=new Array(p),g=o[c]=new Array(p);n(u,h,_,g,l[c]=new Array(f),d,e);for(var y,m,b=0,v=0;b<p;++b)if(y=_[b]){for(b>=v&&(v=b+1);!(m=g[v])&&++v<p;);y._next=m||null}}return(o=new We(o,r))._enter=a,o._exit=l,o},enter:function(){return new We(this._enter||this._groups.map(Qt),this._parents)},exit:function(){return new We(this._exit||this._groups.map(Qt),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,s=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?s.remove():n(s),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,s=r.length,o=Math.min(i,s),a=new Array(i),l=0;l<o;++l)for(var c,u=n[l],h=r[l],f=u.length,d=a[l]=new Array(f),p=0;p<f;++p)(c=u[p]||h[p])&&(d[p]=c);for(;l<i;++l)a[l]=n[l];return new We(a,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],s=i.length-1,o=i[s];--s>=0;)(r=i[s])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=se);for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var o,a=n[s],l=a.length,c=i[s]=new Array(l),u=0;u<l;++u)(o=a[u])&&(c[u]=o);c.sort(e)}return new We(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,s=r.length;i<s;++i){var o=r[i];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,s=e[n],o=0,a=s.length;o<a;++o)(i=s[o])&&t.call(i,i.__data__,o,s);return this},attr:function(t,e){var n=Bt(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?ae:oe:"function"==typeof e?n.local?he:ue:n.local?ce:le)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?de:"function"==typeof e?_e:pe)(t,e,null==n?"":n)):ge(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?ye:"function"==typeof e?be:me)(t,e)):this.node()[t]},classed:function(t,e){var n=ve(t+"");if(arguments.length<2){for(var r=xe(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?Ce:e?Se:Te)(n,e))},text:function(t){return arguments.length?this.each(null==t?ke:("function"==typeof t?Me:Re)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Oe:("function"==typeof t?Ie:Ne)(t)):this.node().innerHTML},raise:function(){return this.each(Pe)},lower:function(){return this.each(Le)},append:function(t){var e="function"==typeof t?t:Ft(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var n="function"==typeof t?t:Ft(t),r=null==e?De:"function"==typeof e?e:Ut(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(Ve)},clone:function(t){return this.select(t?ze:Be)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,s=function(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),o=s.length;if(!(arguments.length<2)){for(a=e?Fe:Ge,r=0;r<o;++r)this.each(a(s[r],e,n));return this}var a=this.node().__on;if(a)for(var l,c=0,u=a.length;c<u;++c)for(r=0,l=a[c];r<o;++r)if((i=s[r]).type===l.type&&i.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?Ye:Ue)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],s=0,o=i.length;s<o;++s)(r=i[s])&&(yield r)}};var Xe=0;function Ke(){return new Ze}function Ze(){this._="@"+(++Xe).toString(36)}function Je(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Qe(t,e){if(t=Je(t),void 0===e&&(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())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}Ze.prototype=Ke.prototype={constructor:Ze,get:function(t){for(var e=this._;!(e in t);)if(!(t=t.parentNode))return;return t[e]},set:function(t,e){return t[this._]=e},remove:function(t){return this._ in t&&delete t[this._]},toString:function(){return this._}};const tn={passive:!1},en={capture:!0,passive:!1};function nn(t){t.stopImmediatePropagation()}function rn(t){t.preventDefault(),t.stopImmediatePropagation()}function sn(t){var e=t.document.documentElement,n=$e(t).on("dragstart.drag",rn,en);"onselectstart"in e?n.on("selectstart.drag",rn,en):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function on(t,e){var n=t.document.documentElement,r=$e(t).on("dragstart.drag",null);e&&(r.on("click.drag",rn,en),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var an=t=>()=>t;function ln(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:s,x:o,y:a,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:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function cn(t){return!t.ctrlKey&&!t.button}function un(){return this.parentNode}function hn(t,e){return null==e?{x:t.x,y:t.y}:e}function fn(){return navigator.maxTouchPoints||"ontouchstart"in this}function dn(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function pn(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function _n(){}ln.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var gn=.7,yn=1/gn,mn="\\s*([+-]?\\d+)\\s*",bn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",vn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xn=/^#([0-9a-f]{3,8})$/,wn=new RegExp(`^rgb\\(${mn},${mn},${mn}\\)$`),En=new RegExp(`^rgb\\(${vn},${vn},${vn}\\)$`),An=new RegExp(`^rgba\\(${mn},${mn},${mn},${bn}\\)$`),Sn=new RegExp(`^rgba\\(${vn},${vn},${vn},${bn}\\)$`),Tn=new RegExp(`^hsl\\(${bn},${vn},${vn}\\)$`),Cn=new RegExp(`^hsla\\(${bn},${vn},${vn},${bn}\\)$`),kn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Rn(){return this.rgb().formatHex()}function Mn(){return this.rgb().formatRgb()}function On(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=xn.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Nn(e):3===n?new Dn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?In(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?In(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=wn.exec(t))?new Dn(e[1],e[2],e[3],1):(e=En.exec(t))?new Dn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=An.exec(t))?In(e[1],e[2],e[3],e[4]):(e=Sn.exec(t))?In(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Tn.exec(t))?jn(e[1],e[2]/100,e[3]/100,1):(e=Cn.exec(t))?jn(e[1],e[2]/100,e[3]/100,e[4]):kn.hasOwnProperty(t)?Nn(kn[t]):"transparent"===t?new Dn(NaN,NaN,NaN,0):null}function Nn(t){return new Dn(t>>16&255,t>>8&255,255&t,1)}function In(t,e,n,r){return r<=0&&(t=e=n=NaN),new Dn(t,e,n,r)}function Pn(t){return t instanceof _n||(t=On(t)),t?new Dn((t=t.rgb()).r,t.g,t.b,t.opacity):new Dn}function Ln(t,e,n,r){return 1===arguments.length?Pn(t):new Dn(t,e,n,null==r?1:r)}function Dn(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Vn(){return`#${Fn(this.r)}${Fn(this.g)}${Fn(this.b)}`}function Bn(){const t=zn(this.opacity);return`${1===t?"rgb(":"rgba("}${Gn(this.r)}, ${Gn(this.g)}, ${Gn(this.b)}${1===t?")":`, ${t})`}`}function zn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Gn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Fn(t){return((t=Gn(t))<16?"0":"")+t.toString(16)}function jn(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Hn(t,e,n,r)}function Un(t){if(t instanceof Hn)return new Hn(t.h,t.s,t.l,t.opacity);if(t instanceof _n||(t=On(t)),!t)return new Hn;if(t instanceof Hn)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=NaN,a=s-i,l=(s+i)/2;return a?(o=e===s?(n-r)/a+6*(n<r):n===s?(r-e)/a+2:(e-n)/a+4,a/=l<.5?s+i:2-s-i,o*=60):a=l>0&&l<1?0:o,new Hn(o,a,l,t.opacity)}function Yn(t,e,n,r){return 1===arguments.length?Un(t):new Hn(t,e,n,null==r?1:r)}function Hn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Wn(t){return(t=(t||0)%360)<0?t+360:t}function qn(t){return Math.max(0,Math.min(1,t||0))}function $n(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}dn(_n,On,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Rn,formatHex:Rn,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Un(this).formatHsl()},formatRgb:Mn,toString:Mn}),dn(Dn,Ln,pn(_n,{brighter(t){return t=null==t?yn:Math.pow(yn,t),new Dn(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?gn:Math.pow(gn,t),new Dn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dn(Gn(this.r),Gn(this.g),Gn(this.b),zn(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:Vn,formatHex:Vn,formatHex8:function(){return`#${Fn(this.r)}${Fn(this.g)}${Fn(this.b)}${Fn(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Bn,toString:Bn})),dn(Hn,Yn,pn(_n,{brighter(t){return t=null==t?yn:Math.pow(yn,t),new Hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?gn:Math.pow(gn,t),new Hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Dn($n(t>=240?t-240:t+120,i,r),$n(t,i,r),$n(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Hn(Wn(this.h),qn(this.s),qn(this.l),zn(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=zn(this.opacity);return`${1===t?"hsl(":"hsla("}${Wn(this.h)}, ${100*qn(this.s)}%, ${100*qn(this.l)}%${1===t?")":`, ${t})`}`}}));const Xn=Math.PI/180,Kn=180/Math.PI,Zn=.96422,Jn=.82521,Qn=4/29,tr=6/29,er=3*tr*tr,nr=tr*tr*tr;function rr(t){if(t instanceof sr)return new sr(t.l,t.a,t.b,t.opacity);if(t instanceof fr)return dr(t);t instanceof Dn||(t=Pn(t));var e,n,r=cr(t.r),i=cr(t.g),s=cr(t.b),o=or((.2225045*r+.7168786*i+.0606169*s)/1);return r===i&&i===s?e=n=o:(e=or((.4360747*r+.3850649*i+.1430804*s)/Zn),n=or((.0139322*r+.0971045*i+.7141733*s)/Jn)),new sr(116*o-16,500*(e-o),200*(o-n),t.opacity)}function ir(t,e,n,r){return 1===arguments.length?rr(t):new sr(t,e,n,null==r?1:r)}function sr(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}function or(t){return t>nr?Math.pow(t,1/3):t/er+Qn}function ar(t){return t>tr?t*t*t:er*(t-Qn)}function lr(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function cr(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ur(t){if(t instanceof fr)return new fr(t.h,t.c,t.l,t.opacity);if(t instanceof sr||(t=rr(t)),0===t.a&&0===t.b)return new fr(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*Kn;return new fr(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function hr(t,e,n,r){return 1===arguments.length?ur(t):new fr(t,e,n,null==r?1:r)}function fr(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}function dr(t){if(isNaN(t.h))return new sr(t.l,0,0,t.opacity);var e=t.h*Xn;return new sr(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}dn(sr,ir,pn(_n,{brighter(t){return new sr(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker(t){return new sr(this.l-18*(null==t?1:t),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 new Dn(lr(3.1338561*(e=Zn*ar(e))-1.6168667*(t=1*ar(t))-.4906146*(n=Jn*ar(n))),lr(-.9787684*e+1.9161415*t+.033454*n),lr(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}})),dn(fr,hr,pn(_n,{brighter(t){return new fr(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker(t){return new fr(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb(){return dr(this).rgb()}}));var pr=-.14861,_r=1.78277,gr=-.29227,yr=-.90649,mr=1.97294,br=mr*yr,vr=mr*_r,xr=_r*gr-yr*pr;function wr(t,e,n,r){return 1===arguments.length?function(t){if(t instanceof Er)return new Er(t.h,t.s,t.l,t.opacity);t instanceof Dn||(t=Pn(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(xr*r+br*e-vr*n)/(xr+br-vr),s=r-i,o=(mr*(n-i)-gr*s)/yr,a=Math.sqrt(o*o+s*s)/(mr*i*(1-i)),l=a?Math.atan2(o,s)*Kn-120:NaN;return new Er(l<0?l+360:l,a,i,t.opacity)}(t):new Er(t,e,n,null==r?1:r)}function Er(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Ar(t,e,n,r,i){var s=t*t,o=s*t;return((1-3*t+3*s-o)*e+(4-6*s+3*o)*n+(1+3*t+3*s-3*o)*r+o*i)/6}function Sr(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],s=t[r+1],o=r>0?t[r-1]:2*i-s,a=r<e-1?t[r+2]:2*s-i;return Ar((n-r/e)*e,o,i,s,a)}}function Tr(t){var e=t.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*e),i=t[(r+e-1)%e],s=t[r%e],o=t[(r+1)%e],a=t[(r+2)%e];return Ar((n-r/e)*e,i,s,o,a)}}dn(Er,wr,pn(_n,{brighter(t){return t=null==t?yn:Math.pow(yn,t),new Er(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?gn:Math.pow(gn,t),new Er(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=isNaN(this.h)?0:(this.h+120)*Xn,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new Dn(255*(e+n*(pr*r+_r*i)),255*(e+n*(gr*r+yr*i)),255*(e+n*(mr*r)),this.opacity)}}));var Cr=t=>()=>t;function kr(t,e){return function(n){return t+n*e}}function Rr(t,e){var n=e-t;return n?kr(t,n>180||n<-180?n-360*Math.round(n/360):n):Cr(isNaN(t)?e:t)}function Mr(t){return 1===(t=+t)?Or:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):Cr(isNaN(e)?n:e)}}function Or(t,e){var n=e-t;return n?kr(t,n):Cr(isNaN(t)?e:t)}var Nr=function t(e){var n=Mr(e);function r(t,e){var r=n((t=Ln(t)).r,(e=Ln(e)).r),i=n(t.g,e.g),s=n(t.b,e.b),o=Or(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=s(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);function Ir(t){return function(e){var n,r,i=e.length,s=new Array(i),o=new Array(i),a=new Array(i);for(n=0;n<i;++n)r=Ln(e[n]),s[n]=r.r||0,o[n]=r.g||0,a[n]=r.b||0;return s=t(s),o=t(o),a=t(a),r.opacity=1,function(t){return r.r=s(t),r.g=o(t),r.b=a(t),r+""}}}var Pr=Ir(Sr),Lr=Ir(Tr);function Dr(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(s){for(n=0;n<r;++n)i[n]=t[n]*(1-s)+e[n]*s;return i}}function Vr(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Br(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,s=new Array(i),o=new Array(r);for(n=0;n<i;++n)s[n]=Hr(t[n],e[n]);for(;n<r;++n)o[n]=e[n];return function(t){for(n=0;n<i;++n)o[n]=s[n](t);return o}}function zr(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Gr(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Fr(t,e){var n,r={},i={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?r[n]=Hr(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var jr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ur=new RegExp(jr.source,"g");function Yr(t,e){var n,r,i,s=jr.lastIndex=Ur.lastIndex=0,o=-1,a=[],l=[];for(t+="",e+="";(n=jr.exec(t))&&(r=Ur.exec(e));)(i=r.index)>s&&(i=e.slice(s,i),a[o]?a[o]+=i:a[++o]=i),(n=n[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:Gr(n,r)})),s=Ur.lastIndex;return s<e.length&&(i=e.slice(s),a[o]?a[o]+=i:a[++o]=i),a.length<2?l[0]?function(t){return function(e){return t(e)+""}}(l[0].x):function(t){return function(){return t}}(e):(e=l.length,function(t){for(var n,r=0;r<e;++r)a[(n=l[r]).i]=n.x(t);return a.join("")})}function Hr(t,e){var n,r=typeof e;return null==e||"boolean"===r?Cr(e):("number"===r?Gr:"string"===r?(n=On(e))?(e=n,Nr):Yr:e instanceof On?Nr:e instanceof Date?zr:Vr(e)?Dr:Array.isArray(e)?Br:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?Fr:Gr)(t,e)}function Wr(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var qr,$r=180/Math.PI,Xr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Kr(t,e,n,r,i,s){var o,a,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),t*r<e*n&&(t=-t,e=-e,l=-l,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(e,t)*$r,skewX:Math.atan(l)*$r,scaleX:o,scaleY:a}}function Zr(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(s,o){var a=[],l=[];return s=t(s),o=t(o),function(t,r,i,s,o,a){if(t!==i||r!==s){var l=o.push("translate(",null,e,null,n);a.push({i:l-4,x:Gr(t,i)},{i:l-2,x:Gr(r,s)})}else(i||s)&&o.push("translate("+i+e+s+n)}(s.translateX,s.translateY,o.translateX,o.translateY,a,l),function(t,e,n,s){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),s.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Gr(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(s.rotate,o.rotate,a,l),function(t,e,n,s){t!==e?s.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Gr(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(s.skewX,o.skewX,a,l),function(t,e,n,r,s,o){if(t!==n||e!==r){var a=s.push(i(s)+"scale(",null,",",null,")");o.push({i:a-4,x:Gr(t,n)},{i:a-2,x:Gr(e,r)})}else 1===n&&1===r||s.push(i(s)+"scale("+n+","+r+")")}(s.scaleX,s.scaleY,o.scaleX,o.scaleY,a,l),s=o=null,function(t){for(var e,n=-1,r=l.length;++n<r;)a[(e=l[n]).i]=e.x(t);return a.join("")}}}var Jr=Zr(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Xr:Kr(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),Qr=Zr(function(t){return null==t?Xr:(qr||(qr=document.createElementNS("http://www.w3.org/2000/svg","g")),qr.setAttribute("transform",t),(t=qr.transform.baseVal.consolidate())?Kr((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Xr)},", ",")",")");function ti(t){return((t=Math.exp(t))+1/t)/2}var ei=function t(e,n,r){function i(t,i){var s,o,a=t[0],l=t[1],c=t[2],u=i[0],h=i[1],f=i[2],d=u-a,p=h-l,_=d*d+p*p;if(_<1e-12)o=Math.log(f/c)/e,s=function(t){return[a+t*d,l+t*p,c*Math.exp(e*t*o)]};else{var g=Math.sqrt(_),y=(f*f-c*c+r*_)/(2*c*n*g),m=(f*f-c*c-r*_)/(2*f*n*g),b=Math.log(Math.sqrt(y*y+1)-y),v=Math.log(Math.sqrt(m*m+1)-m);o=(v-b)/e,s=function(t){var r=t*o,i=ti(b),s=c/(n*g)*(i*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*r+b)-function(t){return((t=Math.exp(t))-1/t)/2}(b));return[a+s*d,l+s*p,c*i/ti(e*r+b)]}}return s.duration=1e3*o*e/Math.SQRT2,s}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r)},i}(Math.SQRT2,2,4);function ni(t){return function(e,n){var r=t((e=Yn(e)).h,(n=Yn(n)).h),i=Or(e.s,n.s),s=Or(e.l,n.l),o=Or(e.opacity,n.opacity);return function(t){return e.h=r(t),e.s=i(t),e.l=s(t),e.opacity=o(t),e+""}}}var ri=ni(Rr),ii=ni(Or);function si(t){return function(e,n){var r=t((e=hr(e)).h,(n=hr(n)).h),i=Or(e.c,n.c),s=Or(e.l,n.l),o=Or(e.opacity,n.opacity);return function(t){return e.h=r(t),e.c=i(t),e.l=s(t),e.opacity=o(t),e+""}}}var oi=si(Rr),ai=si(Or);function li(t){return function e(n){function r(e,r){var i=t((e=wr(e)).h,(r=wr(r)).h),s=Or(e.s,r.s),o=Or(e.l,r.l),a=Or(e.opacity,r.opacity);return function(t){return e.h=i(t),e.s=s(t),e.l=o(Math.pow(t,n)),e.opacity=a(t),e+""}}return n=+n,r.gamma=e,r}(1)}var ci=li(Rr),ui=li(Or);function hi(t,e){void 0===e&&(e=t,t=Hr);for(var n=0,r=e.length-1,i=e[0],s=new Array(r<0?0:r);n<r;)s[n]=t(i,i=e[++n]);return function(t){var e=Math.max(0,Math.min(r-1,Math.floor(t*=r)));return s[e](t-e)}}var fi,di,pi=0,_i=0,gi=0,yi=0,mi=0,bi=0,vi="object"==typeof performance&&performance.now?performance:Date,xi="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function wi(){return mi||(xi(Ei),mi=vi.now()+bi)}function Ei(){mi=0}function Ai(){this._call=this._time=this._next=null}function Si(t,e,n){var r=new Ai;return r.restart(t,e,n),r}function Ti(){wi(),++pi;for(var t,e=fi;e;)(t=mi-e._time)>=0&&e._call.call(void 0,t),e=e._next;--pi}function Ci(){mi=(yi=vi.now())+bi,pi=_i=0;try{Ti()}finally{pi=0,function(){var t,e,n=fi,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:fi=e);di=t,Ri(r)}(),mi=0}}function ki(){var t=vi.now(),e=t-yi;e>1e3&&(bi-=e,yi=t)}function Ri(t){pi||(_i&&(_i=clearTimeout(_i)),t-mi>24?(t<1/0&&(_i=setTimeout(Ci,t-vi.now()-bi)),gi&&(gi=clearInterval(gi))):(gi||(yi=vi.now(),gi=setInterval(ki,1e3)),pi=1,xi(Ci)))}function Mi(t,e,n){var r=new Ai;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}Ai.prototype=Si.prototype={constructor:Ai,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?wi():+n)+(null==e?0:+e),this._next||di===this||(di?di._next=this:fi=this,di=this),this._call=t,this._time=n,Ri()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ri())}};var Oi=Nt("start","end","cancel","interrupt"),Ni=[];function Ii(t,e,n,r,i,s){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function s(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(s){var c,u,h,f;if(1!==n.state)return l();for(c in i)if((f=i[c]).name===n.name){if(3===f.state)return Mi(o);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[c]):+c<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[c])}if(Mi(function(){3===n.state&&(n.state=4,n.timer.restart(a,n.delay,n.time),a(s))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(h=n.tween.length),c=0,u=-1;c<h;++c)(f=n.tween[c].value.call(t,t.__data__,n.index,n.group))&&(r[++u]=f);r.length=u+1}}function a(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(l),n.state=5,1),s=-1,o=r.length;++s<o;)r[s].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=Si(s,0,n.time)}(t,n,{name:e,index:r,group:i,on:Oi,tween:Ni,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:0})}function Pi(t,e){var n=Di(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function Li(t,e){var n=Di(t,e);if(n.state>3)throw new Error("too late; already running");return n}function Di(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Vi(t,e){var n,r,i,s=t.__transition,o=!0;if(s){for(i in e=null==e?null:e+"",s)(n=s[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete s[i]):o=!1;o&&delete t.__transition}}function Bi(t,e){var n,r;return function(){var i=Li(this,t),s=i.tween;if(s!==n)for(var o=0,a=(r=n=s).length;o<a;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r}}function zi(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var s=Li(this,t),o=s.tween;if(o!==r){i=(r=o).slice();for(var a={name:e,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===e){i[l]=a;break}l===c&&i.push(a)}s.tween=i}}function Gi(t,e,n){var r=t._id;return t.each(function(){var t=Li(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return Di(t,r).value[e]}}function Fi(t,e){var n;return("number"==typeof e?Gr:e instanceof On?Nr:(n=On(e))?(e=n,Nr):Yr)(t,e)}function ji(t){return function(){this.removeAttribute(t)}}function Ui(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Yi(t,e,n){var r,i,s=n+"";return function(){var o=this.getAttribute(t);return o===s?null:o===r?i:i=e(r=o,n)}}function Hi(t,e,n){var r,i,s=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===s?null:o===r?i:i=e(r=o,n)}}function Wi(t,e,n){var r,i,s;return function(){var o,a,l=n(this);if(null!=l)return(o=this.getAttribute(t))===(a=l+"")?null:o===r&&a===i?s:(i=a,s=e(r=o,l));this.removeAttribute(t)}}function qi(t,e,n){var r,i,s;return function(){var o,a,l=n(this);if(null!=l)return(o=this.getAttributeNS(t.space,t.local))===(a=l+"")?null:o===r&&a===i?s:(i=a,s=e(r=o,l));this.removeAttributeNS(t.space,t.local)}}function $i(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Xi(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Ki(t,e){return function(){Pi(this,t).delay=+e.apply(this,arguments)}}function Zi(t,e){return e=+e,function(){Pi(this,t).delay=e}}function Ji(t,e){return function(){Li(this,t).duration=+e.apply(this,arguments)}}function Qi(t,e){return e=+e,function(){Li(this,t).duration=e}}var ts=qe.prototype.constructor;function es(t){return function(){this.style.removeProperty(t)}}var ns=0;function rs(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function is(t){return qe().transition(t)}function ss(){return++ns}var os=qe.prototype;rs.prototype=is.prototype={constructor:rs,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Ut(t));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o<i;++o)for(var a,l,c=r[o],u=c.length,h=s[o]=new Array(u),f=0;f<u;++f)(a=c[f])&&(l=t.call(a,a.__data__,f,c))&&("__data__"in a&&(l.__data__=a.__data__),h[f]=l,Ii(h[f],e,n,f,h,Di(a,n)));return new rs(s,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Wt(t));for(var r=this._groups,i=r.length,s=[],o=[],a=0;a<i;++a)for(var l,c=r[a],u=c.length,h=0;h<u;++h)if(l=c[h]){for(var f,d=t.call(l,l.__data__,h,c),p=Di(l,n),_=0,g=d.length;_<g;++_)(f=d[_])&&Ii(f,e,n,_,d,p);s.push(d),o.push(l)}return new rs(s,o,e,n)},selectChild:os.selectChild,selectChildren:os.selectChildren,filter:function(t){"function"!=typeof t&&(t=qt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s,o=e[i],a=o.length,l=r[i]=[],c=0;c<a;++c)(s=o[c])&&t.call(s,s.__data__,c,o)&&l.push(s);return new rs(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,s=Math.min(r,i),o=new Array(r),a=0;a<s;++a)for(var l,c=e[a],u=n[a],h=c.length,f=o[a]=new Array(h),d=0;d<h;++d)(l=c[d]||u[d])&&(f[d]=l);for(;a<r;++a)o[a]=e[a];return new rs(o,this._parents,this._name,this._id)},selection:function(){return new ts(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=ss(),r=this._groups,i=r.length,s=0;s<i;++s)for(var o,a=r[s],l=a.length,c=0;c<l;++c)if(o=a[c]){var u=Di(o,e);Ii(o,t,n,c,a,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new rs(r,this._parents,t,n)},call:os.call,nodes:os.nodes,node:os.node,size:os.size,empty:os.empty,each:os.each,on:function(t,e){var n=this._id;return arguments.length<2?Di(this.node(),n).on.on(t):this.each(function(t,e,n){var r,i,s=function(t){return(t+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?Pi:Li;return function(){var o=s(this,t),a=o.on;a!==r&&(i=(r=a).copy()).on(e,n),o.on=i}}(n,t,e))},attr:function(t,e){var n=Bt(t),r="transform"===n?Qr:Fi;return this.attrTween(t,"function"==typeof e?(n.local?qi:Wi)(n,r,Gi(this,"attr."+t,e)):null==e?(n.local?Ui:ji)(n):(n.local?Hi:Yi)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=Bt(t);return this.tween(n,(r.local?$i:Xi)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Jr:Fi;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var s=ge(this,t),o=(this.style.removeProperty(t),ge(this,t));return s===o?null:s===n&&o===r?i:i=e(n=s,r=o)}}(t,r)).on("end.style."+t,es(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,s;return function(){var o=ge(this,t),a=n(this),l=a+"";return null==a&&(this.style.removeProperty(t),l=a=ge(this,t)),o===l?null:o===r&&l===i?s:(i=l,s=e(r=o,a))}}(t,r,Gi(this,"style."+t,e))).each(function(t,e){var n,r,i,s,o="style."+e,a="end."+o;return function(){var l=Li(this,t),c=l.on,u=null==l.value[o]?s||(s=es(e)):void 0;c===n&&i===u||(r=(n=c).copy()).on(a,i=u),l.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,s=n+"";return function(){var o=ge(this,t);return o===s?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function s(){var s=e.apply(this,arguments);return s!==i&&(r=(i=s)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,s,n)),r}return s._value=e,s}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Gi(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=Di(this.node(),n).tween,s=0,o=i.length;s<o;++s)if((r=i[s]).name===t)return r.value;return null}return this.each((null==e?Bi:zi)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Ki:Zi)(e,t)):Di(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Ji:Qi)(e,t)):Di(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw new Error;return function(){Li(this,t).ease=e}}(e,t)):Di(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;Li(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(s,o){var a={value:o},l={value:function(){0===--i&&s()}};n.each(function(){var n=Li(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),n.on=e}),0===i&&s()})},[Symbol.iterator]:os[Symbol.iterator]};function as(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}function ls(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var cs=function t(e){function n(t){return Math.pow(t,e)}return e=+e,n.exponent=t,n}(3),us=function t(e){function n(t){return 1-Math.pow(1-t,e)}return e=+e,n.exponent=t,n}(3),hs=function t(e){function n(t){return((t*=2)<=1?Math.pow(t,e):2-Math.pow(2-t,e))/2}return e=+e,n.exponent=t,n}(3),fs=Math.PI,ds=fs/2;function ps(t){return(1-Math.cos(fs*t))/2}function _s(t){return 1.0009775171065494*(Math.pow(2,-10*t)-.0009765625)}function gs(t){return((t*=2)<=1?_s(1-t):2-_s(t-1))/2}function ys(t){return((t*=2)<=1?1-Math.sqrt(1-t*t):Math.sqrt(1-(t-=2)*t)+1)/2}var ms=4/11,bs=6/11,vs=8/11,xs=9/11,ws=10/11,Es=21/22,As=7.5625;function Ss(t){return(t=+t)<ms?As*t*t:t<vs?As*(t-=bs)*t+.75:t<ws?As*(t-=xs)*t+.9375:As*(t-=Es)*t+.984375}var Ts=1.70158,Cs=function t(e){function n(t){return(t=+t)*t*(e*(t-1)+t)}return e=+e,n.overshoot=t,n}(Ts),ks=function t(e){function n(t){return--t*t*((t+1)*e+t)+1}return e=+e,n.overshoot=t,n}(Ts),Rs=function t(e){function n(t){return((t*=2)<1?t*t*((e+1)*t-e):(t-=2)*t*((e+1)*t+e)+2)/2}return e=+e,n.overshoot=t,n}(Ts),Ms=2*Math.PI,Os=function t(e,n){var r=Math.asin(1/(e=Math.max(1,e)))*(n/=Ms);function i(t){return e*_s(- --t)*Math.sin((r-t)/n)}return i.amplitude=function(e){return t(e,n*Ms)},i.period=function(n){return t(e,n)},i}(1,.3),Ns=function t(e,n){var r=Math.asin(1/(e=Math.max(1,e)))*(n/=Ms);function i(t){return 1-e*_s(t=+t)*Math.sin((t+r)/n)}return i.amplitude=function(e){return t(e,n*Ms)},i.period=function(n){return t(e,n)},i}(1,.3),Is=function t(e,n){var r=Math.asin(1/(e=Math.max(1,e)))*(n/=Ms);function i(t){return((t=2*t-1)<0?e*_s(-t)*Math.sin((r-t)/n):2-e*_s(t)*Math.sin((r+t)/n))/2}return i.amplitude=function(e){return t(e,n*Ms)},i.period=function(n){return t(e,n)},i}(1,.3),Ps={time:null,delay:0,duration:250,ease:ls};function Ls(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}qe.prototype.interrupt=function(t){return this.each(function(){Vi(this,t)})},qe.prototype.transition=function(t){var e,n;t instanceof rs?(e=t._id,t=t._name):(e=ss(),(n=Ps).time=wi(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var o,a=r[s],l=a.length,c=0;c<l;++c)(o=a[c])&&Ii(o,t,e,c,a,n||Ls(o,e));return new rs(r,this._parents,t,e)};var Ds=[null];var Vs=t=>()=>t;function Bs(t,{sourceEvent:e,target:n,selection:r,mode:i,dispatch:s}){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:i,enumerable:!0,configurable:!0},_:{value:s}})}function zs(t){t.preventDefault(),t.stopImmediatePropagation()}var Gs={name:"drag"},Fs={name:"space"},js={name:"handle"},Us={name:"center"};const{abs:Ys,max:Hs,min:Ws}=Math;function qs(t){return[+t[0],+t[1]]}function $s(t){return[qs(t[0]),qs(t[1])]}var Xs={name:"x",handles:["w","e"].map(ro),input:function(t,e){return null==t?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},Ks={name:"y",handles:["n","s"].map(ro),input:function(t,e){return null==t?null:[[e[0][0],+t[0]],[e[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},Zs={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(ro),input:function(t){return null==t?null:$s(t)},output:function(t){return t}},Js={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"},Qs={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},to={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},eo={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},no={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function ro(t){return{type:t}}function io(t){return!t.ctrlKey&&!t.button}function so(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function oo(){return navigator.maxTouchPoints||"ontouchstart"in this}function ao(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function lo(t){var e,n=so,r=io,i=oo,s=!0,o=Nt("start","brush","end"),a=6;function l(e){var n=e.property("__brush",_).selectAll(".overlay").data([ro("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Js.overlay).merge(n).each(function(){var t=ao(this).extent;$e(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])}),e.selectAll(".selection").data([ro("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Js.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=e.selectAll(".handle").data(t.handles,function(t){return t.type});r.exit().remove(),r.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return Js[t.type]}),e.each(c).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",f).filter(i).on("touchstart.brush",f).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function c(){var t=$e(this),e=ao(this).selection;e?(t.selectAll(".selection").style("display",null).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1]),t.selectAll(".handle").style("display",null).attr("x",function(t){return"e"===t.type[t.type.length-1]?e[1][0]-a/2:e[0][0]-a/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-a/2:e[0][1]-a/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+a:a}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+a:a})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function u(t,e,n){var r=t.__brush.emitter;return!r||n&&r.clean?new h(t,e,n):r}function h(t,e,n){this.that=t,this.args=e,this.state=t.__brush,this.active=0,this.clean=n}function f(n){if((!e||n.touches)&&r.apply(this,arguments)){var i,o,a,l,h,f,d,p,_,g,y,m=this,b=n.target.__data__.type,v="selection"===(s&&n.metaKey?b="overlay":b)?Gs:s&&n.altKey?Us:js,x=t===Ks?null:eo[b],w=t===Xs?null:no[b],E=ao(m),A=E.extent,S=E.selection,T=A[0][0],C=A[0][1],k=A[1][0],R=A[1][1],M=0,O=0,N=x&&w&&s&&n.shiftKey,I=Array.from(n.touches||[n],t=>{const e=t.identifier;return(t=Qe(t,m)).point0=t.slice(),t.identifier=e,t});Vi(m);var P=u(m,arguments,!0).beforestart();if("overlay"===b){S&&(_=!0);const e=[I[0],I[1]||I[0]];E.selection=S=[[i=t===Ks?T:Ws(e[0][0],e[1][0]),a=t===Xs?C:Ws(e[0][1],e[1][1])],[h=t===Ks?k:Hs(e[0][0],e[1][0]),d=t===Xs?R:Hs(e[0][1],e[1][1])]],I.length>1&&z(n)}else i=S[0][0],a=S[0][1],h=S[1][0],d=S[1][1];o=i,l=a,f=h,p=d;var L=$e(m).attr("pointer-events","none"),D=L.selectAll(".overlay").attr("cursor",Js[b]);if(n.touches)P.moved=B,P.ended=G;else{var V=$e(n.view).on("mousemove.brush",B,!0).on("mouseup.brush",G,!0);s&&V.on("keydown.brush",function(t){switch(t.keyCode){case 16:N=x&&w;break;case 18:v===js&&(x&&(h=f-M*x,i=o+M*x),w&&(d=p-O*w,a=l+O*w),v=Us,z(t));break;case 32:v!==js&&v!==Us||(x<0?h=f-M:x>0&&(i=o-M),w<0?d=p-O:w>0&&(a=l-O),v=Fs,D.attr("cursor",Js.selection),z(t));break;default:return}zs(t)},!0).on("keyup.brush",function(t){switch(t.keyCode){case 16:N&&(g=y=N=!1,z(t));break;case 18:v===Us&&(x<0?h=f:x>0&&(i=o),w<0?d=p:w>0&&(a=l),v=js,z(t));break;case 32:v===Fs&&(t.altKey?(x&&(h=f-M*x,i=o+M*x),w&&(d=p-O*w,a=l+O*w),v=Us):(x<0?h=f:x>0&&(i=o),w<0?d=p:w>0&&(a=l),v=js),D.attr("cursor",Js[b]),z(t));break;default:return}zs(t)},!0),sn(n.view)}c.call(m),P.start(n,v.name)}function B(t){for(const e of t.changedTouches||[t])for(const t of I)t.identifier===e.identifier&&(t.cur=Qe(e,m));if(N&&!g&&!y&&1===I.length){const t=I[0];Ys(t.cur[0]-t[0])>Ys(t.cur[1]-t[1])?y=!0:g=!0}for(const t of I)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);_=!0,zs(t),z(t)}function z(t){const e=I[0],n=e.point0;var r;switch(M=e[0]-n[0],O=e[1]-n[1],v){case Fs:case Gs:x&&(M=Hs(T-i,Ws(k-h,M)),o=i+M,f=h+M),w&&(O=Hs(C-a,Ws(R-d,O)),l=a+O,p=d+O);break;case js:I[1]?(x&&(o=Hs(T,Ws(k,I[0][0])),f=Hs(T,Ws(k,I[1][0])),x=1),w&&(l=Hs(C,Ws(R,I[0][1])),p=Hs(C,Ws(R,I[1][1])),w=1)):(x<0?(M=Hs(T-i,Ws(k-i,M)),o=i+M,f=h):x>0&&(M=Hs(T-h,Ws(k-h,M)),o=i,f=h+M),w<0?(O=Hs(C-a,Ws(R-a,O)),l=a+O,p=d):w>0&&(O=Hs(C-d,Ws(R-d,O)),l=a,p=d+O));break;case Us:x&&(o=Hs(T,Ws(k,i-M*x)),f=Hs(T,Ws(k,h+M*x))),w&&(l=Hs(C,Ws(R,a-O*w)),p=Hs(C,Ws(R,d+O*w)))}f<o&&(x*=-1,r=i,i=h,h=r,r=o,o=f,f=r,b in Qs&&D.attr("cursor",Js[b=Qs[b]])),p<l&&(w*=-1,r=a,a=d,d=r,r=l,l=p,p=r,b in to&&D.attr("cursor",Js[b=to[b]])),E.selection&&(S=E.selection),g&&(o=S[0][0],f=S[1][0]),y&&(l=S[0][1],p=S[1][1]),S[0][0]===o&&S[0][1]===l&&S[1][0]===f&&S[1][1]===p||(E.selection=[[o,l],[f,p]],c.call(m),P.brush(t,v.name))}function G(t){if(function(t){t.stopImmediatePropagation()}(t),t.touches){if(t.touches.length)return;e&&clearTimeout(e),e=setTimeout(function(){e=null},500)}else on(t.view,_),V.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);L.attr("pointer-events","all"),D.attr("cursor",Js.overlay),E.selection&&(S=E.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(S)&&(E.selection=null,c.call(m)),P.end(t,v.name)}}function d(t){u(this,arguments).moved(t)}function p(t){u(this,arguments).ended(t)}function _(){var e=this.__brush||{selection:null};return e.extent=$s(n.apply(this,arguments)),e.dim=t,e}return l.move=function(e,n,r){e.tween?e.on("start.brush",function(t){u(this,arguments).beforestart().start(t)}).on("interrupt.brush end.brush",function(t){u(this,arguments).end(t)}).tween("brush",function(){var e=this,r=e.__brush,i=u(e,arguments),s=r.selection,o=t.input("function"==typeof n?n.apply(this,arguments):n,r.extent),a=Hr(s,o);function l(t){r.selection=1===t&&null===o?null:a(t),c.call(e),i.brush()}return null!==s&&null!==o?l:l(1)}):e.each(function(){var e=this,i=arguments,s=e.__brush,o=t.input("function"==typeof n?n.apply(e,i):n,s.extent),a=u(e,i).beforestart();Vi(e),s.selection=null===o?null:o,c.call(e),a.start(r).brush(r).end(r)})},l.clear=function(t,e){l.move(t,null,e)},h.prototype={beforestart:function(){return 1===++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(t,e){return this.starting?(this.starting=!1,this.emit("start",t,e)):this.emit("brush",t),this},brush:function(t,e){return this.emit("brush",t,e),this},end:function(t,e){return 0===--this.active&&(delete this.state.emitter,this.emit("end",t,e)),this},emit:function(e,n,r){var i=$e(this.that).datum();o.call(e,this.that,new Bs(e,{sourceEvent:n,target:l,selection:t.output(this.state.selection),mode:r,dispatch:o}),i)}},l.extent=function(t){return arguments.length?(n="function"==typeof t?t:Vs($s(t)),l):n},l.filter=function(t){return arguments.length?(r="function"==typeof t?t:Vs(!!t),l):r},l.touchable=function(t){return arguments.length?(i="function"==typeof t?t:Vs(!!t),l):i},l.handleSize=function(t){return arguments.length?(a=+t,l):a},l.keyModifiers=function(t){return arguments.length?(s=!!t,l):s},l.on=function(){var t=o.on.apply(o,arguments);return t===o?l:t},l}var co=Math.abs,uo=Math.cos,ho=Math.sin,fo=Math.PI,po=fo/2,_o=2*fo,go=Math.max,yo=1e-12;function mo(t,e){return Array.from({length:e-t},(e,n)=>t+n)}function bo(t,e){var n=0,r=null,i=null,s=null;function o(o){var a,l=o.length,c=new Array(l),u=mo(0,l),h=new Array(l*l),f=new Array(l),d=0;o=Float64Array.from({length:l*l},e?(t,e)=>o[e%l][e/l|0]:(t,e)=>o[e/l|0][e%l]);for(let e=0;e<l;++e){let n=0;for(let r=0;r<l;++r)n+=o[e*l+r]+t*o[r*l+e];d+=c[e]=n}a=(d=go(0,_o-n*l)/d)?n:_o/l;{let e=0;r&&u.sort((t,e)=>r(c[t],c[e]));for(const n of u){const r=e;if(t){const t=mo(1+~l,l).filter(t=>t<0?o[~t*l+n]:o[n*l+t]);i&&t.sort((t,e)=>i(t<0?-o[~t*l+n]:o[n*l+t],e<0?-o[~e*l+n]:o[n*l+e]));for(const r of t)if(r<0){(h[~r*l+n]||(h[~r*l+n]={source:null,target:null})).target={index:n,startAngle:e,endAngle:e+=o[~r*l+n]*d,value:o[~r*l+n]}}else{(h[n*l+r]||(h[n*l+r]={source:null,target:null})).source={index:n,startAngle:e,endAngle:e+=o[n*l+r]*d,value:o[n*l+r]}}f[n]={index:n,startAngle:r,endAngle:e,value:c[n]}}else{const t=mo(0,l).filter(t=>o[n*l+t]||o[t*l+n]);i&&t.sort((t,e)=>i(o[n*l+t],o[n*l+e]));for(const r of t){let t;if(n<r?(t=h[n*l+r]||(h[n*l+r]={source:null,target:null}),t.source={index:n,startAngle:e,endAngle:e+=o[n*l+r]*d,value:o[n*l+r]}):(t=h[r*l+n]||(h[r*l+n]={source:null,target:null}),t.target={index:n,startAngle:e,endAngle:e+=o[n*l+r]*d,value:o[n*l+r]},n===r&&(t.source=t.target)),t.source&&t.target&&t.source.value<t.target.value){const e=t.source;t.source=t.target,t.target=e}}f[n]={index:n,startAngle:r,endAngle:e,value:c[n]}}e+=a}}return(h=Object.values(h)).groups=f,s?h.sort(s):h}return o.padAngle=function(t){return arguments.length?(n=go(0,t),o):n},o.sortGroups=function(t){return arguments.length?(r=t,o):r},o.sortSubgroups=function(t){return arguments.length?(i=t,o):i},o.sortChords=function(t){return arguments.length?(null==t?s=null:(e=t,s=function(t,n){return e(t.source.value+t.target.value,n.source.value+n.target.value)})._=t,o):s&&s._;var e},o}const vo=Math.PI,xo=2*vo,wo=1e-6,Eo=xo-wo;function Ao(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}let So=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?Ao:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Ao;const n=10**e;return function(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=Math.round(arguments[e]*n)/n+t[e]}}(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,n,r){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(t,e,n,r,i,s){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+s}`}arcTo(t,e,n,r,i){if(t=+t,e=+e,n=+n,r=+r,(i=+i)<0)throw new Error(`negative radius: ${i}`);let s=this._x1,o=this._y1,a=n-t,l=r-e,c=s-t,u=o-e,h=c*c+u*u;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(h>wo)if(Math.abs(u*a-l*c)>wo&&i){let f=n-s,d=r-o,p=a*a+l*l,_=f*f+d*d,g=Math.sqrt(p),y=Math.sqrt(h),m=i*Math.tan((vo-Math.acos((p+h-_)/(2*g*y)))/2),b=m/y,v=m/g;Math.abs(b-1)>wo&&this._append`L${t+b*c},${e+b*u}`,this._append`A${i},${i},0,0,${+(u*f>c*d)},${this._x1=t+v*a},${this._y1=e+v*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,s){if(t=+t,e=+e,s=!!s,(n=+n)<0)throw new Error(`negative radius: ${n}`);let o=n*Math.cos(r),a=n*Math.sin(r),l=t+o,c=e+a,u=1^s,h=s?r-i:i-r;null===this._x1?this._append`M${l},${c}`:(Math.abs(this._x1-l)>wo||Math.abs(this._y1-c)>wo)&&this._append`L${l},${c}`,n&&(h<0&&(h=h%xo+xo),h>Eo?this._append`A${n},${n},0,1,${u},${t-o},${e-a}A${n},${n},0,1,${u},${this._x1=l},${this._y1=c}`:h>wo&&this._append`A${n},${n},0,${+(h>=vo)},${u},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};function To(){return new So}To.prototype=So.prototype;var Co=Array.prototype.slice;function ko(t){return function(){return t}}function Ro(t){return t.source}function Mo(t){return t.target}function Oo(t){return t.radius}function No(t){return t.startAngle}function Io(t){return t.endAngle}function Po(){return 0}function Lo(){return 10}function Do(t){var e=Ro,n=Mo,r=Oo,i=Oo,s=No,o=Io,a=Po,l=null;function c(){var c,u=e.apply(this,arguments),h=n.apply(this,arguments),f=a.apply(this,arguments)/2,d=Co.call(arguments),p=+r.apply(this,(d[0]=u,d)),_=s.apply(this,d)-po,g=o.apply(this,d)-po,y=+i.apply(this,(d[0]=h,d)),m=s.apply(this,d)-po,b=o.apply(this,d)-po;if(l||(l=c=To()),f>yo&&(co(g-_)>2*f+yo?g>_?(_+=f,g-=f):(_-=f,g+=f):_=g=(_+g)/2,co(b-m)>2*f+yo?b>m?(m+=f,b-=f):(m-=f,b+=f):m=b=(m+b)/2),l.moveTo(p*uo(_),p*ho(_)),l.arc(0,0,p,_,g),_!==m||g!==b)if(t){var v=y-+t.apply(this,arguments),x=(m+b)/2;l.quadraticCurveTo(0,0,v*uo(m),v*ho(m)),l.lineTo(y*uo(x),y*ho(x)),l.lineTo(v*uo(b),v*ho(b))}else l.quadraticCurveTo(0,0,y*uo(m),y*ho(m)),l.arc(0,0,y,m,b);if(l.quadraticCurveTo(0,0,p*uo(_),p*ho(_)),l.closePath(),c)return l=null,c+""||null}return t&&(c.headRadius=function(e){return arguments.length?(t="function"==typeof e?e:ko(+e),c):t}),c.radius=function(t){return arguments.length?(r=i="function"==typeof t?t:ko(+t),c):r},c.sourceRadius=function(t){return arguments.length?(r="function"==typeof t?t:ko(+t),c):r},c.targetRadius=function(t){return arguments.length?(i="function"==typeof t?t:ko(+t),c):i},c.startAngle=function(t){return arguments.length?(s="function"==typeof t?t:ko(+t),c):s},c.endAngle=function(t){return arguments.length?(o="function"==typeof t?t:ko(+t),c):o},c.padAngle=function(t){return arguments.length?(a="function"==typeof t?t:ko(+t),c):a},c.source=function(t){return arguments.length?(e=t,c):e},c.target=function(t){return arguments.length?(n=t,c):n},c.context=function(t){return arguments.length?(l=null==t?null:t,c):l},c}var Vo=Array.prototype.slice;function Bo(t,e){return t-e}var zo=t=>()=>t;function Go(t,e){for(var n,r=-1,i=e.length;++r<i;)if(n=Fo(t,e[r]))return n;return 0}function Fo(t,e){for(var n=e[0],r=e[1],i=-1,s=0,o=t.length,a=o-1;s<o;a=s++){var l=t[s],c=l[0],u=l[1],h=t[a],f=h[0],d=h[1];if(jo(l,h,e))return 0;u>r!=d>r&&n<(f-c)*(r-u)/(d-u)+c&&(i=-i)}return i}function jo(t,e,n){var r,i,s,o;return function(t,e,n){return(e[0]-t[0])*(n[1]-t[1])===(n[0]-t[0])*(e[1]-t[1])}(t,e,n)&&(i=t[r=+(t[0]===e[0])],s=n[r],o=e[r],i<=s&&s<=o||o<=s&&s<=i)}function Uo(){}var Yo=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Ho(){var t=1,e=1,n=Z,r=a;function i(t){var e=n(t);if(Array.isArray(e))e=e.slice().sort(Bo);else{const n=x(t,Wo);for(e=q(...K(n[0],n[1],e),e);e[e.length-1]>=n[1];)e.pop();for(;e[1]<n[0];)e.shift()}return e.map(e=>s(t,e))}function s(n,i){const s=null==i?NaN:+i;if(isNaN(s))throw new Error(`invalid value: ${i}`);var a=[],l=[];return function(n,r,i){var s,a,l,c,u,h,f=new Array,d=new Array;s=a=-1,c=qo(n[0],r),Yo[c<<1].forEach(p);for(;++s<t-1;)l=c,c=qo(n[s+1],r),Yo[l|c<<1].forEach(p);Yo[c|0].forEach(p);for(;++a<e-1;){for(s=-1,c=qo(n[a*t+t],r),u=qo(n[a*t],r),Yo[c<<1|u<<2].forEach(p);++s<t-1;)l=c,c=qo(n[a*t+t+s+1],r),h=u,u=qo(n[a*t+s+1],r),Yo[l|c<<1|u<<2|h<<3].forEach(p);Yo[c|u<<3].forEach(p)}s=-1,u=n[a*t]>=r,Yo[u<<2].forEach(p);for(;++s<t-1;)h=u,u=qo(n[a*t+s+1],r),Yo[u<<2|h<<3].forEach(p);function p(t){var e,n,r=[t[0][0]+s,t[0][1]+a],l=[t[1][0]+s,t[1][1]+a],c=o(r),u=o(l);(e=d[c])?(n=f[u])?(delete d[e.end],delete f[n.start],e===n?(e.ring.push(l),i(e.ring)):f[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete d[e.end],e.ring.push(l),d[e.end=u]=e):(e=f[u])?(n=d[c])?(delete f[e.start],delete d[n.end],e===n?(e.ring.push(l),i(e.ring)):f[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete f[e.start],e.ring.unshift(r),f[e.start=c]=e):f[c]=d[u]={start:c,end:u,ring:[r,l]}}Yo[u<<3].forEach(p)}(n,s,function(t){r(t,n,s),function(t){for(var e=0,n=t.length,r=t[n-1][1]*t[0][0]-t[n-1][0]*t[0][1];++e<n;)r+=t[e-1][1]*t[e][0]-t[e-1][0]*t[e][1];return r}(t)>0?a.push([t]):l.push(t)}),l.forEach(function(t){for(var e,n=0,r=a.length;n<r;++n)if(-1!==Go((e=a[n])[0],t))return void e.push(t)}),{type:"MultiPolygon",value:i,coordinates:a}}function o(e){return 2*e[0]+e[1]*(t+1)*4}function a(n,r,i){n.forEach(function(n){var s=n[0],o=n[1],a=0|s,l=0|o,c=$o(r[l*t+a]);s>0&&s<t&&a===s&&(n[0]=Xo(s,$o(r[l*t+a-1]),c,i)),o>0&&o<e&&l===o&&(n[1]=Xo(o,$o(r[(l-1)*t+a]),c,i))})}return i.contour=s,i.size=function(n){if(!arguments.length)return[t,e];var r=Math.floor(n[0]),s=Math.floor(n[1]);if(!(r>=0&&s>=0))throw new Error("invalid size");return t=r,e=s,i},i.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:Array.isArray(t)?zo(Vo.call(t)):zo(t),i):n},i.smooth=function(t){return arguments.length?(r=t?a:Uo,i):r===a},i}function Wo(t){return isFinite(t)?t:NaN}function qo(t,e){return null!=t&&+t>=e}function $o(t){return null==t||isNaN(t=+t)?-1/0:t}function Xo(t,e,n,r){const i=r-e,s=n-e,o=isFinite(i)||isFinite(s)?i/s:Math.sign(i)/Math.sign(s);return isNaN(o)?t:t+o-.5}function Ko(t){return t[0]}function Zo(t){return t[1]}function Jo(){return 1}const Qo=134217729;function ta(t,e,n,r,i){let s,o,a,l,c=e[0],u=r[0],h=0,f=0;u>c==u>-c?(s=c,c=e[++h]):(s=u,u=r[++f]);let d=0;if(h<t&&f<n)for(u>c==u>-c?(o=c+s,a=s-(o-c),c=e[++h]):(o=u+s,a=s-(o-u),u=r[++f]),s=o,0!==a&&(i[d++]=a);h<t&&f<n;)u>c==u>-c?(o=s+c,l=o-s,a=s-(o-l)+(c-l),c=e[++h]):(o=s+u,l=o-s,a=s-(o-l)+(u-l),u=r[++f]),s=o,0!==a&&(i[d++]=a);for(;h<t;)o=s+c,l=o-s,a=s-(o-l)+(c-l),c=e[++h],s=o,0!==a&&(i[d++]=a);for(;f<n;)o=s+u,l=o-s,a=s-(o-l)+(u-l),u=r[++f],s=o,0!==a&&(i[d++]=a);return 0===s&&0!==d||(i[d++]=s),d}function ea(t){return new Float64Array(t)}const na=ea(4),ra=ea(8),ia=ea(12),sa=ea(16),oa=ea(4);function aa(t,e,n,r,i,s){const o=(e-s)*(n-i),a=(t-i)*(r-s),l=o-a,c=Math.abs(o+a);return Math.abs(l)>=33306690738754716e-32*c?l:-function(t,e,n,r,i,s,o){let a,l,c,u,h,f,d,p,_,g,y,m,b,v,x,w,E,A;const S=t-i,T=n-i,C=e-s,k=r-s;v=S*k,f=Qo*S,d=f-(f-S),p=S-d,f=Qo*k,_=f-(f-k),g=k-_,x=p*g-(v-d*_-p*_-d*g),w=C*T,f=Qo*C,d=f-(f-C),p=C-d,f=Qo*T,_=f-(f-T),g=T-_,E=p*g-(w-d*_-p*_-d*g),y=x-E,h=x-y,na[0]=x-(y+h)+(h-E),m=v+y,h=m-v,b=v-(m-h)+(y-h),y=b-w,h=b-y,na[1]=b-(y+h)+(h-w),A=m+y,h=A-m,na[2]=m-(A-h)+(y-h),na[3]=A;let R=function(t,e){let n=e[0];for(let r=1;r<t;r++)n+=e[r];return n}(4,na),M=22204460492503146e-32*o;if(R>=M||-R>=M)return R;if(h=t-S,a=t-(S+h)+(h-i),h=n-T,c=n-(T+h)+(h-i),h=e-C,l=e-(C+h)+(h-s),h=r-k,u=r-(k+h)+(h-s),0===a&&0===l&&0===c&&0===u)return R;if(M=11093356479670487e-47*o+33306690738754706e-32*Math.abs(R),R+=S*u+k*a-(C*c+T*l),R>=M||-R>=M)return R;v=a*k,f=Qo*a,d=f-(f-a),p=a-d,f=Qo*k,_=f-(f-k),g=k-_,x=p*g-(v-d*_-p*_-d*g),w=l*T,f=Qo*l,d=f-(f-l),p=l-d,f=Qo*T,_=f-(f-T),g=T-_,E=p*g-(w-d*_-p*_-d*g),y=x-E,h=x-y,oa[0]=x-(y+h)+(h-E),m=v+y,h=m-v,b=v-(m-h)+(y-h),y=b-w,h=b-y,oa[1]=b-(y+h)+(h-w),A=m+y,h=A-m,oa[2]=m-(A-h)+(y-h),oa[3]=A;const O=ta(4,na,4,oa,ra);v=S*u,f=Qo*S,d=f-(f-S),p=S-d,f=Qo*u,_=f-(f-u),g=u-_,x=p*g-(v-d*_-p*_-d*g),w=C*c,f=Qo*C,d=f-(f-C),p=C-d,f=Qo*c,_=f-(f-c),g=c-_,E=p*g-(w-d*_-p*_-d*g),y=x-E,h=x-y,oa[0]=x-(y+h)+(h-E),m=v+y,h=m-v,b=v-(m-h)+(y-h),y=b-w,h=b-y,oa[1]=b-(y+h)+(h-w),A=m+y,h=A-m,oa[2]=m-(A-h)+(y-h),oa[3]=A;const N=ta(O,ra,4,oa,ia);v=a*u,f=Qo*a,d=f-(f-a),p=a-d,f=Qo*u,_=f-(f-u),g=u-_,x=p*g-(v-d*_-p*_-d*g),w=l*c,f=Qo*l,d=f-(f-l),p=l-d,f=Qo*c,_=f-(f-c),g=c-_,E=p*g-(w-d*_-p*_-d*g),y=x-E,h=x-y,oa[0]=x-(y+h)+(h-E),m=v+y,h=m-v,b=v-(m-h)+(y-h),y=b-w,h=b-y,oa[1]=b-(y+h)+(h-w),A=m+y,h=A-m,oa[2]=m-(A-h)+(y-h),oa[3]=A;const I=ta(N,ia,4,oa,sa);return sa[I-1]}(t,e,n,r,i,s,c)}const la=Math.pow(2,-52),ca=new Uint32Array(512);class ua{static from(t,e=ga,n=ya){const r=t.length,i=new Float64Array(2*r);for(let s=0;s<r;s++){const r=t[s];i[2*s]=e(r),i[2*s+1]=n(r)}return new ua(i)}constructor(t){const e=t.length>>1;if(e>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;const n=Math.max(2*e-5,0);this._triangles=new Uint32Array(3*n),this._halfedges=new Int32Array(3*n),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:n,_hullTri:r,_hullHash:i}=this,s=t.length>>1;let o=1/0,a=1/0,l=-1/0,c=-1/0;for(let e=0;e<s;e++){const n=t[2*e],r=t[2*e+1];n<o&&(o=n),r<a&&(a=r),n>l&&(l=n),r>c&&(c=r),this._ids[e]=e}const u=(o+l)/2,h=(a+c)/2;let f,d,p;for(let e=0,n=1/0;e<s;e++){const r=ha(u,h,t[2*e],t[2*e+1]);r<n&&(f=e,n=r)}const _=t[2*f],g=t[2*f+1];for(let e=0,n=1/0;e<s;e++){if(e===f)continue;const r=ha(_,g,t[2*e],t[2*e+1]);r<n&&r>0&&(d=e,n=r)}let y=t[2*d],m=t[2*d+1],b=1/0;for(let e=0;e<s;e++){if(e===f||e===d)continue;const n=da(_,g,y,m,t[2*e],t[2*e+1]);n<b&&(p=e,b=n)}let v=t[2*p],x=t[2*p+1];if(b===1/0){for(let e=0;e<s;e++)this._dists[e]=t[2*e]-t[0]||t[2*e+1]-t[1];pa(this._ids,this._dists,0,s-1);const e=new Uint32Array(s);let n=0;for(let t=0,r=-1/0;t<s;t++){const i=this._ids[t],s=this._dists[i];s>r&&(e[n++]=i,r=s)}return this.hull=e.subarray(0,n),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(aa(_,g,y,m,v,x)<0){const t=d,e=y,n=m;d=p,y=v,m=x,p=t,v=e,x=n}const w=function(t,e,n,r,i,s){const o=n-t,a=r-e,l=i-t,c=s-e,u=o*o+a*a,h=l*l+c*c,f=.5/(o*c-a*l),d=t+(c*u-a*h)*f,p=e+(o*h-l*u)*f;return{x:d,y:p}}(_,g,y,m,v,x);this._cx=w.x,this._cy=w.y;for(let e=0;e<s;e++)this._dists[e]=ha(t[2*e],t[2*e+1],w.x,w.y);pa(this._ids,this._dists,0,s-1),this._hullStart=f;let E=3;n[f]=e[p]=d,n[d]=e[f]=p,n[p]=e[d]=f,r[f]=0,r[d]=1,r[p]=2,i.fill(-1),i[this._hashKey(_,g)]=f,i[this._hashKey(y,m)]=d,i[this._hashKey(v,x)]=p,this.trianglesLen=0,this._addTriangle(f,d,p,-1,-1,-1);for(let s,o,a=0;a<this._ids.length;a++){const l=this._ids[a],c=t[2*l],u=t[2*l+1];if(a>0&&Math.abs(c-s)<=la&&Math.abs(u-o)<=la)continue;if(s=c,o=u,l===f||l===d||l===p)continue;let h=0;for(let t=0,e=this._hashKey(c,u);t<this._hashSize&&(h=i[(e+t)%this._hashSize],-1===h||h===n[h]);t++);h=e[h];let _,g=h;for(;_=n[g],aa(c,u,t[2*g],t[2*g+1],t[2*_],t[2*_+1])>=0;)if(g=_,g===h){g=-1;break}if(-1===g)continue;let y=this._addTriangle(g,l,n[g],-1,-1,r[g]);r[l]=this._legalize(y+2),r[g]=y,E++;let m=n[g];for(;_=n[m],aa(c,u,t[2*m],t[2*m+1],t[2*_],t[2*_+1])<0;)y=this._addTriangle(m,l,_,r[l],-1,r[m]),r[l]=this._legalize(y+2),n[m]=m,E--,m=_;if(g===h)for(;_=e[g],aa(c,u,t[2*_],t[2*_+1],t[2*g],t[2*g+1])<0;)y=this._addTriangle(_,l,g,-1,r[g],r[_]),this._legalize(y+2),r[_]=y,n[g]=g,E--,g=_;this._hullStart=e[l]=g,n[g]=e[m]=l,n[l]=m,i[this._hashKey(c,u)]=l,i[this._hashKey(t[2*g],t[2*g+1])]=g}this.hull=new Uint32Array(E);for(let t=0,e=this._hullStart;t<E;t++)this.hull[t]=e,e=n[e];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(function(t,e){const n=t/(Math.abs(t)+Math.abs(e));return(e>0?3-n:1+n)/4}(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:n,coords:r}=this;let i=0,s=0;for(;;){const o=n[t],a=t-t%3;if(s=a+(t+2)%3,-1===o){if(0===i)break;t=ca[--i];continue}const l=o-o%3,c=a+(t+1)%3,u=l+(o+2)%3,h=e[s],f=e[t],d=e[c],p=e[u];if(fa(r[2*h],r[2*h+1],r[2*f],r[2*f+1],r[2*d],r[2*d+1],r[2*p],r[2*p+1])){e[t]=p,e[o]=h;const r=n[u];if(-1===r){let e=this._hullStart;do{if(this._hullTri[e]===u){this._hullTri[e]=t;break}e=this._hullPrev[e]}while(e!==this._hullStart)}this._link(t,r),this._link(o,n[s]),this._link(s,u);const a=l+(o+1)%3;i<ca.length&&(ca[i++]=a)}else{if(0===i)break;t=ca[--i]}}return s}_link(t,e){this._halfedges[t]=e,-1!==e&&(this._halfedges[e]=t)}_addTriangle(t,e,n,r,i,s){const o=this.trianglesLen;return this._triangles[o]=t,this._triangles[o+1]=e,this._triangles[o+2]=n,this._link(o,r),this._link(o+1,i),this._link(o+2,s),this.trianglesLen+=3,o}}function ha(t,e,n,r){const i=t-n,s=e-r;return i*i+s*s}function fa(t,e,n,r,i,s,o,a){const l=t-o,c=e-a,u=n-o,h=r-a,f=i-o,d=s-a,p=u*u+h*h,_=f*f+d*d;return l*(h*_-p*d)-c*(u*_-p*f)+(l*l+c*c)*(u*d-h*f)<0}function da(t,e,n,r,i,s){const o=n-t,a=r-e,l=i-t,c=s-e,u=o*o+a*a,h=l*l+c*c,f=.5/(o*c-a*l),d=(c*u-a*h)*f,p=(o*h-l*u)*f;return d*d+p*p}function pa(t,e,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){const r=t[i],s=e[r];let o=i-1;for(;o>=n&&e[t[o]]>s;)t[o+1]=t[o--];t[o+1]=r}else{let i=n+1,s=r;_a(t,n+r>>1,i),e[t[n]]>e[t[r]]&&_a(t,n,r),e[t[i]]>e[t[r]]&&_a(t,i,r),e[t[n]]>e[t[i]]&&_a(t,n,i);const o=t[i],a=e[o];for(;;){do{i++}while(e[t[i]]<a);do{s--}while(e[t[s]]>a);if(s<i)break;_a(t,i,s)}t[n+1]=t[s],t[s]=o,r-i+1>=s-n?(pa(t,e,i,r),pa(t,e,n,s-1)):(pa(t,e,n,s-1),pa(t,e,i,r))}}function _a(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function ga(t){return t[0]}function ya(t){return t[1]}const ma=1e-6;let ba=class{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(t,e){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(t,e){this._+=`L${this._x1=+t},${this._y1=+e}`}arc(t,e,n){const r=(t=+t)+(n=+n),i=e=+e;if(n<0)throw new Error("negative radius");null===this._x1?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>ma||Math.abs(this._y1-i)>ma)&&(this._+="L"+r+","+i),n&&(this._+=`A${n},${n},0,1,1,${t-n},${e}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(t,e,n,r){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${+n}v${+r}h${-n}Z`}value(){return this._||null}},va=class{constructor(){this._=[]}moveTo(t,e){this._.push([t,e])}closePath(){this._.push(this._[0].slice())}lineTo(t,e){this._.push([t,e])}value(){return this._.length?this._:null}};class xa{constructor(t,[e,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(e=+e)&&(i=+i)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=t,this._circumcenters=new Float64Array(2*t.points.length),this.vectors=new Float64Array(2*t.points.length),this.xmax=r,this.xmin=e,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:t,hull:e,triangles:n},vectors:r}=this;let i,s;const o=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r,a,l=0,c=0,u=n.length;l<u;l+=3,c+=2){const u=2*n[l],h=2*n[l+1],f=2*n[l+2],d=t[u],p=t[u+1],_=t[h],g=t[h+1],y=t[f],m=t[f+1],b=_-d,v=g-p,x=y-d,w=m-p,E=2*(b*w-v*x);if(Math.abs(E)<1e-9){if(void 0===i){i=s=0;for(const n of e)i+=t[2*n],s+=t[2*n+1];i/=e.length,s/=e.length}const n=1e9*Math.sign((i-d)*w-(s-p)*x);r=(d+y)/2-n*w,a=(p+m)/2+n*x}else{const t=1/E,e=b*b+v*v,n=x*x+w*w;r=d+(w*e-v*n)*t,a=p+(b*n-x*e)*t}o[c]=r,o[c+1]=a}let a,l,c,u=e[e.length-1],h=4*u,f=t[2*u],d=t[2*u+1];r.fill(0);for(let n=0;n<e.length;++n)u=e[n],a=h,l=f,c=d,h=4*u,f=t[2*u],d=t[2*u+1],r[a+2]=r[h]=c-d,r[a+3]=r[h+1]=f-l}render(t){const e=null==t?t=new ba:void 0,{delaunay:{halfedges:n,inedges:r,hull:i},circumcenters:s,vectors:o}=this;if(i.length<=1)return null;for(let e=0,r=n.length;e<r;++e){const r=n[e];if(r<e)continue;const i=2*Math.floor(e/3),o=2*Math.floor(r/3),a=s[i],l=s[i+1],c=s[o],u=s[o+1];this._renderSegment(a,l,c,u,t)}let a,l=i[i.length-1];for(let e=0;e<i.length;++e){a=l,l=i[e];const n=2*Math.floor(r[l]/3),c=s[n],u=s[n+1],h=4*a,f=this._project(c,u,o[h+2],o[h+3]);f&&this._renderSegment(c,u,f[0],f[1],t)}return e&&e.value()}renderBounds(t){const e=null==t?t=new ba:void 0;return t.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),e&&e.value()}renderCell(t,e){const n=null==e?e=new ba:void 0,r=this._clip(t);if(null===r||!r.length)return;e.moveTo(r[0],r[1]);let i=r.length;for(;r[0]===r[i-2]&&r[1]===r[i-1]&&i>1;)i-=2;for(let t=2;t<i;t+=2)r[t]===r[t-2]&&r[t+1]===r[t-1]||e.lineTo(r[t],r[t+1]);return e.closePath(),n&&n.value()}*cellPolygons(){const{delaunay:{points:t}}=this;for(let e=0,n=t.length/2;e<n;++e){const t=this.cellPolygon(e);t&&(t.index=e,yield t)}}cellPolygon(t){const e=new va;return this.renderCell(t,e),e.value()}_renderSegment(t,e,n,r,i){let s;const o=this._regioncode(t,e),a=this._regioncode(n,r);0===o&&0===a?(i.moveTo(t,e),i.lineTo(n,r)):(s=this._clipSegment(t,e,n,r,o,a))&&(i.moveTo(s[0],s[1]),i.lineTo(s[2],s[3]))}contains(t,e,n){return(e=+e)==e&&(n=+n)==n&&this.delaunay._step(t,e,n)===t}*neighbors(t){const e=this._clip(t);if(e)for(const n of this.delaunay.neighbors(t)){const t=this._clip(n);if(t)t:for(let r=0,i=e.length;r<i;r+=2)for(let s=0,o=t.length;s<o;s+=2)if(e[r]===t[s]&&e[r+1]===t[s+1]&&e[(r+2)%i]===t[(s+o-2)%o]&&e[(r+3)%i]===t[(s+o-1)%o]){yield n;break t}}}_cell(t){const{circumcenters:e,delaunay:{inedges:n,halfedges:r,triangles:i}}=this,s=n[t];if(-1===s)return null;const o=[];let a=s;do{const n=Math.floor(a/3);if(o.push(e[2*n],e[2*n+1]),a=a%3==2?a-2:a+1,i[a]!==t)break;a=r[a]}while(a!==s&&-1!==a);return o}_clip(t){if(0===t&&1===this.delaunay.hull.length)return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];const e=this._cell(t);if(null===e)return null;const{vectors:n}=this,r=4*t;return this._simplify(n[r]||n[r+1]?this._clipInfinite(t,e,n[r],n[r+1],n[r+2],n[r+3]):this._clipFinite(t,e))}_clipFinite(t,e){const n=e.length;let r,i,s,o,a=null,l=e[n-2],c=e[n-1],u=this._regioncode(l,c),h=0;for(let f=0;f<n;f+=2)if(r=l,i=c,l=e[f],c=e[f+1],s=u,u=this._regioncode(l,c),0===s&&0===u)o=h,h=0,a?a.push(l,c):a=[l,c];else{let e,n,f,d,p;if(0===s){if(null===(e=this._clipSegment(r,i,l,c,s,u)))continue;[n,f,d,p]=e}else{if(null===(e=this._clipSegment(l,c,r,i,u,s)))continue;[d,p,n,f]=e,o=h,h=this._edgecode(n,f),o&&h&&this._edge(t,o,h,a,a.length),a?a.push(n,f):a=[n,f]}o=h,h=this._edgecode(d,p),o&&h&&this._edge(t,o,h,a,a.length),a?a.push(d,p):a=[d,p]}if(a)o=h,h=this._edgecode(a[0],a[1]),o&&h&&this._edge(t,o,h,a,a.length);else if(this.contains(t,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return a}_clipSegment(t,e,n,r,i,s){const o=i<s;for(o&&([t,e,n,r,i,s]=[n,r,t,e,s,i]);;){if(0===i&&0===s)return o?[n,r,t,e]:[t,e,n,r];if(i&s)return null;let a,l,c=i||s;8&c?(a=t+(n-t)*(this.ymax-e)/(r-e),l=this.ymax):4&c?(a=t+(n-t)*(this.ymin-e)/(r-e),l=this.ymin):2&c?(l=e+(r-e)*(this.xmax-t)/(n-t),a=this.xmax):(l=e+(r-e)*(this.xmin-t)/(n-t),a=this.xmin),i?(t=a,e=l,i=this._regioncode(t,e)):(n=a,r=l,s=this._regioncode(n,r))}}_clipInfinite(t,e,n,r,i,s){let o,a=Array.from(e);if((o=this._project(a[0],a[1],n,r))&&a.unshift(o[0],o[1]),(o=this._project(a[a.length-2],a[a.length-1],i,s))&&a.push(o[0],o[1]),a=this._clipFinite(t,a))for(let e,n=0,r=a.length,i=this._edgecode(a[r-2],a[r-1]);n<r;n+=2)e=i,i=this._edgecode(a[n],a[n+1]),e&&i&&(n=this._edge(t,e,i,a,n),r=a.length);else this.contains(t,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(a=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return a}_edge(t,e,n,r,i){for(;e!==n;){let n,s;switch(e){case 5:e=4;continue;case 4:e=6,n=this.xmax,s=this.ymin;break;case 6:e=2;continue;case 2:e=10,n=this.xmax,s=this.ymax;break;case 10:e=8;continue;case 8:e=9,n=this.xmin,s=this.ymax;break;case 9:e=1;continue;case 1:e=5,n=this.xmin,s=this.ymin}r[i]===n&&r[i+1]===s||!this.contains(t,n,s)||(r.splice(i,0,n,s),i+=2)}return i}_project(t,e,n,r){let i,s,o,a=1/0;if(r<0){if(e<=this.ymin)return null;(i=(this.ymin-e)/r)<a&&(o=this.ymin,s=t+(a=i)*n)}else if(r>0){if(e>=this.ymax)return null;(i=(this.ymax-e)/r)<a&&(o=this.ymax,s=t+(a=i)*n)}if(n>0){if(t>=this.xmax)return null;(i=(this.xmax-t)/n)<a&&(s=this.xmax,o=e+(a=i)*r)}else if(n<0){if(t<=this.xmin)return null;(i=(this.xmin-t)/n)<a&&(s=this.xmin,o=e+(a=i)*r)}return[s,o]}_edgecode(t,e){return(t===this.xmin?1:t===this.xmax?2:0)|(e===this.ymin?4:e===this.ymax?8:0)}_regioncode(t,e){return(t<this.xmin?1:t>this.xmax?2:0)|(e<this.ymin?4:e>this.ymax?8:0)}_simplify(t){if(t&&t.length>4){for(let e=0;e<t.length;e+=2){const n=(e+2)%t.length,r=(e+4)%t.length;(t[e]===t[n]&&t[n]===t[r]||t[e+1]===t[n+1]&&t[n+1]===t[r+1])&&(t.splice(n,2),e-=2)}t.length||(t=null)}return t}}const wa=2*Math.PI,Ea=Math.pow;function Aa(t){return t[0]}function Sa(t){return t[1]}function Ta(t,e,n){return[t+Math.sin(t+e)*n,e+Math.cos(t-e)*n]}class Ca{static from(t,e=Aa,n=Sa,r){return new Ca("length"in t?function(t,e,n,r){const i=t.length,s=new Float64Array(2*i);for(let o=0;o<i;++o){const i=t[o];s[2*o]=e.call(r,i,o,t),s[2*o+1]=n.call(r,i,o,t)}return s}(t,e,n,r):Float64Array.from(function*(t,e,n,r){let i=0;for(const s of t)yield e.call(r,s,i,t),yield n.call(r,s,i,t),++i}(t,e,n,r)))}constructor(t){this._delaunator=new ua(t),this.inedges=new Int32Array(t.length/2),this._hullIndex=new Int32Array(t.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const t=this._delaunator,e=this.points;if(t.hull&&t.hull.length>2&&function(t){const{triangles:e,coords:n}=t;for(let t=0;t<e.length;t+=3){const r=2*e[t],i=2*e[t+1],s=2*e[t+2];if((n[s]-n[r])*(n[i+1]-n[r+1])-(n[i]-n[r])*(n[s+1]-n[r+1])>1e-10)return!1}return!0}(t)){this.collinear=Int32Array.from({length:e.length/2},(t,e)=>e).sort((t,n)=>e[2*t]-e[2*n]||e[2*t+1]-e[2*n+1]);const t=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[e[2*t],e[2*t+1],e[2*n],e[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let t=0,n=e.length/2;t<n;++t){const n=Ta(e[2*t],e[2*t+1],i);e[2*t]=n[0],e[2*t+1]=n[1]}this._delaunator=new ua(e)}else delete this.collinear;const n=this.halfedges=this._delaunator.halfedges,r=this.hull=this._delaunator.hull,i=this.triangles=this._delaunator.triangles,s=this.inedges.fill(-1),o=this._hullIndex.fill(-1);for(let t=0,e=n.length;t<e;++t){const e=i[t%3==2?t-2:t+1];-1!==n[t]&&-1!==s[e]||(s[e]=t)}for(let t=0,e=r.length;t<e;++t)o[r[t]]=t;r.length<=2&&r.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],s[r[0]]=1,2===r.length&&(s[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(t){return new xa(this,t)}*neighbors(t){const{inedges:e,hull:n,_hullIndex:r,halfedges:i,triangles:s,collinear:o}=this;if(o){const e=o.indexOf(t);return e>0&&(yield o[e-1]),void(e<o.length-1&&(yield o[e+1]))}const a=e[t];if(-1===a)return;let l=a,c=-1;do{if(yield c=s[l],l=l%3==2?l-2:l+1,s[l]!==t)return;if(l=i[l],-1===l){const e=n[(r[t]+1)%n.length];return void(e!==c&&(yield e))}}while(l!==a)}find(t,e,n=0){if((t=+t)!=t||(e=+e)!=e)return-1;const r=n;let i;for(;(i=this._step(n,t,e))>=0&&i!==n&&i!==r;)n=i;return i}_step(t,e,n){const{inedges:r,hull:i,_hullIndex:s,halfedges:o,triangles:a,points:l}=this;if(-1===r[t]||!l.length)return(t+1)%(l.length>>1);let c=t,u=Ea(e-l[2*t],2)+Ea(n-l[2*t+1],2);const h=r[t];let f=h;do{let r=a[f];const h=Ea(e-l[2*r],2)+Ea(n-l[2*r+1],2);if(h<u&&(u=h,c=r),f=f%3==2?f-2:f+1,a[f]!==t)break;if(f=o[f],-1===f){if(f=i[(s[t]+1)%i.length],f!==r&&Ea(e-l[2*f],2)+Ea(n-l[2*f+1],2)<u)return f;break}}while(f!==h);return c}render(t){const e=null==t?t=new ba:void 0,{points:n,halfedges:r,triangles:i}=this;for(let e=0,s=r.length;e<s;++e){const s=r[e];if(s<e)continue;const o=2*i[e],a=2*i[s];t.moveTo(n[o],n[o+1]),t.lineTo(n[a],n[a+1])}return this.renderHull(t),e&&e.value()}renderPoints(t,e){void 0!==e||t&&"function"==typeof t.moveTo||(e=t,t=null),e=null==e?2:+e;const n=null==t?t=new ba:void 0,{points:r}=this;for(let n=0,i=r.length;n<i;n+=2){const i=r[n],s=r[n+1];t.moveTo(i+e,s),t.arc(i,s,e,0,wa)}return n&&n.value()}renderHull(t){const e=null==t?t=new ba:void 0,{hull:n,points:r}=this,i=2*n[0],s=n.length;t.moveTo(r[i],r[i+1]);for(let e=1;e<s;++e){const i=2*n[e];t.lineTo(r[i],r[i+1])}return t.closePath(),e&&e.value()}hullPolygon(){const t=new va;return this.renderHull(t),t.value()}renderTriangle(t,e){const n=null==e?e=new ba:void 0,{points:r,triangles:i}=this,s=2*i[t*=3],o=2*i[t+1],a=2*i[t+2];return e.moveTo(r[s],r[s+1]),e.lineTo(r[o],r[o+1]),e.lineTo(r[a],r[a+1]),e.closePath(),n&&n.value()}*trianglePolygons(){const{triangles:t}=this;for(let e=0,n=t.length/3;e<n;++e)yield this.trianglePolygon(e)}trianglePolygon(t){const e=new va;return this.renderTriangle(t,e),e.value()}}var ka={},Ra={};function Ma(t){return new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'}).join(",")+"}")}function Oa(t){var e=Object.create(null),n=[];return t.forEach(function(t){for(var r in t)r in e||n.push(e[r]=r)}),n}function Na(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function Ia(t){var e,n=t.getUTCHours(),r=t.getUTCMinutes(),i=t.getUTCSeconds(),s=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":((e=t.getUTCFullYear())<0?"-"+Na(-e,6):e>9999?"+"+Na(e,6):Na(e,4))+"-"+Na(t.getUTCMonth()+1,2)+"-"+Na(t.getUTCDate(),2)+(s?"T"+Na(n,2)+":"+Na(r,2)+":"+Na(i,2)+"."+Na(s,3)+"Z":i?"T"+Na(n,2)+":"+Na(r,2)+":"+Na(i,2)+"Z":r||n?"T"+Na(n,2)+":"+Na(r,2)+"Z":"")}function Pa(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],s=t.length,o=0,a=0,l=s<=0,c=!1;function u(){if(l)return Ra;if(c)return c=!1,ka;var e,r,i=o;if(34===t.charCodeAt(i)){for(;o++<s&&34!==t.charCodeAt(o)||34===t.charCodeAt(++o););return(e=o)>=s?l=!0:10===(r=t.charCodeAt(o++))?c=!0:13===r&&(c=!0,10===t.charCodeAt(o)&&++o),t.slice(i+1,e-1).replace(/""/g,'"')}for(;o<s;){if(10===(r=t.charCodeAt(e=o++)))c=!0;else if(13===r)c=!0,10===t.charCodeAt(o)&&++o;else if(r!==n)continue;return t.slice(i,e)}return l=!0,t.slice(i,s)}for(10===t.charCodeAt(s-1)&&--s,13===t.charCodeAt(s-1)&&--s;(r=u())!==Ra;){for(var h=[];r!==ka&&r!==Ra;)h.push(r),r=u();e&&null==(h=e(h,a++))||i.push(h)}return i}function i(e,n){return e.map(function(e){return n.map(function(t){return o(e[t])}).join(t)})}function s(e){return e.map(o).join(t)}function o(t){return null==t?"":t instanceof Date?Ia(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,s=r(t,function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=Ma(t);return function(r,i){return e(n(r),i,t)}}(t,e):Ma(t)});return s.columns=i||[],s},parseRows:r,format:function(e,n){return null==n&&(n=Oa(e)),[n.map(o).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=Oa(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(s).join("\n")},formatRow:s,formatValue:o}}var La=Pa(","),Da=La.parse,Va=La.parseRows,Ba=La.format,za=La.formatBody,Ga=La.formatRows,Fa=La.formatRow,ja=La.formatValue,Ua=Pa("\t"),Ya=Ua.parse,Ha=Ua.parseRows,Wa=Ua.format,qa=Ua.formatBody,$a=Ua.formatRows,Xa=Ua.formatRow,Ka=Ua.formatValue;function Za(t){for(var e in t){var n,r,i=t[e].trim();if(i)if("true"===i)i=!0;else if("false"===i)i=!1;else if("NaN"===i)i=NaN;else if(isNaN(n=+i)){if(!(r=i.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;Ja&&r[4]&&!r[7]&&(i=i.replace(/-/g,"/").replace(/T/," ")),i=new Date(i)}else i=n;else i=null;t[e]=i}return t}const Ja=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();function Qa(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.blob()}function tl(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.arrayBuffer()}function el(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.text()}function nl(t,e){return fetch(t,e).then(el)}function rl(t){return function(e,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=void 0),nl(e,n).then(function(e){return t(e,r)})}}var il=rl(Da),sl=rl(Ya);function ol(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);if(204!==t.status&&205!==t.status)return t.json()}function al(t){return(e,n)=>nl(e,n).then(e=>(new DOMParser).parseFromString(e,t))}var ll=al("application/xml"),cl=al("text/html"),ul=al("image/svg+xml");function hl(t,e){var n,r=1;function i(){var i,s,o=n.length,a=0,l=0;for(i=0;i<o;++i)a+=(s=n[i]).x,l+=s.y;for(a=(a/o-t)*r,l=(l/o-e)*r,i=0;i<o;++i)(s=n[i]).x-=a,s.y-=l}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function fl(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,s,o,a,l,c,u,h,f,d=t._root,p={data:r},_=t._x0,g=t._y0,y=t._x1,m=t._y1;if(!d)return t._root=p,t;for(;d.length;)if((c=e>=(s=(_+y)/2))?_=s:y=s,(u=n>=(o=(g+m)/2))?g=o:m=o,i=d,!(d=d[h=u<<1|c]))return i[h]=p,t;if(a=+t._x.call(null,d.data),l=+t._y.call(null,d.data),e===a&&n===l)return p.next=d,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(c=e>=(s=(_+y)/2))?_=s:y=s,(u=n>=(o=(g+m)/2))?g=o:m=o}while((h=u<<1|c)==(f=(l>=o)<<1|a>=s));return i[f]=d,i[h]=p,t}function dl(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function pl(t){return t[0]}function _l(t){return t[1]}function gl(t,e,n){var r=new yl(null==e?pl:e,null==n?_l:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function yl(t,e,n,r,i,s){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=s,this._root=void 0}function ml(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var bl=gl.prototype=yl.prototype;function vl(t){return function(){return t}}function xl(t){return 1e-6*(t()-.5)}function wl(t){return t.x+t.vx}function El(t){return t.y+t.vy}function Al(t){return t.index}function Sl(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Tl(t){var e,n,r,i,s,o,a=Al,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=vl(30),u=1;function h(r){for(var i=0,a=t.length;i<u;++i)for(var l,c,h,f,d,p,_,g=0;g<a;++g)c=(l=t[g]).source,f=(h=l.target).x+h.vx-c.x-c.vx||xl(o),d=h.y+h.vy-c.y-c.vy||xl(o),f*=p=((p=Math.sqrt(f*f+d*d))-n[g])/p*r*e[g],d*=p,h.vx-=f*(_=s[g]),h.vy-=d*_,c.vx+=f*(_=1-_),c.vy+=d*_}function f(){if(r){var o,l,c=r.length,u=t.length,h=new Map(r.map((t,e)=>[a(t,e,r),t]));for(o=0,i=new Array(c);o<u;++o)(l=t[o]).index=o,"object"!=typeof l.source&&(l.source=Sl(h,l.source)),"object"!=typeof l.target&&(l.target=Sl(h,l.target)),i[l.source.index]=(i[l.source.index]||0)+1,i[l.target.index]=(i[l.target.index]||0)+1;for(o=0,s=new Array(u);o<u;++o)l=t[o],s[o]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(u),d(),n=new Array(u),p()}}function d(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+c(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,o=e,f()},h.links=function(e){return arguments.length?(t=e,f(),h):t},h.id=function(t){return arguments.length?(a=t,h):a},h.iterations=function(t){return arguments.length?(u=+t,h):u},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:vl(+t),d(),h):l},h.distance=function(t){return arguments.length?(c="function"==typeof t?t:vl(+t),p(),h):c},h}bl.copy=function(){var t,e,n=new yl(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=ml(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=ml(e));return n},bl.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return fl(this.cover(e,n),e,n,t)},bl.addAll=function(t){var e,n,r,i,s=t.length,o=new Array(s),a=new Array(s),l=1/0,c=1/0,u=-1/0,h=-1/0;for(n=0;n<s;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(o[n]=r,a[n]=i,r<l&&(l=r),r>u&&(u=r),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<s;++n)fl(this,o[n],a[n],t[n]);return this},bl.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,s=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,s=(r=Math.floor(e))+1;else{for(var o,a,l=i-n||1,c=this._root;n>t||t>=i||r>e||e>=s;)switch(a=(e<r)<<1|t<n,(o=new Array(4))[a]=c,c=o,l*=2,a){case 0:i=n+l,s=r+l;break;case 1:n=i-l,s=r+l;break;case 2:i=n+l,r=s-l;break;case 3:n=i-l,r=s-l}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=r,this._x1=i,this._y1=s,this},bl.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},bl.extent=function(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]]},bl.find=function(t,e,n){var r,i,s,o,a,l,c,u=this._x0,h=this._y0,f=this._x1,d=this._y1,p=[],_=this._root;for(_&&p.push(new dl(_,u,h,f,d)),null==n?n=1/0:(u=t-n,h=e-n,f=t+n,d=e+n,n*=n);l=p.pop();)if(!(!(_=l.node)||(i=l.x0)>f||(s=l.y0)>d||(o=l.x1)<u||(a=l.y1)<h))if(_.length){var g=(i+o)/2,y=(s+a)/2;p.push(new dl(_[3],g,y,o,a),new dl(_[2],i,y,g,a),new dl(_[1],g,s,o,y),new dl(_[0],i,s,g,y)),(c=(e>=y)<<1|t>=g)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=l)}else{var m=t-+this._x.call(null,_.data),b=e-+this._y.call(null,_.data),v=m*m+b*b;if(v<n){var x=Math.sqrt(n=v);u=t-x,h=e-x,f=t+x,d=e+x,r=_.data}}return r},bl.remove=function(t){if(isNaN(s=+this._x.call(null,t))||isNaN(o=+this._y.call(null,t)))return this;var e,n,r,i,s,o,a,l,c,u,h,f,d=this._root,p=this._x0,_=this._y0,g=this._x1,y=this._y1;if(!d)return this;if(d.length)for(;;){if((c=s>=(a=(p+g)/2))?p=a:g=a,(u=o>=(l=(_+y)/2))?_=l:y=l,e=d,!(d=d[h=u<<1|c]))return this;if(!d.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,f=h)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(n?n[f]=d:this._root=d),this):(this._root=i,this)},bl.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},bl.root=function(){return this._root},bl.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},bl.visit=function(t){var e,n,r,i,s,o,a=[],l=this._root;for(l&&a.push(new dl(l,this._x0,this._y0,this._x1,this._y1));e=a.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,s=e.x1,o=e.y1)&&l.length){var c=(r+s)/2,u=(i+o)/2;(n=l[3])&&a.push(new dl(n,c,u,s,o)),(n=l[2])&&a.push(new dl(n,r,u,c,o)),(n=l[1])&&a.push(new dl(n,c,i,s,u)),(n=l[0])&&a.push(new dl(n,r,i,c,u))}return this},bl.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new dl(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var s,o=e.x0,a=e.y0,l=e.x1,c=e.y1,u=(o+l)/2,h=(a+c)/2;(s=i[0])&&n.push(new dl(s,o,a,u,h)),(s=i[1])&&n.push(new dl(s,u,a,l,h)),(s=i[2])&&n.push(new dl(s,o,h,u,c)),(s=i[3])&&n.push(new dl(s,u,h,l,c))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},bl.x=function(t){return arguments.length?(this._x=t,this):this._x},bl.y=function(t){return arguments.length?(this._y=t,this):this._y};const Cl=4294967296;function kl(t){return t.x}function Rl(t){return t.y}var Ml=Math.PI*(3-Math.sqrt(5));function Ol(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),s=0,o=.6,a=new Map,l=Si(h),c=Nt("tick","end"),u=function(){let t=1;return()=>(t=(1664525*t+1013904223)%Cl)/Cl}();function h(){f(),c.call("tick",e),n<r&&(l.stop(),c.call("end",e))}function f(r){var l,c,u=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(s-n)*i,a.forEach(function(t){t(n)}),l=0;l<u;++l)null==(c=t[l]).fx?c.x+=c.vx*=o:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=o:(c.y=c.fy,c.vy=0);return e}function d(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),s=n*Ml;e.x=i*Math.cos(s),e.y=i*Math.sin(s)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,u),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,d(),a.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(s=+t,e):s},velocityDecay:function(t){return arguments.length?(o=1-t,e):1-o},randomSource:function(t){return arguments.length?(u=t,a.forEach(p),e):u},force:function(t,n){return arguments.length>1?(null==n?a.delete(t):a.set(t,p(n)),e):a.get(t)},find:function(e,n,r){var i,s,o,a,l,c=0,u=t.length;for(null==r?r=1/0:r*=r,c=0;c<u;++c)(o=(i=e-(a=t[c]).x)*i+(s=n-a.y)*s)<r&&(l=a,r=o);return l},on:function(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t)}}}function Nl(){var t,e,n,r,i,s=vl(-30),o=1,a=1/0,l=.81;function c(n){var i,s=t.length,o=gl(t,kl,Rl).visitAfter(h);for(r=n,i=0;i<s;++i)e=t[i],o.visit(f)}function u(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+s(n,e,t)}}function h(t){var e,n,r,s,o,a=0,l=0;if(t.length){for(r=s=o=0;o<4;++o)(e=t[o])&&(n=Math.abs(e.value))&&(a+=e.value,l+=n,r+=n*e.x,s+=n*e.y);t.x=r/l,t.y=s/l}else{(e=t).x=e.data.x,e.y=e.data.y;do{a+=i[e.data.index]}while(e=e.next)}t.value=a}function f(t,s,c,u){if(!t.value)return!0;var h=t.x-e.x,f=t.y-e.y,d=u-s,p=h*h+f*f;if(d*d/l<p)return p<a&&(0===h&&(p+=(h=xl(n))*h),0===f&&(p+=(f=xl(n))*f),p<o&&(p=Math.sqrt(o*p)),e.vx+=h*t.value*r/p,e.vy+=f*t.value*r/p),!0;if(!(t.length||p>=a)){(t.data!==e||t.next)&&(0===h&&(p+=(h=xl(n))*h),0===f&&(p+=(f=xl(n))*f),p<o&&(p=Math.sqrt(o*p)));do{t.data!==e&&(d=i[t.data.index]*r/p,e.vx+=h*d,e.vy+=f*d)}while(t=t.next)}}return c.initialize=function(e,r){t=e,n=r,u()},c.strength=function(t){return arguments.length?(s="function"==typeof t?t:vl(+t),u(),c):s},c.distanceMin=function(t){return arguments.length?(o=t*t,c):Math.sqrt(o)},c.distanceMax=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.theta=function(t){return arguments.length?(l=t*t,c):Math.sqrt(l)},c}function Il(t){var e,n,r,i=vl(.1);function s(t){for(var i,s=0,o=e.length;s<o;++s)(i=e[s]).vx+=(r[s]-i.x)*n[s]*t}function o(){if(e){var s,o=e.length;for(n=new Array(o),r=new Array(o),s=0;s<o;++s)n[s]=isNaN(r[s]=+t(e[s],s,e))?0:+i(e[s],s,e)}}return"function"!=typeof t&&(t=vl(null==t?0:+t)),s.initialize=function(t){e=t,o()},s.strength=function(t){return arguments.length?(i="function"==typeof t?t:vl(+t),o(),s):i},s.x=function(e){return arguments.length?(t="function"==typeof e?e:vl(+e),o(),s):t},s}function Pl(t){var e,n,r,i=vl(.1);function s(t){for(var i,s=0,o=e.length;s<o;++s)(i=e[s]).vy+=(r[s]-i.y)*n[s]*t}function o(){if(e){var s,o=e.length;for(n=new Array(o),r=new Array(o),s=0;s<o;++s)n[s]=isNaN(r[s]=+t(e[s],s,e))?0:+i(e[s],s,e)}}return"function"!=typeof t&&(t=vl(null==t?0:+t)),s.initialize=function(t){e=t,o()},s.strength=function(t){return arguments.length?(i="function"==typeof t?t:vl(+t),o(),s):i},s.y=function(e){return arguments.length?(t="function"==typeof e?e:vl(+e),o(),s):t},s}function Ll(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 Dl(t){return(t=Ll(Math.abs(t)))?t[1]:NaN}var Vl,Bl=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function zl(t){if(!(e=Bl.exec(t)))throw new Error("invalid format: "+t);var e;return new Gl({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]})}function Gl(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Fl(t,e){var n=Ll(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}zl.prototype=Gl.prototype,Gl.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var jl={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,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)=>Fl(100*t,e),r:Fl,s:function(t,e){var n=Ll(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(Vl=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return s===o?r:s>o?r+new Array(s-o+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+Ll(t,Math.max(0,e+s-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Ul(t){return t}var Yl,Hl,Wl,ql=Array.prototype.map,$l=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Xl(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Ul:(e=ql.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,s=[],o=0,a=e[0],l=0;i>0&&a>0&&(l+a+1>r&&(a=Math.max(1,r-l)),s.push(t.substring(i-=a,i+a)),!((l+=a+1)>r));)a=e[o=(o+1)%e.length];return s.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",s=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",a=void 0===t.numerals?Ul:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(ql.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",c=void 0===t.minus?"−":t.minus+"",u=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=zl(t)).fill,n=t.align,h=t.sign,f=t.symbol,d=t.zero,p=t.width,_=t.comma,g=t.precision,y=t.trim,m=t.type;"n"===m?(_=!0,m="g"):jl[m]||(void 0===g&&(g=12),y=!0,m="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var b="$"===f?i:"#"===f&&/[boxX]/.test(m)?"0"+m.toLowerCase():"",v="$"===f?s:/[%p]/.test(m)?l:"",x=jl[m],w=/[defgprs%]/.test(m);function E(t){var i,s,l,f=b,E=v;if("c"===m)E=x(t)+E,t="";else{var A=(t=+t)<0||1/t<0;if(t=isNaN(t)?u:x(Math.abs(t),g),y&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),A&&0===+t&&"+"!==h&&(A=!1),f=(A?"("===h?h:c:"-"===h||"("===h?"":h)+f,E=("s"===m?$l[8+Vl/3]:"")+E+(A&&"("===h?")":""),w)for(i=-1,s=t.length;++i<s;)if(48>(l=t.charCodeAt(i))||l>57){E=(46===l?o+t.slice(i+1):t.slice(i))+E,t=t.slice(0,i);break}}_&&!d&&(t=r(t,1/0));var S=f.length+t.length+E.length,T=S<p?new Array(p-S+1).join(e):"";switch(_&&d&&(t=r(T+t,T.length?p-E.length:1/0),T=""),n){case"<":t=f+t+E+T;break;case"=":t=f+T+t+E;break;case"^":t=T.slice(0,S=T.length>>1)+f+t+E+T.slice(S);break;default:t=T+f+t+E}return a(t)}return g=void 0===g?6:/[gprs]/.test(m)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),E.toString=function(){return t+""},E}return{format:h,formatPrefix:function(t,e){var n=h(((t=zl(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Dl(e)/3))),i=Math.pow(10,-r),s=$l[8+r/3];return function(t){return n(i*t)+s}}}}function Kl(t){return Yl=Xl(t),Hl=Yl.format,Wl=Yl.formatPrefix,Yl}function Zl(t){return Math.max(0,-Dl(Math.abs(t)))}function Jl(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Dl(e)/3)))-Dl(Math.abs(t)))}function Ql(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Dl(e)-Dl(t))+1}Kl({thousands:",",grouping:[3],currency:["$",""]});var tc=1e-6,ec=1e-12,nc=Math.PI,rc=nc/2,ic=nc/4,sc=2*nc,oc=180/nc,ac=nc/180,lc=Math.abs,cc=Math.atan,uc=Math.atan2,hc=Math.cos,fc=Math.ceil,dc=Math.exp,pc=Math.hypot,_c=Math.log,gc=Math.pow,yc=Math.sin,mc=Math.sign||function(t){return t>0?1:t<0?-1:0},bc=Math.sqrt,vc=Math.tan;function xc(t){return t>1?0:t<-1?nc:Math.acos(t)}function wc(t){return t>1?rc:t<-1?-rc:Math.asin(t)}function Ec(t){return(t=yc(t/2))*t}function Ac(){}function Sc(t,e){t&&Cc.hasOwnProperty(t.type)&&Cc[t.type](t,e)}var Tc={Feature:function(t,e){Sc(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;)Sc(n[r].geometry,e)}},Cc={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)t=n[r],e.point(t[0],t[1],t[2])},LineString:function(t,e){kc(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)kc(n[r],e,0)},Polygon:function(t,e){Rc(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)Rc(n[r],e)},GeometryCollection:function(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;)Sc(n[r],e)}};function kc(t,e,n){var r,i=-1,s=t.length-n;for(e.lineStart();++i<s;)r=t[i],e.point(r[0],r[1],r[2]);e.lineEnd()}function Rc(t,e){var n=-1,r=t.length;for(e.polygonStart();++n<r;)kc(t[n],e,1);e.polygonEnd()}function Mc(t,e){t&&Tc.hasOwnProperty(t.type)?Tc[t.type](t,e):Sc(t,e)}var Oc,Nc,Ic,Pc,Lc,Dc,Vc,Bc,zc,Gc,Fc,jc,Uc,Yc,Hc,Wc,qc=new w,$c=new w,Xc={point:Ac,lineStart:Ac,lineEnd:Ac,polygonStart:function(){qc=new w,Xc.lineStart=Kc,Xc.lineEnd=Zc},polygonEnd:function(){var t=+qc;$c.add(t<0?sc+t:t),this.lineStart=this.lineEnd=this.point=Ac},sphere:function(){$c.add(sc)}};function Kc(){Xc.point=Jc}function Zc(){Qc(Oc,Nc)}function Jc(t,e){Xc.point=Qc,Oc=t,Nc=e,Ic=t*=ac,Pc=hc(e=(e*=ac)/2+ic),Lc=yc(e)}function Qc(t,e){var n=(t*=ac)-Ic,r=n>=0?1:-1,i=r*n,s=hc(e=(e*=ac)/2+ic),o=yc(e),a=Lc*o,l=Pc*s+a*hc(i),c=a*r*yc(i);qc.add(uc(c,l)),Ic=t,Pc=s,Lc=o}function tu(t){return[uc(t[1],t[0]),wc(t[2])]}function eu(t){var e=t[0],n=t[1],r=hc(n);return[r*hc(e),r*yc(e),yc(n)]}function nu(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ru(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function iu(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function su(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function ou(t){var e=bc(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}var au,lu,cu,uu,hu,fu,du,pu,_u,gu,yu,mu,bu,vu,xu,wu,Eu={point:Au,lineStart:Tu,lineEnd:Cu,polygonStart:function(){Eu.point=ku,Eu.lineStart=Ru,Eu.lineEnd=Mu,Yc=new w,Xc.polygonStart()},polygonEnd:function(){Xc.polygonEnd(),Eu.point=Au,Eu.lineStart=Tu,Eu.lineEnd=Cu,qc<0?(Dc=-(Bc=180),Vc=-(zc=90)):Yc>tc?zc=90:Yc<-1e-6&&(Vc=-90),Wc[0]=Dc,Wc[1]=Bc},sphere:function(){Dc=-(Bc=180),Vc=-(zc=90)}};function Au(t,e){Hc.push(Wc=[Dc=t,Bc=t]),e<Vc&&(Vc=e),e>zc&&(zc=e)}function Su(t,e){var n=eu([t*ac,e*ac]);if(Uc){var r=ru(Uc,n),i=ru([r[1],-r[0],0],r);ou(i),i=tu(i);var s,o=t-Gc,a=o>0?1:-1,l=i[0]*oc*a,c=lc(o)>180;c^(a*Gc<l&&l<a*t)?(s=i[1]*oc)>zc&&(zc=s):c^(a*Gc<(l=(l+360)%360-180)&&l<a*t)?(s=-i[1]*oc)<Vc&&(Vc=s):(e<Vc&&(Vc=e),e>zc&&(zc=e)),c?t<Gc?Ou(Dc,t)>Ou(Dc,Bc)&&(Bc=t):Ou(t,Bc)>Ou(Dc,Bc)&&(Dc=t):Bc>=Dc?(t<Dc&&(Dc=t),t>Bc&&(Bc=t)):t>Gc?Ou(Dc,t)>Ou(Dc,Bc)&&(Bc=t):Ou(t,Bc)>Ou(Dc,Bc)&&(Dc=t)}else Hc.push(Wc=[Dc=t,Bc=t]);e<Vc&&(Vc=e),e>zc&&(zc=e),Uc=n,Gc=t}function Tu(){Eu.point=Su}function Cu(){Wc[0]=Dc,Wc[1]=Bc,Eu.point=Au,Uc=null}function ku(t,e){if(Uc){var n=t-Gc;Yc.add(lc(n)>180?n+(n>0?360:-360):n)}else Fc=t,jc=e;Xc.point(t,e),Su(t,e)}function Ru(){Xc.lineStart()}function Mu(){ku(Fc,jc),Xc.lineEnd(),lc(Yc)>tc&&(Dc=-(Bc=180)),Wc[0]=Dc,Wc[1]=Bc,Uc=null}function Ou(t,e){return(e-=t)<0?e+360:e}function Nu(t,e){return t[0]-e[0]}function Iu(t,e){return t[0]<=t[1]?t[0]<=e&&e<=t[1]:e<t[0]||t[1]<e}var Pu={sphere:Ac,point:Lu,lineStart:Vu,lineEnd:Gu,polygonStart:function(){Pu.lineStart=Fu,Pu.lineEnd=ju},polygonEnd:function(){Pu.lineStart=Vu,Pu.lineEnd=Gu}};function Lu(t,e){t*=ac;var n=hc(e*=ac);Du(n*hc(t),n*yc(t),yc(e))}function Du(t,e,n){++au,cu+=(t-cu)/au,uu+=(e-uu)/au,hu+=(n-hu)/au}function Vu(){Pu.point=Bu}function Bu(t,e){t*=ac;var n=hc(e*=ac);vu=n*hc(t),xu=n*yc(t),wu=yc(e),Pu.point=zu,Du(vu,xu,wu)}function zu(t,e){t*=ac;var n=hc(e*=ac),r=n*hc(t),i=n*yc(t),s=yc(e),o=uc(bc((o=xu*s-wu*i)*o+(o=wu*r-vu*s)*o+(o=vu*i-xu*r)*o),vu*r+xu*i+wu*s);lu+=o,fu+=o*(vu+(vu=r)),du+=o*(xu+(xu=i)),pu+=o*(wu+(wu=s)),Du(vu,xu,wu)}function Gu(){Pu.point=Lu}function Fu(){Pu.point=Uu}function ju(){Yu(mu,bu),Pu.point=Lu}function Uu(t,e){mu=t,bu=e,t*=ac,e*=ac,Pu.point=Yu;var n=hc(e);vu=n*hc(t),xu=n*yc(t),wu=yc(e),Du(vu,xu,wu)}function Yu(t,e){t*=ac;var n=hc(e*=ac),r=n*hc(t),i=n*yc(t),s=yc(e),o=xu*s-wu*i,a=wu*r-vu*s,l=vu*i-xu*r,c=pc(o,a,l),u=wc(c),h=c&&-u/c;_u.add(h*o),gu.add(h*a),yu.add(h*l),lu+=u,fu+=u*(vu+(vu=r)),du+=u*(xu+(xu=i)),pu+=u*(wu+(wu=s)),Du(vu,xu,wu)}function Hu(t){return function(){return t}}function Wu(t,e){function n(n,r){return n=t(n,r),e(n[0],n[1])}return t.invert&&e.invert&&(n.invert=function(n,r){return(n=e.invert(n,r))&&t.invert(n[0],n[1])}),n}function qu(t,e){return lc(t)>nc&&(t-=Math.round(t/sc)*sc),[t,e]}function $u(t,e,n){return(t%=sc)?e||n?Wu(Ku(t),Zu(e,n)):Ku(t):e||n?Zu(e,n):qu}function Xu(t){return function(e,n){return lc(e+=t)>nc&&(e-=Math.round(e/sc)*sc),[e,n]}}function Ku(t){var e=Xu(t);return e.invert=Xu(-t),e}function Zu(t,e){var n=hc(t),r=yc(t),i=hc(e),s=yc(e);function o(t,e){var o=hc(e),a=hc(t)*o,l=yc(t)*o,c=yc(e),u=c*n+a*r;return[uc(l*i-u*s,a*n-c*r),wc(u*i+l*s)]}return o.invert=function(t,e){var o=hc(e),a=hc(t)*o,l=yc(t)*o,c=yc(e),u=c*i-l*s;return[uc(l*i+c*s,a*n+u*r),wc(u*n-a*r)]},o}function Ju(t){function e(e){return(e=t(e[0]*ac,e[1]*ac))[0]*=oc,e[1]*=oc,e}return t=$u(t[0]*ac,t[1]*ac,t.length>2?t[2]*ac:0),e.invert=function(e){return(e=t.invert(e[0]*ac,e[1]*ac))[0]*=oc,e[1]*=oc,e},e}function Qu(t,e,n,r,i,s){if(n){var o=hc(e),a=yc(e),l=r*n;null==i?(i=e+r*sc,s=e-l/2):(i=th(o,i),s=th(o,s),(r>0?i<s:i>s)&&(i+=r*sc));for(var c,u=i;r>0?u>s:u<s;u-=l)c=tu([o,-a*hc(u),-a*yc(u)]),t.point(c[0],c[1])}}function th(t,e){(e=eu(e))[0]-=t,ou(e);var n=xc(-e[1]);return((-e[2]<0?-n:n)+sc-tc)%sc}function eh(){var t,e=[];return{point:function(e,n,r){t.push([e,n,r])},lineStart:function(){e.push(t=[])},lineEnd:Ac,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function nh(t,e){return lc(t[0]-e[0])<tc&&lc(t[1]-e[1])<tc}function rh(t,e,n,r){this.x=t,this.z=e,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function ih(t,e,n,r,i){var s,o,a=[],l=[];if(t.forEach(function(t){if(!((e=t.length-1)<=0)){var e,n,r=t[0],o=t[e];if(nh(r,o)){if(!r[2]&&!o[2]){for(i.lineStart(),s=0;s<e;++s)i.point((r=t[s])[0],r[1]);return void i.lineEnd()}o[0]+=2e-6}a.push(n=new rh(r,t,null,!0)),l.push(n.o=new rh(r,null,n,!1)),a.push(n=new rh(o,t,null,!1)),l.push(n.o=new rh(o,null,n,!0))}}),a.length){for(l.sort(e),sh(a),sh(l),s=0,o=l.length;s<o;++s)l[s].e=n=!n;for(var c,u,h=a[0];;){for(var f=h,d=!0;f.v;)if((f=f.n)===h)return;c=f.z,i.lineStart();do{if(f.v=f.o.v=!0,f.e){if(d)for(s=0,o=c.length;s<o;++s)i.point((u=c[s])[0],u[1]);else r(f.x,f.n.x,1,i);f=f.n}else{if(d)for(c=f.p.z,s=c.length-1;s>=0;--s)i.point((u=c[s])[0],u[1]);else r(f.x,f.p.x,-1,i);f=f.p}c=(f=f.o).z,d=!d}while(!f.v);i.lineEnd()}}}function sh(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r<e;)i.n=n=t[r],n.p=i,i=n;i.n=n=t[0],n.p=i}}function oh(t){return lc(t[0])<=nc?t[0]:mc(t[0])*((lc(t[0])+nc)%sc-nc)}function ah(t,e){var n=oh(e),r=e[1],i=yc(r),s=[yc(n),-hc(n),0],o=0,a=0,l=new w;1===i?r=rc+tc:-1===i&&(r=-rc-tc);for(var c=0,u=t.length;c<u;++c)if(f=(h=t[c]).length)for(var h,f,d=h[f-1],p=oh(d),_=d[1]/2+ic,g=yc(_),y=hc(_),m=0;m<f;++m,p=v,g=E,y=A,d=b){var b=h[m],v=oh(b),x=b[1]/2+ic,E=yc(x),A=hc(x),S=v-p,T=S>=0?1:-1,C=T*S,k=C>nc,R=g*E;if(l.add(uc(R*T*yc(C),y*A+R*hc(C))),o+=k?S+T*sc:S,k^p>=n^v>=n){var M=ru(eu(d),eu(b));ou(M);var O=ru(s,M);ou(O);var N=(k^S>=0?-1:1)*wc(O[2]);(r>N||r===N&&(M[0]||M[1]))&&(a+=k^S>=0?1:-1)}}return(o<-1e-6||o<tc&&l<-1e-12)^1&a}function lh(t,e,n,r){return function(i){var s,o,a,l=e(i),c=eh(),u=e(c),h=!1,f={point:d,lineStart:_,lineEnd:g,polygonStart:function(){f.point=y,f.lineStart=m,f.lineEnd=b,o=[],s=[]},polygonEnd:function(){f.point=d,f.lineStart=_,f.lineEnd=g,o=ht(o);var t=ah(s,r);o.length?(h||(i.polygonStart(),h=!0),ih(o,uh,t,n,i)):t&&(h||(i.polygonStart(),h=!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),h&&(i.polygonEnd(),h=!1),o=s=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function d(e,n){t(e,n)&&i.point(e,n)}function p(t,e){l.point(t,e)}function _(){f.point=p,l.lineStart()}function g(){f.point=d,l.lineEnd()}function y(t,e){a.push([t,e]),u.point(t,e)}function m(){u.lineStart(),a=[]}function b(){y(a[0][0],a[0][1]),u.lineEnd();var t,e,n,r,l=u.clean(),f=c.result(),d=f.length;if(a.pop(),s.push(a),a=null,d)if(1&l){if((e=(n=f[0]).length-1)>0){for(h||(i.polygonStart(),h=!0),i.lineStart(),t=0;t<e;++t)i.point((r=n[t])[0],r[1]);i.lineEnd()}}else d>1&&2&l&&f.push(f.pop().concat(f.shift())),o.push(f.filter(ch))}return f}}function ch(t){return t.length>1}function uh(t,e){return((t=t.x)[0]<0?t[1]-rc-tc:rc-t[1])-((e=e.x)[0]<0?e[1]-rc-tc:rc-e[1])}qu.invert=qu;var hh=lh(function(){return!0},function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(s,o){var a=s>0?nc:-nc,l=lc(s-n);lc(l-nc)<tc?(t.point(n,r=(r+o)/2>0?rc:-rc),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),t.point(s,r),e=0):i!==a&&l>=nc&&(lc(n-i)<tc&&(n-=i*tc),lc(s-a)<tc&&(s-=a*tc),r=function(t,e,n,r){var i,s,o=yc(t-n);return lc(o)>tc?cc((yc(e)*(s=hc(r))*yc(n)-yc(r)*(i=hc(e))*yc(t))/(i*s*o)):(e+r)/2}(n,r,s,o),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),e=0),t.point(n=s,r=o),i=a},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}},function(t,e,n,r){var i;if(null==t)i=n*rc,r.point(-nc,i),r.point(0,i),r.point(nc,i),r.point(nc,0),r.point(nc,-i),r.point(0,-i),r.point(-nc,-i),r.point(-nc,0),r.point(-nc,i);else if(lc(t[0]-e[0])>tc){var s=t[0]<e[0]?nc:-nc;i=n*s/2,r.point(-s,i),r.point(0,i),r.point(s,i)}else r.point(e[0],e[1])},[-nc,-rc]);function fh(t){var e=hc(t),n=2*ac,r=e>0,i=lc(e)>tc;function s(t,n){return hc(t)*hc(n)>e}function o(t,n,r){var i=[1,0,0],s=ru(eu(t),eu(n)),o=nu(s,s),a=s[0],l=o-a*a;if(!l)return!r&&t;var c=e*o/l,u=-e*a/l,h=ru(i,s),f=su(i,c);iu(f,su(s,u));var d=h,p=nu(f,d),_=nu(d,d),g=p*p-_*(nu(f,f)-1);if(!(g<0)){var y=bc(g),m=su(d,(-p-y)/_);if(iu(m,f),m=tu(m),!r)return m;var b,v=t[0],x=n[0],w=t[1],E=n[1];x<v&&(b=v,v=x,x=b);var A=x-v,S=lc(A-nc)<tc;if(!S&&E<w&&(b=w,w=E,E=b),S||A<tc?S?w+E>0^m[1]<(lc(m[0]-v)<tc?w:E):w<=m[1]&&m[1]<=E:A>nc^(v<=m[0]&&m[0]<=x)){var T=su(d,(-p+y)/_);return iu(T,f),[m,tu(T)]}}}function a(e,n){var i=r?t:nc-t,s=0;return e<-i?s|=1:e>i&&(s|=2),n<-i?s|=4:n>i&&(s|=8),s}return lh(s,function(t){var e,n,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(h,f){var d,p=[h,f],_=s(h,f),g=r?_?0:a(h,f):_?a(h+(h<0?nc:-nc),f):0;if(!e&&(c=l=_)&&t.lineStart(),_!==l&&(!(d=o(e,p))||nh(e,d)||nh(p,d))&&(p[2]=1),_!==l)u=0,_?(t.lineStart(),d=o(p,e),t.point(d[0],d[1])):(d=o(e,p),t.point(d[0],d[1],2),t.lineEnd()),e=d;else if(i&&e&&r^_){var y;g&n||!(y=o(p,e,!0))||(u=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1],3)))}!_||e&&nh(e,p)||t.point(p[0],p[1]),e=p,l=_,n=g},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return u|(c&&l)<<1}}},function(e,r,i,s){Qu(s,t,n,i,e,r)},r?[0,-t]:[-nc,t-nc])}var dh,ph,_h,gh,yh=1e9,mh=-yh;function bh(t,e,n,r){function i(i,s){return t<=i&&i<=n&&e<=s&&s<=r}function s(i,s,a,c){var u=0,h=0;if(null==i||(u=o(i,a))!==(h=o(s,a))||l(i,s)<0^a>0)do{c.point(0===u||3===u?t:n,u>1?r:e)}while((u=(u+a+4)%4)!==h);else c.point(s[0],s[1])}function o(r,i){return lc(r[0]-t)<tc?i>0?0:3:lc(r[0]-n)<tc?i>0?2:1:lc(r[1]-e)<tc?i>0?1:0:i>0?3:2}function a(t,e){return l(t.x,e.x)}function l(t,e){var n=o(t,1),r=o(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(o){var l,c,u,h,f,d,p,_,g,y,m,b=o,v=eh(),x={point:w,lineStart:function(){x.point=E,c&&c.push(u=[]);y=!0,g=!1,p=_=NaN},lineEnd:function(){l&&(E(h,f),d&&g&&v.rejoin(),l.push(v.result()));x.point=w,g&&b.lineEnd()},polygonStart:function(){b=v,l=[],c=[],m=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=c.length;n<i;++n)for(var s,o,a=c[n],l=1,u=a.length,h=a[0],f=h[0],d=h[1];l<u;++l)s=f,o=d,f=(h=a[l])[0],d=h[1],o<=r?d>r&&(f-s)*(r-o)>(d-o)*(t-s)&&++e:d<=r&&(f-s)*(r-o)<(d-o)*(t-s)&&--e;return e}(),n=m&&e,i=(l=ht(l)).length;(n||i)&&(o.polygonStart(),n&&(o.lineStart(),s(null,null,1,o),o.lineEnd()),i&&ih(l,a,e,s,o),o.polygonEnd());b=o,l=c=u=null}};function w(t,e){i(t,e)&&b.point(t,e)}function E(s,o){var a=i(s,o);if(c&&u.push([s,o]),y)h=s,f=o,d=a,y=!1,a&&(b.lineStart(),b.point(s,o));else if(a&&g)b.point(s,o);else{var l=[p=Math.max(mh,Math.min(yh,p)),_=Math.max(mh,Math.min(yh,_))],v=[s=Math.max(mh,Math.min(yh,s)),o=Math.max(mh,Math.min(yh,o))];!function(t,e,n,r,i,s){var o,a=t[0],l=t[1],c=0,u=1,h=e[0]-a,f=e[1]-l;if(o=n-a,h||!(o>0)){if(o/=h,h<0){if(o<c)return;o<u&&(u=o)}else if(h>0){if(o>u)return;o>c&&(c=o)}if(o=i-a,h||!(o<0)){if(o/=h,h<0){if(o>u)return;o>c&&(c=o)}else if(h>0){if(o<c)return;o<u&&(u=o)}if(o=r-l,f||!(o>0)){if(o/=f,f<0){if(o<c)return;o<u&&(u=o)}else if(f>0){if(o>u)return;o>c&&(c=o)}if(o=s-l,f||!(o<0)){if(o/=f,f<0){if(o>u)return;o>c&&(c=o)}else if(f>0){if(o<c)return;o<u&&(u=o)}return c>0&&(t[0]=a+c*h,t[1]=l+c*f),u<1&&(e[0]=a+u*h,e[1]=l+u*f),!0}}}}}(l,v,t,e,n,r)?a&&(b.lineStart(),b.point(s,o),m=!1):(g||(b.lineStart(),b.point(l[0],l[1])),b.point(v[0],v[1]),a||b.lineEnd(),m=!1)}p=s,_=o,g=a}return x}}var vh={sphere:Ac,point:Ac,lineStart:function(){vh.point=wh,vh.lineEnd=xh},lineEnd:Ac,polygonStart:Ac,polygonEnd:Ac};function xh(){vh.point=vh.lineEnd=Ac}function wh(t,e){ph=t*=ac,_h=yc(e*=ac),gh=hc(e),vh.point=Eh}function Eh(t,e){t*=ac;var n=yc(e*=ac),r=hc(e),i=lc(t-ph),s=hc(i),o=r*yc(i),a=gh*n-_h*r*s,l=_h*n+gh*r*s;dh.add(uc(bc(o*o+a*a),l)),ph=t,_h=n,gh=r}function Ah(t){return dh=new w,Mc(t,vh),+dh}var Sh=[null,null],Th={type:"LineString",coordinates:Sh};function Ch(t,e){return Sh[0]=t,Sh[1]=e,Ah(Th)}var kh={Feature:function(t,e){return Mh(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;)if(Mh(n[r].geometry,e))return!0;return!1}},Rh={Sphere:function(){return!0},Point:function(t,e){return Oh(t.coordinates,e)},MultiPoint:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(Oh(n[r],e))return!0;return!1},LineString:function(t,e){return Nh(t.coordinates,e)},MultiLineString:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(Nh(n[r],e))return!0;return!1},Polygon:function(t,e){return Ih(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(Ih(n[r],e))return!0;return!1},GeometryCollection:function(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;)if(Mh(n[r],e))return!0;return!1}};function Mh(t,e){return!(!t||!Rh.hasOwnProperty(t.type))&&Rh[t.type](t,e)}function Oh(t,e){return 0===Ch(t,e)}function Nh(t,e){for(var n,r,i,s=0,o=t.length;s<o;s++){if(0===(r=Ch(t[s],e)))return!0;if(s>0&&(i=Ch(t[s],t[s-1]))>0&&n<=i&&r<=i&&(n+r-i)*(1-Math.pow((n-r)/i,2))<ec*i)return!0;n=r}return!1}function Ih(t,e){return!!ah(t.map(Ph),Lh(e))}function Ph(t){return(t=t.map(Lh)).pop(),t}function Lh(t){return[t[0]*ac,t[1]*ac]}function Dh(t,e,n){var r=dt(t,e-tc,n).concat(e);return function(t){return r.map(function(e){return[t,e]})}}function Vh(t,e,n){var r=dt(t,e-tc,n).concat(e);return function(t){return r.map(function(e){return[e,t]})}}function Bh(){var t,e,n,r,i,s,o,a,l,c,u,h,f=10,d=f,p=90,_=360,g=2.5;function y(){return{type:"MultiLineString",coordinates:m()}}function m(){return dt(fc(r/p)*p,n,p).map(u).concat(dt(fc(a/_)*_,o,_).map(h)).concat(dt(fc(e/f)*f,t,f).filter(function(t){return lc(t%p)>tc}).map(l)).concat(dt(fc(s/d)*d,i,d).filter(function(t){return lc(t%_)>tc}).map(c))}return y.lines=function(){return m().map(function(t){return{type:"LineString",coordinates:t}})},y.outline=function(){return{type:"Polygon",coordinates:[u(r).concat(h(o).slice(1),u(n).reverse().slice(1),h(a).reverse().slice(1))]}},y.extent=function(t){return arguments.length?y.extentMajor(t).extentMinor(t):y.extentMinor()},y.extentMajor=function(t){return arguments.length?(r=+t[0][0],n=+t[1][0],a=+t[0][1],o=+t[1][1],r>n&&(t=r,r=n,n=t),a>o&&(t=a,a=o,o=t),y.precision(g)):[[r,a],[n,o]]},y.extentMinor=function(n){return arguments.length?(e=+n[0][0],t=+n[1][0],s=+n[0][1],i=+n[1][1],e>t&&(n=e,e=t,t=n),s>i&&(n=s,s=i,i=n),y.precision(g)):[[e,s],[t,i]]},y.step=function(t){return arguments.length?y.stepMajor(t).stepMinor(t):y.stepMinor()},y.stepMajor=function(t){return arguments.length?(p=+t[0],_=+t[1],y):[p,_]},y.stepMinor=function(t){return arguments.length?(f=+t[0],d=+t[1],y):[f,d]},y.precision=function(f){return arguments.length?(g=+f,l=Dh(s,i,90),c=Vh(e,t,g),u=Dh(a,o,90),h=Vh(r,n,g),y):g},y.extentMajor([[-180,-89.999999],[180,89.999999]]).extentMinor([[-180,-80.000001],[180,80.000001]])}var zh,Gh,Fh,jh,Uh=t=>t,Yh=new w,Hh=new w,Wh={point:Ac,lineStart:Ac,lineEnd:Ac,polygonStart:function(){Wh.lineStart=qh,Wh.lineEnd=Kh},polygonEnd:function(){Wh.lineStart=Wh.lineEnd=Wh.point=Ac,Yh.add(lc(Hh)),Hh=new w},result:function(){var t=Yh/2;return Yh=new w,t}};function qh(){Wh.point=$h}function $h(t,e){Wh.point=Xh,zh=Fh=t,Gh=jh=e}function Xh(t,e){Hh.add(jh*t-Fh*e),Fh=t,jh=e}function Kh(){Xh(zh,Gh)}var Zh=1/0,Jh=Zh,Qh=-Zh,tf=Qh,ef={point:function(t,e){t<Zh&&(Zh=t);t>Qh&&(Qh=t);e<Jh&&(Jh=e);e>tf&&(tf=e)},lineStart:Ac,lineEnd:Ac,polygonStart:Ac,polygonEnd:Ac,result:function(){var t=[[Zh,Jh],[Qh,tf]];return Qh=tf=-(Jh=Zh=1/0),t}};var nf,rf,sf,of,af=0,lf=0,cf=0,uf=0,hf=0,ff=0,df=0,pf=0,_f=0,gf={point:yf,lineStart:mf,lineEnd:xf,polygonStart:function(){gf.lineStart=wf,gf.lineEnd=Ef},polygonEnd:function(){gf.point=yf,gf.lineStart=mf,gf.lineEnd=xf},result:function(){var t=_f?[df/_f,pf/_f]:ff?[uf/ff,hf/ff]:cf?[af/cf,lf/cf]:[NaN,NaN];return af=lf=cf=uf=hf=ff=df=pf=_f=0,t}};function yf(t,e){af+=t,lf+=e,++cf}function mf(){gf.point=bf}function bf(t,e){gf.point=vf,yf(sf=t,of=e)}function vf(t,e){var n=t-sf,r=e-of,i=bc(n*n+r*r);uf+=i*(sf+t)/2,hf+=i*(of+e)/2,ff+=i,yf(sf=t,of=e)}function xf(){gf.point=yf}function wf(){gf.point=Af}function Ef(){Sf(nf,rf)}function Af(t,e){gf.point=Sf,yf(nf=sf=t,rf=of=e)}function Sf(t,e){var n=t-sf,r=e-of,i=bc(n*n+r*r);uf+=i*(sf+t)/2,hf+=i*(of+e)/2,ff+=i,df+=(i=of*t-sf*e)*(sf+t),pf+=i*(of+e),_f+=3*i,yf(sf=t,of=e)}function Tf(t){this._context=t}Tf.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(t,e){switch(this._point){case 0:this._context.moveTo(t,e),this._point=1;break;case 1:this._context.lineTo(t,e);break;default:this._context.moveTo(t+this._radius,e),this._context.arc(t,e,this._radius,0,sc)}},result:Ac};var Cf,kf,Rf,Mf,Of,Nf=new w,If={point:Ac,lineStart:function(){If.point=Pf},lineEnd:function(){Cf&&Lf(kf,Rf),If.point=Ac},polygonStart:function(){Cf=!0},polygonEnd:function(){Cf=null},result:function(){var t=+Nf;return Nf=new w,t}};function Pf(t,e){If.point=Lf,kf=Mf=t,Rf=Of=e}function Lf(t,e){Mf-=t,Of-=e,Nf.add(bc(Mf*Mf+Of*Of)),Mf=t,Of=e}let Df,Vf,Bf,zf;class Gf{constructor(t){this._append=null==t?Ff:function(t){const e=Math.floor(t);if(!(e>=0))throw new RangeError(`invalid digits: ${t}`);if(e>15)return Ff;if(e!==Df){const t=10**e;Df=e,Vf=function(e){let n=1;this._+=e[0];for(const r=e.length;n<r;++n)this._+=Math.round(arguments[n]*t)/t+e[n]}}return Vf}(t),this._radius=4.5,this._=""}pointRadius(t){return this._radius=+t,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){0===this._line&&(this._+="Z"),this._point=NaN}point(t,e){switch(this._point){case 0:this._append`M${t},${e}`,this._point=1;break;case 1:this._append`L${t},${e}`;break;default:if(this._append`M${t},${e}`,this._radius!==Bf||this._append!==Vf){const t=this._radius,e=this._;this._="",this._append`m0,${t}a${t},${t} 0 1,1 0,${-2*t}a${t},${t} 0 1,1 0,${2*t}z`,Bf=t,Vf=this._append,zf=this._,this._=e}this._+=zf}}result(){const t=this._;return this._="",t.length?t:null}}function Ff(t){let e=1;this._+=t[0];for(const n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function jf(t){return function(e){var n=new Uf;for(var r in t)n[r]=t[r];return n.stream=e,n}}function Uf(){}function Yf(t,e,n){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),Mc(n,t.stream(ef)),e(ef.result()),null!=r&&t.clipExtent(r),t}function Hf(t,e,n){return Yf(t,function(n){var r=e[1][0]-e[0][0],i=e[1][1]-e[0][1],s=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+e[0][0]+(r-s*(n[1][0]+n[0][0]))/2,a=+e[0][1]+(i-s*(n[1][1]+n[0][1]))/2;t.scale(150*s).translate([o,a])},n)}function Wf(t,e,n){return Hf(t,[[0,0],e],n)}function qf(t,e,n){return Yf(t,function(n){var r=+e,i=r/(n[1][0]-n[0][0]),s=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];t.scale(150*i).translate([s,o])},n)}function $f(t,e,n){return Yf(t,function(n){var r=+e,i=r/(n[1][1]-n[0][1]),s=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;t.scale(150*i).translate([s,o])},n)}Uf.prototype={constructor:Uf,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var Xf=hc(30*ac);function Kf(t,e){return+e?function(t,e){function n(r,i,s,o,a,l,c,u,h,f,d,p,_,g){var y=c-r,m=u-i,b=y*y+m*m;if(b>4*e&&_--){var v=o+f,x=a+d,w=l+p,E=bc(v*v+x*x+w*w),A=wc(w/=E),S=lc(lc(w)-1)<tc||lc(s-h)<tc?(s+h)/2:uc(x,v),T=t(S,A),C=T[0],k=T[1],R=C-r,M=k-i,O=m*R-y*M;(O*O/b>e||lc((y*R+m*M)/b-.5)>.3||o*f+a*d+l*p<Xf)&&(n(r,i,s,o,a,l,C,k,S,v/=E,x/=E,w,_,g),g.point(C,k),n(C,k,S,v,x,w,c,u,h,f,d,p,_,g))}}return function(e){var r,i,s,o,a,l,c,u,h,f,d,p,_={point:g,lineStart:y,lineEnd:b,polygonStart:function(){e.polygonStart(),_.lineStart=v},polygonEnd:function(){e.polygonEnd(),_.lineStart=y}};function g(n,r){n=t(n,r),e.point(n[0],n[1])}function y(){u=NaN,_.point=m,e.lineStart()}function m(r,i){var s=eu([r,i]),o=t(r,i);n(u,h,c,f,d,p,u=o[0],h=o[1],c=r,f=s[0],d=s[1],p=s[2],16,e),e.point(u,h)}function b(){_.point=g,e.lineEnd()}function v(){y(),_.point=x,_.lineEnd=w}function x(t,e){m(r=t,e),i=u,s=h,o=f,a=d,l=p,_.point=m}function w(){n(u,h,c,f,d,p,i,s,r,o,a,l,16,e),_.lineEnd=b,b()}return _}}(t,e):function(t){return jf({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}(t)}var Zf=jf({point:function(t,e){this.stream.point(t*ac,e*ac)}});function Jf(t,e,n,r,i,s){if(!s)return function(t,e,n,r,i){function s(s,o){return[e+t*(s*=r),n-t*(o*=i)]}return s.invert=function(s,o){return[(s-e)/t*r,(n-o)/t*i]},s}(t,e,n,r,i);var o=hc(s),a=yc(s),l=o*t,c=a*t,u=o/t,h=a/t,f=(a*n-o*e)/t,d=(a*e+o*n)/t;function p(t,s){return[l*(t*=r)-c*(s*=i)+e,n-c*t-l*s]}return p.invert=function(t,e){return[r*(u*t-h*e+f),i*(d-h*t-u*e)]},p}function Qf(t){return td(function(){return t})()}function td(t){var e,n,r,i,s,o,a,l,c,u,h=150,f=480,d=250,p=0,_=0,g=0,y=0,m=0,b=0,v=1,x=1,w=null,E=hh,A=null,S=Uh,T=.5;function C(t){return l(t[0]*ac,t[1]*ac)}function k(t){return(t=l.invert(t[0],t[1]))&&[t[0]*oc,t[1]*oc]}function R(){var t=Jf(h,0,0,v,x,b).apply(null,e(p,_)),r=Jf(h,f-t[0],d-t[1],v,x,b);return n=$u(g,y,m),a=Wu(e,r),l=Wu(n,a),o=Kf(a,T),M()}function M(){return c=u=null,C}return C.stream=function(t){return c&&u===t?c:c=Zf(function(t){return jf({point:function(e,n){var r=t(e,n);return this.stream.point(r[0],r[1])}})}(n)(E(o(S(u=t)))))},C.preclip=function(t){return arguments.length?(E=t,w=void 0,M()):E},C.postclip=function(t){return arguments.length?(S=t,A=r=i=s=null,M()):S},C.clipAngle=function(t){return arguments.length?(E=+t?fh(w=t*ac):(w=null,hh),M()):w*oc},C.clipExtent=function(t){return arguments.length?(S=null==t?(A=r=i=s=null,Uh):bh(A=+t[0][0],r=+t[0][1],i=+t[1][0],s=+t[1][1]),M()):null==A?null:[[A,r],[i,s]]},C.scale=function(t){return arguments.length?(h=+t,R()):h},C.translate=function(t){return arguments.length?(f=+t[0],d=+t[1],R()):[f,d]},C.center=function(t){return arguments.length?(p=t[0]%360*ac,_=t[1]%360*ac,R()):[p*oc,_*oc]},C.rotate=function(t){return arguments.length?(g=t[0]%360*ac,y=t[1]%360*ac,m=t.length>2?t[2]%360*ac:0,R()):[g*oc,y*oc,m*oc]},C.angle=function(t){return arguments.length?(b=t%360*ac,R()):b*oc},C.reflectX=function(t){return arguments.length?(v=t?-1:1,R()):v<0},C.reflectY=function(t){return arguments.length?(x=t?-1:1,R()):x<0},C.precision=function(t){return arguments.length?(o=Kf(a,T=t*t),M()):bc(T)},C.fitExtent=function(t,e){return Hf(C,t,e)},C.fitSize=function(t,e){return Wf(C,t,e)},C.fitWidth=function(t,e){return qf(C,t,e)},C.fitHeight=function(t,e){return $f(C,t,e)},function(){return e=t.apply(this,arguments),C.invert=e.invert&&k,R()}}function ed(t){var e=0,n=nc/3,r=td(t),i=r(e,n);return i.parallels=function(t){return arguments.length?r(e=t[0]*ac,n=t[1]*ac):[e*oc,n*oc]},i}function nd(t,e){var n=yc(t),r=(n+yc(e))/2;if(lc(r)<tc)return function(t){var e=hc(t);function n(t,n){return[t*e,yc(n)/e]}return n.invert=function(t,n){return[t/e,wc(n*e)]},n}(t);var i=1+n*(2*r-n),s=bc(i)/r;function o(t,e){var n=bc(i-2*r*yc(e))/r;return[n*yc(t*=r),s-n*hc(t)]}return o.invert=function(t,e){var n=s-e,o=uc(t,lc(n))*mc(n);return n*r<0&&(o-=nc*mc(t)*mc(n)),[o/r,wc((i-(t*t+n*n)*r*r)/(2*r))]},o}function rd(){return ed(nd).scale(155.424).center([0,33.6442])}function id(){return rd().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}function sd(t){return function(e,n){var r=hc(e),i=hc(n),s=t(r*i);return s===1/0?[2,0]:[s*i*yc(e),s*yc(n)]}}function od(t){return function(e,n){var r=bc(e*e+n*n),i=t(r),s=yc(i),o=hc(i);return[uc(e*s,r*o),wc(r&&n*s/r)]}}var ad=sd(function(t){return bc(2/(1+t))});ad.invert=od(function(t){return 2*wc(t/2)});var ld=sd(function(t){return(t=xc(t))&&t/yc(t)});function cd(t,e){return[t,_c(vc((rc+e)/2))]}function ud(t){var e,n,r,i=Qf(t),s=i.center,o=i.scale,a=i.translate,l=i.clipExtent,c=null;function u(){var s=nc*o(),a=i(Ju(i.rotate()).invert([0,0]));return l(null==c?[[a[0]-s,a[1]-s],[a[0]+s,a[1]+s]]:t===cd?[[Math.max(a[0]-s,c),e],[Math.min(a[0]+s,n),r]]:[[c,Math.max(a[1]-s,e)],[n,Math.min(a[1]+s,r)]])}return i.scale=function(t){return arguments.length?(o(t),u()):o()},i.translate=function(t){return arguments.length?(a(t),u()):a()},i.center=function(t){return arguments.length?(s(t),u()):s()},i.clipExtent=function(t){return arguments.length?(null==t?c=e=n=r=null:(c=+t[0][0],e=+t[0][1],n=+t[1][0],r=+t[1][1]),u()):null==c?null:[[c,e],[n,r]]},u()}function hd(t){return vc((rc+t)/2)}function fd(t,e){var n=hc(t),r=t===e?yc(t):_c(n/hc(e))/_c(hd(e)/hd(t)),i=n*gc(hd(t),r)/r;if(!r)return cd;function s(t,e){i>0?e<-rc+tc&&(e=-rc+tc):e>rc-tc&&(e=rc-tc);var n=i/gc(hd(e),r);return[n*yc(r*t),i-n*hc(r*t)]}return s.invert=function(t,e){var n=i-e,s=mc(r)*bc(t*t+n*n),o=uc(t,lc(n))*mc(n);return n*r<0&&(o-=nc*mc(t)*mc(n)),[o/r,2*cc(gc(i/s,1/r))-rc]},s}function dd(t,e){return[t,e]}function pd(t,e){var n=hc(t),r=t===e?yc(t):(n-hc(e))/(e-t),i=n/r+t;if(lc(r)<tc)return dd;function s(t,e){var n=i-e,s=r*t;return[n*yc(s),i-n*hc(s)]}return s.invert=function(t,e){var n=i-e,s=uc(t,lc(n))*mc(n);return n*r<0&&(s-=nc*mc(t)*mc(n)),[s/r,i-mc(r)*bc(t*t+n*n)]},s}ld.invert=od(function(t){return t}),cd.invert=function(t,e){return[t,2*cc(dc(e))-rc]},dd.invert=dd;var _d=1.340264,gd=-.081106,yd=893e-6,md=.003796,bd=bc(3)/2;function vd(t,e){var n=wc(bd*yc(e)),r=n*n,i=r*r*r;return[t*hc(n)/(bd*(_d+3*gd*r+i*(7*yd+9*md*r))),n*(_d+gd*r+i*(yd+md*r))]}function xd(t,e){var n=hc(e),r=hc(t)*n;return[n*yc(t)/r,yc(e)/r]}function wd(t,e){var n=e*e,r=n*n;return[t*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791)),e*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))]}function Ed(t,e){return[hc(e)*yc(t),yc(e)]}function Ad(t,e){var n=hc(e),r=1+hc(t)*n;return[n*yc(t)/r,yc(e)/r]}function Sd(t,e){return[_c(vc((rc+e)/2)),-t]}function Td(t,e){return t.parent===e.parent?1:2}function Cd(t,e){return t+e.x}function kd(t,e){return Math.max(t,e.y)}function Rd(){var t=Td,e=1,n=1,r=!1;function i(i){var s,o=0;i.eachAfter(function(e){var n=e.children;n?(e.x=function(t){return t.reduce(Cd,0)/t.length}(n),e.y=function(t){return 1+t.reduce(kd,0)}(n)):(e.x=s?o+=t(e,s):0,e.y=0,s=e)});var a=function(t){for(var e;e=t.children;)t=e[0];return t}(i),l=function(t){for(var e;e=t.children;)t=e[e.length-1];return t}(i),c=a.x-t(a,l)/2,u=l.x+t(l,a)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*e,t.y=(i.y-t.y)*n}:function(t){t.x=(t.x-c)/(u-c)*e,t.y=(1-(i.y?t.y/i.y:1))*n})}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}function Md(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function Od(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=Id)):void 0===e&&(e=Nd);for(var n,r,i,s,o,a=new Dd(t),l=[a];n=l.pop();)if((i=e(n.data))&&(o=(i=Array.from(i)).length))for(n.children=i,s=o-1;s>=0;--s)l.push(r=i[s]=new Dd(i[s])),r.parent=n,r.depth=n.depth+1;return a.eachBefore(Ld)}function Nd(t){return t.children}function Id(t){return Array.isArray(t)?t[1]:null}function Pd(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Ld(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Dd(t){this.data=t,this.depth=this.height=0,this.parent=null}function Vd(t){return null==t?null:Bd(t)}function Bd(t){if("function"!=typeof t)throw new Error;return t}function zd(){return 0}function Gd(t){return function(){return t}}vd.invert=function(t,e){for(var n,r=e,i=r*r,s=i*i*i,o=0;o<12&&(s=(i=(r-=n=(r*(_d+gd*i+s*(yd+md*i))-e)/(_d+3*gd*i+s*(7*yd+9*md*i)))*r)*i*i,!(lc(n)<ec));++o);return[bd*t*(_d+3*gd*i+s*(7*yd+9*md*i))/hc(r),wc(yc(r)/bd)]},xd.invert=od(cc),wd.invert=function(t,e){var n,r=e,i=25;do{var s=r*r,o=s*s;r-=n=(r*(1.007226+s*(.015085+o*(.028874*s-.044475-.005916*o)))-e)/(1.007226+s*(.045255+o*(.259866*s-.311325-.005916*11*o)))}while(lc(n)>tc&&--i>0);return[t/(.8707+(s=r*r)*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979)),r]},Ed.invert=od(wc),Ad.invert=od(function(t){return 2*cc(t)}),Sd.invert=function(t,e){return[-e,2*cc(dc(t))-rc]},Dd.prototype=Od.prototype={constructor:Dd,count:function(){return this.eachAfter(Md)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,s=this,o=[s],a=[],l=-1;s=o.pop();)if(a.push(s),n=s.children)for(r=0,i=n.length;r<i;++r)o.push(n[r]);for(;s=a.pop();)t.call(e,s,++l,this);return this},eachBefore:function(t,e){for(var n,r,i=this,s=[i],o=-1;i=s.pop();)if(t.call(e,i,++o,this),n=i.children)for(r=n.length-1;r>=0;--r)s.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n})},sort:function(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t},links:function(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e},copy:function(){return Od(this).eachBefore(Pd)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,s=[i];do{for(t=s.reverse(),s=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)s.push(e[n])}while(s.length)}};const Fd=4294967296;function jd(){let t=1;return()=>(t=(1664525*t+1013904223)%Fd)/Fd}function Ud(t,e){for(var n,r,i=0,s=(t=function(t,e){let n,r,i=t.length;for(;i;)r=e()*i--|0,n=t[i],t[i]=t[r],t[r]=n;return t}(Array.from(t),e)).length,o=[];i<s;)n=t[i],r&&Wd(r,n)?++i:(r=$d(o=Yd(o,n)),i=0);return r}function Yd(t,e){var n,r;if(qd(e,t))return[e];for(n=0;n<t.length;++n)if(Hd(e,t[n])&&qd(Xd(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(Hd(Xd(t[n],t[r]),e)&&Hd(Xd(t[n],e),t[r])&&Hd(Xd(t[r],e),t[n])&&qd(Kd(t[n],t[r],e),t))return[t[n],t[r],e];throw new Error}function Hd(t,e){var n=t.r-e.r,r=e.x-t.x,i=e.y-t.y;return n<0||n*n<r*r+i*i}function Wd(t,e){var n=t.r-e.r+1e-9*Math.max(t.r,e.r,1),r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function qd(t,e){for(var n=0;n<e.length;++n)if(!Wd(t,e[n]))return!1;return!0}function $d(t){switch(t.length){case 1:return function(t){return{x:t.x,y:t.y,r:t.r}}(t[0]);case 2:return Xd(t[0],t[1]);case 3:return Kd(t[0],t[1],t[2])}}function Xd(t,e){var n=t.x,r=t.y,i=t.r,s=e.x,o=e.y,a=e.r,l=s-n,c=o-r,u=a-i,h=Math.sqrt(l*l+c*c);return{x:(n+s+l/h*u)/2,y:(r+o+c/h*u)/2,r:(h+i+a)/2}}function Kd(t,e,n){var r=t.x,i=t.y,s=t.r,o=e.x,a=e.y,l=e.r,c=n.x,u=n.y,h=n.r,f=r-o,d=r-c,p=i-a,_=i-u,g=l-s,y=h-s,m=r*r+i*i-s*s,b=m-o*o-a*a+l*l,v=m-c*c-u*u+h*h,x=d*p-f*_,w=(p*v-_*b)/(2*x)-r,E=(_*g-p*y)/x,A=(d*b-f*v)/(2*x)-i,S=(f*y-d*g)/x,T=E*E+S*S-1,C=2*(s+w*E+A*S),k=w*w+A*A-s*s,R=-(Math.abs(T)>1e-6?(C+Math.sqrt(C*C-4*T*k))/(2*T):k/C);return{x:r+w+E*R,y:i+A+S*R,r:R}}function Zd(t,e,n){var r,i,s,o,a=t.x-e.x,l=t.y-e.y,c=a*a+l*l;c?(i=e.r+n.r,i*=i,o=t.r+n.r,i>(o*=o)?(r=(c+o-i)/(2*c),s=Math.sqrt(Math.max(0,o/c-r*r)),n.x=t.x-r*a-s*l,n.y=t.y-r*l+s*a):(r=(c+i-o)/(2*c),s=Math.sqrt(Math.max(0,i/c-r*r)),n.x=e.x+r*a-s*l,n.y=e.y+r*l+s*a)):(n.x=e.x+n.r,n.y=e.y)}function Jd(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function Qd(t){var e=t._,n=t.next._,r=e.r+n.r,i=(e.x*n.r+n.x*e.r)/r,s=(e.y*n.r+n.y*e.r)/r;return i*i+s*s}function tp(t){this._=t,this.next=null,this.previous=null}function ep(t,e){if(!(s=(t=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(t)).length))return 0;var n,r,i,s,o,a,l,c,u,h,f;if((n=t[0]).x=0,n.y=0,!(s>1))return n.r;if(r=t[1],n.x=-r.r,r.x=n.r,r.y=0,!(s>2))return n.r+r.r;Zd(r,n,i=t[2]),n=new tp(n),r=new tp(r),i=new tp(i),n.next=i.previous=r,r.next=n.previous=i,i.next=r.previous=n;t:for(l=3;l<s;++l){Zd(n._,r._,i=t[l]),i=new tp(i),c=r.next,u=n.previous,h=r._.r,f=n._.r;do{if(h<=f){if(Jd(c._,i._)){r=c,n.next=r,r.previous=n,--l;continue t}h+=c._.r,c=c.next}else{if(Jd(u._,i._)){(n=u).next=r,r.previous=n,--l;continue t}f+=u._.r,u=u.previous}}while(c!==u.next);for(i.previous=n,i.next=r,n.next=r.previous=r=i,o=Qd(n);(i=i.next)!==r;)(a=Qd(i))<o&&(n=i,o=a);r=n.next}for(n=[r._],i=r;(i=i.next)!==r;)n.push(i._);for(i=Ud(n,e),l=0;l<s;++l)(n=t[l]).x-=i.x,n.y-=i.y;return i.r}function np(t){return Math.sqrt(t.value)}function rp(){var t=null,e=1,n=1,r=zd;function i(i){const s=jd();return i.x=e/2,i.y=n/2,t?i.eachBefore(ip(t)).eachAfter(sp(r,.5,s)).eachBefore(op(1)):i.eachBefore(ip(np)).eachAfter(sp(zd,1,s)).eachAfter(sp(r,i.r/Math.min(e,n),s)).eachBefore(op(Math.min(e,n)/(2*i.r))),i}return i.radius=function(e){return arguments.length?(t=Vd(e),i):t},i.size=function(t){return arguments.length?(e=+t[0],n=+t[1],i):[e,n]},i.padding=function(t){return arguments.length?(r="function"==typeof t?t:Gd(+t),i):r},i}function ip(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0))}}function sp(t,e,n){return function(r){if(i=r.children){var i,s,o,a=i.length,l=t(r)*e||0;if(l)for(s=0;s<a;++s)i[s].r+=l;if(o=ep(i,n),l)for(s=0;s<a;++s)i[s].r-=l;r.r=o+l}}}function op(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 ap(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 lp(t,e,n,r,i){for(var s,o=t.children,a=-1,l=o.length,c=t.value&&(r-e)/t.value;++a<l;)(s=o[a]).y0=n,s.y1=i,s.x0=e,s.x1=e+=s.value*c}var cp={depth:-1},up={},hp={};function fp(t){return t.id}function dp(t){return t.parentId}function pp(t){let e=t.length;if(e<2)return"";for(;--e>1&&!_p(t,e););return t.slice(0,e)}function _p(t,e){if("/"===t[e]){let n=0;for(;e>0&&"\\"===t[--e];)++n;if(!(1&n))return!0}return!1}function gp(t,e){return t.parent===e.parent?1:2}function yp(t){var e=t.children;return e?e[0]:t.t}function mp(t){var e=t.children;return e?e[e.length-1]:t.t}function bp(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 vp(t,e,n){return t.a.parent===e.parent?t.a:n}function xp(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}function wp(){var t=gp,e=1,n=1,r=null;function i(i){var l=function(t){for(var e,n,r,i,s,o=new xp(t,0),a=[o];e=a.pop();)if(r=e._.children)for(e.children=new Array(s=r.length),i=s-1;i>=0;--i)a.push(n=e.children[i]=new xp(r[i],i)),n.parent=e;return(o.parent=new xp(null,0)).children=[o],o}(i);if(l.eachAfter(s),l.parent.m=-l.z,l.eachBefore(o),r)i.eachBefore(a);else{var c=i,u=i,h=i;i.eachBefore(function(t){t.x<c.x&&(c=t),t.x>u.x&&(u=t),t.depth>h.depth&&(h=t)});var f=c===u?1:t(c,u)/2,d=f-c.x,p=e/(u.x+f+d),_=n/(h.depth||1);i.eachBefore(function(t){t.x=(t.x+d)*p,t.y=t.depth*_})}return i}function s(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){!function(t){for(var e,n=0,r=0,i=t.children,s=i.length;--s>=0;)(e=i[s]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}(e);var s=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-s):e.z=s}else i&&(e.z=i.z+t(e._,i._));e.parent.A=function(e,n,r){if(n){for(var i,s=e,o=e,a=n,l=s.parent.children[0],c=s.m,u=o.m,h=a.m,f=l.m;a=mp(a),s=yp(s),a&&s;)l=yp(l),(o=mp(o)).a=e,(i=a.z+h-s.z-c+t(a._,s._))>0&&(bp(vp(a,e,r),e,i),c+=i,u+=i),h+=a.m,c+=s.m,f+=l.m,u+=o.m;a&&!mp(o)&&(o.t=a,o.m+=h-u),s&&!yp(l)&&(l.t=s,l.m+=c-f,r=e)}return r}(e,i,e.parent.A||r[0])}function o(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function a(t){t.x*=e,t.y=t.depth*n}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}function Ep(t,e,n,r,i){for(var s,o=t.children,a=-1,l=o.length,c=t.value&&(i-n)/t.value;++a<l;)(s=o[a]).x0=e,s.x1=r,s.y0=n,s.y1=n+=s.value*c}xp.prototype=Object.create(Dd.prototype);var Ap=(1+Math.sqrt(5))/2;function Sp(t,e,n,r,i,s){for(var o,a,l,c,u,h,f,d,p,_,g,y=[],m=e.children,b=0,v=0,x=m.length,w=e.value;b<x;){l=i-n,c=s-r;do{u=m[v++].value}while(!u&&v<x);for(h=f=u,g=u*u*(_=Math.max(c/l,l/c)/(w*t)),p=Math.max(f/g,g/h);v<x;++v){if(u+=a=m[v].value,a<h&&(h=a),a>f&&(f=a),g=u*u*_,(d=Math.max(f/g,g/h))>p){u-=a;break}p=d}y.push(o={value:u,dice:l<c,children:m.slice(b,v)}),o.dice?lp(o,n,r,i,w?r+=c*u/w:s):Ep(o,n,r,w?n+=l*u/w:i,s),w-=u,b=v}return y}var Tp=function t(e){function n(t,n,r,i,s){Sp(e,t,n,r,i,s)}return n.ratio=function(e){return t((e=+e)>1?e:1)},n}(Ap);function Cp(){var t=Tp,e=!1,n=1,r=1,i=[0],s=zd,o=zd,a=zd,l=zd,c=zd;function u(t){return t.x0=t.y0=0,t.x1=n,t.y1=r,t.eachBefore(h),i=[0],e&&t.eachBefore(ap),t}function h(e){var n=i[e.depth],r=e.x0+n,u=e.y0+n,h=e.x1-n,f=e.y1-n;h<r&&(r=h=(r+h)/2),f<u&&(u=f=(u+f)/2),e.x0=r,e.y0=u,e.x1=h,e.y1=f,e.children&&(n=i[e.depth+1]=s(e)/2,r+=c(e)-n,u+=o(e)-n,(h-=a(e)-n)<r&&(r=h=(r+h)/2),(f-=l(e)-n)<u&&(u=f=(u+f)/2),t(e,r,u,h,f))}return u.round=function(t){return arguments.length?(e=!!t,u):e},u.size=function(t){return arguments.length?(n=+t[0],r=+t[1],u):[n,r]},u.tile=function(e){return arguments.length?(t=Bd(e),u):t},u.padding=function(t){return arguments.length?u.paddingInner(t).paddingOuter(t):u.paddingInner()},u.paddingInner=function(t){return arguments.length?(s="function"==typeof t?t:Gd(+t),u):s},u.paddingOuter=function(t){return arguments.length?u.paddingTop(t).paddingRight(t).paddingBottom(t).paddingLeft(t):u.paddingTop()},u.paddingTop=function(t){return arguments.length?(o="function"==typeof t?t:Gd(+t),u):o},u.paddingRight=function(t){return arguments.length?(a="function"==typeof t?t:Gd(+t),u):a},u.paddingBottom=function(t){return arguments.length?(l="function"==typeof t?t:Gd(+t),u):l},u.paddingLeft=function(t){return arguments.length?(c="function"==typeof t?t:Gd(+t),u):c},u}var kp=function t(e){function n(t,n,r,i,s){if((o=t._squarify)&&o.ratio===e)for(var o,a,l,c,u,h=-1,f=o.length,d=t.value;++h<f;){for(l=(a=o[h]).children,c=a.value=0,u=l.length;c<u;++c)a.value+=l[c].value;a.dice?lp(a,n,r,i,d?r+=(s-r)*a.value/d:s):Ep(a,n,r,d?n+=(i-n)*a.value/d:i,s),d-=a.value}else t._squarify=o=Sp(e,t,n,r,i,s),o.ratio=e}return n.ratio=function(e){return t((e=+e)>1?e:1)},n}(Ap);function Rp(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function Mp(t,e){return t[0]-e[0]||t[1]-e[1]}function Op(t){const e=t.length,n=[0,1];let r,i=2;for(r=2;r<e;++r){for(;i>1&&Rp(t[n[i-2]],t[n[i-1]],t[r])<=0;)--i;n[i++]=r}return n.slice(0,i)}var Np=Math.random,Ip=function t(e){function n(t,n){return t=null==t?0:+t,n=null==n?1:+n,1===arguments.length?(n=t,t=0):n-=t,function(){return e()*n+t}}return n.source=t,n}(Np),Pp=function t(e){function n(t,n){return arguments.length<2&&(n=t,t=0),t=Math.floor(t),n=Math.floor(n)-t,function(){return Math.floor(e()*n+t)}}return n.source=t,n}(Np),Lp=function t(e){function n(t,n){var r,i;return t=null==t?0:+t,n=null==n?1:+n,function(){var s;if(null!=r)s=r,r=null;else do{r=2*e()-1,s=2*e()-1,i=r*r+s*s}while(!i||i>1);return t+n*s*Math.sqrt(-2*Math.log(i)/i)}}return n.source=t,n}(Np),Dp=function t(e){var n=Lp.source(e);function r(){var t=n.apply(this,arguments);return function(){return Math.exp(t())}}return r.source=t,r}(Np),Vp=function t(e){function n(t){return(t=+t)<=0?()=>0:function(){for(var n=0,r=t;r>1;--r)n+=e();return n+r*e()}}return n.source=t,n}(Np),Bp=function t(e){var n=Vp.source(e);function r(t){if(0===(t=+t))return e;var r=n(t);return function(){return r()/t}}return r.source=t,r}(Np),zp=function t(e){function n(t){return function(){return-Math.log1p(-e())/t}}return n.source=t,n}(Np),Gp=function t(e){function n(t){if((t=+t)<0)throw new RangeError("invalid alpha");return t=1/-t,function(){return Math.pow(1-e(),t)}}return n.source=t,n}(Np),Fp=function t(e){function n(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return function(){return Math.floor(e()+t)}}return n.source=t,n}(Np),jp=function t(e){function n(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return 0===t?()=>1/0:1===t?()=>1:(t=Math.log1p(-t),function(){return 1+Math.floor(Math.log1p(-e())/t)})}return n.source=t,n}(Np),Up=function t(e){var n=Lp.source(e)();function r(t,r){if((t=+t)<0)throw new RangeError("invalid k");if(0===t)return()=>0;if(r=null==r?1:+r,1===t)return()=>-Math.log1p(-e())*r;var i=(t<1?t+1:t)-1/3,s=1/(3*Math.sqrt(i)),o=t<1?()=>Math.pow(e(),1/t):()=>1;return function(){do{do{var t=n(),a=1+s*t}while(a<=0);a*=a*a;var l=1-e()}while(l>=1-.0331*t*t*t*t&&Math.log(l)>=.5*t*t+i*(1-a+Math.log(a)));return i*a*o()*r}}return r.source=t,r}(Np),Yp=function t(e){var n=Up.source(e);function r(t,e){var r=n(t),i=n(e);return function(){var t=r();return 0===t?0:t/(t+i())}}return r.source=t,r}(Np),Hp=function t(e){var n=jp.source(e),r=Yp.source(e);function i(t,e){return t=+t,(e=+e)>=1?()=>t:e<=0?()=>0:function(){for(var i=0,s=t,o=e;s*o>16&&s*(1-o)>16;){var a=Math.floor((s+1)*o),l=r(a,s-a+1)();l<=o?(i+=a,s-=a,o=(o-l)/(1-l)):(s=a-1,o/=l)}for(var c=o<.5,u=n(c?o:1-o),h=u(),f=0;h<=s;++f)h+=u();return i+(c?f:s-f)}}return i.source=t,i}(Np),Wp=function t(e){function n(t,n,r){var i;return 0===(t=+t)?i=t=>-Math.log(t):(t=1/t,i=e=>Math.pow(e,t)),n=null==n?0:+n,r=null==r?1:+r,function(){return n+r*i(-Math.log1p(-e()))}}return n.source=t,n}(Np),qp=function t(e){function n(t,n){return t=null==t?0:+t,n=null==n?1:+n,function(){return t+n*Math.tan(Math.PI*e())}}return n.source=t,n}(Np),$p=function t(e){function n(t,n){return t=null==t?0:+t,n=null==n?1:+n,function(){var r=e();return t+n*Math.log(r/(1-r))}}return n.source=t,n}(Np),Xp=function t(e){var n=Up.source(e),r=Hp.source(e);function i(t){return function(){for(var i=0,s=t;s>16;){var o=Math.floor(.875*s),a=n(o)();if(a>s)return i+r(o-1,s/a)();i+=o,s-=a}for(var l=-Math.log1p(-e()),c=0;l<=s;++c)l-=Math.log1p(-e());return i+c}}return i.source=t,i}(Np);const Kp=1/4294967296;function Zp(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Jp(t,e){switch(arguments.length){case 0:break;case 1:"function"==typeof t?this.interpolator(t):this.range(t);break;default:this.domain(t),"function"==typeof e?this.interpolator(e):this.range(e)}return this}const Qp=Symbol("implicit");function t_(){var t=new E,e=[],n=[],r=Qp;function i(i){let s=t.get(i);if(void 0===s){if(r!==Qp)return r;t.set(i,s=e.push(i)-1)}return n[s%n.length]}return i.domain=function(n){if(!arguments.length)return e.slice();e=[],t=new E;for(const r of n)t.has(r)||t.set(r,e.push(r)-1);return i},i.range=function(t){return arguments.length?(n=Array.from(t),i):n.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return t_(e,n).unknown(r)},Zp.apply(i,arguments),i}function e_(){var t,e,n=t_().unknown(void 0),r=n.domain,i=n.range,s=0,o=1,a=!1,l=0,c=0,u=.5;function h(){var n=r().length,h=o<s,f=h?o:s,d=h?s:o;t=(d-f)/Math.max(1,n-l+2*c),a&&(t=Math.floor(t)),f+=(d-f-t*(n-l))*u,e=t*(1-l),a&&(f=Math.round(f),e=Math.round(e));var p=dt(n).map(function(e){return f+t*e});return i(h?p.reverse():p)}return delete n.unknown,n.domain=function(t){return arguments.length?(r(t),h()):r()},n.range=function(t){return arguments.length?([s,o]=t,s=+s,o=+o,h()):[s,o]},n.rangeRound=function(t){return[s,o]=t,s=+s,o=+o,a=!0,h()},n.bandwidth=function(){return e},n.step=function(){return t},n.round=function(t){return arguments.length?(a=!!t,h()):a},n.padding=function(t){return arguments.length?(l=Math.min(1,c=+t),h()):l},n.paddingInner=function(t){return arguments.length?(l=Math.min(1,t),h()):l},n.paddingOuter=function(t){return arguments.length?(c=+t,h()):c},n.align=function(t){return arguments.length?(u=Math.max(0,Math.min(1,t)),h()):u},n.copy=function(){return e_(r(),[s,o]).round(a).paddingInner(l).paddingOuter(c).align(u)},Zp.apply(h(),arguments)}function n_(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return n_(e())},t}function r_(){return n_(e_.apply(null,arguments).paddingInner(1))}function i_(t){return+t}var s_=[0,1];function o_(t){return t}function a_(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function l_(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=a_(i,r),s=n(o,s)):(r=a_(r,i),s=n(s,o)),function(t){return s(r(t))}}function c_(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),a=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++a<r;)i[a]=a_(t[a],t[a+1]),s[a]=n(e[a],e[a+1]);return function(e){var n=o(t,e,1,r)-1;return s[n](i[n](e))}}function u_(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function h_(){var t,e,n,r,i,s,o=s_,a=s_,l=Hr,c=o_;function u(){var t=Math.min(o.length,a.length);return c!==o_&&(c=function(t,e){var n;return t>e&&(n=t,t=e,e=n),function(n){return Math.max(t,Math.min(e,n))}}(o[0],o[t-1])),r=t>2?c_:l_,i=s=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(o.map(t),a,l)))(t(c(e)))}return h.invert=function(n){return c(e((s||(s=r(a,o.map(t),Gr)))(n)))},h.domain=function(t){return arguments.length?(o=Array.from(t,i_),u()):o.slice()},h.range=function(t){return arguments.length?(a=Array.from(t),u()):a.slice()},h.rangeRound=function(t){return a=Array.from(t),l=Wr,u()},h.clamp=function(t){return arguments.length?(c=!!t||o_,u()):c!==o_},h.interpolate=function(t){return arguments.length?(l=t,u()):l},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,u()}}function f_(){return h_()(o_,o_)}function d_(t,e,n,r){var i,s=X(t,e,n);switch((r=zl(null==r?",f":r)).type){case"s":var o=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=Jl(s,o))||(r.precision=i),Wl(r,o);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=Ql(s,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=Zl(s))||(r.precision=i-2*("%"===r.type))}return Hl(r)}function p_(t){var e=t.domain;return t.ticks=function(t){var n=e();return q(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return d_(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,s=e(),o=0,a=s.length-1,l=s[o],c=s[a],u=10;for(c<l&&(i=l,l=c,c=i,i=o,o=a,a=i);u-- >0;){if((i=$(l,c,n))===r)return s[o]=l,s[a]=c,e(s);if(i>0)l=Math.floor(l/i)*i,c=Math.ceil(c/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,c=Math.floor(c*i)/i}r=i}return t},t}function __(){var t=f_();return t.copy=function(){return u_(t,__())},Zp.apply(t,arguments),p_(t)}function g_(t,e){var n,r=0,i=(t=t.slice()).length-1,s=t[r],o=t[i];return o<s&&(n=r,r=i,i=n,n=s,s=o,o=n),t[r]=e.floor(s),t[i]=e.ceil(o),t}function y_(t){return Math.log(t)}function m_(t){return Math.exp(t)}function b_(t){return-Math.log(-t)}function v_(t){return-Math.exp(-t)}function x_(t){return isFinite(t)?+("1e"+t):t<0?0:t}function w_(t){return(e,n)=>-t(-e,n)}function E_(t){const e=t(y_,m_),n=e.domain;let r,i,s=10;function o(){return r=function(t){return t===Math.E?Math.log:10===t&&Math.log10||2===t&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}(s),i=function(t){return 10===t?x_:t===Math.E?Math.exp:e=>Math.pow(t,e)}(s),n()[0]<0?(r=w_(r),i=w_(i),t(b_,v_)):t(y_,m_),e}return e.base=function(t){return arguments.length?(s=+t,o()):s},e.domain=function(t){return arguments.length?(n(t),o()):n()},e.ticks=t=>{const e=n();let o=e[0],a=e[e.length-1];const l=a<o;l&&([o,a]=[a,o]);let c,u,h=r(o),f=r(a);const d=null==t?10:+t;let p=[];if(!(s%1)&&f-h<d){if(h=Math.floor(h),f=Math.ceil(f),o>0){for(;h<=f;++h)for(c=1;c<s;++c)if(u=h<0?c/i(-h):c*i(h),!(u<o)){if(u>a)break;p.push(u)}}else for(;h<=f;++h)for(c=s-1;c>=1;--c)if(u=h>0?c/i(-h):c*i(h),!(u<o)){if(u>a)break;p.push(u)}2*p.length<d&&(p=q(o,a,d))}else p=q(h,f,Math.min(f-h,d)).map(i);return l?p.reverse():p},e.tickFormat=(t,n)=>{if(null==t&&(t=10),null==n&&(n=10===s?"s":","),"function"!=typeof n&&(s%1||null!=(n=zl(n)).precision||(n.trim=!0),n=Hl(n)),t===1/0)return n;const o=Math.max(1,s*t/e.ticks().length);return t=>{let e=t/i(Math.round(r(t)));return e*s<s-.5&&(e*=s),e<=o?n(t):""}},e.nice=()=>n(g_(n(),{floor:t=>i(Math.floor(r(t))),ceil:t=>i(Math.ceil(r(t)))})),e}function A_(){const t=E_(h_()).domain([1,10]);return t.copy=()=>u_(t,A_()).base(t.base()),Zp.apply(t,arguments),t}function S_(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function T_(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function C_(t){var e=1,n=t(S_(e),T_(e));return n.constant=function(n){return arguments.length?t(S_(e=+n),T_(e)):e},p_(n)}function k_(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function R_(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function M_(t){return t<0?-t*t:t*t}function O_(t){var e=t(o_,o_),n=1;return e.exponent=function(e){return arguments.length?1===(n=+e)?t(o_,o_):.5===n?t(R_,M_):t(k_(n),k_(1/n)):n},p_(e)}function N_(){var t=O_(h_());return t.copy=function(){return u_(t,N_()).exponent(t.exponent())},Zp.apply(t,arguments),t}function I_(t){return Math.sign(t)*t*t}const P_=new Date,L_=new Date;function D_(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=e=>(t(e=new Date(+e)),e),i.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),i.round=t=>{const e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=(t,n)=>(e(t=new Date(+t),null==n?1:Math.floor(n)),t),i.range=(n,r,s)=>{const o=[];if(n=i.ceil(n),s=null==s?1:Math.floor(s),!(n<r&&s>0))return o;let a;do{o.push(a=new Date(+n)),e(n,s),t(n)}while(a<n&&n<r);return o},i.filter=n=>D_(e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)},(t,r)=>{if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}),n&&(i.count=(e,r)=>(P_.setTime(+e),L_.setTime(+r),t(P_),t(L_),Math.floor(n(P_,L_))),i.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?e=>r(e)%t===0:e=>i.count(0,e)%t===0):i:null)),i}const V_=D_(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);V_.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?D_(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):V_:null);const B_=V_.range,z_=1e3,G_=6e4,F_=36e5,j_=864e5,U_=6048e5,Y_=2592e6,H_=31536e6,W_=D_(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*z_)},(t,e)=>(e-t)/z_,t=>t.getUTCSeconds()),q_=W_.range,$_=D_(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*z_)},(t,e)=>{t.setTime(+t+e*G_)},(t,e)=>(e-t)/G_,t=>t.getMinutes()),X_=$_.range,K_=D_(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*G_)},(t,e)=>(e-t)/G_,t=>t.getUTCMinutes()),Z_=K_.range,J_=D_(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*z_-t.getMinutes()*G_)},(t,e)=>{t.setTime(+t+e*F_)},(t,e)=>(e-t)/F_,t=>t.getHours()),Q_=J_.range,tg=D_(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*F_)},(t,e)=>(e-t)/F_,t=>t.getUTCHours()),eg=tg.range,ng=D_(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*G_)/j_,t=>t.getDate()-1),rg=ng.range,ig=D_(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/j_,t=>t.getUTCDate()-1),sg=ig.range,og=D_(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/j_,t=>Math.floor(t/j_)),ag=og.range;function lg(t){return D_(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+7*e)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*G_)/U_)}const cg=lg(0),ug=lg(1),hg=lg(2),fg=lg(3),dg=lg(4),pg=lg(5),_g=lg(6),gg=cg.range,yg=ug.range,mg=hg.range,bg=fg.range,vg=dg.range,xg=pg.range,wg=_g.range;function Eg(t){return D_(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)},(t,e)=>(e-t)/U_)}const Ag=Eg(0),Sg=Eg(1),Tg=Eg(2),Cg=Eg(3),kg=Eg(4),Rg=Eg(5),Mg=Eg(6),Og=Ag.range,Ng=Sg.range,Ig=Tg.range,Pg=Cg.range,Lg=kg.range,Dg=Rg.range,Vg=Mg.range,Bg=D_(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear()),t=>t.getMonth()),zg=Bg.range,Gg=D_(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear()),t=>t.getUTCMonth()),Fg=Gg.range,jg=D_(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());jg.every=t=>isFinite(t=Math.floor(t))&&t>0?D_(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)}):null;const Ug=jg.range,Yg=D_(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());Yg.every=t=>isFinite(t=Math.floor(t))&&t>0?D_(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)}):null;const Hg=Yg.range;function Wg(t,e,r,i,s,o){const a=[[W_,1,z_],[W_,5,5e3],[W_,15,15e3],[W_,30,3e4],[o,1,G_],[o,5,3e5],[o,15,9e5],[o,30,18e5],[s,1,F_],[s,3,108e5],[s,6,216e5],[s,12,432e5],[i,1,j_],[i,2,1728e5],[r,1,U_],[e,1,Y_],[e,3,7776e6],[t,1,H_]];function l(e,r,i){const s=Math.abs(r-e)/i,o=n(([,,t])=>t).right(a,s);if(o===a.length)return t.every(X(e/H_,r/H_,i));if(0===o)return V_.every(Math.max(X(e,r,i),1));const[l,c]=a[s/a[o-1][2]<a[o][2]/s?o-1:o];return l.every(c)}return[function(t,e,n){const r=e<t;r&&([t,e]=[e,t]);const i=n&&"function"==typeof n.range?n:l(t,e,n),s=i?i.range(t,+e+1):[];return r?s.reverse():s},l]}const[qg,$g]=Wg(Yg,Gg,Ag,og,tg,K_),[Xg,Kg]=Wg(jg,Bg,cg,ng,J_,$_);function Zg(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 Jg(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 Qg(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function ty(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,o=t.shortDays,a=t.months,l=t.shortMonths,c=fy(i),u=dy(i),h=fy(s),f=dy(s),d=fy(o),p=dy(o),_=fy(a),g=dy(a),y=fy(l),m=dy(l),b={a:function(t){return o[t.getDay()]},A:function(t){return s[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return a[t.getMonth()]},c:null,d:Py,e:Py,f:zy,g:Ky,G:Jy,H:Ly,I:Dy,j:Vy,L:By,m:Gy,M:Fy,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:xm,s:wm,S:jy,u:Uy,U:Yy,V:Wy,w:qy,W:$y,x:null,X:null,y:Xy,Y:Zy,Z:Qy,"%":vm},v={a:function(t){return o[t.getUTCDay()]},A:function(t){return s[t.getUTCDay()]},b:function(t){return l[t.getUTCMonth()]},B:function(t){return a[t.getUTCMonth()]},c:null,d:tm,e:tm,f:sm,g:gm,G:mm,H:em,I:nm,j:rm,L:im,m:om,M:am,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:xm,s:wm,S:lm,u:cm,U:um,V:fm,w:dm,W:pm,x:null,X:null,y:_m,Y:ym,Z:bm,"%":vm},x={a:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.w=f.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=y.exec(e.slice(n));return r?(t.m=m.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=_.exec(e.slice(n));return r?(t.m=g.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return A(t,e,n,r)},d:Ay,e:Ay,f:My,g:vy,G:by,H:Ty,I:Ty,j:Sy,L:Ry,m:Ey,M:Cy,p:function(t,e,n){var r=c.exec(e.slice(n));return r?(t.p=u.get(r[0].toLowerCase()),n+r[0].length):-1},q:wy,Q:Ny,s:Iy,S:ky,u:_y,U:gy,V:yy,w:py,W:my,x:function(t,e,r){return A(t,n,e,r)},X:function(t,e,n){return A(t,r,e,n)},y:vy,Y:by,Z:xy,"%":Oy};function w(t,e){return function(n){var r,i,s,o=[],a=-1,l=0,c=t.length;for(n instanceof Date||(n=new Date(+n));++a<c;)37===t.charCodeAt(a)&&(o.push(t.slice(l,a)),null!=(i=oy[r=t.charAt(++a)])?r=t.charAt(++a):i="e"===r?" ":"0",(s=e[r])&&(r=s(n,i)),o.push(r),l=a+1);return o.push(t.slice(l,a)),o.join("")}}function E(t,e){return function(n){var r,i,s=Qg(1900,void 0,1);if(A(s,t,n+="",0)!=n.length)return null;if("Q"in s)return new Date(s.Q);if("s"in s)return new Date(1e3*s.s+("L"in s?s.L:0));if(e&&!("Z"in s)&&(s.Z=0),"p"in s&&(s.H=s.H%12+12*s.p),void 0===s.m&&(s.m="q"in s?s.q:0),"V"in s){if(s.V<1||s.V>53)return null;"w"in s||(s.w=1),"Z"in s?(i=(r=Jg(Qg(s.y,0,1))).getUTCDay(),r=i>4||0===i?Sg.ceil(r):Sg(r),r=ig.offset(r,7*(s.V-1)),s.y=r.getUTCFullYear(),s.m=r.getUTCMonth(),s.d=r.getUTCDate()+(s.w+6)%7):(i=(r=Zg(Qg(s.y,0,1))).getDay(),r=i>4||0===i?ug.ceil(r):ug(r),r=ng.offset(r,7*(s.V-1)),s.y=r.getFullYear(),s.m=r.getMonth(),s.d=r.getDate()+(s.w+6)%7)}else("W"in s||"U"in s)&&("w"in s||(s.w="u"in s?s.u%7:"W"in s?1:0),i="Z"in s?Jg(Qg(s.y,0,1)).getUTCDay():Zg(Qg(s.y,0,1)).getDay(),s.m=0,s.d="W"in s?(s.w+6)%7+7*s.W-(i+5)%7:s.w+7*s.U-(i+6)%7);return"Z"in s?(s.H+=s.Z/100|0,s.M+=s.Z%100,Jg(s)):Zg(s)}}function A(t,e,n,r){for(var i,s,o=0,a=e.length,l=n.length;o<a;){if(r>=l)return-1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(s=x[i in oy?e.charAt(o++):i])||(r=s(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return b.x=w(n,b),b.X=w(r,b),b.c=w(e,b),v.x=w(n,v),v.X=w(r,v),v.c=w(e,v),{format:function(t){var e=w(t+="",b);return e.toString=function(){return t},e},parse:function(t){var e=E(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=w(t+="",v);return e.toString=function(){return t},e},utcParse:function(t){var e=E(t+="",!0);return e.toString=function(){return t},e}}}var ey,ny,ry,iy,sy,oy={"-":"",_:" ",0:"0"},ay=/^\s*\d+/,ly=/^%/,cy=/[\\^$*+?|[\]().{}]/g;function uy(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function hy(t){return t.replace(cy,"\\$&")}function fy(t){return new RegExp("^(?:"+t.map(hy).join("|")+")","i")}function dy(t){return new Map(t.map((t,e)=>[t.toLowerCase(),e]))}function py(t,e,n){var r=ay.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function _y(t,e,n){var r=ay.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function gy(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function yy(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function my(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function by(t,e,n){var r=ay.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function vy(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function xy(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 wy(t,e,n){var r=ay.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function Ey(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Ay(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Sy(t,e,n){var r=ay.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Ty(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Cy(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ky(t,e,n){var r=ay.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Ry(t,e,n){var r=ay.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function My(t,e,n){var r=ay.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Oy(t,e,n){var r=ly.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Ny(t,e,n){var r=ay.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Iy(t,e,n){var r=ay.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function Py(t,e){return uy(t.getDate(),e,2)}function Ly(t,e){return uy(t.getHours(),e,2)}function Dy(t,e){return uy(t.getHours()%12||12,e,2)}function Vy(t,e){return uy(1+ng.count(jg(t),t),e,3)}function By(t,e){return uy(t.getMilliseconds(),e,3)}function zy(t,e){return By(t,e)+"000"}function Gy(t,e){return uy(t.getMonth()+1,e,2)}function Fy(t,e){return uy(t.getMinutes(),e,2)}function jy(t,e){return uy(t.getSeconds(),e,2)}function Uy(t){var e=t.getDay();return 0===e?7:e}function Yy(t,e){return uy(cg.count(jg(t)-1,t),e,2)}function Hy(t){var e=t.getDay();return e>=4||0===e?dg(t):dg.ceil(t)}function Wy(t,e){return t=Hy(t),uy(dg.count(jg(t),t)+(4===jg(t).getDay()),e,2)}function qy(t){return t.getDay()}function $y(t,e){return uy(ug.count(jg(t)-1,t),e,2)}function Xy(t,e){return uy(t.getFullYear()%100,e,2)}function Ky(t,e){return uy((t=Hy(t)).getFullYear()%100,e,2)}function Zy(t,e){return uy(t.getFullYear()%1e4,e,4)}function Jy(t,e){var n=t.getDay();return uy((t=n>=4||0===n?dg(t):dg.ceil(t)).getFullYear()%1e4,e,4)}function Qy(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+uy(e/60|0,"0",2)+uy(e%60,"0",2)}function tm(t,e){return uy(t.getUTCDate(),e,2)}function em(t,e){return uy(t.getUTCHours(),e,2)}function nm(t,e){return uy(t.getUTCHours()%12||12,e,2)}function rm(t,e){return uy(1+ig.count(Yg(t),t),e,3)}function im(t,e){return uy(t.getUTCMilliseconds(),e,3)}function sm(t,e){return im(t,e)+"000"}function om(t,e){return uy(t.getUTCMonth()+1,e,2)}function am(t,e){return uy(t.getUTCMinutes(),e,2)}function lm(t,e){return uy(t.getUTCSeconds(),e,2)}function cm(t){var e=t.getUTCDay();return 0===e?7:e}function um(t,e){return uy(Ag.count(Yg(t)-1,t),e,2)}function hm(t){var e=t.getUTCDay();return e>=4||0===e?kg(t):kg.ceil(t)}function fm(t,e){return t=hm(t),uy(kg.count(Yg(t),t)+(4===Yg(t).getUTCDay()),e,2)}function dm(t){return t.getUTCDay()}function pm(t,e){return uy(Sg.count(Yg(t)-1,t),e,2)}function _m(t,e){return uy(t.getUTCFullYear()%100,e,2)}function gm(t,e){return uy((t=hm(t)).getUTCFullYear()%100,e,2)}function ym(t,e){return uy(t.getUTCFullYear()%1e4,e,4)}function mm(t,e){var n=t.getUTCDay();return uy((t=n>=4||0===n?kg(t):kg.ceil(t)).getUTCFullYear()%1e4,e,4)}function bm(){return"+0000"}function vm(){return"%"}function xm(t){return+t}function wm(t){return Math.floor(+t/1e3)}function Em(t){return ey=ty(t),ny=ey.format,ry=ey.parse,iy=ey.utcFormat,sy=ey.utcParse,ey}Em({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"]});var Am="%Y-%m-%dT%H:%M:%S.%LZ";var Sm=Date.prototype.toISOString?function(t){return t.toISOString()}:iy(Am);var Tm=+new Date("2000-01-01T00:00:00.000Z")?function(t){var e=new Date(t);return isNaN(e)?null:e}:sy(Am);function Cm(t){return new Date(t)}function km(t){return t instanceof Date?+t:+new Date(+t)}function Rm(t,e,n,r,i,s,o,a,l,c){var u=f_(),h=u.invert,f=u.domain,d=c(".%L"),p=c(":%S"),_=c("%I:%M"),g=c("%I %p"),y=c("%a %d"),m=c("%b %d"),b=c("%B"),v=c("%Y");function x(t){return(l(t)<t?d:a(t)<t?p:o(t)<t?_:s(t)<t?g:r(t)<t?i(t)<t?y:m:n(t)<t?b:v)(t)}return u.invert=function(t){return new Date(h(t))},u.domain=function(t){return arguments.length?f(Array.from(t,km)):f().map(Cm)},u.ticks=function(e){var n=f();return t(n[0],n[n.length-1],null==e?10:e)},u.tickFormat=function(t,e){return null==e?x:c(e)},u.nice=function(t){var n=f();return t&&"function"==typeof t.range||(t=e(n[0],n[n.length-1],null==t?10:t)),t?f(g_(n,t)):u},u.copy=function(){return u_(u,Rm(t,e,n,r,i,s,o,a,l,c))},u}function Mm(){return Zp.apply(Rm(Xg,Kg,jg,Bg,cg,ng,J_,$_,W_,ny).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Om(){var t,e,n,r,i,s=0,o=1,a=o_,l=!1;function c(e){return null==e||isNaN(e=+e)?i:a(0===n?.5:(e=(r(e)-t)*n,l?Math.max(0,Math.min(1,e)):e))}function u(t){return function(e){var n,r;return arguments.length?([n,r]=e,a=t(n,r),c):[a(0),a(1)]}}return c.domain=function(i){return arguments.length?([s,o]=i,t=r(s=+s),e=r(o=+o),n=t===e?0:1/(e-t),c):[s,o]},c.clamp=function(t){return arguments.length?(l=!!t,c):l},c.interpolator=function(t){return arguments.length?(a=t,c):a},c.range=u(Hr),c.rangeRound=u(Wr),c.unknown=function(t){return arguments.length?(i=t,c):i},function(i){return r=i,t=i(s),e=i(o),n=t===e?0:1/(e-t),c}}function Nm(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function Im(){var t=p_(Om()(o_));return t.copy=function(){return Nm(t,Im())},Jp.apply(t,arguments)}function Pm(){var t=O_(Om());return t.copy=function(){return Nm(t,Pm()).exponent(t.exponent())},Jp.apply(t,arguments)}function Lm(){var t,e,n,r,i,s,o,a=0,l=.5,c=1,u=1,h=o_,f=!1;function d(t){return isNaN(t=+t)?o:(t=.5+((t=+s(t))-e)*(u*t<u*e?r:i),h(f?Math.max(0,Math.min(1,t)):t))}function p(t){return function(e){var n,r,i;return arguments.length?([n,r,i]=e,h=hi(t,[n,r,i]),d):[h(0),h(.5),h(1)]}}return d.domain=function(o){return arguments.length?([a,l,c]=o,t=s(a=+a),e=s(l=+l),n=s(c=+c),r=t===e?0:.5/(e-t),i=e===n?0:.5/(n-e),u=e<t?-1:1,d):[a,l,c]},d.clamp=function(t){return arguments.length?(f=!!t,d):f},d.interpolator=function(t){return arguments.length?(h=t,d):h},d.range=p(Hr),d.rangeRound=p(Wr),d.unknown=function(t){return arguments.length?(o=t,d):o},function(o){return s=o,t=o(a),e=o(l),n=o(c),r=t===e?0:.5/(e-t),i=e===n?0:.5/(n-e),u=e<t?-1:1,d}}function Dm(){var t=O_(Lm());return t.copy=function(){return Nm(t,Dm()).exponent(t.exponent())},Jp.apply(t,arguments)}function Vm(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(6*r,6*++r);return n}var Bm=Vm("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),zm=Vm("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"),Gm=Vm("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"),Fm=Vm("4269d0efb118ff725c6cc5b03ca951ff8ab7a463f297bbf59c6b4e9498a0"),jm=Vm("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),Um=Vm("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"),Ym=Vm("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"),Hm=Vm("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"),Wm=Vm("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"),qm=Vm("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"),$m=Vm("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"),Xm=t=>Pr(t[t.length-1]),Km=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(Vm),Zm=Xm(Km),Jm=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(Vm),Qm=Xm(Jm),tb=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(Vm),eb=Xm(tb),nb=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(Vm),rb=Xm(nb),ib=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(Vm),sb=Xm(ib),ob=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(Vm),ab=Xm(ob),lb=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(Vm),cb=Xm(lb),ub=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(Vm),hb=Xm(ub),fb=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(Vm),db=Xm(fb),pb=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(Vm),_b=Xm(pb),gb=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(Vm),yb=Xm(gb),mb=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(Vm),bb=Xm(mb),vb=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(Vm),xb=Xm(vb),wb=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(Vm),Eb=Xm(wb),Ab=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(Vm),Sb=Xm(Ab),Tb=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(Vm),Cb=Xm(Tb),kb=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(Vm),Rb=Xm(kb),Mb=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(Vm),Ob=Xm(Mb),Nb=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(Vm),Ib=Xm(Nb),Pb=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(Vm),Lb=Xm(Pb),Db=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(Vm),Vb=Xm(Db),Bb=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(Vm),zb=Xm(Bb),Gb=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(Vm),Fb=Xm(Gb),jb=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Vm),Ub=Xm(jb),Yb=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(Vm),Hb=Xm(Yb),Wb=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(Vm),qb=Xm(Wb),$b=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(Vm),Xb=Xm($b);var Kb=ui(wr(300,.5,0),wr(-240,.5,1)),Zb=ui(wr(-100,.75,.35),wr(80,1.5,.8)),Jb=ui(wr(260,.75,.35),wr(80,1.5,.8)),Qb=wr();var tv=Ln(),ev=Math.PI/3,nv=2*Math.PI/3;function rv(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))))+")"}function iv(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}var sv=iv(Vm("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),ov=iv(Vm("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),av=iv(Vm("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),lv=iv(Vm("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function cv(t){return function(){return t}}const uv=Math.abs,hv=Math.atan2,fv=Math.cos,dv=Math.max,pv=Math.min,_v=Math.sin,gv=Math.sqrt,yv=1e-12,mv=Math.PI,bv=mv/2,vv=2*mv;function xv(t){return t>=1?bv:t<=-1?-bv:Math.asin(t)}function wv(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(null==n)e=null;else{const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new So(e)}function Ev(t){return t.innerRadius}function Av(t){return t.outerRadius}function Sv(t){return t.startAngle}function Tv(t){return t.endAngle}function Cv(t){return t&&t.padAngle}function kv(t,e,n,r,i,s,o){var a=t-n,l=e-r,c=(o?s:-s)/gv(a*a+l*l),u=c*l,h=-c*a,f=t+u,d=e+h,p=n+u,_=r+h,g=(f+p)/2,y=(d+_)/2,m=p-f,b=_-d,v=m*m+b*b,x=i-s,w=f*_-p*d,E=(b<0?-1:1)*gv(dv(0,x*x*v-w*w)),A=(w*b-m*E)/v,S=(-w*m-b*E)/v,T=(w*b+m*E)/v,C=(-w*m+b*E)/v,k=A-g,R=S-y,M=T-g,O=C-y;return k*k+R*R>M*M+O*O&&(A=T,S=C),{cx:A,cy:S,x01:-u,y01:-h,x11:A*(i/x-1),y11:S*(i/x-1)}}var Rv=Array.prototype.slice;function Mv(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function Ov(t){this._context=t}function Nv(t){return new Ov(t)}function Iv(t){return t[0]}function Pv(t){return t[1]}function Lv(t,e){var n=cv(!0),r=null,i=Nv,s=null,o=wv(a);function a(a){var l,c,u,h=(a=Mv(a)).length,f=!1;for(null==r&&(s=i(u=o())),l=0;l<=h;++l)!(l<h&&n(c=a[l],l,a))===f&&((f=!f)?s.lineStart():s.lineEnd()),f&&s.point(+t(c,l,a),+e(c,l,a));if(u)return s=null,u+""||null}return t="function"==typeof t?t:void 0===t?Iv:cv(t),e="function"==typeof e?e:void 0===e?Pv:cv(e),a.x=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),a):t},a.y=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),a):e},a.defined=function(t){return arguments.length?(n="function"==typeof t?t:cv(!!t),a):n},a.curve=function(t){return arguments.length?(i=t,null!=r&&(s=i(r)),a):i},a.context=function(t){return arguments.length?(null==t?r=s=null:s=i(r=t),a):r},a}function Dv(t,e,n){var r=null,i=cv(!0),s=null,o=Nv,a=null,l=wv(c);function c(c){var u,h,f,d,p,_=(c=Mv(c)).length,g=!1,y=new Array(_),m=new Array(_);for(null==s&&(a=o(p=l())),u=0;u<=_;++u){if(!(u<_&&i(d=c[u],u,c))===g)if(g=!g)h=u,a.areaStart(),a.lineStart();else{for(a.lineEnd(),a.lineStart(),f=u-1;f>=h;--f)a.point(y[f],m[f]);a.lineEnd(),a.areaEnd()}g&&(y[u]=+t(d,u,c),m[u]=+e(d,u,c),a.point(r?+r(d,u,c):y[u],n?+n(d,u,c):m[u]))}if(p)return a=null,p+""||null}function u(){return Lv().defined(i).curve(o).context(s)}return t="function"==typeof t?t:void 0===t?Iv:cv(+t),e="function"==typeof e?e:cv(void 0===e?0:+e),n="function"==typeof n?n:void 0===n?Pv:cv(+n),c.x=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),r=null,c):t},c.x0=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),c):t},c.x1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:cv(+t),c):r},c.y=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),n=null,c):e},c.y0=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),c):e},c.y1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:cv(+t),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(t){return arguments.length?(i="function"==typeof t?t:cv(!!t),c):i},c.curve=function(t){return arguments.length?(o=t,null!=s&&(a=o(s)),c):o},c.context=function(t){return arguments.length?(null==t?s=a=null:a=o(s=t),c):s},c}function Vv(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function Bv(t){return t}Ov.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&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)}}};var zv=Fv(Nv);function Gv(t){this._curve=t}function Fv(t){function e(e){return new Gv(t(e))}return e._curve=t,e}function jv(t){var e=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(t){return arguments.length?e(Fv(t)):e()._curve},t}function Uv(){return jv(Lv().curve(zv))}function Yv(){var t=Dv().curve(zv),e=t.curve,n=t.lineX0,r=t.lineX1,i=t.lineY0,s=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return jv(n())},delete t.lineX0,t.lineEndAngle=function(){return jv(r())},delete t.lineX1,t.lineInnerRadius=function(){return jv(i())},delete t.lineY0,t.lineOuterRadius=function(){return jv(s())},delete t.lineY1,t.curve=function(t){return arguments.length?e(Fv(t)):e()._curve},t}function Hv(t,e){return[(e=+e)*Math.cos(t-=Math.PI/2),e*Math.sin(t)]}Gv.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(t,e){this._curve.point(e*Math.sin(t),e*-Math.cos(t))}};class Wv{constructor(t,e){this._context=t,this._x=e}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line}point(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._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,e,t,e):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+e)/2,t,this._y0,t,e)}this._x0=t,this._y0=e}}class qv{constructor(t){this._context=t}lineStart(){this._point=0}lineEnd(){}point(t,e){if(t=+t,e=+e,0===this._point)this._point=1;else{const n=Hv(this._x0,this._y0),r=Hv(this._x0,this._y0=(this._y0+e)/2),i=Hv(t,this._y0),s=Hv(t,e);this._context.moveTo(...n),this._context.bezierCurveTo(...r,...i,...s)}this._x0=t,this._y0=e}}function $v(t){return new Wv(t,!0)}function Xv(t){return new Wv(t,!1)}function Kv(t){return new qv(t)}function Zv(t){return t.source}function Jv(t){return t.target}function Qv(t){let e=Zv,n=Jv,r=Iv,i=Pv,s=null,o=null,a=wv(l);function l(){let l;const c=Rv.call(arguments),u=e.apply(this,c),h=n.apply(this,c);if(null==s&&(o=t(l=a())),o.lineStart(),c[0]=u,o.point(+r.apply(this,c),+i.apply(this,c)),c[0]=h,o.point(+r.apply(this,c),+i.apply(this,c)),o.lineEnd(),l)return o=null,l+""||null}return l.source=function(t){return arguments.length?(e=t,l):e},l.target=function(t){return arguments.length?(n=t,l):n},l.x=function(t){return arguments.length?(r="function"==typeof t?t:cv(+t),l):r},l.y=function(t){return arguments.length?(i="function"==typeof t?t:cv(+t),l):i},l.context=function(e){return arguments.length?(null==e?s=o=null:o=t(s=e),l):s},l}function tx(){return Qv($v)}function ex(){return Qv(Xv)}function nx(){const t=Qv(Kv);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t}const rx=gv(3);var ix={draw(t,e){const n=.59436*gv(e+pv(e/28,.75)),r=n/2,i=r*rx;t.moveTo(0,n),t.lineTo(0,-n),t.moveTo(-i,-r),t.lineTo(i,r),t.moveTo(-i,r),t.lineTo(i,-r)}},sx={draw(t,e){const n=gv(e/mv);t.moveTo(n,0),t.arc(0,0,n,0,vv)}},ox={draw(t,e){const n=gv(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}};const ax=gv(1/3),lx=2*ax;var cx={draw(t,e){const n=gv(e/lx),r=n*ax;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},ux={draw(t,e){const n=.62625*gv(e);t.moveTo(0,-n),t.lineTo(n,0),t.lineTo(0,n),t.lineTo(-n,0),t.closePath()}},hx={draw(t,e){const n=.87559*gv(e-pv(e/7,2));t.moveTo(-n,0),t.lineTo(n,0),t.moveTo(0,n),t.lineTo(0,-n)}},fx={draw(t,e){const n=gv(e),r=-n/2;t.rect(r,r,n,n)}},dx={draw(t,e){const n=.4431*gv(e);t.moveTo(n,n),t.lineTo(n,-n),t.lineTo(-n,-n),t.lineTo(-n,n),t.closePath()}};const px=_v(mv/10)/_v(7*mv/10),_x=_v(vv/10)*px,gx=-fv(vv/10)*px;var yx={draw(t,e){const n=gv(.8908130915292852*e),r=_x*n,i=gx*n;t.moveTo(0,-n),t.lineTo(r,i);for(let e=1;e<5;++e){const s=vv*e/5,o=fv(s),a=_v(s);t.lineTo(a*n,-o*n),t.lineTo(o*r-a*i,a*r+o*i)}t.closePath()}};const mx=gv(3);var bx={draw(t,e){const n=-gv(e/(3*mx));t.moveTo(0,2*n),t.lineTo(-mx*n,-n),t.lineTo(mx*n,-n),t.closePath()}};const vx=gv(3);var xx={draw(t,e){const n=.6824*gv(e),r=n/2,i=n*vx/2;t.moveTo(0,-n),t.lineTo(i,r),t.lineTo(-i,r),t.closePath()}};const wx=-.5,Ex=gv(3)/2,Ax=1/gv(12),Sx=3*(Ax/2+1);var Tx={draw(t,e){const n=gv(e/Sx),r=n/2,i=n*Ax,s=r,o=n*Ax+n,a=-s,l=o;t.moveTo(r,i),t.lineTo(s,o),t.lineTo(a,l),t.lineTo(wx*r-Ex*i,Ex*r+wx*i),t.lineTo(wx*s-Ex*o,Ex*s+wx*o),t.lineTo(wx*a-Ex*l,Ex*a+wx*l),t.lineTo(wx*r+Ex*i,wx*i-Ex*r),t.lineTo(wx*s+Ex*o,wx*o-Ex*s),t.lineTo(wx*a+Ex*l,wx*l-Ex*a),t.closePath()}},Cx={draw(t,e){const n=.6189*gv(e-pv(e/6,1.7));t.moveTo(-n,-n),t.lineTo(n,n),t.moveTo(-n,n),t.lineTo(n,-n)}};const kx=[sx,ox,cx,fx,yx,bx,Tx],Rx=[sx,hx,Cx,xx,ix,dx,ux];function Mx(){}function Ox(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 Nx(t){this._context=t}function Ix(t){return new Nx(t)}function Px(t){this._context=t}function Lx(t){this._context=t}function Dx(t,e){this._basis=new Nx(t),this._beta=e}Nx.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:Ox(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&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:Ox(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},Px.prototype={areaStart:Mx,areaEnd:Mx,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:Ox(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},Lx.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(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Ox(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},Dx.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,e=this._y,n=t.length-1;if(n>0)for(var r,i=t[0],s=e[0],o=t[n]-i,a=e[n]-s,l=-1;++l<=n;)r=l/n,this._basis.point(this._beta*t[l]+(1-this._beta)*(i+r*o),this._beta*e[l]+(1-this._beta)*(s+r*a));this._x=this._y=null,this._basis.lineEnd()},point:function(t,e){this._x.push(+t),this._y.push(+e)}};var Vx=function t(e){function n(t){return 1===e?new Nx(t):new Dx(t,e)}return n.beta=function(e){return t(+e)},n}(.85);function Bx(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 zx(t,e){this._context=t,this._k=(1-e)/6}zx.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:Bx(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&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:Bx(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var Gx=function t(e){function n(t){return new zx(t,e)}return n.tension=function(e){return t(+e)},n}(0);function Fx(t,e){this._context=t,this._k=(1-e)/6}Fx.prototype={areaStart:Mx,areaEnd:Mx,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:Bx(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var jx=function t(e){function n(t){return new Fx(t,e)}return n.tension=function(e){return t(+e)},n}(0);function Ux(t,e){this._context=t,this._k=(1-e)/6}Ux.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(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Bx(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var Yx=function t(e){function n(t){return new Ux(t,e)}return n.tension=function(e){return t(+e)},n}(0);function Hx(t,e,n){var r=t._x1,i=t._y1,s=t._x2,o=t._y2;if(t._l01_a>yv){var a=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*a-t._x0*t._l12_2a+t._x2*t._l01_2a)/l,i=(i*a-t._y0*t._l12_2a+t._y2*t._l01_2a)/l}if(t._l23_a>yv){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);s=(s*c+t._x1*t._l23_2a-e*t._l12_2a)/u,o=(o*c+t._y1*t._l23_2a-n*t._l12_2a)/u}t._context.bezierCurveTo(r,i,s,o,t._x2,t._y2)}function Wx(t,e){this._context=t,this._alpha=e}Wx.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)}(this._line||0!==this._line&&1===this._point)&&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:Hx(this,t,e)}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}};var qx=function t(e){function n(t){return e?new Wx(t,e):new zx(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);function $x(t,e){this._context=t,this._alpha=e}$x.prototype={areaStart:Mx,areaEnd:Mx,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=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 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},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._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:Hx(this,t,e)}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}};var Xx=function t(e){function n(t){return e?new $x(t,e):new Fx(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);function Kx(t,e){this._context=t,this._alpha=e}Kx.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(){(this._line||0!==this._line&&3===this._point)&&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;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Hx(this,t,e)}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}};var Zx=function t(e){function n(t){return e?new Kx(t,e):new Ux(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);function Jx(t){this._context=t}function Qx(t){return t<0?-1:1}function tw(t,e,n){var r=t._x1-t._x0,i=e-t._x1,s=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),a=(s*i+o*r)/(r+i);return(Qx(s)+Qx(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(a))||0}function ew(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function nw(t,e,n){var r=t._x0,i=t._y0,s=t._x1,o=t._y1,a=(s-r)/3;t._context.bezierCurveTo(r+a,i+a*e,s-a,o-a*n,s,o)}function rw(t){this._context=t}function iw(t){this._context=new sw(t)}function sw(t){this._context=t}function ow(t){this._context=t}function aw(t){var e,n,r=t.length-1,i=new Array(r),s=new Array(r),o=new Array(r);for(i[0]=0,s[0]=2,o[0]=t[0]+2*t[1],e=1;e<r-1;++e)i[e]=1,s[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[r-1]=2,s[r-1]=7,o[r-1]=8*t[r-1]+t[r],e=1;e<r;++e)n=i[e]/s[e-1],s[e]-=n,o[e]-=n*o[e-1];for(i[r-1]=o[r-1]/s[r-1],e=r-2;e>=0;--e)i[e]=(o[e]-i[e+1])/s[e];for(s[r-1]=(t[r]+i[r-1])/2,e=0;e<r-1;++e)s[e]=2*t[e+1]-i[e+1];return[i,s]}function lw(t){return new ow(t)}function cw(t,e){this._context=t,this._t=e}function uw(t){return new cw(t,.5)}function hw(t,e){if((i=t.length)>1)for(var n,r,i,s=1,o=t[e[0]],a=o.length;s<i;++s)for(r=o,o=t[e[s]],n=0;n<a;++n)o[n][1]+=o[n][0]=isNaN(r[n][1])?r[n][0]:r[n][1]}function fw(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function dw(t,e){return t[e]}function pw(t){const e=[];return e.key=t,e}function _w(t){var e=t.map(gw);return fw(t).sort(function(t,n){return e[t]-e[n]})}function gw(t){for(var e,n=-1,r=0,i=t.length,s=-1/0;++n<i;)(e=+t[n][1])>s&&(s=e,r=n);return r}function yw(t){var e=t.map(mw);return fw(t).sort(function(t,n){return e[t]-e[n]})}function mw(t){for(var e,n=0,r=-1,i=t.length;++r<i;)(e=+t[r][1])&&(n+=e);return n}Jx.prototype={areaStart:Mx,areaEnd:Mx,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e))}},rw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:nw(this,this._t0,ew(this,this._t0))}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(e=+e,(t=+t)!==this._x1||e!==this._y1){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,nw(this,ew(this,n=tw(this,t,e)),n);break;default:nw(this,this._t0,n=tw(this,t,e))}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}},(iw.prototype=Object.create(rw.prototype)).point=function(t,e){rw.prototype.point.call(this,e,t)},sw.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,s){this._context.bezierCurveTo(e,t,r,n,s,i)}},ow.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]),2===n)this._context.lineTo(t[1],e[1]);else for(var r=aw(t),i=aw(e),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],t[o],e[o]);(this._line||0!==this._line&&1===n)&&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)}},cw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,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:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}}this._x=t,this._y=e}};var bw=t=>()=>t;function vw(t,{sourceEvent:e,target:n,transform:r,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},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function xw(t,e,n){this.k=t,this.x=e,this.y=n}xw.prototype={constructor:xw,scale:function(t){return 1===t?this:new xw(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new xw(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+")"}};var ww=new xw(1,0,0);function Ew(t){for(;!t.__zoom;)if(!(t=t.parentNode))return ww;return t.__zoom}function Aw(t){t.stopImmediatePropagation()}function Sw(t){t.preventDefault(),t.stopImmediatePropagation()}function Tw(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Cw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function kw(){return this.__zoom||ww}function Rw(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Mw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ow(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],s=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}Ew.prototype=xw.prototype;var Nw=Object.freeze({__proto__:null,Adder:w,Delaunay:Ca,FormatSpecifier:Gl,InternMap:E,InternSet:A,Node:Dd,Path:So,Voronoi:xa,ZoomTransform:xw,active:function(t,e){var n,r,i=t.__transition;if(i)for(r in e=null==e?null:e+"",i)if((n=i[r]).state>1&&n.name===e)return new rs([[t]],Ds,e,+r);return null},arc:function(){var t=Ev,e=Av,n=cv(0),r=null,i=Sv,s=Tv,o=Cv,a=null,l=wv(c);function c(){var c,u,h=+t.apply(this,arguments),f=+e.apply(this,arguments),d=i.apply(this,arguments)-bv,p=s.apply(this,arguments)-bv,_=uv(p-d),g=p>d;if(a||(a=c=l()),f<h&&(u=f,f=h,h=u),f>yv)if(_>vv-yv)a.moveTo(f*fv(d),f*_v(d)),a.arc(0,0,f,d,p,!g),h>yv&&(a.moveTo(h*fv(p),h*_v(p)),a.arc(0,0,h,p,d,g));else{var y,m,b=d,v=p,x=d,w=p,E=_,A=_,S=o.apply(this,arguments)/2,T=S>yv&&(r?+r.apply(this,arguments):gv(h*h+f*f)),C=pv(uv(f-h)/2,+n.apply(this,arguments)),k=C,R=C;if(T>yv){var M=xv(T/h*_v(S)),O=xv(T/f*_v(S));(E-=2*M)>yv?(x+=M*=g?1:-1,w-=M):(E=0,x=w=(d+p)/2),(A-=2*O)>yv?(b+=O*=g?1:-1,v-=O):(A=0,b=v=(d+p)/2)}var N=f*fv(b),I=f*_v(b),P=h*fv(w),L=h*_v(w);if(C>yv){var D,V=f*fv(v),B=f*_v(v),z=h*fv(x),G=h*_v(x);if(_<mv)if(D=function(t,e,n,r,i,s,o,a){var l=n-t,c=r-e,u=o-i,h=a-s,f=h*l-u*c;if(!(f*f<yv))return[t+(f=(u*(e-s)-h*(t-i))/f)*l,e+f*c]}(N,I,z,G,V,B,P,L)){var F=N-D[0],j=I-D[1],U=V-D[0],Y=B-D[1],H=1/_v(function(t){return t>1?0:t<-1?mv:Math.acos(t)}((F*U+j*Y)/(gv(F*F+j*j)*gv(U*U+Y*Y)))/2),W=gv(D[0]*D[0]+D[1]*D[1]);k=pv(C,(h-W)/(H-1)),R=pv(C,(f-W)/(H+1))}else k=R=0}A>yv?R>yv?(y=kv(z,G,N,I,f,R,g),m=kv(V,B,P,L,f,R,g),a.moveTo(y.cx+y.x01,y.cy+y.y01),R<C?a.arc(y.cx,y.cy,R,hv(y.y01,y.x01),hv(m.y01,m.x01),!g):(a.arc(y.cx,y.cy,R,hv(y.y01,y.x01),hv(y.y11,y.x11),!g),a.arc(0,0,f,hv(y.cy+y.y11,y.cx+y.x11),hv(m.cy+m.y11,m.cx+m.x11),!g),a.arc(m.cx,m.cy,R,hv(m.y11,m.x11),hv(m.y01,m.x01),!g))):(a.moveTo(N,I),a.arc(0,0,f,b,v,!g)):a.moveTo(N,I),h>yv&&E>yv?k>yv?(y=kv(P,L,V,B,h,-k,g),m=kv(N,I,z,G,h,-k,g),a.lineTo(y.cx+y.x01,y.cy+y.y01),k<C?a.arc(y.cx,y.cy,k,hv(y.y01,y.x01),hv(m.y01,m.x01),!g):(a.arc(y.cx,y.cy,k,hv(y.y01,y.x01),hv(y.y11,y.x11),!g),a.arc(0,0,h,hv(y.cy+y.y11,y.cx+y.x11),hv(m.cy+m.y11,m.cx+m.x11),g),a.arc(m.cx,m.cy,k,hv(m.y11,m.x11),hv(m.y01,m.x01),!g))):a.arc(0,0,h,w,x,g):a.lineTo(P,L)}else a.moveTo(0,0);if(a.closePath(),c)return a=null,c+""||null}return c.centroid=function(){var n=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +s.apply(this,arguments))/2-mv/2;return[fv(r)*n,_v(r)*n]},c.innerRadius=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),c):t},c.outerRadius=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),c):e},c.cornerRadius=function(t){return arguments.length?(n="function"==typeof t?t:cv(+t),c):n},c.padRadius=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:cv(+t),c):r},c.startAngle=function(t){return arguments.length?(i="function"==typeof t?t:cv(+t),c):i},c.endAngle=function(t){return arguments.length?(s="function"==typeof t?t:cv(+t),c):s},c.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:cv(+t),c):o},c.context=function(t){return arguments.length?(a=null==t?null:t,c):a},c},area:Dv,areaRadial:Yv,ascending:t,autoType:Za,axisBottom:function(t){return Mt(3,t)},axisLeft:function(t){return Mt(4,t)},axisRight:function(t){return Mt(2,t)},axisTop:function(t){return Mt(1,t)},bin:J,bisect:o,bisectCenter:l,bisectLeft:a,bisectRight:o,bisector:n,blob:function(t,e){return fetch(t,e).then(Qa)},blur:function(t,e){if(!((e=+e)>=0))throw new RangeError("invalid r");let n=t.length;if(!((n=Math.floor(n))>=0))throw new RangeError("invalid length");if(!n||!e)return t;const r=p(e),i=t.slice();return r(t,i,0,n,1),r(i,t,0,n,1),r(t,i,0,n,1),t},blur2:c,blurImage:u,brush:function(){return lo(Zs)},brushSelection:function(t){var e=t.__brush;return e?e.dim.output(e.selection):null},brushX:function(){return lo(Xs)},brushY:function(){return lo(Ks)},buffer:function(t,e){return fetch(t,e).then(tl)},chord:function(){return bo(!1,!1)},chordDirected:function(){return bo(!0,!1)},chordTranspose:function(){return bo(!1,!0)},cluster:Rd,color:On,contourDensity:function(){var t=Ko,e=Zo,n=Jo,r=960,i=500,s=20,o=2,a=3*s,l=r+2*a>>o,u=i+2*a>>o,h=zo(20);function f(r){var i=new Float32Array(l*u),h=Math.pow(2,-o),f=-1;for(const s of r){var d=(t(s,++f,r)+a)*h,p=(e(s,f,r)+a)*h,_=+n(s,f,r);if(_&&d>=0&&d<l&&p>=0&&p<u){var g=Math.floor(d),y=Math.floor(p),m=d-g-.5,b=p-y-.5;i[g+y*l]+=(1-m)*(1-b)*_,i[g+1+y*l]+=m*(1-b)*_,i[g+1+(y+1)*l]+=m*b*_,i[g+(y+1)*l]+=(1-m)*b*_}}return c({data:i,width:l,height:u},s*h),i}function d(t){var e=f(t),n=h(e),r=Math.pow(2,2*o);return Array.isArray(n)||(n=q(Number.MIN_VALUE,Q(e)/r,n)),Ho().size([l,u]).thresholds(n.map(t=>t*r))(e).map((t,e)=>(t.value=+n[e],p(t)))}function p(t){return t.coordinates.forEach(_),t}function _(t){t.forEach(g)}function g(t){t.forEach(y)}function y(t){t[0]=t[0]*Math.pow(2,o)-a,t[1]=t[1]*Math.pow(2,o)-a}function m(){return l=r+2*(a=3*s)>>o,u=i+2*a>>o,d}return d.contours=function(t){var e=f(t),n=Ho().size([l,u]),r=Math.pow(2,2*o),i=t=>{t=+t;var i=p(n.contour(e,t*r));return i.value=t,i};return Object.defineProperty(i,"max",{get:()=>Q(e)/r}),i},d.x=function(e){return arguments.length?(t="function"==typeof e?e:zo(+e),d):t},d.y=function(t){return arguments.length?(e="function"==typeof t?t:zo(+t),d):e},d.weight=function(t){return arguments.length?(n="function"==typeof t?t:zo(+t),d):n},d.size=function(t){if(!arguments.length)return[r,i];var e=+t[0],n=+t[1];if(!(e>=0&&n>=0))throw new Error("invalid size");return r=e,i=n,m()},d.cellSize=function(t){if(!arguments.length)return 1<<o;if(!((t=+t)>=1))throw new Error("invalid cell size");return o=Math.floor(Math.log(t)/Math.LN2),m()},d.thresholds=function(t){return arguments.length?(h="function"==typeof t?t:Array.isArray(t)?zo(Vo.call(t)):zo(t),d):h},d.bandwidth=function(t){if(!arguments.length)return Math.sqrt(s*(s+1));if(!((t=+t)>=0))throw new Error("invalid bandwidth");return s=(Math.sqrt(4*t*t+1)-1)/2,m()},d},contours:Ho,count:_,create:function(t){return $e(Ft(t).call(document.documentElement))},creator:Ft,cross:function(...t){const e="function"==typeof t[t.length-1]&&function(t){return e=>t(...e)}(t.pop()),n=(t=t.map(m)).map(g),r=t.length-1,i=new Array(r+1).fill(0),s=[];if(r<0||n.some(y))return s;for(;;){s.push(i.map((e,n)=>t[n][e]));let o=r;for(;++i[o]===n[o];){if(0===o)return e?s.map(e):s;i[o--]=0}}},csv:il,csvFormat:Ba,csvFormatBody:za,csvFormatRow:Fa,csvFormatRows:Ga,csvFormatValue:ja,csvParse:Da,csvParseRows:Va,cubehelix:wr,cumsum:function(t,e){var n=0,r=0;return Float64Array.from(t,void 0===e?t=>n+=+t||0:i=>n+=+e(i,r++,t)||0)},curveBasis:Ix,curveBasisClosed:function(t){return new Px(t)},curveBasisOpen:function(t){return new Lx(t)},curveBumpX:$v,curveBumpY:Xv,curveBundle:Vx,curveCardinal:Gx,curveCardinalClosed:jx,curveCardinalOpen:Yx,curveCatmullRom:qx,curveCatmullRomClosed:Xx,curveCatmullRomOpen:Zx,curveLinear:Nv,curveLinearClosed:function(t){return new Jx(t)},curveMonotoneX:function(t){return new rw(t)},curveMonotoneY:function(t){return new iw(t)},curveNatural:lw,curveStep:uw,curveStepAfter:function(t){return new cw(t,1)},curveStepBefore:function(t){return new cw(t,0)},descending:e,deviation:v,difference:function(t,...e){t=new A(t);for(const n of e)for(const e of n)t.delete(e);return t},disjoint:function(t,e){const n=e[Symbol.iterator](),r=new A;for(const e of t){if(r.has(e))return!1;let t,i;for(;({value:t,done:i}=n.next())&&!i;){if(Object.is(e,t))return!1;r.add(t)}}return!0},dispatch:Nt,drag:function(){var t,e,n,r,i=cn,s=un,o=hn,a=fn,l={},c=Nt("start","drag","end"),u=0,h=0;function f(t){t.on("mousedown.drag",d).filter(a).on("touchstart.drag",g).on("touchmove.drag",y,tn).on("touchend.drag touchcancel.drag",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(o,a){if(!r&&i.call(this,o,a)){var l=b(this,s.call(this,o,a),o,a,"mouse");l&&($e(o.view).on("mousemove.drag",p,en).on("mouseup.drag",_,en),sn(o.view),nn(o),n=!1,t=o.clientX,e=o.clientY,l("start",o))}}function p(r){if(rn(r),!n){var i=r.clientX-t,s=r.clientY-e;n=i*i+s*s>h}l.mouse("drag",r)}function _(t){$e(t.view).on("mousemove.drag mouseup.drag",null),on(t.view,n),rn(t),l.mouse("end",t)}function g(t,e){if(i.call(this,t,e)){var n,r,o=t.changedTouches,a=s.call(this,t,e),l=o.length;for(n=0;n<l;++n)(r=b(this,a,t,e,o[n].identifier,o[n]))&&(nn(t),r("start",t,o[n]))}}function y(t){var e,n,r=t.changedTouches,i=r.length;for(e=0;e<i;++e)(n=l[r[e].identifier])&&(rn(t),n("drag",t,r[e]))}function m(t){var e,n,i=t.changedTouches,s=i.length;for(r&&clearTimeout(r),r=setTimeout(function(){r=null},500),e=0;e<s;++e)(n=l[i[e].identifier])&&(nn(t),n("end",t,i[e]))}function b(t,e,n,r,i,s){var a,h,d,p=c.copy(),_=Qe(s||n,e);if(null!=(d=o.call(t,new ln("beforestart",{sourceEvent:n,target:f,identifier:i,active:u,x:_[0],y:_[1],dx:0,dy:0,dispatch:p}),r)))return a=d.x-_[0]||0,h=d.y-_[1]||0,function n(s,o,c){var g,y=_;switch(s){case"start":l[i]=n,g=u++;break;case"end":delete l[i],--u;case"drag":_=Qe(c||o,e),g=u}p.call(s,t,new ln(s,{sourceEvent:o,subject:d,target:f,identifier:i,active:g,x:_[0]+a,y:_[1]+h,dx:_[0]-y[0],dy:_[1]-y[1],dispatch:p}),r)}}return f.filter=function(t){return arguments.length?(i="function"==typeof t?t:an(!!t),f):i},f.container=function(t){return arguments.length?(s="function"==typeof t?t:an(t),f):s},f.subject=function(t){return arguments.length?(o="function"==typeof t?t:an(t),f):o},f.touchable=function(t){return arguments.length?(a="function"==typeof t?t:an(!!t),f):a},f.on=function(){var t=c.on.apply(c,arguments);return t===c?f:t},f.clickDistance=function(t){return arguments.length?(h=(t=+t)*t,f):Math.sqrt(h)},f},dragDisable:sn,dragEnable:on,dsv:function(t,e,n,r){3===arguments.length&&"function"==typeof n&&(r=n,n=void 0);var i=Pa(t);return nl(e,n).then(function(t){return i.parse(t,r)})},dsvFormat:Pa,easeBack:Rs,easeBackIn:Cs,easeBackInOut:Rs,easeBackOut:ks,easeBounce:Ss,easeBounceIn:function(t){return 1-Ss(1-t)},easeBounceInOut:function(t){return((t*=2)<=1?1-Ss(1-t):Ss(t-1)+1)/2},easeBounceOut:Ss,easeCircle:ys,easeCircleIn:function(t){return 1-Math.sqrt(1-t*t)},easeCircleInOut:ys,easeCircleOut:function(t){return Math.sqrt(1- --t*t)},easeCubic:ls,easeCubicIn:function(t){return t*t*t},easeCubicInOut:ls,easeCubicOut:function(t){return--t*t*t+1},easeElastic:Ns,easeElasticIn:Os,easeElasticInOut:Is,easeElasticOut:Ns,easeExp:gs,easeExpIn:function(t){return _s(1-+t)},easeExpInOut:gs,easeExpOut:function(t){return 1-_s(t)},easeLinear:t=>+t,easePoly:hs,easePolyIn:cs,easePolyInOut:hs,easePolyOut:us,easeQuad:as,easeQuadIn:function(t){return t*t},easeQuadInOut:as,easeQuadOut:function(t){return t*(2-t)},easeSin:ps,easeSinIn:function(t){return 1===+t?1:1-Math.cos(t*ds)},easeSinInOut:ps,easeSinOut:function(t){return Math.sin(t*ds)},every:function(t,e){if("function"!=typeof e)throw new TypeError("test is not a function");let n=-1;for(const r of t)if(!e(r,++n,t))return!1;return!0},extent:x,fcumsum:function(t,e){const n=new w;let r=-1;return Float64Array.from(t,void 0===e?t=>n.add(+t||0):i=>n.add(+e(i,++r,t)||0))},filter:function(t,e){if("function"!=typeof e)throw new TypeError("test is not a function");const n=[];let r=-1;for(const i of t)e(i,++r,t)&&n.push(i);return n},flatGroup:function(t,...e){return N(O(t,...e),e)},flatRollup:function(t,e,...n){return N(P(t,e,...n),n)},forceCenter:hl,forceCollide:function(t){var e,n,r,i=1,s=1;function o(){for(var t,o,l,c,u,h,f,d=e.length,p=0;p<s;++p)for(o=gl(e,wl,El).visitAfter(a),t=0;t<d;++t)l=e[t],h=n[l.index],f=h*h,c=l.x+l.vx,u=l.y+l.vy,o.visit(_);function _(t,e,n,s,o){var a=t.data,d=t.r,p=h+d;if(!a)return e>c+p||s<c-p||n>u+p||o<u-p;if(a.index>l.index){var _=c-a.x-a.vx,g=u-a.y-a.vy,y=_*_+g*g;y<p*p&&(0===_&&(y+=(_=xl(r))*_),0===g&&(y+=(g=xl(r))*g),y=(p-(y=Math.sqrt(y)))/y*i,l.vx+=(_*=y)*(p=(d*=d)/(f+d)),l.vy+=(g*=y)*p,a.vx-=_*(p=1-p),a.vy-=g*p)}}}function a(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function l(){if(e){var r,i,s=e.length;for(n=new Array(s),r=0;r<s;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=vl(null==t?1:+t)),o.initialize=function(t,n){e=t,r=n,l()},o.iterations=function(t){return arguments.length?(s=+t,o):s},o.strength=function(t){return arguments.length?(i=+t,o):i},o.radius=function(e){return arguments.length?(t="function"==typeof e?e:vl(+e),l(),o):t},o},forceLink:Tl,forceManyBody:Nl,forceRadial:function(t,e,n){var r,i,s,o=vl(.1);function a(t){for(var o=0,a=r.length;o<a;++o){var l=r[o],c=l.x-e||1e-6,u=l.y-n||1e-6,h=Math.sqrt(c*c+u*u),f=(s[o]-h)*i[o]*t/h;l.vx+=c*f,l.vy+=u*f}}function l(){if(r){var e,n=r.length;for(i=new Array(n),s=new Array(n),e=0;e<n;++e)s[e]=+t(r[e],e,r),i[e]=isNaN(s[e])?0:+o(r[e],e,r)}}return"function"!=typeof t&&(t=vl(+t)),null==e&&(e=0),null==n&&(n=0),a.initialize=function(t){r=t,l()},a.strength=function(t){return arguments.length?(o="function"==typeof t?t:vl(+t),l(),a):o},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:vl(+e),l(),a):t},a.x=function(t){return arguments.length?(e=+t,a):e},a.y=function(t){return arguments.length?(n=+t,a):n},a},forceSimulation:Ol,forceX:Il,forceY:Pl,get format(){return Hl},formatDefaultLocale:Kl,formatLocale:Xl,get formatPrefix(){return Wl},formatSpecifier:zl,fsum:function(t,e){const n=new w;if(void 0===e)for(let e of t)(e=+e)&&n.add(e);else{let r=-1;for(let i of t)(i=+e(i,++r,t))&&n.add(i)}return+n},geoAlbers:id,geoAlbersUsa:function(){var t,e,n,r,i,s,o=id(),a=rd().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=rd().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(t,e){s=[t,e]}};function u(t){var e=t[0],o=t[1];return s=null,n.point(e,o),s||(r.point(e,o),s)||(i.point(e,o),s)}function h(){return t=e=null,u}return u.invert=function(t){var e=o.scale(),n=o.translate(),r=(t[0]-n[0])/e,i=(t[1]-n[1])/e;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?a:i>=.166&&i<.234&&r>=-.214&&r<-.115?l:o).invert(t)},u.stream=function(n){return t&&e===n?t:(r=[o.stream(e=n),a.stream(n),l.stream(n)],i=r.length,t={point:function(t,e){for(var n=-1;++n<i;)r[n].point(t,e)},sphere:function(){for(var t=-1;++t<i;)r[t].sphere()},lineStart:function(){for(var t=-1;++t<i;)r[t].lineStart()},lineEnd:function(){for(var t=-1;++t<i;)r[t].lineEnd()},polygonStart:function(){for(var t=-1;++t<i;)r[t].polygonStart()},polygonEnd:function(){for(var t=-1;++t<i;)r[t].polygonEnd()}});var r,i},u.precision=function(t){return arguments.length?(o.precision(t),a.precision(t),l.precision(t),h()):o.precision()},u.scale=function(t){return arguments.length?(o.scale(t),a.scale(.35*t),l.scale(t),u.translate(o.translate())):o.scale()},u.translate=function(t){if(!arguments.length)return o.translate();var e=o.scale(),s=+t[0],u=+t[1];return n=o.translate(t).clipExtent([[s-.455*e,u-.238*e],[s+.455*e,u+.238*e]]).stream(c),r=a.translate([s-.307*e,u+.201*e]).clipExtent([[s-.425*e+tc,u+.12*e+tc],[s-.214*e-tc,u+.234*e-tc]]).stream(c),i=l.translate([s-.205*e,u+.212*e]).clipExtent([[s-.214*e+tc,u+.166*e+tc],[s-.115*e-tc,u+.234*e-tc]]).stream(c),h()},u.fitExtent=function(t,e){return Hf(u,t,e)},u.fitSize=function(t,e){return Wf(u,t,e)},u.fitWidth=function(t,e){return qf(u,t,e)},u.fitHeight=function(t,e){return $f(u,t,e)},u.scale(1070)},geoArea:function(t){return $c=new w,Mc(t,Xc),2*$c},geoAzimuthalEqualArea:function(){return Qf(ad).scale(124.75).clipAngle(179.999)},geoAzimuthalEqualAreaRaw:ad,geoAzimuthalEquidistant:function(){return Qf(ld).scale(79.4188).clipAngle(179.999)},geoAzimuthalEquidistantRaw:ld,geoBounds:function(t){var e,n,r,i,s,o,a;if(zc=Bc=-(Dc=Vc=1/0),Hc=[],Mc(t,Eu),n=Hc.length){for(Hc.sort(Nu),e=1,s=[r=Hc[0]];e<n;++e)Iu(r,(i=Hc[e])[0])||Iu(r,i[1])?(Ou(r[0],i[1])>Ou(r[0],r[1])&&(r[1]=i[1]),Ou(i[0],r[1])>Ou(r[0],r[1])&&(r[0]=i[0])):s.push(r=i);for(o=-1/0,e=0,r=s[n=s.length-1];e<=n;r=i,++e)i=s[e],(a=Ou(r[1],i[0]))>o&&(o=a,Dc=i[0],Bc=r[1])}return Hc=Wc=null,Dc===1/0||Vc===1/0?[[NaN,NaN],[NaN,NaN]]:[[Dc,Vc],[Bc,zc]]},geoCentroid:function(t){au=lu=cu=uu=hu=fu=du=pu=0,_u=new w,gu=new w,yu=new w,Mc(t,Pu);var e=+_u,n=+gu,r=+yu,i=pc(e,n,r);return i<ec&&(e=fu,n=du,r=pu,lu<tc&&(e=cu,n=uu,r=hu),(i=pc(e,n,r))<ec)?[NaN,NaN]:[uc(n,e)*oc,wc(r/i)*oc]},geoCircle:function(){var t,e,n=Hu([0,0]),r=Hu(90),i=Hu(2),s={point:function(n,r){t.push(n=e(n,r)),n[0]*=oc,n[1]*=oc}};function o(){var o=n.apply(this,arguments),a=r.apply(this,arguments)*ac,l=i.apply(this,arguments)*ac;return t=[],e=$u(-o[0]*ac,-o[1]*ac,0).invert,Qu(s,a,l,1),o={type:"Polygon",coordinates:[t]},t=e=null,o}return o.center=function(t){return arguments.length?(n="function"==typeof t?t:Hu([+t[0],+t[1]]),o):n},o.radius=function(t){return arguments.length?(r="function"==typeof t?t:Hu(+t),o):r},o.precision=function(t){return arguments.length?(i="function"==typeof t?t:Hu(+t),o):i},o},geoClipAntimeridian:hh,geoClipCircle:fh,geoClipExtent:function(){var t,e,n,r=0,i=0,s=960,o=500;return n={stream:function(n){return t&&e===n?t:t=bh(r,i,s,o)(e=n)},extent:function(a){return arguments.length?(r=+a[0][0],i=+a[0][1],s=+a[1][0],o=+a[1][1],t=e=null,n):[[r,i],[s,o]]}}},geoClipRectangle:bh,geoConicConformal:function(){return ed(fd).scale(109.5).parallels([30,30])},geoConicConformalRaw:fd,geoConicEqualArea:rd,geoConicEqualAreaRaw:nd,geoConicEquidistant:function(){return ed(pd).scale(131.154).center([0,13.9389])},geoConicEquidistantRaw:pd,geoContains:function(t,e){return(t&&kh.hasOwnProperty(t.type)?kh[t.type]:Mh)(t,e)},geoDistance:Ch,geoEqualEarth:function(){return Qf(vd).scale(177.158)},geoEqualEarthRaw:vd,geoEquirectangular:function(){return Qf(dd).scale(152.63)},geoEquirectangularRaw:dd,geoGnomonic:function(){return Qf(xd).scale(144.049).clipAngle(60)},geoGnomonicRaw:xd,geoGraticule:Bh,geoGraticule10:function(){return Bh()()},geoIdentity:function(){var t,e,n,r,i,s,o,a=1,l=0,c=0,u=1,h=1,f=0,d=null,p=1,_=1,g=jf({point:function(t,e){var n=b([t,e]);this.stream.point(n[0],n[1])}}),y=Uh;function m(){return p=a*u,_=a*h,s=o=null,b}function b(n){var r=n[0]*p,i=n[1]*_;if(f){var s=i*t-r*e;r=r*t+i*e,i=s}return[r+l,i+c]}return b.invert=function(n){var r=n[0]-l,i=n[1]-c;if(f){var s=i*t+r*e;r=r*t-i*e,i=s}return[r/p,i/_]},b.stream=function(t){return s&&o===t?s:s=g(y(o=t))},b.postclip=function(t){return arguments.length?(y=t,d=n=r=i=null,m()):y},b.clipExtent=function(t){return arguments.length?(y=null==t?(d=n=r=i=null,Uh):bh(d=+t[0][0],n=+t[0][1],r=+t[1][0],i=+t[1][1]),m()):null==d?null:[[d,n],[r,i]]},b.scale=function(t){return arguments.length?(a=+t,m()):a},b.translate=function(t){return arguments.length?(l=+t[0],c=+t[1],m()):[l,c]},b.angle=function(n){return arguments.length?(e=yc(f=n%360*ac),t=hc(f),m()):f*oc},b.reflectX=function(t){return arguments.length?(u=t?-1:1,m()):u<0},b.reflectY=function(t){return arguments.length?(h=t?-1:1,m()):h<0},b.fitExtent=function(t,e){return Hf(b,t,e)},b.fitSize=function(t,e){return Wf(b,t,e)},b.fitWidth=function(t,e){return qf(b,t,e)},b.fitHeight=function(t,e){return $f(b,t,e)},b},geoInterpolate:function(t,e){var n=t[0]*ac,r=t[1]*ac,i=e[0]*ac,s=e[1]*ac,o=hc(r),a=yc(r),l=hc(s),c=yc(s),u=o*hc(n),h=o*yc(n),f=l*hc(i),d=l*yc(i),p=2*wc(bc(Ec(s-r)+o*l*Ec(i-n))),_=yc(p),g=p?function(t){var e=yc(t*=p)/_,n=yc(p-t)/_,r=n*u+e*f,i=n*h+e*d,s=n*a+e*c;return[uc(i,r)*oc,uc(s,bc(r*r+i*i))*oc]}:function(){return[n*oc,r*oc]};return g.distance=p,g},geoLength:Ah,geoMercator:function(){return ud(cd).scale(961/sc)},geoMercatorRaw:cd,geoNaturalEarth1:function(){return Qf(wd).scale(175.295)},geoNaturalEarth1Raw:wd,geoOrthographic:function(){return Qf(Ed).scale(249.5).clipAngle(90.000001)},geoOrthographicRaw:Ed,geoPath:function(t,e){let n,r,i=3,s=4.5;function o(t){return t&&("function"==typeof s&&r.pointRadius(+s.apply(this,arguments)),Mc(t,n(r))),r.result()}return o.area=function(t){return Mc(t,n(Wh)),Wh.result()},o.measure=function(t){return Mc(t,n(If)),If.result()},o.bounds=function(t){return Mc(t,n(ef)),ef.result()},o.centroid=function(t){return Mc(t,n(gf)),gf.result()},o.projection=function(e){return arguments.length?(n=null==e?(t=null,Uh):(t=e).stream,o):t},o.context=function(t){return arguments.length?(r=null==t?(e=null,new Gf(i)):new Tf(e=t),"function"!=typeof s&&r.pointRadius(s),o):e},o.pointRadius=function(t){return arguments.length?(s="function"==typeof t?t:(r.pointRadius(+t),+t),o):s},o.digits=function(t){if(!arguments.length)return i;if(null==t)i=null;else{const e=Math.floor(t);if(!(e>=0))throw new RangeError(`invalid digits: ${t}`);i=e}return null===e&&(r=new Gf(i)),o},o.projection(t).digits(i).context(e)},geoProjection:Qf,geoProjectionMutator:td,geoRotation:Ju,geoStereographic:function(){return Qf(Ad).scale(250).clipAngle(142)},geoStereographicRaw:Ad,geoStream:Mc,geoTransform:function(t){return{stream:jf(t)}},geoTransverseMercator:function(){var t=ud(Sd),e=t.center,n=t.rotate;return t.center=function(t){return arguments.length?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return arguments.length?n([t[0],t[1],t.length>2?t[2]+90:90]):[(t=n())[0],t[1],t[2]-90]},n([0,0,90]).scale(159.155)},geoTransverseMercatorRaw:Sd,gray:function(t,e){return new sr(t,0,0,null==e?1:e)},greatest:st,greatestIndex:function(e,n=t){if(1===n.length)return tt(e,n);let r,i=-1,s=-1;for(const t of e)++s,(i<0?0===n(t,t):n(t,r)>0)&&(r=t,i=s);return i},group:M,groupSort:function(e,n,r){return(2!==n.length?B(I(e,n,r),([e,n],[r,i])=>t(n,i)||t(e,r)):B(M(e,r),([e,r],[i,s])=>n(r,s)||t(e,i))).map(([t])=>t)},groups:O,hcl:hr,hierarchy:Od,histogram:J,hsl:Yn,html:cl,image:function(t,e){return new Promise(function(n,r){var i=new Image;for(var s in e)i[s]=e[s];i.onerror=r,i.onload=function(){n(i)},i.src=t})},index:function(t,...e){return D(t,R,L,e)},indexes:function(t,...e){return D(t,Array.from,L,e)},interpolate:Hr,interpolateArray:function(t,e){return(Vr(e)?Dr:Br)(t,e)},interpolateBasis:Sr,interpolateBasisClosed:Tr,interpolateBlues:zb,interpolateBrBG:Zm,interpolateBuGn:_b,interpolateBuPu:yb,interpolateCividis:function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-t*(35.34-t*(2381.73-t*(6402.7-t*(7024.72-2710.57*t)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+t*(170.73+t*(52.82-t*(131.46-t*(176.58-67.37*t)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+t*(442.36-t*(2482.43-t*(6167.24-t*(6614.94-2475.67*t)))))))+")"},interpolateCool:Jb,interpolateCubehelix:ci,interpolateCubehelixDefault:Kb,interpolateCubehelixLong:ui,interpolateDate:zr,interpolateDiscrete:function(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}},interpolateGnBu:bb,interpolateGreens:Fb,interpolateGreys:Ub,interpolateHcl:oi,interpolateHclLong:ai,interpolateHsl:ri,interpolateHslLong:ii,interpolateHue:function(t,e){var n=Rr(+t,+e);return function(t){var e=n(t);return e-360*Math.floor(e/360)}},interpolateInferno:av,interpolateLab:function(t,e){var n=Or((t=ir(t)).l,(e=ir(e)).l),r=Or(t.a,e.a),i=Or(t.b,e.b),s=Or(t.opacity,e.opacity);return function(e){return t.l=n(e),t.a=r(e),t.b=i(e),t.opacity=s(e),t+""}},interpolateMagma:ov,interpolateNumber:Gr,interpolateNumberArray:Dr,interpolateObject:Fr,interpolateOrRd:xb,interpolateOranges:Xb,interpolatePRGn:Qm,interpolatePiYG:eb,interpolatePlasma:lv,interpolatePuBu:Sb,interpolatePuBuGn:Eb,interpolatePuOr:rb,interpolatePuRd:Cb,interpolatePurples:Hb,interpolateRainbow:function(t){(t<0||t>1)&&(t-=Math.floor(t));var e=Math.abs(t-.5);return Qb.h=360*t-100,Qb.s=1.5-1.5*e,Qb.l=.8-.9*e,Qb+""},interpolateRdBu:sb,interpolateRdGy:ab,interpolateRdPu:Rb,interpolateRdYlBu:cb,interpolateRdYlGn:hb,interpolateReds:qb,interpolateRgb:Nr,interpolateRgbBasis:Pr,interpolateRgbBasisClosed:Lr,interpolateRound:Wr,interpolateSinebow:function(t){var e;return t=(.5-t)*Math.PI,tv.r=255*(e=Math.sin(t))*e,tv.g=255*(e=Math.sin(t+ev))*e,tv.b=255*(e=Math.sin(t+nv))*e,tv+""},interpolateSpectral:db,interpolateString:Yr,interpolateTransformCss:Jr,interpolateTransformSvg:Qr,interpolateTurbo:rv,interpolateViridis:sv,interpolateWarm:Zb,interpolateYlGn:Ib,interpolateYlGnBu:Ob,interpolateYlOrBr:Lb,interpolateYlOrRd:Vb,interpolateZoom:ei,interrupt:Vi,intersection:function(t,...e){t=new A(t),e=e.map(vt);t:for(const n of t)for(const r of e)if(!r.has(n)){t.delete(n);continue t}return t},interval:function(t,e,n){var r=new Ai,i=e;return null==e?(r.restart(t,e,n),r):(r._restart=r.restart,r.restart=function(t,e,n){e=+e,n=null==n?wi():+n,r._restart(function s(o){o+=i,r._restart(s,i+=e,n),t(o)},e,n)},r.restart(t,e,n),r)},isoFormat:Sm,isoParse:Tm,json:function(t,e){return fetch(t,e).then(ol)},lab:ir,lch:function(t,e,n,r){return 1===arguments.length?ur(t):new fr(n,e,t,null==r?1:r)},least:function(e,n=t){let r,i=!1;if(1===n.length){let s;for(const o of e){const e=n(o);(i?t(e,s)<0:0===t(e,e))&&(r=o,s=e,i=!0)}}else for(const t of e)(i?n(t,r)<0:0===n(t,t))&&(r=t,i=!0);return r},leastIndex:pt,line:Lv,lineRadial:Uv,link:Qv,linkHorizontal:tx,linkRadial:nx,linkVertical:ex,local:Ke,map:function(t,e){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof e)throw new TypeError("mapper is not a function");return Array.from(t,(n,r)=>e(n,r,t))},matcher:qt,max:Q,maxIndex:tt,mean:ct,median:ut,medianIndex:function(t,e){return lt(t,.5,e)},merge:ht,min:et,minIndex:nt,mode:function(t,e){const n=new E;if(void 0===e)for(let e of t)null!=e&&e>=e&&n.set(e,(n.get(e)||0)+1);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&i>=i&&n.set(i,(n.get(i)||0)+1)}let r,i=0;for(const[t,e]of n)e>i&&(i=e,r=t);return r},namespace:Bt,namespaces:Vt,nice:K,now:wi,pack:rp,packEnclose:function(t){return Ud(t,jd())},packSiblings:function(t){return ep(t,jd()),t},pairs:function(t,e=ft){const n=[];let r,i=!1;for(const s of t)i&&n.push(e(r,s)),r=s,i=!0;return n},partition:function(){var t=1,e=1,n=0,r=!1;function i(i){var s=i.height+1;return i.x0=i.y0=n,i.x1=t,i.y1=e/s,i.eachBefore(function(t,e){return function(r){r.children&&lp(r,r.x0,t*(r.depth+1)/e,r.x1,t*(r.depth+2)/e);var i=r.x0,s=r.y0,o=r.x1-n,a=r.y1-n;o<i&&(i=o=(i+o)/2),a<s&&(s=a=(s+a)/2),r.x0=i,r.y0=s,r.x1=o,r.y1=a}}(e,s)),r&&i.eachBefore(ap),i}return i.round=function(t){return arguments.length?(r=!!t,i):r},i.size=function(n){return arguments.length?(t=+n[0],e=+n[1],i):[t,e]},i.padding=function(t){return arguments.length?(n=+t,i):n},i},path:To,pathRound:function(t=3){return new So(+t)},permute:V,pie:function(){var t=Bv,e=Vv,n=null,r=cv(0),i=cv(vv),s=cv(0);function o(o){var a,l,c,u,h,f=(o=Mv(o)).length,d=0,p=new Array(f),_=new Array(f),g=+r.apply(this,arguments),y=Math.min(vv,Math.max(-vv,i.apply(this,arguments)-g)),m=Math.min(Math.abs(y)/f,s.apply(this,arguments)),b=m*(y<0?-1:1);for(a=0;a<f;++a)(h=_[p[a]=a]=+t(o[a],a,o))>0&&(d+=h);for(null!=e?p.sort(function(t,n){return e(_[t],_[n])}):null!=n&&p.sort(function(t,e){return n(o[t],o[e])}),a=0,c=d?(y-f*b)/d:0;a<f;++a,g=u)l=p[a],u=g+((h=_[l])>0?h*c:0)+b,_[l]={data:o[l],index:a,value:h,startAngle:g,endAngle:u,padAngle:m};return _}return o.value=function(e){return arguments.length?(t="function"==typeof e?e:cv(+e),o):t},o.sortValues=function(t){return arguments.length?(e=t,n=null,o):e},o.sort=function(t){return arguments.length?(n=t,e=null,o):n},o.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:cv(+t),o):r},o.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:cv(+t),o):i},o.padAngle=function(t){return arguments.length?(s="function"==typeof t?t:cv(+t),o):s},o},piecewise:hi,pointRadial:Hv,pointer:Qe,pointers:function(t,e){return t.target&&(t=Je(t),void 0===e&&(e=t.currentTarget),t=t.touches||[t]),Array.from(t,t=>Qe(t,e))},polygonArea:function(t){for(var e,n=-1,r=t.length,i=t[r-1],s=0;++n<r;)e=i,i=t[n],s+=e[1]*i[0]-e[0]*i[1];return s/2},polygonCentroid:function(t){for(var e,n,r=-1,i=t.length,s=0,o=0,a=t[i-1],l=0;++r<i;)e=a,a=t[r],l+=n=e[0]*a[1]-a[0]*e[1],s+=(e[0]+a[0])*n,o+=(e[1]+a[1])*n;return[s/(l*=3),o/l]},polygonContains:function(t,e){for(var n,r,i=t.length,s=t[i-1],o=e[0],a=e[1],l=s[0],c=s[1],u=!1,h=0;h<i;++h)n=(s=t[h])[0],(r=s[1])>a!=c>a&&o<(l-n)*(a-r)/(c-r)+n&&(u=!u),l=n,c=r;return u},polygonHull:function(t){if((n=t.length)<3)return null;var e,n,r=new Array(n),i=new Array(n);for(e=0;e<n;++e)r[e]=[+t[e][0],+t[e][1],e];for(r.sort(Mp),e=0;e<n;++e)i[e]=[r[e][0],-r[e][1]];var s=Op(r),o=Op(i),a=o[0]===s[0],l=o[o.length-1]===s[s.length-1],c=[];for(e=s.length-1;e>=0;--e)c.push(t[r[s[e]][2]]);for(e=+a;e<o.length-l;++e)c.push(t[r[o[e]][2]]);return c},polygonLength:function(t){for(var e,n,r=-1,i=t.length,s=t[i-1],o=s[0],a=s[1],l=0;++r<i;)e=o,n=a,e-=o=(s=t[r])[0],n-=a=s[1],l+=Math.hypot(e,n);return l},precisionFixed:Zl,precisionPrefix:Jl,precisionRound:Ql,quadtree:gl,quantile:ot,quantileIndex:lt,quantileSorted:at,quantize:function(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t(r/(e-1));return n},quickselect:rt,radialArea:Yv,radialLine:Uv,randomBates:Bp,randomBernoulli:Fp,randomBeta:Yp,randomBinomial:Hp,randomCauchy:qp,randomExponential:zp,randomGamma:Up,randomGeometric:jp,randomInt:Pp,randomIrwinHall:Vp,randomLcg:function(t=Math.random()){let e=0|(0<=t&&t<1?t/Kp:Math.abs(t));return()=>(e=1664525*e+1013904223|0,Kp*(e>>>0))},randomLogNormal:Dp,randomLogistic:$p,randomNormal:Lp,randomPareto:Gp,randomPoisson:Xp,randomUniform:Ip,randomWeibull:Wp,range:dt,rank:function(e,n=t){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");let r=Array.from(e);const i=new Float64Array(r.length);2!==n.length&&(r=r.map(n),n=t);const s=(t,e)=>n(r[t],r[e]);let o,a;return(e=Uint32Array.from(r,(t,e)=>e)).sort(n===t?(t,e)=>G(r[t],r[e]):z(s)),e.forEach((t,e)=>{const n=s(t,void 0===o?t:o);n>=0?((void 0===o||n>0)&&(o=t,a=e),i[t]=a):i[t]=NaN}),i},reduce:function(t,e,n){if("function"!=typeof e)throw new TypeError("reducer is not a function");const r=t[Symbol.iterator]();let i,s,o=-1;if(arguments.length<3){if(({done:i,value:n}=r.next()),i)return;++o}for(;({done:i,value:s}=r.next()),!i;)n=e(n,s,++o,t);return n},reverse:function(t){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(t).reverse()},rgb:Ln,ribbon:function(){return Do()},ribbonArrow:function(){return Do(Lo)},rollup:I,rollups:P,scaleBand:e_,scaleDiverging:function t(){var e=p_(Lm()(o_));return e.copy=function(){return Nm(e,t())},Jp.apply(e,arguments)},scaleDivergingLog:function t(){var e=E_(Lm()).domain([.1,1,10]);return e.copy=function(){return Nm(e,t()).base(e.base())},Jp.apply(e,arguments)},scaleDivergingPow:Dm,scaleDivergingSqrt:function(){return Dm.apply(null,arguments).exponent(.5)},scaleDivergingSymlog:function t(){var e=C_(Lm());return e.copy=function(){return Nm(e,t()).constant(e.constant())},Jp.apply(e,arguments)},scaleIdentity:function t(e){var n;function r(t){return null==t||isNaN(t=+t)?n:t}return r.invert=r,r.domain=r.range=function(t){return arguments.length?(e=Array.from(t,i_),r):e.slice()},r.unknown=function(t){return arguments.length?(n=t,r):n},r.copy=function(){return t(e).unknown(n)},e=arguments.length?Array.from(e,i_):[0,1],p_(r)},scaleImplicit:Qp,scaleLinear:__,scaleLog:A_,scaleOrdinal:t_,scalePoint:r_,scalePow:N_,scaleQuantile:function e(){var n,r=[],i=[],s=[];function a(){var t=0,e=Math.max(1,i.length);for(s=new Array(e-1);++t<e;)s[t-1]=at(r,t/e);return l}function l(t){return null==t||isNaN(t=+t)?n:i[o(s,t)]}return l.invertExtent=function(t){var e=i.indexOf(t);return e<0?[NaN,NaN]:[e>0?s[e-1]:r[0],e<s.length?s[e]:r[r.length-1]]},l.domain=function(e){if(!arguments.length)return r.slice();r=[];for(let t of e)null==t||isNaN(t=+t)||r.push(t);return r.sort(t),a()},l.range=function(t){return arguments.length?(i=Array.from(t),a()):i.slice()},l.unknown=function(t){return arguments.length?(n=t,l):n},l.quantiles=function(){return s.slice()},l.copy=function(){return e().domain(r).range(i).unknown(n)},Zp.apply(l,arguments)},scaleQuantize:function t(){var e,n=0,r=1,i=1,s=[.5],a=[0,1];function l(t){return null!=t&&t<=t?a[o(s,t,0,i)]:e}function c(){var t=-1;for(s=new Array(i);++t<i;)s[t]=((t+1)*r-(t-i)*n)/(i+1);return l}return l.domain=function(t){return arguments.length?([n,r]=t,n=+n,r=+r,c()):[n,r]},l.range=function(t){return arguments.length?(i=(a=Array.from(t)).length-1,c()):a.slice()},l.invertExtent=function(t){var e=a.indexOf(t);return e<0?[NaN,NaN]:e<1?[n,s[0]]:e>=i?[s[i-1],r]:[s[e-1],s[e]]},l.unknown=function(t){return arguments.length?(e=t,l):l},l.thresholds=function(){return s.slice()},l.copy=function(){return t().domain([n,r]).range(a).unknown(e)},Zp.apply(p_(l),arguments)},scaleRadial:function t(){var e,n=f_(),r=[0,1],i=!1;function s(t){var r=function(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}(n(t));return isNaN(r)?e:i?Math.round(r):r}return s.invert=function(t){return n.invert(I_(t))},s.domain=function(t){return arguments.length?(n.domain(t),s):n.domain()},s.range=function(t){return arguments.length?(n.range((r=Array.from(t,i_)).map(I_)),s):r.slice()},s.rangeRound=function(t){return s.range(t).round(!0)},s.round=function(t){return arguments.length?(i=!!t,s):i},s.clamp=function(t){return arguments.length?(n.clamp(t),s):n.clamp()},s.unknown=function(t){return arguments.length?(e=t,s):e},s.copy=function(){return t(n.domain(),r).round(i).clamp(n.clamp()).unknown(e)},Zp.apply(s,arguments),p_(s)},scaleSequential:Im,scaleSequentialLog:function t(){var e=E_(Om()).domain([1,10]);return e.copy=function(){return Nm(e,t()).base(e.base())},Jp.apply(e,arguments)},scaleSequentialPow:Pm,scaleSequentialQuantile:function e(){var n=[],r=o_;function i(t){if(null!=t&&!isNaN(t=+t))return r((o(n,t,1)-1)/(n.length-1))}return i.domain=function(e){if(!arguments.length)return n.slice();n=[];for(let t of e)null==t||isNaN(t=+t)||n.push(t);return n.sort(t),i},i.interpolator=function(t){return arguments.length?(r=t,i):r},i.range=function(){return n.map((t,e)=>r(e/(n.length-1)))},i.quantiles=function(t){return Array.from({length:t+1},(e,r)=>ot(n,r/t))},i.copy=function(){return e(r).domain(n)},Jp.apply(i,arguments)},scaleSequentialSqrt:function(){return Pm.apply(null,arguments).exponent(.5)},scaleSequentialSymlog:function t(){var e=C_(Om());return e.copy=function(){return Nm(e,t()).constant(e.constant())},Jp.apply(e,arguments)},scaleSqrt:function(){return N_.apply(null,arguments).exponent(.5)},scaleSymlog:function t(){var e=C_(h_());return e.copy=function(){return u_(e,t()).constant(e.constant())},Zp.apply(e,arguments)},scaleThreshold:function t(){var e,n=[.5],r=[0,1],i=1;function s(t){return null!=t&&t<=t?r[o(n,t,0,i)]:e}return s.domain=function(t){return arguments.length?(n=Array.from(t),i=Math.min(n.length,r.length-1),s):n.slice()},s.range=function(t){return arguments.length?(r=Array.from(t),i=Math.min(n.length,r.length-1),s):r.slice()},s.invertExtent=function(t){var e=r.indexOf(t);return[n[e-1],n[e]]},s.unknown=function(t){return arguments.length?(e=t,s):e},s.copy=function(){return t().domain(n).range(r).unknown(e)},Zp.apply(s,arguments)},scaleTime:Mm,scaleUtc:function(){return Zp.apply(Rm(qg,$g,Yg,Gg,Ag,ig,tg,K_,W_,iy).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},scan:function(t,e){const n=pt(t,e);return n<0?void 0:n},schemeAccent:zm,schemeBlues:Bb,schemeBrBG:Km,schemeBuGn:pb,schemeBuPu:gb,schemeCategory10:Bm,schemeDark2:Gm,schemeGnBu:mb,schemeGreens:Gb,schemeGreys:jb,schemeObservable10:Fm,schemeOrRd:vb,schemeOranges:$b,schemePRGn:Jm,schemePaired:jm,schemePastel1:Um,schemePastel2:Ym,schemePiYG:tb,schemePuBu:Ab,schemePuBuGn:wb,schemePuOr:nb,schemePuRd:Tb,schemePurples:Yb,schemeRdBu:ib,schemeRdGy:ob,schemeRdPu:kb,schemeRdYlBu:lb,schemeRdYlGn:ub,schemeReds:Wb,schemeSet1:Hm,schemeSet2:Wm,schemeSet3:qm,schemeSpectral:fb,schemeTableau10:$m,schemeYlGn:Nb,schemeYlGnBu:Mb,schemeYlOrBr:Pb,schemeYlOrRd:Db,select:$e,selectAll:function(t){return"string"==typeof t?new We([document.querySelectorAll(t)],[document.documentElement]):new We([Yt(t)],He)},selection:qe,selector:Ut,selectorAll:Wt,shuffle:_t,shuffler:gt,some:function(t,e){if("function"!=typeof e)throw new TypeError("test is not a function");let n=-1;for(const r of t)if(e(r,++n,t))return!0;return!1},sort:B,stack:function(){var t=cv([]),e=fw,n=hw,r=dw;function i(i){var s,o,a=Array.from(t.apply(this,arguments),pw),l=a.length,c=-1;for(const t of i)for(s=0,++c;s<l;++s)(a[s][c]=[0,+r(t,a[s].key,c,i)]).data=t;for(s=0,o=Mv(e(a));s<l;++s)a[o[s]].index=s;return n(a,o),a}return i.keys=function(e){return arguments.length?(t="function"==typeof e?e:cv(Array.from(e)),i):t},i.value=function(t){return arguments.length?(r="function"==typeof t?t:cv(+t),i):r},i.order=function(t){return arguments.length?(e=null==t?fw:"function"==typeof t?t:cv(Array.from(t)),i):e},i.offset=function(t){return arguments.length?(n=null==t?hw:t,i):n},i},stackOffsetDiverging:function(t,e){if((a=t.length)>0)for(var n,r,i,s,o,a,l=0,c=t[e[0]].length;l<c;++l)for(s=o=0,n=0;n<a;++n)(i=(r=t[e[n]][l])[1]-r[0])>0?(r[0]=s,r[1]=s+=i):i<0?(r[1]=o,r[0]=o+=i):(r[0]=0,r[1]=i)},stackOffsetExpand:function(t,e){if((r=t.length)>0){for(var n,r,i,s=0,o=t[0].length;s<o;++s){for(i=n=0;n<r;++n)i+=t[n][s][1]||0;if(i)for(n=0;n<r;++n)t[n][s][1]/=i}hw(t,e)}},stackOffsetNone:hw,stackOffsetSilhouette:function(t,e){if((n=t.length)>0){for(var n,r=0,i=t[e[0]],s=i.length;r<s;++r){for(var o=0,a=0;o<n;++o)a+=t[o][r][1]||0;i[r][1]+=i[r][0]=-a/2}hw(t,e)}},stackOffsetWiggle:function(t,e){if((i=t.length)>0&&(r=(n=t[e[0]]).length)>0){for(var n,r,i,s=0,o=1;o<r;++o){for(var a=0,l=0,c=0;a<i;++a){for(var u=t[e[a]],h=u[o][1]||0,f=(h-(u[o-1][1]||0))/2,d=0;d<a;++d){var p=t[e[d]];f+=(p[o][1]||0)-(p[o-1][1]||0)}l+=h,c+=f*h}n[o-1][1]+=n[o-1][0]=s,l&&(s-=c/l)}n[o-1][1]+=n[o-1][0]=s,hw(t,e)}},stackOrderAppearance:_w,stackOrderAscending:yw,stackOrderDescending:function(t){return yw(t).reverse()},stackOrderInsideOut:function(t){var e,n,r=t.length,i=t.map(mw),s=_w(t),o=0,a=0,l=[],c=[];for(e=0;e<r;++e)n=s[e],o<a?(o+=i[n],l.push(n)):(a+=i[n],c.push(n));return c.reverse().concat(l)},stackOrderNone:fw,stackOrderReverse:function(t){return fw(t).reverse()},stratify:function(){var t,e=fp,n=dp;function r(r){var i,s,o,a,l,c,u,h,f=Array.from(r),d=e,p=n,_=new Map;if(null!=t){const e=f.map((e,n)=>function(t){t=`${t}`;let e=t.length;_p(t,e-1)&&!_p(t,e-2)&&(t=t.slice(0,-1));return"/"===t[0]?t:`/${t}`}(t(e,n,r))),n=e.map(pp),i=new Set(e).add("");for(const t of n)i.has(t)||(i.add(t),e.push(t),n.push(pp(t)),f.push(hp));d=(t,n)=>e[n],p=(t,e)=>n[e]}for(o=0,i=f.length;o<i;++o)s=f[o],c=f[o]=new Dd(s),null!=(u=d(s,o,r))&&(u+="")&&(h=c.id=u,_.set(h,_.has(h)?up:c)),null!=(u=p(s,o,r))&&(u+="")&&(c.parent=u);for(o=0;o<i;++o)if(u=(c=f[o]).parent){if(!(l=_.get(u)))throw new Error("missing: "+u);if(l===up)throw new Error("ambiguous: "+u);l.children?l.children.push(c):l.children=[c],c.parent=l}else{if(a)throw new Error("multiple roots");a=c}if(!a)throw new Error("no root");if(null!=t){for(;a.data===hp&&1===a.children.length;)a=a.children[0],--i;for(let t=f.length-1;t>=0&&(c=f[t]).data===hp;--t)c.data=null}if(a.parent=cp,a.eachBefore(function(t){t.depth=t.parent.depth+1,--i}).eachBefore(Ld),a.parent=null,i>0)throw new Error("cycle");return a}return r.id=function(t){return arguments.length?(e=Vd(t),r):e},r.parentId=function(t){return arguments.length?(n=Vd(t),r):n},r.path=function(e){return arguments.length?(t=Vd(e),r):t},r},style:ge,subset:function(t,e){return xt(e,t)},sum:yt,superset:xt,svg:ul,symbol:function(t,e){let n=null,r=wv(i);function i(){let i;if(n||(n=i=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),i)return n=null,i+""||null}return t="function"==typeof t?t:cv(t||sx),e="function"==typeof e?e:cv(void 0===e?64:+e),i.type=function(e){return arguments.length?(t="function"==typeof e?e:cv(e),i):t},i.size=function(t){return arguments.length?(e="function"==typeof t?t:cv(+t),i):e},i.context=function(t){return arguments.length?(n=null==t?null:t,i):n},i},symbolAsterisk:ix,symbolCircle:sx,symbolCross:ox,symbolDiamond:cx,symbolDiamond2:ux,symbolPlus:hx,symbolSquare:fx,symbolSquare2:dx,symbolStar:yx,symbolTimes:Cx,symbolTriangle:bx,symbolTriangle2:xx,symbolWye:Tx,symbolX:Cx,symbols:kx,symbolsFill:kx,symbolsStroke:Rx,text:nl,thresholdFreedmanDiaconis:function(t,e,n){const r=_(t),i=ot(t,.75)-ot(t,.25);return r&&i?Math.ceil((n-e)/(2*i*Math.pow(r,-1/3))):1},thresholdScott:function(t,e,n){const r=_(t),i=v(t);return r&&i?Math.ceil((n-e)*Math.cbrt(r)/(3.49*i)):1},thresholdSturges:Z,tickFormat:d_,tickIncrement:$,tickStep:X,ticks:q,timeDay:ng,timeDays:rg,get timeFormat(){return ny},timeFormatDefaultLocale:Em,timeFormatLocale:ty,timeFriday:pg,timeFridays:xg,timeHour:J_,timeHours:Q_,timeInterval:D_,timeMillisecond:V_,timeMilliseconds:B_,timeMinute:$_,timeMinutes:X_,timeMonday:ug,timeMondays:yg,timeMonth:Bg,timeMonths:zg,get timeParse(){return ry},timeSaturday:_g,timeSaturdays:wg,timeSecond:W_,timeSeconds:q_,timeSunday:cg,timeSundays:gg,timeThursday:dg,timeThursdays:vg,timeTickInterval:Kg,timeTicks:Xg,timeTuesday:hg,timeTuesdays:mg,timeWednesday:fg,timeWednesdays:bg,timeWeek:cg,timeWeeks:gg,timeYear:jg,timeYears:Ug,timeout:Mi,timer:Si,timerFlush:Ti,transition:is,transpose:mt,tree:wp,treemap:Cp,treemapBinary:function(t,e,n,r,i){var s,o,a=t.children,l=a.length,c=new Array(l+1);for(c[0]=o=s=0;s<l;++s)c[s+1]=o+=a[s].value;!function t(e,n,r,i,s,o,l){if(e>=n-1){var u=a[e];return u.x0=i,u.y0=s,u.x1=o,void(u.y1=l)}var h=c[e],f=r/2+h,d=e+1,p=n-1;for(;d<p;){var _=d+p>>>1;c[_]<f?d=_+1:p=_}f-c[d-1]<c[d]-f&&e+1<d&&--d;var g=c[d]-h,y=r-g;if(o-i>l-s){var m=r?(i*y+o*g)/r:o;t(e,d,g,i,s,m,l),t(d,n,y,m,s,o,l)}else{var b=r?(s*y+l*g)/r:l;t(e,d,g,i,s,o,b),t(d,n,y,i,b,o,l)}}(0,l,t.value,e,n,r,i)},treemapDice:lp,treemapResquarify:kp,treemapSlice:Ep,treemapSliceDice:function(t,e,n,r,i){(1&t.depth?Ep:lp)(t,e,n,r,i)},treemapSquarify:Tp,tsv:sl,tsvFormat:Wa,tsvFormatBody:qa,tsvFormatRow:Xa,tsvFormatRows:$a,tsvFormatValue:Ka,tsvParse:Ya,tsvParseRows:Ha,union:function(...t){const e=new A;for(const n of t)for(const t of n)e.add(t);return e},unixDay:og,unixDays:ag,utcDay:ig,utcDays:sg,get utcFormat(){return iy},utcFriday:Rg,utcFridays:Dg,utcHour:tg,utcHours:eg,utcMillisecond:V_,utcMilliseconds:B_,utcMinute:K_,utcMinutes:Z_,utcMonday:Sg,utcMondays:Ng,utcMonth:Gg,utcMonths:Fg,get utcParse(){return sy},utcSaturday:Mg,utcSaturdays:Vg,utcSecond:W_,utcSeconds:q_,utcSunday:Ag,utcSundays:Og,utcThursday:kg,utcThursdays:Lg,utcTickInterval:$g,utcTicks:qg,utcTuesday:Tg,utcTuesdays:Ig,utcWednesday:Cg,utcWednesdays:Pg,utcWeek:Ag,utcWeeks:Og,utcYear:Yg,utcYears:Hg,variance:b,window:fe,xml:ll,zip:function(){return mt(arguments)},zoom:function(){var t,e,n,r=Tw,i=Cw,s=Ow,o=Rw,a=Mw,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,h=ei,f=Nt("start","zoom","end"),d=0,p=10;function _(t){t.property("__zoom",kw).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",E).on("dblclick.zoom",A).filter(a).on("touchstart.zoom",S).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",C).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(t,e){return(e=Math.max(l[0],Math.min(l[1],e)))===t.k?t:new xw(e,t.x,t.y)}function y(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new xw(t.k,r,i)}function m(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function b(t,e,n,r){t.on("start.zoom",function(){v(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){v(this,arguments).event(r).end()}).tween("zoom",function(){var t=this,s=arguments,o=v(t,s).event(r),a=i.apply(t,s),l=null==n?m(a):"function"==typeof n?n.apply(t,s):n,c=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),u=t.__zoom,f="function"==typeof e?e.apply(t,s):e,d=h(u.invert(l).concat(c/u.k),f.invert(l).concat(c/f.k));return function(t){if(1===t)t=f;else{var e=d(t),n=c/e[2];t=new xw(n,l[0]-e[0]*n,l[1]-e[1]*n)}o.zoom(null,t)}})}function v(t,e,n){return!n&&t.__zooming||new x(t,e)}function x(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function w(t,...e){if(r.apply(this,arguments)){var n=v(this,e).event(t),i=this.__zoom,a=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,o.apply(this,arguments)))),u=Qe(t);if(n.wheel)n.mouse[0][0]===u[0]&&n.mouse[0][1]===u[1]||(n.mouse[1]=i.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else{if(i.k===a)return;n.mouse=[u,i.invert(u)],Vi(this),n.start()}Sw(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",s(y(g(i,a),n.mouse[0],n.mouse[1]),n.extent,c))}}function E(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,o=v(this,e,!0).event(t),a=$e(t.view).on("mousemove.zoom",function(t){if(Sw(t),!o.moved){var e=t.clientX-u,n=t.clientY-h;o.moved=e*e+n*n>d}o.event(t).zoom("mouse",s(y(o.that.__zoom,o.mouse[0]=Qe(t,i),o.mouse[1]),o.extent,c))},!0).on("mouseup.zoom",function(t){a.on("mousemove.zoom mouseup.zoom",null),on(t.view,o.moved),Sw(t),o.event(t).end()},!0),l=Qe(t,i),u=t.clientX,h=t.clientY;sn(t.view),Aw(t),o.mouse=[l,this.__zoom.invert(l)],Vi(this),o.start()}}function A(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,o=Qe(t.changedTouches?t.changedTouches[0]:t,this),a=n.invert(o),l=n.k*(t.shiftKey?.5:2),h=s(y(g(n,l),o,a),i.apply(this,e),c);Sw(t),u>0?$e(this).transition().duration(u).call(b,h,o,t):$e(this).call(_.transform,h,o,t)}}function S(n,...i){if(r.apply(this,arguments)){var s,o,a,l,c=n.touches,u=c.length,h=v(this,i,n.changedTouches.length===u).event(n);for(Aw(n),o=0;o<u;++o)l=[l=Qe(a=c[o],this),this.__zoom.invert(l),a.identifier],h.touch0?h.touch1||h.touch0[2]===l[2]||(h.touch1=l,h.taps=0):(h.touch0=l,s=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),s&&(h.taps<2&&(e=l[0],t=setTimeout(function(){t=null},500)),Vi(this),h.start())}}function T(t,...e){if(this.__zooming){var n,r,i,o,a=v(this,e).event(t),l=t.changedTouches,u=l.length;for(Sw(t),n=0;n<u;++n)i=Qe(r=l[n],this),a.touch0&&a.touch0[2]===r.identifier?a.touch0[0]=i:a.touch1&&a.touch1[2]===r.identifier&&(a.touch1[0]=i);if(r=a.that.__zoom,a.touch1){var h=a.touch0[0],f=a.touch0[1],d=a.touch1[0],p=a.touch1[1],_=(_=d[0]-h[0])*_+(_=d[1]-h[1])*_,m=(m=p[0]-f[0])*m+(m=p[1]-f[1])*m;r=g(r,Math.sqrt(_/m)),i=[(h[0]+d[0])/2,(h[1]+d[1])/2],o=[(f[0]+p[0])/2,(f[1]+p[1])/2]}else{if(!a.touch0)return;i=a.touch0[0],o=a.touch0[1]}a.zoom("touch",s(y(r,i,o),a.extent,c))}}function C(t,...r){if(this.__zooming){var i,s,o=v(this,r).event(t),a=t.changedTouches,l=a.length;for(Aw(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<l;++i)s=a[i],o.touch0&&o.touch0[2]===s.identifier?delete o.touch0:o.touch1&&o.touch1[2]===s.identifier&&delete o.touch1;if(o.touch1&&!o.touch0&&(o.touch0=o.touch1,delete o.touch1),o.touch0)o.touch0[1]=this.__zoom.invert(o.touch0[0]);else if(o.end(),2===o.taps&&(s=Qe(s,this),Math.hypot(e[0]-s[0],e[1]-s[1])<p)){var c=$e(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return _.transform=function(t,e,n,r){var i=t.selection?t.selection():t;i.property("__zoom",kw),t!==i?b(t,e,n,r):i.interrupt().each(function(){v(this,arguments).event(r).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},_.scaleBy=function(t,e,n,r){_.scaleTo(t,function(){return this.__zoom.k*("function"==typeof e?e.apply(this,arguments):e)},n,r)},_.scaleTo=function(t,e,n,r){_.transform(t,function(){var t=i.apply(this,arguments),r=this.__zoom,o=null==n?m(t):"function"==typeof n?n.apply(this,arguments):n,a=r.invert(o),l="function"==typeof e?e.apply(this,arguments):e;return s(y(g(r,l),o,a),t,c)},n,r)},_.translateBy=function(t,e,n,r){_.transform(t,function(){return s(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),c)},null,r)},_.translateTo=function(t,e,n,r,o){_.transform(t,function(){var t=i.apply(this,arguments),o=this.__zoom,a=null==r?m(t):"function"==typeof r?r.apply(this,arguments):r;return s(ww.translate(a[0],a[1]).scale(o.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,c)},r,o)},x.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1===++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0===--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var e=$e(this.that).datum();f.call(t,this.that,new vw(t,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:f}),e)}},_.wheelDelta=function(t){return arguments.length?(o="function"==typeof t?t:bw(+t),_):o},_.filter=function(t){return arguments.length?(r="function"==typeof t?t:bw(!!t),_):r},_.touchable=function(t){return arguments.length?(a="function"==typeof t?t:bw(!!t),_):a},_.extent=function(t){return arguments.length?(i="function"==typeof t?t:bw([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),_):i},_.scaleExtent=function(t){return arguments.length?(l[0]=+t[0],l[1]=+t[1],_):[l[0],l[1]]},_.translateExtent=function(t){return arguments.length?(c[0][0]=+t[0][0],c[1][0]=+t[1][0],c[0][1]=+t[0][1],c[1][1]=+t[1][1],_):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},_.constrain=function(t){return arguments.length?(s=t,_):s},_.duration=function(t){return arguments.length?(u=+t,_):u},_.interpolate=function(t){return arguments.length?(h=t,_):h},_.on=function(){var t=f.on.apply(f,arguments);return t===f?_:t},_.clickDistance=function(t){return arguments.length?(d=(t=+t)*t,_):Math.sqrt(d)},_.tapDistance=function(t){return arguments.length?(p=+t,_):p},_},zoomIdentity:ww,zoomTransform:Ew});const Iw=Object.freeze({Rect:"rect",Circle:"circle",Line:"line",Ring:"ring",Path:"path",Image:"image",Symbol:"symbol",SimpleText:"text",RichText:"richText",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord",Arrow:"arrow"}),Pw=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord",Line:"line",Path:"path",Image:"image",Symbol:"symbol",SimpleText:"text",RichText:"richText",Collection:"collection",Group:"group",Composite:"composite",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",Trajectory:"trajectory",LinearGradient:"LinearGradient",PathGradient:"PathGradient",Link:"link",DataTable:"datatable",Layout:"layout",NetworkData:"networkdata",TreeData:"treedata",Arrow:"arrow"}),Lw=Object.freeze({Axis:"axis",Legend:"legend",Gridlines:"gridlines",Trajectory:"trajectory"});function Dw(){return Date.now().toString(36)+"_"+Math.random().toString(36).slice(2)}const Vw=Object.freeze({Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"});function Bw(t){var e=Object.values(Vw);for(let n=0;n<t.length;n++){let r=t[n];if(null!=r){for(let t=0;t<e.length;t++)zw[e[t]](r)||(e.splice(t,1),t-=1);if(1==e.length)return e[0]}}return e[0]}const zw={boolean:function(t){return"true"===t||"false"===t||!0===t||!1===t||"[object Boolean]"==toString.call(t)},integer:function(t){return zw.number(t)&&(t=+t)===~~t},number:function(t){return!isNaN(+t)&&"[object Date]"!=toString.call(t)},date:function(t){let e=new Date(t);return null!=e&&!isNaN(e)},string:function(t){return!0}};function Gw(t,e){let n={};switch(e){case Vw.Boolean:n.trueCount=t.filter(t=>t).length,n.falseCount=t.filter(t=>!t).length;break;case Vw.Date:n.min=et(t),n.max=Q(t),n.extent=[n.min,n.max],n.unique=[...new Set(t)];break;case Vw.String:n.unique=[...new Set(t)];break;default:n.min=et(t),n.max=Q(t),n.extent=[n.min,n.max],n.mean=ct(t),n.median=ut(t),n.unique=[...new Set(t)]}return n}const Fw="max",jw="min",Uw="avg",Yw="mean",Hw="median",Ww="count",qw="percentile 25",$w="percentile 75";function Xw(t,e={},n){return{dataTable:t,filters:Object.assign({},e),rowIds:n?n.slice():void 0}}function Kw(t){if(t)return Xw(t.dataTable,t.filters,t.rowIds)}function Zw(t){return Kw(t)}function Jw(t){if(t)return t.dataTable}function Qw(t){return t&&t.filters||{}}function tE(t){return t?t.rowIds&&t.dataTable?t.dataTable.rows({[_E]:t.rowIds}):t.dataTable?t.dataTable.rows(t.filters):[]:[]}function eE(t){let e=tE(t);return e.length>0?e[0]:{}}function nE(t){return tE(t).length}function rE(t,e){return e in Qw(t)}function iE(t,e){let n=Qw(t);if(e in n)return n[e];let r=tE(t);return r.length>0?r[0][e]:void 0}function sE(t,e){let n=Qw(t);return e in n?[n[e]]:Array.from(new Set(tE(t).map(t=>t[e])))}function oE(t,e,n){let r=tE(t).map(t=>t[e]);switch(n){case Fw:return Q(r);case jw:return et(r);case Uw:case Yw:return ct(r);case Hw:return ut(r);case Ww:return r.length;case qw:return ot(r,.25);case $w:return ot(r,.75);default:return yt(r)}}function aE(t,e,n){let r=Jw(t),i=Object.assign({},Qw(t),{[e]:n});return Xw(r,i,hE(r,i))}function lE(t,e){if(!t)return Zw(e);if(!e)return Zw(t);let n=Jw(t),r=Object.assign({},Qw(t));for(let[t,n]of Object.entries(Qw(e)))t in r&&r[t]!==n?console.warn("Conflict in attribute values when merging dataScope:",t,r[t],n):r[t]=n;return Xw(n,r,hE(n,r))}function cE(t){return Xw(t,{},t.data.map(t=>t[_E]))}function uE(t,e,n=!1){let r=Jw(t),i=Qw(t),s=Object.entries(i).filter(([t])=>t!==e),o=r._attrValueIndexes.get(e),a=[];for(let t of r.unique(e)){let l=o&&o.get(t)?o.get(t):[];s.length>0&&(l=l.filter(t=>s.every(([e,n])=>t[e]==n))),(n||0!==l.length)&&a.push(Xw(r,Object.assign({},i,{[e]:t}),l.map(t=>t[_E])))}return a}function hE(t,e){return t.rows(e).map(t=>t[_E])}class fE{constructor(t,e,n){this._id=Pw.DataTable+Dw(),this.initialize(t,e,n)}initialize(t,e,n){if(this.url=e,this._rawData=JSON.parse(JSON.stringify(t)),this._data=t,this._dataScopeCache=new Map,this._scopeTupleCache=new Map,this._attrValueIndexes=new Map,this._rowIdIndex=new Map,this._dateMap=new Map,this._attributes=0===this._data.length?[]:Object.keys(this._data[0]),this._newAttribute=0,n)this._attrTypes=n;else{this._attrTypes={};for(let t of this._attributes)this._attrTypes[t]=Bw(this.data.map(e=>e[t])),"year"==t.toLowerCase()&&this._attrTypes[t]==Vw.Integer&&(this._attrTypes[t]=Vw.Date)}this._validate(this.data,this._attrTypes),this._attrSummaries={};for(let t of this._attributes)this._attrSummaries[t]=Gw(this.data.map(e=>e[t]),this._attrTypes[t]);this._attributes.indexOf(_E)<0&&this.addAttr(_E,Vw.String,this.data.map((t,e)=>"r"+e)),this._buildAttributeValueIndexes()}clone(){let t=[];for(let e of this._data)t.push(Object.assign({},e));let e=new fE(t,this.url,Object.assign({},this._attrTypes));return e.sourceDataTable=this,e}get id(){return this._id}get name(){return this.url?function(t){var e=t.indexOf("\\")>=0?t.lastIndexOf("\\"):t.lastIndexOf("/"),n=t.substring(e);0!==n.indexOf("\\")&&0!==n.indexOf("/")||(n=n.substring(1));return n}(this.url):this.id}get data(){return this._data}encodable(t){switch(t){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":case"text":return this.measures.concat(this.dimensions);default:return this.measures}}addAttr(t,e,n){this._data.forEach((e,r)=>e[t]=n[r]),t!==_E&&this._rawData.forEach((e,r)=>e[t]=n[r]),this._attrTypes[t]=e,this._attributes.includes(t)||this._attributes.push(t),this._attrSummaries[t]=Gw(n,e),this._clearDataCaches()}type(t){return this._attrTypes[t]}summary(t){return this._attrSummaries[t]}values(t){return this.data.map(e=>e[t])}unique(t){return this._attrSummaries[t].unique}order(t,e){this._attrSummaries[t].unique=e}load(t){this._data=t,this._clearDataCaches(),this.summarize()}rows(t={}){let e=this._getFilterKey(t);if(this._scopeTupleCache.has(e))return this._scopeTupleCache.get(e);let n=Object.entries(t);if(0===n.length)return this._scopeTupleCache.set(e,this.data),this.data;if(1===n.length&&n[0][0]===_E&&Array.isArray(n[0][1])){let t=n[0][1].map(t=>this._rowIdIndex.get(t)).filter(t=>t);return this._scopeTupleCache.set(e,t),t}let r=this.data;for(let[t,e]of n){if(Array.isArray(e)||dE(e))continue;let n=this._getRowsByAttributeValue(t,e);n&&n.length<r.length&&(r=n)}let i=r.filter(t=>n.every(([e,n])=>{if(dE(n)){let r=t[e];return(!("min"in n)||r>=n.min)&&(!("max"in n)||r<=n.max)}return Array.isArray(n)?n.includes(t[e]):t[e]==n}));return this._scopeTupleCache.set(e,i),i}_getRowsByAttributeValue(t,e){let n=this._attrValueIndexes.get(t);return n?n.get(e):void 0}_buildAttributeValueIndexes(){this._attrValueIndexes=new Map,this._rowIdIndex=new Map;for(let t of this._attributes){let e=new Map;for(let n of this.data){let r=n[t];e.has(r)||e.set(r,[]),e.get(r).push(n)}this._attrValueIndexes.set(t,e)}for(let t of this.data)this._rowIdIndex.set(t[_E],t)}_getFilterKey(t={}){return Object.entries(t).sort(([t],[e])=>t.localeCompare(e)).map(([t,e])=>dE(e)?t+":["+(e.min??"-inf")+","+(e.max??"+inf")+"]":t+":"+JSON.stringify(e)).join("|")}_clearDataCaches(){this._dataScopeCache&&this._dataScopeCache.clear(),this._scopeTupleCache&&this._scopeTupleCache.clear(),this._attrValueIndexes&&(this._attrValueIndexes.clear(),this._buildAttributeValueIndexes())}count(){return this.data.length}has(t){return this._attributes.indexOf(t)>=0}parseDate(t,e){let n=ry(e);for(let e of this.data){let r=e[t];null==r||null==r?(r="",e[t]=new Date(1899,11,31).getTime()):e[t]=n(r).getTime(),this._dateMap.set(e[t],r)}this._attrTypes[t]=Vw.Date,this._attrSummaries[t]=Gw(this.data.map(e=>e[t]),Vw.Date),this._clearDataCaches()}raw(t,e){return this.type(t)===Vw.Date?this._dateMap.get(e).toString():e}get dimensions(){let t=[];for(let e in this._attrTypes)this._attrTypes[e]!=Vw.Number&&this._attrTypes[e]!=Vw.Integer&&e!=fE.RowID&&t.push(e);return t.sort((t,e)=>this.unique(t).length-this.unique(e).length),t}get measures(){let t=[];for(let e in this._attrTypes)this._attrTypes[e]!==Vw.Number&&this._attrTypes[e]!==Vw.Integer||e==fE.RowID||t.push(e);return t}attrs(t){if(void 0===t)return this._attributes;let e=[];for(let n in this._attrTypes)this._attrTypes[n]===t&&n!=fE.RowID&&e.push(n);return e}summarize(){for(let t of this._attributes)this._attrSummaries[t]=Gw(this.data.map(e=>e[t]),this._attrTypes[t])}_validate(t,e){for(let n of t)for(let t in e){let r,i=e[t],s=n[t];if(null==n[t]||null==n[t])switch(i){case Vw.Boolean:r=!1;break;case Vw.Date:r=new Date(1899,11,31).getTime();break;case Vw.String:r="";break;default:r=0}else switch(i){case Vw.Boolean:r=s;break;case Vw.Date:r=Number.isInteger(s)&&s<=9999?new Date(s,0).getTime():Number.isInteger(s)?s:new Date(s+"").getTime(),this._dateMap.set(r,s);break;case Vw.String:r=s.toString();break;default:r=s}n[t]=r}}}function dE(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&("min"in t||"max"in t)}function pE(t){return t.dataScope?Jw(t.dataScope):t.parent&&t.parent.dataScope?Jw(t.parent.dataScope):void 0}const _E="mascot_rowId";class gE{constructor(t,e){this._id=Pw.TreeData+Dw(),this.initialize(t,e)}initialize(t,e){this.url=e,this._data=t,this._nodeList=[],this._linkList=[],this._nodeHash={},this._traverse(t,this._nodeList,this._linkList),this._nodeTable=new fE(this._nodeList,"nodes"),this._linkTable=new fE(this._linkList,"links"),this._nodeTable.tree=this,this._linkTable.tree=this}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}_traverse(t,e,n,r=0){let i={};xE in t||(t[xE]="n"+e.length),e.push(i),t._depth=r;for(let s in t)if("children"==s&&t[s]&&t[s].length>0)for(let i of t[s]){let s=this._traverse(i,e,n,r+1);n.push({parent:t[xE],child:s})}else i[s]=t[s];return this._nodeHash[i[xE]]=i,i[xE]}getNodeDataScopeRef(t){return aE(cE(this._nodeTable),_E,t[_E])}getNode(t){return this._nodeHash[t]}getRoot(){return this._nodeTable.data[0]}getChildren(t){let e=t[xE],n=[],r=this._linkTable.data,i=this._nodeTable.data;for(let t in r)if(r[t].parent==e){let e=r[t].child,s=i.findIndex(t=>t[xE]==e);n.push(i[s])}return n}getParent(t){let e=t[xE],n=this._linkTable.data,r=this._nodeTable.data;for(let t in n)if(n[t].child==e){let e=n[t].parent,i=r.findIndex(t=>t[xE]==e);return r[i]}}}function yE(t){return Jw(t.dataScope).tree}class mE{constructor(t,e){this._id=Pw.NetworkData+Dw(),this.initialize(t,e)}initialize(t,e){this.url=e,this._nodeTable=new fE(t.nodes,this._id+"_nodes"),this._linkTable=new fE(t.links,this._id+"_links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._rawNodes=t.nodes,this._rawLinks=t.links,this._nodeHash={};for(let e of t.nodes)this._nodeHash[e[xE]]=e}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodeList(){return this._rawNodes}get linkList(){return this._rawLinks}getNode(t){return this._nodeHash[t]}getLinks(t){let e=t[xE],n=this._rawLinks,r=[];for(let t in n)n[t].target!==e&&n[t].source!==e||r.push(n[t]);return r}buildNodeHierarchy(t){let e={};return e[xE]="root",vE(e,this._rawNodes,t),new gE(e,this.url)}}function bE(t){return Jw(t.dataScope).graph}function vE(t,e,n){if(0===e.length||0===n.length)return;"children"in t||(t.children=[]);let r={};for(let t of e){let e=t[n[0]];e in r||(r[e]=[]),r[e].push(t)}if(1===n.length)for(let e in r){let n={children:r[e]};n[xE]=e,t.children.push(n)}else for(let e in r){let i={};i[xE]=e,t.children.push(i),vE(i,r[e],n.slice(1))}}const xE="id";function wE(t,e){return fetch(e,{method:t}).then(t=>t.ok?t.text():(console.log(t.status),Promise.reject({status:t.status,statusText:t.statusText}))).catch(t=>(console.log(t),Promise.reject({status:t.status,statusText:t.statusText})))}class EE{constructor(t,e,n){this._id="predicate_"+Dw(),this._type=t||AE.POINT,this._variableType=e,this._variableName=n,this._value=void 0}get type(){return this._type}get value(){return this._value}set value(t){this._value=t}get id(){return this._id}get variableType(){return this._variableType}get variableName(){return this._variableName}}const AE=Object.freeze({POINT:"point",INTERVAL:"interval",LIST:"list"});class SE extends EE{constructor(t,e,n){super(t,e,n)}testElement(t){let e;if("attribute"==this._variableType){if(!t.dataScope)return!1;e=t.datum[this._variableName]}else e=t[this._variableName];return this._value[0]<=e&&this._value[1]>=e}testTuple(t){if("attribute"==this._variableType){let e=t[this._variableName];return this._value[0]<=e&&this._value[1]>=e}return!1}}class TE extends EE{constructor(t,e,n){super(t,e,n)}addValue(t){this._value||(this._value=[]),this._value.push(t)}resetValue(){this._value=void 0}testElement(t){if("attribute"==this._variableType){if(!t.dataScope)return!1;let e=Array.from(new Set(t.data.map(t=>t[this._variableName])));return 1===e.length&&this._value.indexOf(e[0])>=0}return this._value.indexOf(t[this._variableName])>=0}testTuple(t){if("attribute"==this._variableType){let e=t[this._variableName];return this._value.indexOf(e)>=0}return!1}}class CE extends EE{constructor(t,e,n){super(t,e,n)}testElement(t){if("attribute"==this._variableType){if(!t.dataScope)return!1;return t.datum[this._variableName]==this._value}return t[this._variableName]==this._value}testTuple(t){if("attribute"==this._variableType){let e=t[this._variableName];return this._value===e}return!1}equals(t){return this.type===t.type&&this.variableName===t.variableName&&this.value===t.value}}function kE(t){let e,n="attribute"in t?"attribute":"property",r=t[n];switch(t.type){case AE.LIST:e=new TE(t.type,n,r);break;case AE.INTERVAL:e=new SE(t.type,n,r);break;case AE.POINT:default:e=new CE(t.type,n,r)}return e.value=t.value,e}function RE(t,e){for(let n of e)if(!n.testElement(t))return!1;return!0}const ME={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.visibility="hidden",this.svg.style.pointerEvents="none",this.svg.setAttribute("aria-hidden","true"),document.body.appendChild(this.svg)),this.svg):null}};function OE(t,e,n,r,i){const s=i*Math.PI/180,o=t-n,a=e-r;return{x:o*Math.cos(s)-a*Math.sin(s)+n,y:o*Math.sin(s)+a*Math.cos(s)+r}}function NE(t,e,n,r){return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-r,2))}const IE=Object.freeze({fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",strokeDash:"stroke-dasharray",opacity:"opacity",fontSize:"font-size",fontFamily:"font-family",fontWeight:"font-weight",visibility:"visibility",cursor:"cursor"});class PE{constructor(t,e,n,r){this._x=t+n/2,this._y=e+r/2,this._width=n,this._height=r}translate(t,e){this._x+=t,this._y+=e}toJSON(){let t={};return t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t}union(t){let e=d3.min([this.left,t.left]),n=d3.min([this.top,t.top]),r=d3.max([this.right,t.right]),i=d3.max([this.bottom,t.bottom]);return new PE(e,n,r-e,i-n)}clone(){return new PE(this.left,this.top,this._width,this._height)}get left(){return this._x-this._width/2}set left(t){this._x=t+this._width/2}get right(){return this._x+this._width/2}set right(t){this._x=t-this._width/2}get top(){return this._y-this._height/2}set top(t){this._y=t+this._height/2}get bottom(){return this._y+this._height/2}set bottom(t){this._y=t-this._height/2}get x(){return this._x}get y(){return this._y}get center(){return this.x}get middle(){return this.y}get width(){return this._width}setWidth(t,e){switch(e){case zE.RIGHT:this._x=this.right-t/2;break;case zE.CENTER:this._width=2*t;break;default:this._x=this.left+t/2}this._width=t}get height(){return this._height}setHeight(t,e){switch(e){case zE.TOP:this._y=this.top+t/2;break;case zE.MIDDLE:this._height=2*t;break;default:this._y=this.bottom-t/2}this._height=t}contains(t,e){return this.left<=t&&this.right>=t&&this.top<=e&&this.bottom>=e}intersects(t){return!(this.right<t.left||this.bottom<t.top||this.left>t.right||this.top>t.bottom)}}function LE(t){let e=t[0].clone();for(let n=1;n<t.length;n++)e=e.union(t[n]);return e}function DE(t){return LE(("vertex"==t[0].type||"segment"==t[0].type?t.map(t=>t.parent):t).map(t=>t.refBounds?t.refBounds:t.bounds))}function VE(t){return LE(("vertex"==t[0].type||"segment"==t[0].type?t.map(t=>t.parent):t).map(t=>t.bounds))}function BE(t){let e=JE(t);for(let t of e)t._updateBounds();let n=[];for(let t of e)t.parent&&!n.includes(t.parent)&&n.push(t.parent);for(let t of n)BE(t)}const zE=Object.freeze({TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",CENTER:"center",MIDDLE:"middle"});class GE{constructor(t){if(this._dataScopeRef=void 0,this._type="type"in t?t.type:Pw.Mark,this._id=t.id?t.id:this._type+"_"+Dw(),this._classId=void 0,this._bounds=void 0,this._rotate=void 0,this._refBounds=void 0,this._dirty=!0,this._clipMask=void 0,this._cursor=void 0,this._styles={},void 0!==t)for(let e in IE)e in t&&(this.styles[e]=t[e])}get scene(){return aA(this)}get datum(){return eE(this._dataScopeRef)}get data(){return tE(this._dataScopeRef)}set strokeColor(t){this.styles.strokeColor!==t&&(this.styles.strokeColor=t,this._dirty=!0)}get strokeColor(){return this.styles.strokeColor}set strokeWidth(t){this.styles.strokeWidth!==t&&(this.styles.strokeWidth=t,this._dirty=!0)}get strokeWidth(){return this.styles.strokeWidth}get strokeDash(){return this.styles.strokeDash}set strokeDash(t){this.styles.strokeDash!==t&&(this.styles.strokeDash=t,this._dirty=!0)}set fillColor(t){this.styles.fillColor!==t&&(this.styles.fillColor=t,this._dirty=!0)}get fillColor(){return this.styles.fillColor}get rotation(){return this._rotate}get cursor(){return this._cursor}get id(){return this._id}set id(t){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}get classId(){return this._classId?this._classId:this._id}set classId(t){this._classId=t}get type(){return this._type}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){return this._refBounds?this._refBounds:this.bounds}set dataScope(t){this._dataScopeRef=Kw(t)}get dataScope(){return this._dataScopeRef}get styles(){return this._styles}set styles(t){this._styles!==t&&(this._styles=t,this._dirty=!0)}set visibility(t){this.styles.visibility!==t&&(this.styles.visibility=t,this._dirty=!0)}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(t){this.styles.opacity!==t&&(this.styles.opacity=t,this._dirty=!0)}get z(){return"z"in this.styles?this.styles.z:0}set z(t){this.styles.z!==t&&(this.styles.z=t,this._dirty=!0)}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t._dataScopeRef=Zw(this._dataScopeRef))}createClipMask(){let t=this._bounds;this._clipMask=new PE(t.left,t.top,t.width,t.height)}get clipMask(){return this._clipMask}}function FE(t){return t instanceof GE&&t.type!==Pw.Gridlines}const jE=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",Symbol:"symbol",SimpleText:"text",RichText:"richText",Polygon:"polygon",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord",Arrow:"arrow"});class UE{constructor(){this._refElements=[]}addRefElement(t){this._refElements.push(t)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}}function YE(t){return t instanceof UE}const HE=Object.freeze({GRID:"grid",STACK:"stack",PACKING:"packing",FORCE:"force",DIRECTED:"directedgraph",TIDYTREE:"tidytree",TREEMAP:"treemap",STRATA:"strata",CIRCULAR:"circular",CLUSTER:"cluster",SPIRAL:"spiral",CUSTOM:"custom"});function WE(t,e){return!!(t.startsWith("h")&&[zE.LEFT,zE.CENTER,zE.RIGHT].indexOf(e)>=0)||(!!(t.startsWith("v")&&[zE.TOP,zE.MIDDLE,zE.BOTTOM].indexOf(e)>=0)||(console.warn("Invalid alignment:",e),!1))}class qE{constructor(t){this._id=t+"_"+Dw(),this._type=t,this._inputVars=[],this._outputVars=[]}run(){}get id(){return this._id}get type(){return this._type}get inputVars(){return this._inputVars}get outputVars(){return this._outputVars}get outputVar(){return this._outputVars[0]}isIsolated(){return 0==this._inputVars.length&&0==this._outputVars.length}}const $E=Object.freeze({CONDUIT:"conduit",ENCODER:"encoder",LAYOUT:"layout",LINK_PLACER:"linkRouter",CONSTRAINT:"constraint",EVAL_BBOX:"evalBBox",EVAL_REFBOUNDS:"evalRefBounds",AFFIXER:"affixer",ALIGNER:"aligner",DATA_EXTRACTOR:"dataExtractor",SCALE_BUILDER:"scaleBuilder",AXIS_PATH_PLACER:"axisPathPlacer",AXIS_TICKS_PLACER:"axisTicksPlacer",AXIS_LABELS_PLACER:"axisLabelsPlacer",AXIS_TITLE_PLACER:"axisTitlePlacer",GRIDLINES_PLACER:"gridlinesPlacer",SPIRAL_TRAJECTORY_PLACER:"spiralTrajectoryPlacer",GRID_LAYOUT:"gridLayout",STACK_LAYOUT:"stackLayout",PACK_LAYOUT:"packLayout",FORCE_LAYOUT:"forceLayout",DIRECTED_LAYOUT:"directedLayout",TIDY_TREE_LAYOUT:"tidyTreeLayout",TREEMAP_LAYOUT:"treemapLayout",STRATA_LAYOUT:"strataLayout",CIRCULAR_LAYOUT:"circularLayout",CLUSTER_LAYOUT:"clusterLayout",SPIRAL_LAYOUT:"spiralLayout",CUSTOM_LAYOUT:"customLayout",BIN_TRANSFORMER:"binTransformer",FILTER_TRANSFORMER:"filterTransformer",KDE_TRANSFORMER:"kdeTransformer",CUSTOM_TRANSFORMER:"customTransformer",UNPIVOT_TRANSFORMER:"unpivotTransformer",REPOPULATE:"repopulate",TARGET_EVALUATOR:"targetEvaluator",TARGET_UPDATER:"targetUpdater"});class XE{constructor(t){this._id="v_"+Dw(),this._type=t,this._incomings=[],this._outgoings=[],this._undirected=[]}get id(){return this._id}get incomingEdges(){return this._incomings}get outgoingEdges(){return this._outgoings}get undirectedEdges(){return this._undirected}get type(){return this._type}get incomingDataflow(){for(let t of this._incomings)if(t.fromNode&&t.fromNode instanceof qE)return t.fromNode;return null}isIsolated(){return 0==this._incomings.length&&0==this._outgoings.length}}const KE=Object.freeze({CHANNEL:"channel",PROPERTY:"property",STATE:"state",ATTRIBUTE:"attribute",ITEMS:"items",DATASCOPE:"datascope",ATTR_VALUE:"dataValue",BOUNDS:"bounds",SCALE:"scale",CONDITION_RESULT:"conditionResult",AFFIXATION:"affixation",ALIGNMENT:"alignment",EVT_CTX:"evtContext"});class ZE extends Map{constructor(t){super(),this._scene=t}get scene(){return this._scene}var(t){if("string"!=typeof t||0===t.length)throw new Error("state.var(...) expects a non-empty variable name");return{type:"stateVar",key:t,stateContext:this}}set(t,e){const n=this.get(t);return super.set(t,e),n!==e&&(this._scene.depGraph.getVariable(KE.STATE,t,this),this._scene.onChange(KE.STATE,t,this)),this}}function JE(t,e){let n=aA(t);return"vertex"===t.type||"segment"===t.type?function(t,e){let n=aA(t),r=e||n;if("vertex"===t.type){return QE(t,rA(r,[{property:"classId",value:t.parent.classId}],!0))}if("segment"===t.type){return nA(t,rA(r,[{property:"classId",value:t.parent.classId}],!0))}return t.classId?rA(r,[{property:"classId",value:t.classId}]):[t]}(t,e):t.classId?rA(e||n,[{property:"classId",value:t.classId}]):[t]}function QE(t,e){if(!t.classId){if(t.dataScope){let n=t.parent;if(!n)throw new Error("vertex has no parent mark");let r=[];if(n.type!==Pw.Area||t._isAnyVertex)for(let t of e)r=r.concat(t.vertices.filter(t=>t.dataScope));else{let i=n.vertices.indexOf(t)<n.vertices.length/2;for(let t of e){let e=i?t.vertices.slice(0,t.vertices.length/2):t.vertices.slice(t.vertices.length/2);r=r.concat(e.filter(t=>t.dataScope))}}return r}{let n=t.parent;if(!n)throw new Error("vertex has no parent mark");let r=n.vertices.indexOf(t),i=[];for(let t of e)i.push(t.vertices[r]);return i}}}function tA(t,e){return t.id+"_v_"+t._vertices._ids[e]}function eA(t,e){let n=t.parent,r=t._index,i=[];if(t.dataScope)if(n.type!==Pw.Area||t._isAnyVertex)for(let t of e){let e=[];for(let n=0;n<t._vertices.length;n++)t._vertices.hasDataScope(n)&&e.push(n);i.push({parent:t,indices:e})}else{let t=r<n._vertices.length/2;for(let n of e){let e=t?0:n._vertices.length/2,r=t?n._vertices.length/2:n._vertices.length,s=[];for(let t=e;t<r;t++)n._vertices.hasDataScope(t)&&s.push(t);i.push({parent:n,indices:s})}}else for(let t of e)i.push({parent:t,indices:[r]});return i}function nA(t,e){if(t._dataScopeRef){if(!t.parent)throw new Error("segment has no parent mark");let n=[];for(let t of e)n=n.concat(t.segments);return n}{let n=t.parent;if(!n)throw new Error("segment has no parent mark");let r=n.segments.indexOf(t),i=[];for(let t of e)i.push(t.segments[r]);return i}}function rA(t,e,n){let r=[];return oA(t,e?e.map(t=>kE(t)):[],r,n),r}function iA(t,e){let n=t.children.filter(t=>t.type==Pw.Collection);if(0!==n.length)for(let t of n){let n=t;for(;n&&n.dataScope;){if(rE(n.dataScope,e))return n;n=n.children?n.children[0]:void 0}}}function sA(t){return t.type==Pw.Collection?t:t.parent?sA(t.parent):void 0}function oA(t,e,n,r){if(t)if(RE(t,e)&&n.push(t),t.vertices&&r)for(let r of t.vertices.concat(t.segments))RE(r,e)&&n.push(r);else if(t.children&&t.children.length>0)for(let i of t.children)oA(i,e,n,r)}function aA(t){let e;if(e=Array.isArray(t)?t[0]:t,e){if(e instanceof ZE)return e.scene;if(e._scene)return e._scene;for(YE(e)&&e.group&&(e=e.group),e.id.startsWith("encoding_")&&(e=e.element);e;){if(e.type==Pw.Scene)return e;e=e.parent}}}function lA(t){let e=t;for("vertex"!=e.type&&"segment"!=e.type||(e=e.parent);e.parent&&[Pw.Collection,Pw.Glyph].includes(e.parent.type);)e=e.parent;return e}function cA(t,e){let n=[];if(uA(t,n),e){let t={};for(let e of n)t[e.classId]=e;return Object.values(t)}return n}function uA(t,e){if(FE(t))e.push(t);else if(t.children&&!Object.values(Lw).includes(t.type))for(let n of t.children)uA(n,e)}class hA extends XE{constructor(t,e,n){super(t),this._channel=e,this._elem=n}get channel(){return this._channel}get element(){return this._elem}}const fA=Object.freeze({X:"x",Y:"y",WIDTH:"width",HEIGHT:"height",RADIUS:"radius",FILLCOLOR:"fillColor",STROKECOLOR:"strokeColor",FILLGRADIENT:"fillGradient",STROKEGRADIENT:"strokeGradient",TEXT:"text",ANGLE:"angle",THICKNESS:"thickness",AREA:"area",FONTSIZE:"fontSize",POLARRADIUS:"polarRadius",POLARANGLE:"polarAngle",STROKEWIDTH:"strokeWidth",OPACITY:"opacity",VISIBILITY:"visibility",STRENGTH:"strength",SRC:"src",PATH:"path",Z:"z"});class dA extends XE{constructor(t,e,n){super(t),this._property=e,this._elem=n}get property(){return this._property}get element(){return this._elem}}function pA(t){return t in _A?_A[t]:t}const _A=Object.freeze({numCols:"layoutParameter",numRows:"layoutParameter",startCorner:"layoutParameter",direction:"layoutParameter",params:"layoutParameter"}),gA=Object.freeze({AXIS_ORIENTATION:"axisOrientation",AXIS_PATH_POSITION:"axisPathPosition",AXIS_TICK_SIZE:"axisTickSize",AXIS_TICK_OFFSET:"axisTickOffset",AXIS_TICKS_POSITION:"axisTicksPosition",AXIS_LABELS_POSITION:"axisLabelsPosition",AXIS_TITLE_POSITION:"axisTitlePosition",AXIS_LABEL_OFFSET:"axisLabelOffset",AXIS_LABEL_FORMAT:"axisLabelFormat",AXIS_FONT_SIZE:"axisFontSize",LEGEND_POSITION:"legendPosition",GRIDLINES_POSITION:"gridlinesPosition",TRAJECTORY_POSITION:"trajectoryPosition",INCLUDE_ZERO:"includeZero",FLIP_SCALE:"flipScale",RANGE_START:"rangeStart",RANGE_EXTENT:"rangeExtent",BASE_LINE:"baseline",LAYOUT_PARAMETER:"layoutParameter",NUM_BINS:"numBins",CHILDREN_ORDER:"childrenOrder",ATTRIBUTE:"attribute"});class yA{constructor(){this._vals={},this._vals.elements=[]}set(t,e){this._vals[t]=e}get(t){return this._vals[t]}clear(){this._vals={},this._vals.elements=[]}}class mA{constructor(t,e,n,r){this._id=t,this._event=n,this._source=e,this._evtCtx=new yA,this._cumulative=r}get id(){return this._id}get event(){return this._event}get eventContext(){return this._evtCtx}get source(){return this._source}isCumulative(){return this._cumulative}isMouseDriven(){return["brush","brushX","brushY","click","hover"].includes(this._event)}isKeyboardDriven(){return["keydown","keyup"].includes(this._event)}isWidgetDriven(){return["change","input"].includes(this._event)}isStateDriven(){return null!==this._source&&"object"==typeof this._source&&"stateVar"===this._source.type}}const bA=Symbol("msc.TRIGGER_ELEMENT");function vA(t){let e=t?aA(t):void 0;e&&e._clearInteractionCaches&&e._clearInteractionCaches()}function xA(t,e){if(vA(t),e.findVariable(KE.BOUNDS,[t]))return;let n=e.getVariable(KE.BOUNDS,t),r=e.createOneWayDependency($E.EVAL_BBOX);switch(e.connect(r,n),t.type){case Pw.Circle:case Pw.Polygon:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"radius",t),o=e.getVariable(KE.CHANNEL,"area",t);e.connect(s,r),e.connect(n,r),e.connect(i,r),e.connect(o,r);break}case Pw.Area:case Pw.Line:case Pw.BezierCurve:case Pw.Path:case Pw.Image:case Pw.Symbol:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"width",t),o=e.getVariable(KE.CHANNEL,"height",t);e.connect(n,r),e.connect(i,r),e.connect(s,r),e.connect(o,r);break}case Pw.Rect:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"width",t),o=e.getVariable(KE.CHANNEL,"height",t),a=e.getVariable(KE.CHANNEL,"area",t);e.connect(n,r),e.connect(i,r),e.connect(s,r),e.connect(o,r),e.connect(a,r);break}case Pw.SimpleText:case Pw.RichText:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"text",t);e.connect(n,r),e.connect(i,r),e.connect(s,r);break}case Pw.Ring:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"innerRadius",t),o=e.getVariable(KE.CHANNEL,"outerRadius",t);e.connect(n,r),e.connect(i,r),e.connect(s,r),e.connect(o,r);break}case Pw.Pie:case Pw.Arc:{let n=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"innerRadius",t),o=e.getVariable(KE.CHANNEL,"outerRadius",t),a=e.getVariable(KE.CHANNEL,"startAngle",t),l=e.getVariable(KE.CHANNEL,"endAngle",t),c=e.getVariable(KE.CHANNEL,"angle",t),u=e.getVariable(KE.CHANNEL,"thickness",t);e.connect(n,r),e.connect(i,r),e.connect(s,r),e.connect(o,r),e.connect(a,r),e.connect(l,r),e.connect(c,r),e.connect(u,r);break}}r.run()}function wA(t,e){if(t.type===Pw.Axis){let n=e.findVariable(KE.PROPERTY,[gA.AXIS_PATH_POSITION,t]).incomingDataflow;console.log(n,t),e.deleteOperator(n),n=e.findVariable(KE.PROPERTY,[gA.AXIS_TICKS_POSITION,t]).incomingDataflow,e.deleteOperator(n),n=e.findVariable(KE.PROPERTY,[gA.AXIS_LABELS_POSITION,t]).incomingDataflow,e.deleteOperator(n),n=e.findVariable(KE.PROPERTY,[gA.AXIS_TITLE_POSITION,t]).incomingDataflow,e.deleteOperator(n)}else if(t.type===Pw.Gridlines){let n=e.findVariable(KE.PROPERTY,[gA.GRIDLINES_POSITION,t]).incomingDataflow;e.deleteOperator(n)}}function EA(t,e){if(vA(t),e.findVariable(KE.BOUNDS,[t]))return;let n=e.getVariable(KE.BOUNDS,t),r=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"width",t),o=e.getVariable(KE.CHANNEL,"height",t),a=e.createOneWayDependency($E.EVAL_BBOX);e.connect(r,a),e.connect(i,a),e.connect(s,a),e.connect(o,a),e.connect(a,n),a.run()}function AA(t,e){vA(t);let n=e.getVariable(KE.BOUNDS,t),r=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getVariable(KE.CHANNEL,"width",t),o=e.getVariable(KE.CHANNEL,"height",t),a=e.createOneWayDependency($E.EVAL_BBOX);e.connect(r,a),e.connect(i,a),e.connect(s,a),e.connect(o,a),e.connect(a,n),a.run()}function SA(t,e,n){vA(t);let r=n.getVariable(KE.BOUNDS,t),i=n.getVariable(KE.BOUNDS,e),s=n.getIncomingDataflowOperator($E.EVAL_BBOX,r),o=i.outgoingEdges.find(t=>t.fromNode===i&&t.toNode===s);if(o&&n.disconnect(i,s,o),t.layout){let r=n.getVariable(KE.CHANNEL,"x",e),i=n.getIncomingDataflowOperator(kA(t.layout.type),r);i&&n.deleteOperator(i)}}function TA(t,e,n){vA(t);let r=n.getVariable(KE.BOUNDS,t),i=n.getVariable(KE.BOUNDS,e),s=n.getIncomingDataflowOperator($E.EVAL_BBOX,r);n.connect(i,s),n.connect(s,r),t.layout&&MA(t,t.layout,n)}function CA(t,e){vA(t);let n=e.getVariable(KE.BOUNDS,t),r=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"y",t),s=e.getIncomingDataflowOperator($E.EVAL_BBOX,n);e.connect(r,s),e.connect(i,s);for(let n of t.children)e.connect(e.getVariable(KE.BOUNDS,n),s);e.connect(s,n),s.run()}function kA(t){switch(t){case HE.GRID:return $E.GRID_LAYOUT;case HE.STACK:return $E.STACK_LAYOUT;case HE.PACKING:return $E.PACK_LAYOUT;case HE.FORCE:return $E.FORCE_LAYOUT;case HE.DIRECTED:return $E.DIRECTED_LAYOUT;case HE.TIDYTREE:return $E.TIDY_TREE_LAYOUT;case HE.TREEMAP:return $E.TREEMAP_LAYOUT;case HE.STRATA:return $E.STRATA_LAYOUT;case HE.CIRCULAR:return $E.CIRCULAR_LAYOUT;case HE.CLUSTER:return $E.CLUSTER_LAYOUT;case HE.SPIRAL:return $E.SPIRAL_LAYOUT;case HE.CUSTOM:return $E.CUSTOM_LAYOUT}}function RA(t,e,n){let r=n.getVariable(KE.PROPERTY,gA.CHILDREN_ORDER,t),i=n.getOutgoingDataflowOperator(kA(e.type),r);n.deleteOperator(i)}function MA(t,e,n){let r=e?e.type:"none",i=r===HE.TREEMAP?cA(t)[0]:t.children[0];if(!i)return;let s=n.getVariable(KE.CHANNEL,"width",i),o=n.getVariable(KE.CHANNEL,"height",i),a=n.getVariable(KE.PROPERTY,gA.CHILDREN_ORDER,t),l=n.getVariable(KE.CHANNEL,"x",i),c=n.getVariable(KE.CHANNEL,"y",i),u=n.getVariable(KE.CHANNEL,"visibility",i),h=n.getVariable(KE.PROPERTY,gA.LAYOUT_PARAMETER,e),f=n.getOutgoingDataflowOperator(kA(r),a);if(n.connect(s,f),n.connect(o,f),n.connect(a,f),n.connect(h,f),n.connect(u,f),n.connect(f,l),n.connect(f,c),n.disconnectChannelVarFromBBoxOperator(s),n.disconnectChannelVarFromBBoxOperator(o),i.type===Pw.Arc||i.type===Pw.Pie){let t=n.getVariable(KE.CHANNEL,"angle",i),e=n.getVariable(KE.CHANNEL,"thickness",i);n.connect(t,f),n.connect(e,f)}else if(i.type===Pw.Circle){let t=n.getVariable(KE.CHANNEL,"area",i),e=n.getVariable(KE.CHANNEL,"radius",i);n.connect(t,f),n.connect(e,f),n.disconnectChannelVarFromBBoxOperator(t),n.disconnectChannelVarFromBBoxOperator(e)}else if(i.type===Pw.Rect){let t=n.getVariable(KE.CHANNEL,"area",i);n.connect(t,f),n.disconnectChannelVarFromBBoxOperator(t)}if(f.run(),i.links&&OA(i,n),i.children&&i.children[0]){let t=n.getVariable(KE.BOUNDS,i.children[0]),e=n.getVariable(KE.CHANNEL,"x",i).incomingDataflow;e&&n.connect(t,e),n.disconnectChannelVarFromBBoxOperator(t)}}function OA(t,e){let n=t.links[0],r=e.getVariable(KE.CHANNEL,"x",t),i=e.getVariable(KE.CHANNEL,"x",n),s=e.getVariable(KE.CHANNEL,"strokeWidth",n),o=e.getVariable(KE.CHANNEL,"strength",n),a=e.createOneWayDependency($E.LINK_PLACER);e.connect(r,a),e.connect(s,a),e.connect(o,a),e.connect(a,i)}function NA(t,e,n){if(!t||"segment"!==t.type)return;let r=pE(t),i=r?n.findVariable(KE.ITEMS,[r]):null;if(i)for(let t of i.outgoingEdges)if(t.isDirected&&t.toNode.type===$E.REPOPULATE)return void n.connect(t.toNode,e)}function IA(t,e,n){let r=t.attribute,i=t.channel,s=t.element,o=e.createOneWayDependency($E.ENCODER);if(["width","height"].includes(t.channel)&&s.type===Pw.Area){let t=e.getVariable(KE.PROPERTY,gA.BASE_LINE,s);e.connect(t,o)}if(n){let r=e.getVariable(KE.ATTR_VALUE,n),a=e.getVariable(KE.SCALE,n),l=e.getVariable(KE.CHANNEL,i,s);e.connect(a,o),e.connect(o,l),r.addLinkedEncoding(t),a.addLinkedEncoding(t);let c=e.getVariable(KE.DATASCOPE,t.element),u=r.incomingDataflow;u&&c&&(e.connect(c,u),NA(t.element,c,e)),r.incomingDataflow.run()}else{let n=e.getVariable(KE.ATTRIBUTE,r,pE(s),t),a=e.getVariable(KE.PROPERTY,gA.INCLUDE_ZERO,t),l=e.getVariable(KE.ATTR_VALUE,t),c=e.getVariable(KE.DATASCOPE,s),u=e.createOneWayDependency($E.DATA_EXTRACTOR);e.connect(n,u),e.connect(a,u),e.connect(c,u),e.connect(u,l),NA(s,c,e),u.run();let h=e.getVariable(KE.PROPERTY,gA.RANGE_START,t),f=e.getVariable(KE.PROPERTY,gA.RANGE_EXTENT,t),d=e.getVariable(KE.PROPERTY,gA.FLIP_SCALE,t),p=e.getVariable(KE.SCALE,t),_=e.createOneWayDependency($E.SCALE_BUILDER);e.connect(h,_),e.connect(f,_),e.connect(d,_),e.connect(l,_),e.connect(_,p),_.run();let g=e.getVariable(KE.CHANNEL,i,s);e.connect(p,o),e.connect(o,g),o.run()}}function PA(t,e){let n=e.getVariable(KE.PROPERTY,gA.AXIS_ORIENTATION,t),r=e.getVariable(KE.BOUNDS,t.elements[0].parent),i=e.getVariable(KE.PROPERTY,gA.AXIS_PATH_POSITION,t),s=e.createOneWayDependency($E.AXIS_PATH_PLACER);e.connect(n,s),e.connect(r,s),e.connect(s,i),s.run();let o=e.getVariable(KE.PROPERTY,gA.AXIS_TICK_OFFSET,t),a=e.getVariable(KE.PROPERTY,gA.AXIS_TICK_SIZE,t),l=e.createOneWayDependency($E.AXIS_TICKS_PLACER),c=e.getVariable(KE.PROPERTY,gA.AXIS_TICKS_POSITION,t);e.connect(i,l),e.connect(o,l),e.connect(a,l),e.connect(l,c),l.run();let u=e.getVariable(KE.PROPERTY,gA.AXIS_LABEL_OFFSET,t),h=e.getVariable(KE.PROPERTY,gA.AXIS_LABEL_FORMAT,t),f=e.getVariable(KE.PROPERTY,gA.AXIS_FONT_SIZE,t),d=e.createOneWayDependency($E.AXIS_LABELS_PLACER),p=e.getVariable(KE.PROPERTY,gA.AXIS_LABELS_POSITION,t);e.connect(i,d),e.connect(u,d),e.connect(h,d),e.connect(f,d),e.connect(d,p),d.run();let _=e.getVariable(KE.PROPERTY,gA.AXIS_TITLE_POSITION,t),g=e.createOneWayDependency($E.AXIS_TITLE_PLACER);e.connect(i,g),e.connect(g,_),g.run();let y=e.getVariable(KE.BOUNDS,t),m=e.getIncomingDataflowOperator($E.EVAL_BBOX,y);e.connect(c,m),e.connect(p,m),e.connect(m,y)}function LA(t,e){let n=e.getVariable(KE.PROPERTY,gA.AXIS_ORIENTATION,t),r=e.getVariable(KE.BOUNDS,lA(t.elements[0])),i=e.getVariable(KE.PROPERTY,gA.AXIS_PATH_POSITION,t),s=e.createOneWayDependency($E.AXIS_PATH_PLACER);e.connect(n,s),e.connect(r,s),e.connect(s,i),s.run();let o=e.getVariable(KE.PROPERTY,gA.AXIS_TICK_OFFSET,t),a=e.getVariable(KE.PROPERTY,gA.AXIS_TICK_SIZE,t),l=e.createOneWayDependency($E.AXIS_TICKS_PLACER),c=e.getVariable(KE.PROPERTY,gA.AXIS_TICKS_POSITION,t);e.connect(i,l),e.connect(o,l),e.connect(a,l),e.connect(l,c),l.run();let u=e.getVariable(KE.PROPERTY,gA.AXIS_LABEL_OFFSET,t),h=e.getVariable(KE.PROPERTY,gA.AXIS_LABEL_FORMAT,t),f=e.getVariable(KE.PROPERTY,gA.AXIS_FONT_SIZE,t),d=e.createOneWayDependency($E.AXIS_LABELS_PLACER),p=e.getVariable(KE.PROPERTY,gA.AXIS_LABELS_POSITION,t);e.connect(i,d),e.connect(u,d),e.connect(h,d),e.connect(f,d),e.connect(d,p),d.run();let _=e.getVariable(KE.PROPERTY,gA.AXIS_TITLE_POSITION,t),g=e.createOneWayDependency($E.AXIS_TITLE_PLACER);e.connect(i,g),e.connect(g,_),g.run();let y=e.getVariable(KE.BOUNDS,t),m=e.getIncomingDataflowOperator($E.EVAL_BBOX,y);e.connect(c,m),e.connect(p,m),e.connect(m,y)}function DA(t,e){let n=e.getVariable(KE.BOUNDS,lA(t.elements[0])),r=e.getVariable(KE.PROPERTY,gA.GRIDLINES_POSITION,t),i=e.createOneWayDependency($E.GRIDLINES_PLACER);e.connect(n,i),e.connect(i,r),i.run();let s=e.getVariable(KE.BOUNDS,t),o=e.getIncomingDataflowOperator($E.EVAL_BBOX,s);e.connect(r,o),e.connect(o,s)}function VA(t,e,n,r){let i,s=t.domain,o=t.range;switch(t.type){case"linear":case"log":{let a=Math.abs(o[0]-o[1]);i="width"==e||"x"==e?45:30;let l,c=Math.max(2,Math.floor(a/i));if("width"==e||"height"==e){let i=!!r&&(r.elements[0].parent.layout&&r.elements[0].parent.layout.type==HE.STACK);s[1]=t._scale.invert(i?VE(n)[e]:DE(n)[e])}if("log"===t.type){l=[];let e=t._scale.ticks();for(let t of e){let n=Math.log(t)/Math.log(10)+1e-6;Math.abs(n-Math.floor(n))<c/e.length&&l.push(t)}}else l=q(s[0],s[1],c);return l}case"point":{i="width"==e||"x"==e?80:30;let n=Math.floor(t.rangeExtent/s.length),r=Math.ceil(i/n);return"x"==e?s.filter((t,e)=>e%r==0):s}case"band":{i="width"==e||"x"==e?80:30;let n=Math.floor(t.rangeExtent/s.length),r=Math.max(1,Math.ceil(i/n));return s.filter((t,e)=>e%r==0)}case"time":{i="width"==e||"x"==e?80:30;let t,n,r=Math.floor((o[1]-o[0])/i),a=Math.ceil((s[1]-s[0])/r)/1e3,l=[1,60,3600,86400,2628003,31536e3],c=[q_,X_,Q_,rg,zg,Ug];for(let e=0;e<l.length-1;e++)if(a>=l[e]&&a<l[e+1])return t=Math.floor(a/l[e]),n=c[e],n(s[0],s[1],t);return a>l[l.length-1]?(t=Math.floor(a/l[l.length-1]),n=c[l.length-1],n(s[0],s[1],t)):[]}default:return[]}}function BA(t,e){e.removeChild(t)}function zA(t,e){let n=e||aA(t.element);delete n._encodings[UA(t.element)][t.channel],console.log("remove encoding",t.channel,t.attribute),function(t,e){let n=e.findVariable(KE.CHANNEL,[t.channel,t.element]);n||console.warn("cannot find encoding to remove from the dep graph");let r=n.incomingDataflow;e.deleteOperator(r)}(t,n._depGraph);for(let e of t.refElements)BA(e,n),wA(e,n._depGraph);t.clearRefElements()}function GA(t,e){if(!t||!t.scene)return[];let n=t.scene._encodings[UA(t)],r=[];n&&(r=r.concat(Object.values(n)));{let e=t.scene;for(let n in e._encodings){let i=n.split("_");i.pop(),i.join("_")===t.classId&&(r=r.concat(Object.values(e._encodings[n])))}}return r}function FA(t,e,n){for(let r in n._encodings){let i=n._encodings[r];if(i[e]&&i[e].attribute==t)return i[e]}return null}function jA(t,e){if(!t||!t.scene)return null;let n=t.scene._encodings[UA(t)];return n&&n[e]?n[e]:null}function UA(t){if(Array.isArray(t))return t.map(t=>UA(t)).join("_");if(t.classId)return t.classId;if("vertex"==t.type&&t._isAnyVertex)return t.parent.classId+"_vAny";if("vertex"==t.type&&t.dataScope){if(t.parent.type===Pw.Area){let e=t._index<t.parent._vertices.length/2;return t.parent.classId+"_v"+(e?0:t.parent._vertices.length-1)}return t.parent.classId+"_v"}return"vertex"==t.type?t.parent.classId+"_v"+t._index:"segment"==t.type&&t._dataScopeRef?t.parent.classId+"_s":"segment"==t.type?t.parent.classId+"_s"+t.parent.segments.indexOf(t):null}function YA(t,e){if(0==t.children.length)return[];let n=aA(t),r=t.type===Pw.Composite?t.children:[t.children[0]],i=Object.keys(n._encodings),s=[];for(let t of r){let e=t;for(;e;){if(e.classId&&s.indexOf(e.classId)<0&&s.push(e.classId),e.type===Pw.Glyph){e.children.forEach(t=>s.push(t.classId));break}if(!e.children)break;e=e.children[0]}}let o=[];for(let t of i)for(let r of s)0===t.indexOf(r)&&n._encodings[t][e]&&o.push(n._encodings[t][e]);return o}function HA(t){let e=jA(t,"y"),n=jA(t,"height");return e||n&&n.scales[0].domain[0]<0}function WA(t){let e=jA(t,"x"),n=jA(t,"width");return e||n&&n.scales[0].domain[0]<0}function qA(t,e){let n=function(t){let e=t.parent,n=[];for(;e.type!==Pw.Scene;)n.push(e),e=e.parent;return n}(t);for(let t of n)if(jA(t,e))return!1;return n.length>=2?n[n.length-2]:t}function $A(t,e,n){XA(t,e,n);let r=aA(t);if(!r)return;let i=cA(t,!0);for(let t of i)BE(t);for(let t of i)r.onChange(KE.CHANNEL,"x",t)}function XA(t,e,n){switch(t.type){case Pw.Rect:case Pw.Path:case Pw.Line:case Pw.Area:!function(t,e,n){for(let r of t.vertices)KA(r,e,n);t._updateBounds(),t._refBounds&&t._refBounds.translate(e,n)}(t,e,n),0===e&&0===n||(t._dirty=!0);break;case Pw.Group:case Pw.Collection:case Pw.Glyph:!function(t,e,n){for(let r of t.children)XA(r,e,n);t._layout&&(void 0!==t._layout._left&&(t._layout._left+=e),void 0!==t._layout._top&&(t._layout._top+=n),t._layout._cellBounds&&t._layout._cellBounds.forEach(t=>t.translate(e,n)));0===e&&0===n||(t._dirty=!0);t._updateBounds(),t._refBounds&&t._refBounds.translate(e,n)}(t,e,n);break;case"segment":!function(t,e,n){KA(t.vertex1,e,n),KA(t.vertex2,e,n)}(t,e,n),0===e&&0===n||(t.parent._dirty=!0);break;case"vertex":KA(t,e,n),0===e&&0===n||(t.parent._dirty=!0);break;default:!function(t,e,n){t._x+=e,t._y+=n,t._updateBounds(),t._refBounds&&t._refBounds.translate(e,n)}(t,e,n),0===e&&0===n||(t._dirty=!0)}}function KA(t,e,n){t.x+=e,t.y+=n}class ZA{constructor(){this._id=this.type+Dw(),this._type=Pw.Group,this._dataScopeRef=void 0,this._bounds=void 0,this._layout=void 0,this._children=[],this._sortBy={property:_E,descending:!1},this._z=0}get id(){return this._id}get type(){return this._type}get datum(){return eE(this._dataScopeRef)}get data(){return tE(this._dataScopeRef)}get children(){return this._children}addChild(t){this._children.indexOf(t)>=0||(t.parent&&t.parent.removeChild(t),this._children.push(t),t.parent=this)}addChildAt(t,e){t.parent&&t.parent.removeChild(t),this.children.splice(e,0,t),t.parent=this}removeChild(t){let e=this.children.indexOf(t);e>=0&&(this.children.splice(e,1),t.parent=null)}removeChildAt(t){this.children[t].parent=null,this.children.splice(t,1)}removeAll(){for(let t of this.children)t.parent=null;this._children=[]}get dataScope(){return this._dataScopeRef}set dataScope(t){if(this._dataScopeRef=Kw(t),void 0===this._dataScopeRef)for(let t of this.children)t.dataScope=void 0;else for(let t of this.children)t.dataScope?t.dataScope=lE(t.dataScope,this._dataScopeRef):t.dataScope=this._dataScopeRef}getInternalEncodings(t){if(0==this.children.length)return[];let e=this.children[0],n=this.getScene(),r=Object.keys(n.encodings),i=[];for(;e;){if(e.classId&&i.indexOf(e.classId)<0&&i.push(e.classId),e.type===Pw.Glyph){e.children.forEach(t=>i.push(t.classId));break}if(!e.children)break;e=e.children[0]}let s=[];for(let e of r){let r=e.split("_");for(let o of i)r[0]==o&&n.encodings[e][t]&&s.push(n.encodings[e][t])}return s}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(t){if(this._layout=t,t&&(t.group=this),MA(this,t,this.scene._depGraph),this.children&&this.children.length>0){let t=cA(this,!0);for(let e of t)this.scene.onChange(KE.CHANNEL,"x",e)}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){let t=this.children.map(t=>t.refBounds),e=d3.min(t.map(t=>t.left)),n=d3.min(t.map(t=>t.top)),r=d3.max(t.map(t=>t.right)),i=d3.max(t.map(t=>t.bottom));return new PE(e,n,r-e,i-n)}get x(){return this.bounds.x}get y(){return this.bounds.y}set x(t){$A(this,t-this.bounds.x,0)}set y(t){$A(this,0,t-this.bounds.y)}_updateBounds(){let t=this.children;if(t.length>0){this._bounds=t[0].bounds.clone();for(let e=1;e<t.length;e++)"hidden"!=t[e].visibility&&(this._bounds=this._bounds.union(t[e].bounds))}else this._bounds=new PE(0,0,0,0)}set visibility(t){let e="hidden"==t?"hidden":"visible";if(this.visibility!==e){this._visibility="hidden"==t?t:"visible";for(let e of this.children)e.visibility=t}}get visibility(){return this._visibility?this._visibility:"visible"}get z(){return this._z}set z(t){this._z!==t&&(this._z=t)}get scene(){return aA(this)}get sortBy(){return this._sortBy}}class JA extends ZA{constructor(t){super(),this._type=Pw.Collection,this._id=t.id?t.id:this._type+"_"+Dw(),this._classId=this.id,this._childrenOrder=void 0,this._clipMask=void 0}get classId(){return this._classId}getSVGPathData(){let t="";for(let e of this.children)if(e.getSVGPathData)t+=e.getSVGPathData();else if(e.bounds){let n=e.bounds;t+=["M",n.left,n.top].join(" "),t+=["L",n.right,n.top].join(" "),t+=["L",n.right,n.bottom].join(" "),t+=["L",n.left,n.bottom,"Z"].join(" ")}return t}createClipMask(){let t=DE(this._children);this._clipMask=new PE(t.left,t.top,t.width,t.height)}get clipMask(){return this._clipMask}}class QA extends ZA{constructor(t){if(super(),this._type=Pw.Glyph,this._id=t&&t.id?t.id:this.type+"_"+Dw(),this._classId=this._id,t&&t.children)for(let e of t.children)this.addChild(e)}get classId(){return this._classId}}const tS=Object.freeze({RowFirst:"rowFirst",ColumnFirst:"columnFirst"}),eS=Object.freeze({TopLeft:"topLeft",TopRight:"topRight",BottomLeft:"bottomLeft",BottomRight:"bottomRight"}),nS="horizontal",rS="vertical",iS="angular",sS="radial",oS={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"},aS=Object.freeze({CLOCKWISE:"clockwise",ANTI_CLOCKWISE:"anti-clockwise"}),lS=Object.freeze({INWARD:"inward",OUTWARD:"outward"}),cS=Object.freeze({INWARD:"inward",OUTWARD:"outward",TANGENTIAL_CLOCKWISE:"tangentialClockwise",TANGENTIAL_COUNTERCLOCKWISE:"tangentialCounterClockwise",UPRIGHT:"upright"});class uS{constructor(t,e){this.type="vertex",this.parent=t,this._index=e}_getStored(t){return this.parent._vertices.getProperty(this._index,t)}_setStored(t,e){this._getStored(t)!==e&&(this.parent._vertices.setProperty(this._index,t,e),this.parent._dirty=!0)}get datum(){return this.dataScope?eE(this.dataScope):this.parent.datum}get data(){return this.dataScope?tE(this.dataScope):this.parent.data}get dataScope(){return this.parent._vertices.getDataScopeRef(this._index)}set dataScope(t){this.dataScope!==t&&(this.parent._vertices.setDataScopeRef(this._index,t),this.parent._dirty=!0)}get bounds(){switch(this.shape){case"rect":return new PE(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new PE(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new PE(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this.parent._vertices._ids[this._index]}set polarAngle(t){this._setStored("polarAngle",t)}get polarAngle(){return this._getStored("polarAngle")}get _polarAngle(){return this.polarAngle}set _polarAngle(t){this.polarAngle=t}get scene(){return this.parent.scene}get x(){return this.parent._vertices._xs[this._index]}set x(t){this.parent._vertices._xs[this._index]!==t&&(this.parent._vertices._xs[this._index]=t,this.parent._dirty=!0)}get y(){return this.parent._vertices._ys[this._index]}set y(t){this.parent._vertices._ys[this._index]!==t&&(this.parent._vertices._ys[this._index]=t,this.parent._dirty=!0)}get shape(){return this._getStored("shape")}set shape(t){this._setStored("shape",t)}get width(){return this._getStored("width")}set width(t){this._setStored("width",t)}get height(){return this._getStored("height")}set height(t){this._setStored("height",t)}get radius(){return this._getStored("radius")}set radius(t){this._setStored("radius",t)}get fillColor(){return this._getStored("fillColor")}set fillColor(t){this._setStored("fillColor",t)}get opacity(){return this._getStored("opacity")}set opacity(t){this._setStored("opacity",t)}get strokeWidth(){return this._getStored("strokeWidth")}set strokeWidth(t){this._setStored("strokeWidth",t)}get strokeColor(){return this._getStored("strokeColor")}set strokeColor(t){this._setStored("strokeColor",t)}}uS.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class hS{constructor(t,e,n,r){this.type="segment",this._id=r,this._vertex1Index="number"==typeof t?t:t._index,this._vertex2Index="number"==typeof e?e:e._index,this._dataScopeRef=void 0,this.parent=n}get dataScope(){return this._dataScopeRef?this._dataScopeRef:this.parent.dataScope}set dataScope(t){this._dataScopeRef=Kw(t)}get datum(){return this.dataScope?eE(this.dataScope):this.parent.datum}get data(){return this.dataScope?tE(this.dataScope):this.parent.data}get id(){return this.parent.id+"_s_"+this._id}get vertex1(){return this.parent.vertices[this._vertex1Index]}set vertex1(t){this._vertex1Index="number"==typeof t?t:t._index}get vertex2(){return this.parent.vertices[this._vertex2Index]}set vertex2(t){this._vertex2Index="number"==typeof t?t:t._index}get x(){return(this.parent._vertices._xs[this._vertex1Index]+this.parent._vertices._xs[this._vertex2Index])/2}get y(){return(this.parent._vertices._ys[this._vertex1Index]+this.parent._vertices._ys[this._vertex2Index])/2}get scene(){return this.parent.scene}}class fS{constructor(t){return this._path=t,this.clear(),new Proxy(this,{get:(t,e)=>"length"===e?t.length:e===Symbol.iterator?t[Symbol.iterator].bind(t):fS._isIndex(e)?t.get(Number(e)):t[e],set(t,e,n){if(fS._isIndex(e))return t.replace(Number(e),n),!0;if("string"==typeof e&&"_"===e[0])return t[e]=n,!0;throw new Error("path.vertices is read-only; mutate vertex properties or use path.vertices = [...].")}})}static _isIndex(t){if("string"!=typeof t||""===t)return!1;let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t}static getCoords(t){return Array.isArray(t)?t:[t.x,t.y]}static getId(t){return t&&t.parent&&t.parent._vertices&&void 0!==t._index?t.parent._vertices._ids[t._index]:t?t.id:void 0}static get storageKeys(){return["_ids","_xs","_ys","_dataScopeRefs","_polarAngles","_shapes","_widths","_heights","_radii","_fillColors","_opacities","_strokeWidths","_strokeColors","_refs"]}static get propertyArrays(){return{dataScope:"_dataScopeRefs",polarAngle:"_polarAngles",shape:"_shapes",width:"_widths",height:"_heights",radius:"_radii",fillColor:"_fillColors",opacity:"_opacities",strokeWidth:"_strokeWidths",strokeColor:"_strokeColors"}}get length(){return this._xs.length}clear(){this._ids=[],this._xs=[],this._ys=[],this._dataScopeRefs=[],this._polarAngles=[],this._shapes=[],this._widths=[],this._heights=[],this._radii=[],this._fillColors=[],this._opacities=[],this._strokeWidths=[],this._strokeColors=[],this._refs=[]}get(t){if(!(t<0||t>=this.length))return this._refs[t]||(this._refs[t]=new uS(this._path,t)),this._refs[t]}at(t){return t<0&&(t=this.length+t),this.get(t)}append(t,e){let[n,r]=fS.getCoords(t),i=Array.isArray(t)?void 0:t.dataScope,s=void 0!==e?e:fS.getId(t),o=this.length;return this._ids.push(s),this._xs.push(n),this._ys.push(r),this._dataScopeRefs.push(i?this._copyDataScopeRef(i):void 0),this._polarAngles.push(Array.isArray(t)?void 0:t.polarAngle),this._shapes.push(Array.isArray(t)?void 0:t.shape),this._widths.push(Array.isArray(t)?0:t.width),this._heights.push(Array.isArray(t)?0:t.height),this._radii.push(Array.isArray(t)?0:t.radius),this._fillColors.push(Array.isArray(t)?"#555":t.fillColor),this._opacities.push(Array.isArray(t)?1:t.opacity),this._strokeWidths.push(Array.isArray(t)?0:t.strokeWidth),this._strokeColors.push(Array.isArray(t)?"#aaa":t.strokeColor),this._refs.push(void 0),o}insert(t,e,n,r){let i="number"==typeof e,s=i?[e,n]:fS.getCoords(e),o=s[0],a=s[1],l=i||Array.isArray(e)?void 0:e.dataScope,c=i?r:fS.getId(e);this._ids.splice(t,0,c),this._xs.splice(t,0,o),this._ys.splice(t,0,a),this._dataScopeRefs.splice(t,0,l?this._copyDataScopeRef(l):void 0),this._polarAngles.splice(t,0,i||Array.isArray(e)?void 0:e.polarAngle),this._shapes.splice(t,0,i||Array.isArray(e)?void 0:e.shape),this._widths.splice(t,0,i||Array.isArray(e)?0:e.width),this._heights.splice(t,0,i||Array.isArray(e)?0:e.height),this._radii.splice(t,0,i||Array.isArray(e)?0:e.radius),this._fillColors.splice(t,0,i||Array.isArray(e)?"#555":e.fillColor),this._opacities.splice(t,0,i||Array.isArray(e)?1:e.opacity),this._strokeWidths.splice(t,0,i||Array.isArray(e)?0:e.strokeWidth),this._strokeColors.splice(t,0,i||Array.isArray(e)?"#aaa":e.strokeColor),this._refs.splice(t,0,void 0),this._reindexRefs()}replace(t,e){let[n,r]=fS.getCoords(e),i=Array.isArray(e)?void 0:e.dataScope;this._xs[t]=n,this._ys[t]=r,this._dataScopeRefs[t]=i?this._copyDataScopeRef(i):void 0,this._polarAngles[t]=Array.isArray(e)?void 0:e.polarAngle,this._shapes[t]=Array.isArray(e)?void 0:e.shape,this._widths[t]=Array.isArray(e)?0:e.width,this._heights[t]=Array.isArray(e)?0:e.height,this._radii[t]=Array.isArray(e)?0:e.radius,this._fillColors[t]=Array.isArray(e)?"#555":e.fillColor,this._opacities[t]=Array.isArray(e)?1:e.opacity,this._strokeWidths[t]=Array.isArray(e)?0:e.strokeWidth,this._strokeColors[t]=Array.isArray(e)?"#aaa":e.strokeColor,this._refs[t]=void 0}copyFrom(t){this._ids=t._ids.slice(),this._xs=t._xs.slice(),this._ys=t._ys.slice(),this._dataScopeRefs=t._dataScopeRefs.map(t=>this._copyDataScopeRef(t)),this._polarAngles=t._polarAngles.slice(),this._shapes=t._shapes.slice(),this._widths=t._widths.slice(),this._heights=t._heights.slice(),this._radii=t._radii.slice(),this._fillColors=t._fillColors.slice(),this._opacities=t._opacities.slice(),this._strokeWidths=t._strokeWidths.slice(),this._strokeColors=t._strokeColors.slice(),this._refs=[]}getProperty(t,e){let n=fS.propertyArrays[e];return"dataScope"===e?this.getDataScopeRef(t):n?this[n][t]:void 0}setProperty(t,e,n){let r=fS.propertyArrays[e];r&&("dataScope"===e?this.setDataScopeRef(t,n):this[r][t]=n)}setDataScopeRef(t,e){this._dataScopeRefs[t]=e?this._copyDataScopeRef(e):void 0}getDataScopeRef(t){return this._dataScopeRefs[t]}hasDataScope(t){return!!this._dataScopeRefs[t]}getDataScopeRows(t){let e=this._dataScopeRefs[t];if(e)return tE(e)}getDataScopeAttrVal(t,e){let n=this._dataScopeRefs[t];if(n)return iE(n,e)}getDataScopeAttributeValues(t,e){let n=this._dataScopeRefs[t];return n?sE(n,e):[]}aggregateDataScopeAttribute(t,e,n){return oE(this._dataScopeRefs[t],e,n)}_copyDataScopeRef(t){return t?Kw(t):t}sort(t){let e=Array.from({length:this.length},(t,e)=>e);return e.sort((e,n)=>t(this.get(e),this.get(n))),this._reorder(e),this._path._reindexSegments(),this}reverse(){let t=Array.from({length:this.length},(t,e)=>this.length-e-1);return this._reorder(t),this._path._reindexSegments(),this}splice(t,e,...n){let r=this.slice(t,t+e);for(let n of fS.storageKeys)this[n].splice(t,e);for(let e=0;e<n.length;e++)this.insert(t+e,n[e],void 0);return this._reindexRefs(),this._path._reindexSegments(),r}push(...t){for(let e of t)this.append(e,void 0);return this._path._reindexSegments(),this.length}map(t,e){let n=[];for(let r=0;r<this.length;r++)n.push(t.call(e,this.get(r),r,this));return n}filter(t,e){let n=[];for(let r=0;r<this.length;r++){let i=this.get(r);t.call(e,i,r,this)&&n.push(i)}return n}find(t,e){for(let n=0;n<this.length;n++){let r=this.get(n);if(t.call(e,r,n,this))return r}}forEach(t,e){for(let n=0;n<this.length;n++)t.call(e,this.get(n),n,this)}slice(t,e){return Array.from(this).slice(t,e)}concat(...t){return Array.from(this).concat(...t)}entries(){let t=this;return function*(){for(let e=0;e<t.length;e++)yield[e,t.get(e)]}()}indexOf(t){return t&&t.parent===this._path?t._index:-1}includes(t){return this.indexOf(t)>=0}[Symbol.iterator](){let t=this;return function*(){for(let e=0;e<t.length;e++)yield t.get(e)}()}_reorder(t){for(let e of fS.storageKeys){let n=this[e];this[e]=t.map(t=>n[t])}this._reindexRefs()}_reindexRefs(){for(let t=0;t<this._refs.length;t++)this._refs[t]&&(this._refs[t]._index=t)}}class dS extends GE{constructor(t){super(t),this._type="type"in t?t.type:Pw.Path,this._vertices=new fS(this),this.vertexCounter=0,this._sortBy={},this.segmentCounter=0,this.segments=[],this.anchor=void 0,this.closed="closed"in t&&t.closed,this.curveMode="curveMode"in t?t.curveMode:"linear",this._vxShape=void 0,this._vxWidth=0,this._vxHeight=0,this._vxRadius=0,this._vxFillColor="#555555",this._vxStrokeColor="#aaaaaa",this._vxStrokeWidth=0,this._vxOpacity=1;for(let e of uS.styles)e in t&&(this["_"+e]=t[e]);"vertices"in t&&(this.vertices=t.vertices),this._sourceAnchor="sourceAnchor"in t?t.sourceAnchor:["center","middle"],this._targetAnchor="targetAnchor"in t?t.targetAnchor:["center","middle"],this._sourceOffset="sourceOffset"in t?t.sourceOffset:[0,0],this._targetOffset="targetOffset"in t?t.targetOffset:[0,0],this._strength="strength"in t?t.strength:.85,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}set vertices(t){if(this._vertices.clear(),this.segments=[],this.vertexCounter=0,this.segmentCounter=0,0===t.length)return this._dirty=!0,void(this._bounds=void 0);for(let e=0;e<t.length;e++){let n=fS.getCoords(t[e]),r=fS.getCoords(t[0]);if(e==t.length-1&&n[0]===r[0]&&n[1]===r[1]&&this.type===Pw.Path)continue;let i=Array.isArray(t[e])?this.vertexCounter++:fS.getId(t[e]),s=this._vertices.append(t[e],i);!Array.isArray(t[e])&&"number"==typeof i&&i>=this.vertexCounter&&(this.vertexCounter=i+1);for(let n of uS.styles){if(void 0===this[n])continue;let r=n.replace("vx",""),i=r[0].toLowerCase()+r.slice(1);(Array.isArray(t[e])||void 0===t[e][i])&&this._vertices.setProperty(s,i,this[n])}e>0&&this.segments.push(new hS(s-1,s,this,this.segmentCounter++))}let e=fS.getCoords(t[0]),n=fS.getCoords(t[t.length-1]);this._vertices.length>1&&(this.closed||e[0]===n[0]&&e[1]===n[1]||this.type===Pw.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new hS(this._vertices.length-1,0,this,this.segmentCounter++))),this._dirty=!0,this._updateBounds()}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles);for(let e of uS.styles)void 0!==this["_"+e]&&(t["_"+e]=this["_"+e]);this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t.closed=this.closed,t.curveMode=this.curveMode,t.vertexCounter=this.vertexCounter,t._vertices.copyFrom(this._vertices),t.segments=[],t.segmentCounter=0;for(let e=1;e<t._vertices.length;e++)t.segments.push(new hS(e-1,e,t,t.segmentCounter++));t.closed&&t.segments.push(new hS(t._vertices.length-1,0,t,t.segmentCounter++)),t._sourceAnchor=this._sourceAnchor.slice(),t._targetAnchor=this._targetAnchor.slice(),t._sourceOffset=this._sourceOffset.slice(),t._targetOffset=this._targetOffset.slice(),t._beta=this._beta}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get x(){return this.bounds.x}get y(){return this.bounds.y}set x(t){$A(this,t-this.bounds.x,0)}set y(t){$A(this,0,t-this.bounds.y)}resize(t,e,n,r){let i=this.bounds,s=0===i.width?1:i.width,o=0===i.height?1:i.height,a=this._vertices._xs,l=this._vertices._ys;if("right"===n)for(let e=0;e<this._vertices.length;e++)a[e]=i.right-t/s*(i.right-a[e]);else for(let e=0;e<this._vertices.length;e++)a[e]=i.left+t/s*(a[e]-i.left);if("top"===r)for(let t=0;t<this._vertices.length;t++)l[t]=i.top+e/o*(l[t]-i.top);else for(let t=0;t<this._vertices.length;t++)l[t]=i.bottom-e/o*(i.bottom-l[t]);this._updateBounds(),this._dirty=!0}_updateBounds(){let t=[],e=[];if(this._d){const n=this._d.match(/[a-zA-Z][^a-zA-Z]*/g),r=" ";n.forEach(n=>{let i=n.slice(1).trim().split(r).map(Number);for(let[n,r]of i.entries())n%2==0?t.push(r):e.push(r)})}else t=this._vertices._xs,e=this._vertices._ys;let n=et(t),r=et(e),i=Q(t),s=Q(e),o=i-n,a=s-r;if(this._bounds=new PE(n,r,o,a),this.type===Pw.Line||this.type===Pw.Path){let t=this.styles.strokeWidth?this.styles.strokeWidth:1;n===i?this._bounds=new PE(n-t/2,r,i-n+t,s-r):r===s&&(this._bounds=new PE(n,r-t/2,i-n,s-r+t))}}addVertex(t,e,n){void 0===n&&(n=this._vertices.length),this._vertices.insert(n,t,e,this.vertexCounter++),this._reindexSegments()}sortVertices(t,e){this._vertices.sort((e,n)=>e[t]-n[t]),e&&this._vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=t,e.vertex2=(t+1)%this._vertices.length}this._dirty=!0}sortVerticesByData(t,e,n){let r;r=n?(e,r)=>n.indexOf(e.datum[t])-n.indexOf(r.datum[t]):(e,n)=>e.datum[t]<n.datum[t]?-1:1,this._vertices.sort(r),e&&this._vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=t,e.vertex2=(t+1)%this._vertices.length}this._dirty=!0}getSVGPathData(){if(this._d)return this._d;if(this._vertices.length<2)return"";let t=To(),e=this._getD3CurveFunction(this.curveMode)(t);e.lineStart();for(let t=0;t<this._vertices.length;t++)e.point(this._vertices._xs[t],this._vertices._ys[t]);return this.closed&&e.point(this._vertices._xs[0],this._vertices._ys[0]),e.lineEnd(),t._}get firstVertex(){return this._vertices[0]}get anyVertex(){return this._anyVertexRef||(this._anyVertexRef=new uS(this,0),this._anyVertexRef._isAnyVertex=!0),this._anyVertexRef}get firstSegment(){return this.segments[0]}get lastVertex(){return this._vertices[this._vertices.length-1]}get lastSegment(){return this.segments[this.segments.length-1]}_reindexSegments(){for(let t=0;t<this.segments.length;t++)this.segments[t].vertex1=t,this.segments[t].vertex2=(t+1)%this._vertices.length}_getD3CurveFunction(t){switch(t){case gS.Natural:return lw;case gS.Basis:return Ix;case gS.BumpX:return $v;case gS.BumpY:return Xv;case gS.Linear:return Nv;case gS.Step:return uw;case gS.CatmullRom:return qx;case gS.Cardinal:return Gx;case gS.Bundle:return Vx.beta(.5);default:return Nv}}get vxShape(){return this._vxShape}get vxWidth(){return this._vxWidth}get vxHeight(){return this._vxHeight}get vxRadius(){return this._vxRadius}get vxFillColor(){return this._vxFillColor}get vxStrokeColor(){return this._vxStrokeColor}get vxStrokeWidth(){return this._vxStrokeWidth}get vxOpacity(){return this._vxOpacity}set vxOpacity(t){this._vxOpacity=t;for(let e of this.vertices)e.opacity=t}get sourceAnchor(){return this._sourceAnchor}get targetAnchor(){return this._targetAnchor}get sourceOffset(){return this._sourceOffset}get targetOffset(){return this._targetOffset}get strength(){return this._strength}set strength(t){this._strength=t,this._dirty=!0}get vertices(){return this._vertices}}function pS(t,e){const n=ME.getSVG();let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",t.getSVGPathData()),n.appendChild(r);let i=r.getTotalLength();return r.getPointAtLength(i*e)}function _S(t){return t instanceof dS&&t.source&&t.target}const gS={Natural:"natural",Basis:"basis",BumpX:"bumpX",BumpY:"bumpY",Bundle:"bundle",Linear:"linear",Step:"step",CatmullRom:"CatmullRom",Cardinal:"cardinal"};function yS(t,e,n){const r=t.match(/[a-zA-Z][^a-zA-Z]*/g),i=",",s=r.map(t=>{const r=t[0],s=t.slice(1).trim();if("M"===r||"L"===r||"T"===r){const[t,o]=s.split(i).map(Number);return`${r}${t+e} ${o+n}`}if("C"===r){const t=s.split(i).map(Number);return`${r}${t[0]+e} ${t[1]+n} ${t[2]+e} ${t[3]+n} ${t[4]+e} ${t[5]+n}`}if("Q"===r){const t=s.split(i).map(Number);return`${r}${t[0]+e} ${t[1]+n} ${t[2]+e} ${t[3]+n}`}if("A"===r){const t=s.split(i).map(Number);return`${r}${t[0]} ${t[1]} ${t[2]} ${t[3]} ${t[4]} ${t[5]+e} ${t[6]+n}`}return"Z"===r||"z"===r?r:t});return s.join(" ")}class mS extends dS{constructor(t){super(t),this._type=Pw.Arc,this.closed=!0,this._x="x"in t?t.x:100,this._y="y"in t?t.y:100,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200,this._thickness="thickness"in t?t.thickness:this._outerRadius-this._innerRadius,this._startAngle="startAngle"in t?t.startAngle:0,this._endAngle="endAngle"in t?t.endAngle:90,this._sr=bS(this._startAngle),this._er=bS(this._endAngle),this._direction="direction"in t?t.direction:aS.ANTI_CLOCKWISE;let e=this._x+this._innerRadius*Math.cos(this._sr),n=this._y-this._innerRadius*Math.sin(this._sr),r=this._x+this._innerRadius*Math.cos(this._er),i=this._y-this._innerRadius*Math.sin(this._er),s=this._x+this._outerRadius*Math.cos(this._sr),o=this._y-this._outerRadius*Math.sin(this._sr),a=this._x+this._outerRadius*Math.cos(this._er),l=this._y-this._outerRadius*Math.sin(this._er);this.vertices=[[e,n],[s,o],[a,l],[r,i]]}get type(){return 0===this._innerRadius?Pw.Pie:Pw.Arc}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}get direction(){return this._direction}get x(){return this._x}get y(){return this._y}get startAngle(){return this._startAngle}get endAngle(){return this._endAngle}get angle(){return this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle}setAngles(t,e){this._startAngle=t,this._endAngle=e,this._sr=bS(this._startAngle),this._er=bS(this._endAngle),this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._dirty=!0}_updateBounds(){let t=this.vertices.map(t=>t.x),e=this.vertices.map(t=>t.y),n=d3.min(t),r=d3.min(e),i=d3.max(t)-n,s=d3.max(e)-r;this._bounds=new PE(n,r,i,s)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius,t._startAngle=this._startAngle,t._endAngle=this._endAngle,t._thickness=this._thickness,t._direction=this._direction,t._sr=this._sr,t._er=this._er}getSVGPathData(){let t=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,e=t>180?1:0;return["M "+this.vertices[0].x+", "+this.vertices[0].y,"L "+this.vertices[1].x+", "+this.vertices[1].y,"A "+[this._outerRadius,this._outerRadius,t,e,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,t,e,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}}function bS(t){return t*Math.PI/180}function vS(t){return 180*t/Math.PI}function xS(t){return(t%360+360)%360}function wS(t,e,n,r){let i=t-n,s=r-e;return Math.atan2(s,i)*(180/Math.PI)}class ES extends dS{constructor(t){super(t),this._type=Pw.Area,this.closed=!0,this._orientation="orientation"in t?t.orientation:void 0,this._baseline="baseline"in t?t.baseline:void 0,t&&"vertices"in t&&this.segments.push(new hS(this.vertices.length-1,0,this,this.segmentCounter++))}get topLeftVertex(){return this._orientation===nS?this.vertices[0]:this.vertices[this.vertices.length-1]}get bottomLeftVertex(){return this._orientation===nS?this.vertices[this.vertices.length-1]:this.vertices[this.vertices.length/2]}get topRightVertex(){return this._orientation===nS?this.vertices[this.vertices.length/2-1]:this.vertices[0]}get bottomRightVertex(){return this._orientation===nS?this.vertices[this.vertices.length/2]:this.vertices[this.vertices.length/2-1]}get baseline(){return this._baseline}set baseline(t){this._baseline=t,this._dirty=!0}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this._dirty=!0}get firstVertexPair(){return[this.vertices[0],this.vertices[this.vertices.length-1]]}get width(){return this.vertices[this.vertices.length/2].x-this.vertices[0].x}get height(){return this.vertices[this.vertices.length/2].y-this.vertices[0].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}copyPropertiesTo(t){super.copyPropertiesTo(t),t._baseline=this._baseline,t._orientation=this._orientation}getSVGPathData(){return super.getSVGPathData()+" z"}}class AS extends dS{constructor(t){super(t),this._type=Pw.BezierCurve,this._orientation="orientation"in t?t.orientation:nS}get type(){return this._type}get orientation(){return this._orientation}copyPropertiesTo(t){super.copyPropertiesTo(t),t._orientation=this._orientation}getSVGPathData(){if(this._d)return this._d;let t="M ";return t+=this.vertices[0].x+" "+this.vertices[0].y+" ",t+="C "+this.vertices[1].x+" "+this.vertices[1].y+" ",t+=this.vertices[2].x+" "+this.vertices[2].y+" ",t+=this.vertices[3].x+" "+this.vertices[3].y,t}}class SS extends GE{constructor(t){super(t),this._type=Pw.Circle,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._radius="radius"in t?t.radius:100,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}set x(t){this._x=t,this._dirty=!0}set y(t){this._y=t,this._dirty=!0}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}set radius(t){this._radius=t,this._dirty=!0}get area(){return Math.PI*Math.pow(this._radius,2)}_updateBounds(){if(this._rotate){let t=OE(this._x,this._y,this._rotate[1],this._rotate[2],this._rotate[0]);this._bounds=new PE(t.x-this._radius,t.y-this._radius,2*this._radius,2*this._radius)}else this._bounds=new PE(this._x-this._radius,this._y-this._radius,2*this._radius,2*this._radius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._radius=this._radius}getSVGPathData(){return["M",this._x,this._y,"m",-this._radius,", 0 a",this._radius,",",this._radius,"0 1,0",2*this._radius,",0 a",this._radius,",",this._radius,"0 1,0",-2*this._radius,",0"].join(" ")}}let TS=class extends GE{constructor(t){super(t),this._type=Pw.Image,this._src=t.src,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._width="width"in t?t.width:100,this._height="height"in t?t.height:100}get src(){return this._src}set src(t){this._src=t,this._dirty=!0}get width(){return this._width}set width(t){this._width=t,this._updateBounds(),this._dirty=!0}get height(){return this._height}set height(t){this._height=t,this._updateBounds(),this._dirty=!0}resize(t,e){this._width=t,this._height=e,this._dirty=!0,this._updateBounds()}get x(){return this._x}set x(t){this._x=t,this._dirty=!0,this._updateBounds()}get y(){return this._y}set y(t){this._y=t,this._dirty=!0,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new PE(this._x,this._y,this._width,this._height)}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t.src=this._src}},CS=class extends GE{constructor(t){super(t),this._type=Pw.Symbol,this._path=t.path,this._viewBox="viewBox"in t?t.viewBox:[0,0,24,24],this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._width="width"in t?t.width:24,this._height="height"in t?t.height:24}get path(){return this._path}set path(t){this._path=t,this._dirty=!0}get viewBox(){return this._viewBox}set viewBox(t){this._viewBox=t,this._dirty=!0}get width(){return this._width}set width(t){this._width=t,this._updateBounds(),this._dirty=!0}get height(){return this._height}set height(t){this._height=t,this._updateBounds(),this._dirty=!0}resize(t,e){this._width=t,this._height=e,this._dirty=!0,this._updateBounds()}get x(){return this._x}set x(t){this._x=t,this._dirty=!0,this._updateBounds()}get y(){return this._y}set y(t){this._y=t,this._dirty=!0,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new PE(this._x,this._y,this._width,this._height)}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t.path=this._path,t.viewBox=this._viewBox}};class kS extends dS{constructor(t){super(t)}get x1(){return this.vertices[0].x}get y1(){return this.vertices[0].y}get x2(){return this.vertices[1].x}get y2(){return this.vertices[1].y}get x(){return(this.vertices[0].x+this.vertices[1].x)/2}get y(){return(this.vertices[0].y+this.vertices[1].y)/2}set x(t){let e=t-this.x;this.vertices[0].x+=e,this.vertices[1].x+=e,this._dirty=!0}set y(t){let e=t-this.y;this.vertices[0].y+=e,this.vertices[1].y+=e,this._dirty=!0}set x1(t){this.vertices[0].x=t,this._dirty=!0}set x2(t){this.vertices[1].x=t,this._dirty=!0}set y1(t){this.vertices[0].y=t,this._dirty=!0}set y2(t){this.vertices[1].y=t,this._dirty=!0}}const RS="filled",MS="none";class OS extends dS{constructor(t={}){const e="x1"in t?t.x1:0,n="y1"in t?t.y1:0,r="x2"in t?t.x2:100,i="y2"in t?t.y2:0,s=[[e,n],...t.controlPoints||[],[r,i]];super({...t,type:Pw.Arrow,vertices:s}),this._startStyle=t.startStyle??MS,this._startSize=t.startSize??8,this._endStyle=t.endStyle??RS,this._endSize=t.endSize??8}get x1(){return this.vertices[0].x}set x1(t){this.vertices[0].x=t,this._dirty=!0}get y1(){return this.vertices[0].y}set y1(t){this.vertices[0].y=t,this._dirty=!0}get x2(){return this.vertices[this.vertices.length-1].x}set x2(t){this.vertices[this.vertices.length-1].x=t,this._dirty=!0}get y2(){return this.vertices[this.vertices.length-1].y}set y2(t){this.vertices[this.vertices.length-1].y=t,this._dirty=!0}get startStyle(){return this._startStyle}set startStyle(t){this._startStyle=t,this._dirty=!0}get startSize(){return this._startSize}set startSize(t){this._startSize=t,this._dirty=!0}get endStyle(){return this._endStyle}set endStyle(t){this._endStyle=t,this._dirty=!0}get endSize(){return this._endSize}set endSize(t){this._endSize=t,this._dirty=!0}}class NS extends GE{constructor(t){super(t),this._type=Pw.SimpleText,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._text="text"in t?t.text:"",this._anchor="anchor"in t?t.anchor:[zE.CENTER,zE.MIDDLE],this._textPath=void 0,this._textPathOffset="50%","fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),"backgroundColor"in t&&(this._backgroundColor=t.backgroundColor),"borderWidth"in t&&(this._borderWidth=t.borderWidth),"borderColor"in t&&(this._borderColor=t.borderColor),this._rotate="rotate"in t?t.rotate:void 0}hasBackground(){return this._backgroundColor||this._borderStroke||this._borderColor}_updateBounds(){let t,e,n=function(t,e,n){const r=ME.getSVG(),i=document.createElementNS("http://www.w3.org/2000/svg","text");i.setAttribute("font-family",e),i.setAttribute("font-size",n),i.textContent=t,r.appendChild(i);const s=i.getBBox();return r.removeChild(i),{width:s.width,height:s.height}}(this._text,[this.fontWeight,this.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),r=n.width,i=n.height;switch(this._anchor[0]){case zE.LEFT:t=this._x;break;case zE.RIGHT:t=this._x-r;break;case zE.CENTER:t=this._x-r/2;break;default:t=this._x}switch(this._anchor[1]){case zE.TOP:e=this._y;break;case zE.BOTTOM:e=this._y-i;break;case zE.MIDDLE:default:e=this._y-i/2}if(this._rotate&&3===this._rotate.length){let n=[{x:t,y:e},{x:t+r,y:e},{x:t,y:e+i},{x:t+r,y:e+i}].map(t=>OE(t.x,t.y,this._rotate[1],this._rotate[2],this._rotate[0])),s=d3.min(n.map(t=>t.x)),o=d3.max(n.map(t=>t.x)),a=d3.min(n.map(t=>t.y)),l=d3.max(n.map(t=>t.y));this._bounds=new PE(s,a,o-s,l-a)}else this._bounds=new PE(t,e,r,i)}get x(){return this._x}set x(t){this._x=t,this._dirty=!0}get y(){return this._y}set y(t){this._y=t,this._dirty=!0}get text(){return this._text}set text(t){this._text=t,this._dirty=!0}get anchor(){return this._anchor}get fontFamily(){return this.styles.fontFamily}get fontSize(){return this.styles.fontSize}get fontWeight(){return this.styles.fontWeight}set fontWeight(t){this.styles.fontWeight=t,this._dirty=!0}get textPath(){return this._textPath}set textPath(t){this._textPath=t,this._dirty=!0}get textPathOffset(){return this._textPathOffset}set textPathOffset(t){this._textPathOffset=t,this._dirty=!0}get backgroundColor(){return this._backgroundColor?this._backgroundColor:"#fff"}get borderColor(){return this._borderColor?this._borderColor:"#ccc"}get borderWidth(){return this._borderWidth?this._borderWidth:1}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t._x=this._x,t._y=this._y,t._text=this._text,t._anchor=[this._anchor[0],this._anchor[1]],t._backgroundColor=this._backgroundColor,t._borderColor=this._borderColor,t._borderStroke=this._borderStroke}}class IS extends dS{constructor(t){super(t),this._type=Pw.Polygon,this.closed=!0,"x"in t&&(this._x=t.x),"y"in t&&(this._y=t.y),"radius"in t&&(this._radius=t.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}set x(t){this._x=t,this._dirty=!0}set y(t){this._y=t,this._dirty=!0}set radius(t){this._radius=t,this._dirty=!0}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._radius=this._radius}}class PS extends dS{constructor(t){super(t)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}get right(){return this.vertices[1].x}get bottom(){return this.vertices[2].y}get area(){return this.width*this.height}setBounds(t,e,n,r){this.vertices[0].x=t,this.vertices[0].y=e,this.vertices[1].x=t+n,this.vertices[1].y=e,this.vertices[2].x=t+n,this.vertices[2].y=e+r,this.vertices[3].x=t,this.vertices[3].y=e+r,this._dirty=!0}resize(t,e,n,r){t!==this.width&&("right"===n?(this.vertices[1].x=this.refBounds.right,this.vertices[2].x=this.refBounds.right,this.vertices[0].x=this.vertices[1].x-t,this.vertices[3].x=this.vertices[0].x):(this.vertices[0].x=this.refBounds.left,this.vertices[3].x=this.refBounds.left,this.vertices[1].x=this.vertices[0].x+t,this.vertices[2].x=this.vertices[1].x)),e!==this.height&&("top"===r?(this.vertices[0].y=this.refBounds.top,this.vertices[1].y=this.refBounds.top,this.vertices[3].y=this.vertices[0].y+e,this.vertices[2].y=this.vertices[3].y):(this.vertices[2].y=this.refBounds.bottom,this.vertices[3].y=this.refBounds.bottom,this.vertices[0].y=this.vertices[3].y-e,this.vertices[1].y=this.vertices[0].y)),this._dirty=!0}get leftSegment(){return this.segments[3]}get rightSegment(){return this.segments[1]}get topSegment(){return this.segments[0]}get bottomSegment(){return this.segments[2]}}class LS extends dS{constructor(t){super(t),this._type=Pw.Ring,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get x(){return this._x}get y(){return this._y}get thickness(){return this._outerRadius-this._innerRadius}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius}getSVGPathData(){return["M "+this._x+" "+this._y,"m 0, -"+this._outerRadius,"a "+this._outerRadius+","+this._outerRadius+", 0, 1, 0, 1, 0","Z","m 0 "+(this._outerRadius-this._innerRadius),"a "+this._innerRadius+", "+this._innerRadius+", 0, 1, 1, -1, 0","Z"].join(" ")}}class DS extends GE{constructor(t){super(t),this._type=Pw.RichText,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._text="text"in t?t.text:"",this._width="width"in t?t.width:200,this._anchor="anchor"in t?t.anchor:[zE.CENTER,zE.MIDDLE],"fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),"backgroundColor"in t&&(this._backgroundColor=t.backgroundColor),"borderWidth"in t&&(this._borderWidth=t.borderWidth),"borderColor"in t&&(this._borderColor=t.borderColor),this._rotate="rotate"in t?t.rotate:void 0}hasBackground(){return this._backgroundColor||this._borderStroke||this._borderColor}_updateBounds(){let t,e,n=function(t,e,n){const r=ME.getSVG(),i=document.createElementNS("http://www.w3.org/2000/svg","text");i.setAttribute("font-family",e),i.setAttribute("font-size",n),i.textContent=t,r.appendChild(i);const s=i.getBBox();return r.removeChild(i),{width:s.width,height:s.height}}(this._text,[this.fontWeight,this.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),r=n.width,i=n.height;switch(this._anchor[0]){case zE.LEFT:t=this._x;break;case zE.RIGHT:t=this._x-r;break;case zE.CENTER:t=this._x-r/2;break;default:t=this._x}switch(this._anchor[1]){case zE.TOP:e=this._y;break;case zE.BOTTOM:e=this._y-i;break;case zE.MIDDLE:default:e=this._y-i/2}if(this._rotate&&3===this._rotate.length){let n=[{x:t,y:e},{x:t+r,y:e},{x:t,y:e+i},{x:t+r,y:e+i}].map(t=>OE(t.x,t.y,this._rotate[1],this._rotate[2],this._rotate[0])),s=d3.min(n.map(t=>t.x)),o=d3.max(n.map(t=>t.x)),a=d3.min(n.map(t=>t.y)),l=d3.max(n.map(t=>t.y));this._bounds=new PE(s,a,o-s,l-a)}else this._bounds=new PE(t,e,r,i)}get x(){return this._x}get y(){return this._y}set x(t){this._x=t,this._dirty=!0}set y(t){this._y=t,this._dirty=!0}get text(){return this._text}set text(t){this._text=t,this._dirty=!0}get anchor(){return this._anchor}get fontFamily(){return this.styles.fontFamily}get fontSize(){return this.styles.fontSize}get fontWeight(){return this.styles.fontWeight}get textPath(){return this._textPath}set textPath(t){this._textPath=t,this._dirty=!0}get textPathOffset(){return this._textPathOffset}set textPathOffset(t){this._textPathOffset=t,this._dirty=!0}get backgroundColor(){return this._backgroundColor?this._backgroundColor:"#fff"}get borderColor(){return this._borderColor?this._borderColor:"#ccc"}get borderWidth(){return this._borderWidth?this._borderWidth:1}get width(){return this._width}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScopeRef&&(t.dataScope=this._dataScopeRef),t._x=this._x,t._y=this._y,t._text=this._text,t._anchor=[this._anchor[0],this._anchor[1]],t._backgroundColor=this._backgroundColor,t._borderColor=this._borderColor,t._borderStroke=this._borderStroke}}class VS{constructor(t){let e=t||{};this._stops=[],this.type=Pw.LinearGradient,this.id=this.type+Dw(),this.x1="x1"in e?e.x1:0,this.x2="x2"in e?e.x2:100,this.y1="y1"in e?e.y1:0,this.y2="y2"in e?e.y2:0}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.x1=this.x1,t.x2=this.x2,t.y1=this.y1,t.y2=this.y2,t.stops=this._stops,t}addStop(t,e,n){this._stops.push({offset:t,color:e,opacity:n})}get stops(){return this._stops}}class BS{constructor(t){this.type=Pw.PathGradient,this.id=this.type+Dw(),this._colors=t?t.slice():[]}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.colors=this._colors.slice(),t}get colors(){return this._colors}set colors(t){this._colors=t}}class zS extends ZA{constructor(t){super(),this._type=Pw.Axis,this._id=t.id?t.id:this._type+Dw(),this._attribute=void 0,this._channel=void 0,this._orientation=void 0,this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._textColor="textColor"in t?t.textColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._tickOffset="tickOffset"in t?t.tickOffset:0,this._tickSize="tickSize"in t?t.tickSize:5,this._tickAnchor=t.tickAnchor,this._tickVisible=!("tickVisible"in t)||t.tickVisible,this._pathVisible=!("pathVisible"in t)||t.pathVisible,this._labelVisible=!("labelVisible"in t)||t.labelVisible,this._labelOffset="labelOffset"in t?t.labelOffset:this._tickSize+this._tickOffset+3,this._labelFormat="labelFormat"in t?t.labelFormat:"",this._titleOffset="titleOffset"in t?t.titleOffset:40,this._rotateYTitle=!("rotateTitle"in t&&!t.rotateTitle),this._showTitle=!("titleVisible"in t)||t.titleVisible,this._labelRotation="labelRotation"in t?t.labelRotation:0,this._ticks=new ZA,this._ticks._id=this._id+"_ticks",this.addChild(this._ticks),this._labels=new ZA,this._labels._id=this._id+"_labels",this.addChild(this._labels),this._title=new NS({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title._id=this.id+"_title",this.addChild(this._title),this._showTitle||(this._title.visibility="hidden"),this._pathPos=void 0,this._args=t}get id(){return this._id}get pathPosition(){return this._pathPos}get pathVisible(){return this._pathVisible}get attribute(){return this._attribute}get channel(){return this._channel}get orientation(){return this._orientation}get ticksVisible(){return this._tickVisible}get labelsVisible(){return this._labelVisible}get tickSize(){return this._tickSize}get tickOffset(){return this._tickOffset}get tickAnchor(){return this._tickAnchor?this._tickAnchor:"x"===this._channel||"width"===this._channel?"center":"middle"}get labelOffset(){return this._labelOffset}get labelFormat(){return this._labelFormat}get labelRotation(){return this._labelRotation}get tickValues(){return this._tickValues}get labelValues(){return this._labelValues}get titleOffset(){return this._titleOffset}get titleVisisble(){return this._showTitle}get boundsWithoutTitle(){let t=this.children.filter(t=>t.type!==Pw.SimpleText),e=t[0].bounds.clone();for(let n=1;n<t.length;n++)"hidden"!=t[n].visibility&&(e=e.union(t[n].bounds));return e}get strokeColor(){return this._strokeColor}get textColor(){return this._textColor}}const GS="top",FS="bottom",jS="left";function US(t,e,n){if(t&&t.origin)return t.origin;let r=e[0].parent;if(r.type===Pw.Polygon)return[r.x,r.y];throw new Error('Mascot: "polarRadius"/"polarAngle" '+n+' need an explicit {origin: [x, y]} option (passed to encode(), or to gridlines()/axis() themselves) because the encoded shape has no fixed center of its own -- e.g. it came from densify() on a "line" mark rather than a "circle".')}class YS extends zS{constructor(t,e,n,r){if(super(r),this._encoding=t,this._attribute=this._encoding.attribute,this._channel=this._encoding.channel,this._scale=e,this._elems=n,this._flip="flip"in r&&r.flip,this._posArg="x"==this._channel||"width"==this._channel?r.pathY:r.pathX,this._orientation="orientation"in r?r.orientation:"x"===this._channel||"width"==this._channel?FS:jS,this._titleText="title"in r?r.title:this._encoding.sourceAttribute??this._encoding.attribute,this._path="angle"===this._channel||"polarAngle"===this._channel?new SS({strokeColor:this._strokeColor,id:this._id+"_path"}):new dS({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(r),t.dataTable.type(this._attribute)!==Vw.Date||"labelFormat"in r||(this._labelFormat="%m/%d/%y"),"polarRadius"===this._channel&&"rotation"in r){let[t,e]=this.origin;this._rotate=[-r.rotation,t,e]}"polarAngle"===this._channel&&(this._radius="radius"in r?r.radius:100)}get radius(){return this._radius}get origin(){return US(this._args,this._elems,"axis")}isFlipped(){return this._flip}get elements(){return this._elems}get scale(){return this._scale}get encoding(){return this._encoding}get includeZero(){return this._encoding.includeZero}createTicksLabels(t){"tickValues"in t?(this._tickValues=t.tickValues,this._labelValues="labelValues"in t?t.labelValues:t.tickValues):(this._tickValues=VA(this._scale,this._channel,this._elems,this),this._labelValues="labelValues"in t?t.labelValues:this._tickValues),this._ticks.removeAll();for(let t=0;t<this._tickValues.length;t++){let e=new dS({strokeColor:this._strokeColor,id:this._id+"_tick"+t});this._tickVisible||(e.visibility="hidden"),this._ticks.addChild(e)}this._labels.removeAll();let e,n=this._encoding.dataTable.type(this._attribute);if("labelValues"in t)e=function(t){return t};else switch(n){case Vw.Date:e=iy(this._labelFormat);break;case Vw.String:e=function(t){return t};break;default:e=Hl(this._labelFormat)}for(let[t,n]of this._labelValues.entries()){let r=new NS({text:e(n),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+t});this._labelVisible||(r.visibility="hidden"),this._labels.addChild(r)}this._title._text=this._titleText}}class HS{constructor(t,e){switch(this._id="scale_"+Dw(),this._type=t,e&&(this._args=e),t){case"linear":this._scale=__();break;case"point":this._scale=r_();break;case"band":this._scale=e_().padding(0);break;case"ordinal":this._scale=t_();break;case"ordinalColor":this._scale=t_(Nw[e.scheme]);break;case"power":this._scale=N_().exponent(2);break;case"sqrt":this._scale=N_().exponent(.5);break;case"log":this._scale=A_();break;case"identity":case"time":this._scale=Mm();break;case"sequentialColor":e.scheme?this._scale=Im(Nw[e.scheme]):this._scale=Im()}}get id(){return this._id}get domain(){return this._scale.domain()}set domain(t){this._scale.domain(t)}get range(){return this._scale.range()}set range(t){this._scale.range(t)}get rangeExtent(){let t=this._scale.range();return Math.abs(t[1]-t[0])}set rangeExtent(t){let e=this._scale.range();e[0]<e[1]?this._scale.range([e[0],e[0]+t]):this._scale.range([e[1]+t,e[1]])}get type(){return this._type}map(t){return this._scale(t)}invert(t,e){let n=et(this._scale.range()),r=Q(this._scale.range()),i=t;if(e||(i=Q([n,et([t,r])])),"time"===this._type)return this._scale.invert(i).getTime();if(["point","band","ordinal","ordinalColor"].includes(this._type)){return this._scale.domain().reduce((t,e)=>{let n=this._scale(e);"band"===this._type&&(n+=this._scale.bandwidth()/2);let r=this._scale(t);return"band"===this._type&&(r+=this._scale.bandwidth()/2),Math.abs(n-i)<Math.abs(r-i)?e:t})}return this._scale.invert(i)}}function WS(t){if(t.scaleType)return new HS(t.scaleType);if(t._baseEnc&&t._baseEnc.scales.length>0){let e=t._baseEnc.scales[0];return new HS(e.type,e._args)}if("text"===t.channel||"src"===t.channel||"path"===t.channel)return new HS("ordinal");switch(t.dataTable.type(t.attribute)){case Vw.Boolean:break;case Vw.Date:return new HS("time");case Vw.String:if("count"==t.aggregator)return new HS("linear");if(t.channel.indexOf("Color")>=0||"fillGradient"===t.channel||"strokeGradient"===t.channel){let e={};return e.scheme=t.colorScheme?t.colorScheme:"schemeCategory10",new HS("ordinalColor",e)}return new HS("point");default:return["strokeColor","fillColor","fillGradient","strokeGradient"].indexOf(t.channel)>=0?t.mapping?new HS("linear"):new HS("sequentialColor",{scheme:t.colorScheme}):new HS("linear")}}const qS=["schemeBrBG","schemePRGn","schemePiYG","schemePuOr","schemeRdBu","schemeRdGy","schemeRdYlBu","schemeRdYlGn","schemeSpectral"],$S=["schemeBlues","schemeGreens","schemeGreys","schemeOranges","schemePurples","schemeReds","schemeBuGn","schemeBuPu","schemeGnBu","schemeOrRd","schemePuBuGn","schemePuBu","schemePuRd","schemeRdPu","schemeYlGnBu","schemeYlGn","schemeYlOrBr","schemeYlOrRd"];class XS extends dS{constructor(t,e,n,r,i){super(i),this._type=Pw.Gridlines,this._id=this._type+Dw(),this._attribute=e,this._channel=t,this._scale=n,this._elems=r,this._args=i,"strokeColor"in i||(this.styles.strokeColor="#ddd"),"opacity"in i||(this.styles.opacity=.5),this.updateValues(),this._lines=[]}updateValues(){"values"in this._args?this._values=this._args.values:this._scale?this._values=VA(this._scale,this._channel,this._elems):this._values=this._elems.map(t=>t.datum[this._attribute])}get type(){return this._type}get id(){return this._id}getSVGPathData(){let t="";if("polarRadius"===this._channel)for(let e of this._lines)t+="M "+e.x+" "+e.y+" m -"+e.r+" 0 a "+e.r+" "+e.r+" 0 1 0 "+2*e.r+" 0 a "+e.r+" "+e.r+" 0 1 0 -"+2*e.r+" 0 ";else for(let e of this._lines)t+=["M",e.x1,e.y1].join(" ")+[" L",e.x2,e.y2].join(" ")+" ";return t}_updateBounds(){if("polarRadius"===this._channel){let t=this._lines.map(t=>new PE(t.x-t.r,t.y-t.y,2*t.r,2*t.r));this._bounds=LE(t)}else{let t=this._lines.map(t=>t.x1).concat(this._lines.map(t=>t.x2)),e=this._lines.map(t=>t.y1).concat(this._lines.map(t=>t.y2)),n=d3.min(t),r=d3.max(t),i=d3.min(e),s=d3.max(e);this._bounds=new PE(n,i,r-n,s-i)}}get elements(){return this._elems}get values(){return this._values}get channel(){return this._channel}get attribute(){return this._attribute}get scale(){return this._scale}get origin(){return US(this._args,this._elems,"gridlines")}get lines(){return this._lines}set lines(t){this._lines=t}}class KS{constructor(t,e,n,r,i){this._id="encoding_"+Dw(),this._elem=t,this._channel=e,this._attribute=n,this._table=i.table,this._aggregator=r,this._includeZero=i.includeZero,this._flipScale=i.flipScale,this._mapping=i.mapping,this._preferredRangeExtent=i.rangeExtent,this._preferredRangeStart=i.rangeStart,this._preferredDomain=i.domain,this._preferredRange=i.range,this._preferredOrigin=i.origin,this._scaleType=i.scaleType,this._colorScheme=i.scheme,this._forLegend=i.forLegend,this._sourceAttribute=i.sourceAttribute??null,i.shareScale&&(this._baseEnc=i.shareScale),this._scales=[],this._elemGroups=[],this._elem2scale={},this._refElements=[],["width","height","radius","angle","thickness","polarRadius","strokeWidth","area"].indexOf(this._channel)>=0&&(this._includeZero=!0),this.initialize()}get id(){return this._id}initialize(){if(this._scales=[],this._elemGroups=[],"vertex"===this._elem.type){let t,e=lA(this._elem),n=JE(this._elem.parent);if("x"!==this._channel&&"y"!==this._channel||!e.layout||e.layout.type!=HE.GRID)t=WA(this._elem.parent)||HA(this._elem.parent)?n.map(t=>eA(this._elem,[t])):[eA(this._elem,n)];else{t=("x"===this._channel?e.layout.getElementsByCol(!0,this._elem.parent):e.layout.getElementsByRow(!0,this._elem.parent)).map(t=>eA(this._elem,t))}for(let e of t)this._createScaleForVertexIndices(e)}else if("x"===this._channel||"y"===this._channel){let t=this._elem,e=lA(t);if(e.layout&&e.layout.type==HE.GRID){let n="x"===this._channel?e.layout.getElementsByCol(!0,t):e.layout.getElementsByRow(!0,t);for(let t of n)this._createScaleForElems(t)}else{let t=JE(this._elem);this._createScaleForElems(t)}}else if("angle"===this._channel){let t=JE(this._elem).reduce((t,e)=>{const n=e.parent.id;return t[n]||(t[n]=[]),t[n].push(e),t},{}),e=Object.values(t);for(let t of e)this._createScaleForElems(t)}else{let t=JE(this._elem);this._createScaleForElems(t)}}_createScaleForElems(t){this._elemGroups.push(t);var e=WS(this);this._scales.push(e);for(let n of t)this._elem2scale[n.id]=e}_createScaleForVertexIndices(t){this._elemGroups.push({type:"vertexIndices",groups:t});var e=WS(this);this._scales.push(e);for(let n of t)for(let t of n.indices)this._elem2scale[tA(n.parent,t)]=e}refreshElementMappings(){if(1===this._scales.length)if(this._elem2scale={},"vertex"===this._elem.type){let t=JE(this._elem.parent),e=eA(this._elem,t);this._elemGroups=[{type:"vertexIndices",groups:e}];for(let t of e)for(let e of t.indices)this._elem2scale[tA(t.parent,e)]=this._scales[0]}else{let t=JE(this._elem);this._elemGroups=[t];for(let e of t)this._elem2scale[e.id]=this._scales[0]}}getScale(t){return this._elem2scale[t.id]}getAttrValue(t,e,n){let r=(e?this.getScale(e):this._scales[0]).invert(t,n),i=this._attribute;if(this.dataTable.type(i)===Vw.Date){const t=this.dataTable.values(i).slice().sort((t,e)=>t-e);let e=a(t,r);return e=Math.min(e,t.length-1),e>0&&Math.abs(t[e-1]-r)<Math.abs(t[e]-r)&&e--,t[e]}return r}getChannelValue(t,e){return(e?this.getScale(e):this._scales[0]).map(t)}getElements(t){let e=this._scales.indexOf(t);return this._elemGroups[e]}getNormalizedElements(t){let e=this.getElements(t);return e&&"vertexIndices"===e.type?Array.from(new Set(e.groups.map(t=>t.parent))):e}get elementGroups(){return this._elemGroups}get element(){return this._elem}get channel(){return this._channel}get origin(){return this._preferredOrigin}get attribute(){return this._attribute}get sourceAttribute(){return this._sourceAttribute}set attribute(t){let e=this._attribute;this._attribute=t;for(let e of this._refElements)e instanceof YS?(e._attribute=t,e.createTicksLabels({}),e._titleText&&(e._titleText=this._sourceAttribute??t)):e instanceof XS&&(e._attribute=t,e.updateValues());const n=this._elem.scene._depGraph.getVariable(KE.ATTRIBUTE,e,this.dataTable,this);n&&(n._attribute=t,this._elem.scene.onChange(KE.ATTRIBUTE,t,this.dataTable,this))}get dataTable(){return this._table}get aggregator(){return this._aggregator}hasMultipleScales(){return this._scales.length>0}get scales(){return this._scales}getRangeStart(t){return et(this.getScale(t).range)}getRangeExtent(t){return this.getScale(t).rangeExtent}get domain(){if(1===this._scales.length)return this._scales[0].domain;throw new Error("AttributeEncoding: multiple scales exist, specify element to get domain.")}get rangeExtent(){if(1===this._scales.length)return this._scales[0].rangeExtent;throw new Error("AttributeEncoding: multiple scales exist, specify element to get rangeExtent.")}get scaleType(){return this._scaleType}set scaleType(t){this._scaleType=t}getDomain(t){return this.getScale(t).domain}set domain(t){this._preferredDomain=t;for(let e of this._scales)e._scale.domain(t);for(let t of this._refElements)t instanceof YS&&t.createTicksLabels({});this._elem.scene.onChange(KE.ATTR_VALUE,this)}set rangeExtent(t){let e=t<1?1:Math.round(t);for(let t of this._scales)t.rangeExtent=e;for(let t of this._refElements)t instanceof YS&&t.createTicksLabels({});this._elem.scene.onChange(KE.PROPERTY,gA.RANGE_EXTENT,this)}set includeZero(t){this._includeZero=t;for(let t of this._refElements)t instanceof YS&&t.createTicksLabels({});this._elem.scene.onChange(KE.PROPERTY,gA.INCLUDE_ZERO,this)}get includeZero(){return this._includeZero}set flipScale(t){this._flipScale=t,this._elem.scene.onChange(KE.PROPERTY,gA.FLIP_SCALE,this)}get flipScale(){return this._flipScale}set mapping(t){this._mapping=t}get mapping(){return this._mapping}set colorScheme(t){this._colorScheme=t}get colorScheme(){return this._colorScheme}addRefElement(t){this._refElements.indexOf(t)<0&&this._refElements.push(t)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}zoom(t,e,n,r){let i=r||this._elem,s=this.getDomain(i),o=et(s),a=Q(s),l="log"!==this._scales[0].type,c=this.getAttrValue(e,i,l),u=o-(c-o)*t*n,h=a+(a-c)*t*n;u!==h&&(!l&&u<=0||(this.domain=[u,h]))}}function ZS(t,e,n,r={}){let i={channel:e,attribute:n,...r};if("rowId"===i.attribute&&(i.attribute=_E),function(t,e,n){if(!t||!e||!n)throw new Error("encode(elem, channel, attribute) — all three arguments are required");if(!Object.values(fA).includes(e))throw new Error(`Unknown channel "${e}"`);let r=pE(t);if(r&&r.tree){if(n.indexOf(".")>0&&!r.tree.nodeTable.has(n.split(".")[1]))throw new Error(`Data attribute "${n}" does not exist in the data table`)}else if(!r||!r.has(n))throw new Error(`Data attribute "${n}" does not exist in the data table`)}(t,e,n),i.shareScale){let t=i.shareScale;if(t.channel!=i.channel&&t.channel.indexOf("Color")<0&&i.channel.indexOf("Color")<0)throw new Error("Cannot share scales between "+t.channel+" and "+i.channel+" encodings");i.scheme=i.shareScale.colorScheme}!function(t){let e;"vertex"===t.type&&t.parent.type===Pw.Area?e=t.parent:t.type===Pw.Area&&(e=t),e&&!e._refBounds&&JE(e).forEach(t=>t._refBounds=t.bounds.clone())}(t);let s=i.aggregator?i.aggregator:"sum";i.table=pE(t);let o=new KS(t,i.channel,i.attribute,s,i),a=t.scene;return a._addAttributeEncoding(o),IA(o,a._depGraph,i.shareScale),i.shareScale?a.onChange(KE.ATTR_VALUE,o):a.onChange(KE.CHANNEL,i.channel,t),o}function JS(t,e,n,r){for(let i=e;i<n;i++)t._vertices._xs[i]=r;t._dirty=!0}function QS(t,e,n,r){for(let i=e;i<n;i++)t._vertices._xs[i]=r(i);t._dirty=!0}function tT(t,e,n,r){for(let i=e;i<n;i++)t._vertices._ys[i]=r;t._dirty=!0}function eT(t,e,n,r){for(let i=e;i<n;i++)t._vertices._ys[i]=r(i);t._dirty=!0}function nT(t,e,n){return"number"==typeof e?function(t,e){if(!Number.isInteger(e)||e<1)throw new Error("Repeat count must be a positive integer");let n=[];for(let t=0;t<e;t++)n.push({index:t});let r=new fE(n,"from count");return rT(t,r)}(t,e):function(t){if(!t||"object"!=typeof t||Array.isArray(t))return!1;if(t instanceof fE||t instanceof gE||t instanceof mE)return!1;let e=Object.values(t);return e.length>0&&e.every(t=>"number"==typeof t)}(e)?function(t,e){let n=[];for(let t of Object.keys(e)){let r=e[t];if(!Number.isInteger(r)||r<0)throw new Error("Repeat group counts must be non-negative integers: "+t+" = "+r);for(let e=0;e<r;e++)n.push({group:t})}if(0===n.length)throw new Error("Repeat counts must include at least one group with a positive count");let r=new fE(n,"from group counts");return rT(t,r)}(t,e):rT(t,e)}function rT(t,e,n){let r=aA(t),i={};if(i.attribute=i.attribute||_E,function(t,e,n){if(!t||void 0===e)throw new Error("Incomplete information to do repeat. You must specify an element, a categorical data attribute and a data table");if(e instanceof gE||e instanceof mE){if(!Array.isArray(t)||2!==t.length)throw new Error("To repeat with a tree or a network, you need to provide two marks, one for node and one for link")}else e instanceof fE&&function(t,e){if(e.has(t))return!0;if(e.tree&&e.tree.nodeTable.has(t.split(".")[1]))return!0;throw new Error(["Attribute",t,"does not exist in the table",e.name].join(" "))}(n.attribute,e);if(n.layout&&!(n.layout instanceof UE))throw new Error("Invalid layout: "+n.layout)}(t,e,i),e instanceof gE||e instanceof mE){let n=t[0].parent,i=t[1].parent,[s,o]=function(t,e,n,r){let i=e.dataScope?e.dataScope:cE(r.nodeTable),s=uE(i,xE),o=hT(t,{type:Pw.Collection}),a=hT(t,{type:Pw.Collection}),l={};a.dataScope=i,a.addChild(e);for(let t=1;t<s.length;t++){let t=pT(e);a.addChild(t)}a.children.forEach((t,e)=>{t.dataScope=s[e],t.links=[],l[iE(t.dataScope,xE)]=t});let c=n.dataScope?n.dataScope:cE(r.linkTable),u=uE(c,_E);o.dataScope=c,o.addChild(n);for(let t=1;t<u.length;t++){let t=pT(n);o.addChild(t)}o.children.forEach((t,e)=>t.dataScope=u[e]);let h=r instanceof gE?"parent":"source",f=r instanceof gE?"child":"target";for(let t of o.children){let e=iE(t.dataScope,h),n=iE(t.dataScope,f),r=l[e],i=l[n];t.source=r,t.target=i,r.links.push(t),i.links.push(t)}return[a,o]}(r,t[0],t[1],e);return SA(n,t[0],r._depGraph),SA(i,t[1],r._depGraph),EA(s,r._depGraph),EA(o,r._depGraph),TA(s,t[0],r._depGraph),TA(s.parent,s,r._depGraph),TA(o,t[1],r._depGraph),TA(o.parent,o,r._depGraph),[s,o]}if(e instanceof fE){let n=t.parent,s=function(t,e,n,r){let i=r.type(n);if(i!=Vw.String&&i!=Vw.Date&&i!=Vw.Integer)throw new Error("Repeat only works on a string or date attribute: "+n+" is "+i);if(!function(t){if(Array.isArray(t)){if(1===t.length)return iT(t[0]);for(let e of t)if(!FE(e)||e.dataScope)return!1;return!0}return iT(t)}(e))throw new Error("The "+e.type+" is not repeatable");return function(t,e,n,r){let i=e.dataScope?e.dataScope:cE(r),s=uE(i,n),o=hT(t,{type:Pw.Collection});o.dataScope=i,o.addChild(e),e._refBounds||(e._refBounds=e.bounds.clone());for(let t=1;t<s.length;t++){let t=pT(e);o.addChild(t)}return o.children.forEach((t,e)=>t.dataScope=s[e]),o}(t,e,n,r)}(r,t,i.attribute,e);return SA(n,t,r._depGraph),EA(s,r._depGraph),TA(s,t,r._depGraph),TA(s.parent,s,r._depGraph),function(t,e,n,r){let i=r.getVariable(KE.ITEMS,n),s=r.createOneWayDependency($E.REPOPULATE);s._collection=t,s._repeatAttr=e,r.connect(i,s);let o=t.children[0],a=new Set([o,...cA(o)]);for(let t of a)r.connect(s,r.getVariable(KE.DATASCOPE,t))}(s,i.attribute,e,r._depGraph),i.layout&&(s.layout=i.layout),s}}function iT(t){return!(!FE(t)&&t.type!=Pw.Glyph||t.dataScope)||t.type===Pw.Collection&&nE(t.firstChild.dataScope)>1}class sT extends UE{constructor(t){super(),this.type=HE.GRID,this._numCols=t.numCols,this._numRows=t.numRows,this._start="start"in t?t.start:eS.TopLeft,this._direction="direction"in t?t.direction:tS.RowFirst,this._rowGap="rowGap"in t&&void 0!==t.rowGap?t.rowGap:5,this._colGap="colGap"in t&&void 0!==t.colGap?t.colGap:5,this._cellHorzAlignment="horzCellAlignment"in t&&WE("h",t.horzCellAlignment)?t.horzCellAlignment:zE.LEFT,this._cellVertAlignment="vertCellAlignment"in t&&WE("v",t.vertCellAlignment)?t.vertCellAlignment:zE.BOTTOM,this._rowOffset="rowOffset"in t&&void 0!==t.rowOffset?t.rowOffset:0,this._colOffset="colOffset"in t&&void 0!==t.colOffset?t.colOffset:0,this._numCols||this._numRows||(this._numRows=1),this._includeInvisible=!1,this._left=void 0,this._top=void 0,this._cellBounds=void 0,this._grid=void 0}get includeInvisible(){return this._includeInvisible}set includeInvisible(t){this._includeInvisible=t}get cellBounds(){return this._cellBounds}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}set numCols(t){this._numCols=t}set numRows(t){this._numRows=t}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}get rowOffset(){return this._rowOffset}set rowOffset(t){this._rowOffset=t}get colOffset(){return this._colOffset}set colOffset(t){this._colOffset=t}clone(){let t=new sT({numCols:this._numCols,numRows:this._numRows,start:this._start,direction:this._direction,colGap:this._colGap,rowGap:this._rowGap,horzCellAlignment:this._cellHorzAlignment,vertCellAlignment:this._cellVertAlignment,rowOffset:this._rowOffset,colOffset:this._colOffset});return t._includeInvisible=this._includeInvisible,t._left=this._left,t._top=this._top,this._cellBounds&&(t._cellBounds=this._cellBounds.map(t=>t.clone())),t}getElementsByRow(t,e){let n=[],r=this.group.children;for(let e=0;e<this.numRows;e++){let i=this._grid[e].filter(t=>null!=t).map(t=>r[t]);if(t){let t=[];for(let e of i)t=t.concat(cA(e));n.push(t)}else n.push(i)}return e&&(n=this._filterElementsByExample(n,e)),n}getElementsByCol(t,e){let n=[],r=this.group.children,i=this._grid;for(let e=0;e<this.numCols;e++){let s=i.map(t=>t[e]).filter(t=>null!=t).map(t=>r[t]);if(t){let t=[];for(let e of s)t=t.concat(cA(e));n.push(t)}else n.push(s)}return e&&(n=this._filterElementsByExample(n,e)),n}getElementsByCell(t,e){let n=[],r=this.group.children;for(let e=0;e<r.length;e++)if(t){let t=cA(r[e]);n.push(t)}else n.push(r[e]);return e&&(n=this._filterElementsByExample(n,e)),n}_filterElementsByExample(t,e){let n;return"vertex"===e.type?(n=t.map(t=>t.filter(t=>t.classId===e.parent.classId)),n=n.map(t=>QE(e,t))):"segment"===e.type?(n=t.map(t=>t.filter(t=>t.classId===e.parent.classId)),n=n.map(t=>nA(e,t))):n=t.map(t=>t.filter(t=>t.classId===e.classId)),n}getIndex(t){let e=t;for(;e&&e.parent!==this.group;)e=e.parent;return this.group.children.indexOf(e)}getRowCol(t){let e,n;switch(this._direction){case tS.RowFirst:e=Math.floor(t/this.numCols),n=t%this.numCols;break;case tS.ColumnFirst:e=t%this.numRows,n=Math.floor(t/this.numRows);break;default:throw new Error("Invalid fill direction. Use 'row_first' or 'column_first'.")}return this._start.toLowerCase().includes("bottom")&&(e=this.numRows-1-e),this._start.toLowerCase().includes("right")&&(n=this.numCols-1-n),{row:e,col:n}}get startCorner(){return this._start}set startCorner(t){this._start=t}get direction(){return this._direction}set direction(t){this._direction=t}}class oT extends ZA{constructor(t,e){super(),this._type=Pw.Legend,this._id=this._type+Dw(),this._enc=t,this._textColor="textColor"in e?e.textColor:"#555",this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._x="x"in e?e.x:100,this._y="y"in e?e.y:100,this._showTitle=!("showTitle"in e)||e.showTitle,this._orientation="orientation"in e?e.orientation:rS,this._numberFormat=e.numberFormat?e.numberFormat:""}get attribute(){return this._enc.attribute}get channel(){return this._enc.channel}get attributeType(){return pE(this._enc.element).getFieldType(this.attribute)}get orientation(){return this._orientation}get textColor(){return this._textColor}}class aT extends oT{constructor(t,e){super(t,e),"numCols"in e||"numRows"in e?(this._numCols=e.numCols,this._numRows=e.numRows):this._orientation===rS?this._numCols=1:this._numRows=1,this._initialize()}_initialize(){let t=this._enc.element.scene,e=this._enc.attribute,n=this._enc.scales[0],r=new fE(n.domain.map(t=>({category:t,value:n.map(t)}))),i=r.unique("category").sort((t,e)=>e.length-t.length)[0],s=this._enc.element,o=s instanceof dS&&s.closed&&"strokeColor"!==this._enc.channel?s.strokeWidth:0;if(this._orientation===rS){let n=0;this._showTitle&&(this.addChild(new NS({fillColor:this._textColor,fontSize:this._fontSize,text:e,x:this._x,y:this._y,anchor:["left","top"]})),n=parseFloat(this._fontSize)+5);let a=t.mark("rect",{top:this._y+2+n,left:this._x,width:10,height:10,strokeWidth:o,strokeColor:s.strokeColor,opacity:s.opacity}),l=t.mark("text",{text:i,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+n+12+o,anchor:["left","bottom"]}),c=nT(t.glyph(a,l),r);ZS(l,"text","category",{forLegend:!0}),ZS(a,"fillColor","category",{shareScale:this._enc,forLegend:!0}),c.layout=new sT({numCols:this._numCols,numRows:this._numRows}),this.addChild(c)}else{let e=t.mark("rect",{top:this._y,left:this._x,width:10,height:10,strokeWidth:o,strokeColor:s.strokeColor,opacity:s.opacity}),n=t.mark("text",{text:i,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+15,y:this._y,anchor:["left","top"]}),a=nT(t.glyph(e,n),r);ZS(n,"text","category",{forLegend:!0}),ZS(e,"fillColor","category",{shareScale:this._enc,forLegend:!0}),a.layout=new sT({numCols:this._numCols,numRows:this._numRows,colGap:15}),this.addChild(a)}}}class lT extends oT{constructor(t,e){super(t,e),this._initialize()}_initialize(){let t,e,n,r=this._enc.element.scene,i=this._enc.attribute;if(this._orientation==rS?(t=15,e=300):(t=300,e=15),this._showTitle){let e=r.mark("text",{fillColor:this._textColor,text:i,x:this._x+t/2,y:this._y,anchor:["center","middle"]});this.addChild(e),n=20}else n=0;let s,o=r.mark("rect",{top:this._y+n,left:this._x,width:t,height:e,strokeWidth:0,opacity:this._enc.element.opacity}),a=Object.values(this._enc.attrValues),l=[et(a),Q(a)],c=this._enc.mapping,u=[],h=[],f=Hl(this._numberFormat);if(c){let i=Object.keys(c).map(t=>parseFloat(t)).sort((t,e)=>t-e);this._orientation==rS?(s=new VS({x1:0,y1:100,x2:0,y2:0}),i.forEach(i=>{let o=(i-l[0])/(l[1]-l[0]);s.addStop(100*o,c[i],1);let a=r.mark("line",{x1:this._x+t,x2:this._x+t+5,y1:this._y+e-o*e+n,y2:this._y+e-o*e+n,strokeColor:this._strokeColor});h.push(a);let d=r.mark("text",{fillColor:this._textColor,text:this._numberFormat?f(i):i.toFixed(0),x:this._x+t+5+5,y:this._y+e-o*e+n,anchor:["left","middle"]});u.push(d)})):(s=new VS({x1:0,y1:0,x2:100,y2:0}),i.forEach(i=>{let o=(i-l[0])/(l[1]-l[0]);s.addStop(100*o,c[i],1);let a=r.mark("line",{x1:this._x+o*t,x2:this._x+o*t,y1:this._y+20-5+n,y2:this._y+e+5+n,strokeColor:this._strokeColor});h.push(a);let d=r.mark("text",{fillColor:this._textColor,text:this._numberFormat?f(i):i.toFixed(0),x:this._x+o*t,y:this._y+e+5+n,anchor:["center","top"]});u.push(d)}))}else{let o=this._enc.scales[0].domain,a=pE(this._enc.element),l=a.type(i),c=[],d=l===Vw.Date?a.getUniqueFieldValues(i):[...new Set(Object.values(this._enc.attrValues))];if(d.length<=10)c=d,c.sort((t,e)=>t-e);else if(l===Vw.Date){d.sort((t,e)=>t-e);for(let t=0;t<d.length;t+=Math.ceil(d.length/10))c.push(d[t])}else{let t=(o[1]-o[0])/9;for(let e=0;e<10;e++)c.push(o[0]+e*t)}let p=0,_=Math.abs((c[c.length-1]-c[0])/c.length);for(;_>0&&_<1&&p<10;)_*=10,p++;c=c.map(t=>t.toFixed(p)),this._orientation==rS?(s=new VS({x1:0,y1:100,x2:0,y2:0}),c.forEach(c=>{let d=(c-o[0])/(o[1]-o[0]);s.addStop(100*d,this._enc.scales[0].map(c),1);let p=r.mark("line",{x1:this._x+t,x2:this._x+t+5,y1:this._y+e-d*e+n,y2:this._y+e-d*e+n,strokeColor:this._strokeColor});h.push(p);let _=r.mark("text",{fillColor:this._textColor,text:l===Vw.Date?a.raw(i,c):this._numberFormat?f(c):c,x:this._x+t+5+5,y:this._y+e-d*e+n,anchor:["left","middle"]});u.push(_)})):(s=new VS({x1:0,y1:0,x2:100,y2:0}),c.forEach(c=>{let f=(c-o[0])/(o[1]-o[0]);s.addStop(100*f,this._enc.scales[0].map(c),1);let d=r.mark("line",{x1:this._x+f*t,x2:this._x+f*t,y1:this._y+e+n,y2:this._y+e+5+n,strokeColor:this._strokeColor});h.push(d);let p=r.mark("text",{fillColor:this._textColor,text:l===Vw.Date?a.raw(i,c):c,x:this._x+f*t,y:this._y+e+5+n,anchor:["center","top"]});u.push(p)}))}o.styles.fillColor=s,this.addChild(o);for(let t of u)this.addChild(t);for(let t of h)this.addChild(t)}}class cT extends zS{constructor(t,e,n,r){super(r),this._elems=t,this._attribute=n,this._channel=e,this._posArg="x"==this._channel||"width"==this._channel?r.pathY:r.pathX,this._labelAttribute=r.labelAttribute,this._orientation="orientation"in r?r.orientation:"x"===this._channel||"width"==this._channel?FS:jS,this._titleText="title"in r?r.title:this._attribute,this._path="angle"===this._channel?new SS({strokeColor:this._strokeColor,id:this._id+"_path"}):new dS({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(r),Jw(this._elems[0].dataScope).type(this._attribute)!==Vw.Date||"labelFormat"in r||(this._labelFormat="%m/%d/%y")}get elements(){if(this.layout.type===HE.CLUSTER){const t=new Map(this._elems.map(t=>[t.datum[xE],t]));return this.layout._d3Root.leaves().map(e=>t.get(e.data[xE]))}return this._elems}get layout(){return this._elems[0].parent.layout}createTicksLabels(t){"tickValues"in t?(this._tickValues=t.tickValues,this._labelValues=t.tickValues):(this._tickValues=this.elements.map(t=>t.datum[this._labelAttribute?this._labelAttribute:this._attribute]),this._labelValues=this._tickValues),this._ticks.removeAll();for(let t=0;t<this._tickValues.length;t++){let e=new dS({strokeColor:this._strokeColor,id:this._id+"_tick"+t});this._tickVisible||(e.visibility="hidden"),this._ticks.addChild(e)}let e;switch(this._labels.removeAll(),Jw(this._elems[0].dataScope).type(this._labelAttribute?this._labelAttribute:this._attribute)){case Vw.Date:e=ny(this._labelFormat);break;case Vw.String:e=function(t){return t};break;default:e=Hl(this._labelFormat)}for(let[t,n]of this._labelValues.entries()){let r=new NS({text:e(n),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+t});this._labels.addChild(r)}this._title._text=this._titleText}}class uT extends ZA{constructor(t){super(),this._type=Pw.Composite,this._id=t&&t.id?t.id:this._type+Dw()}addChild(t){let e=t.parent;super.addChild(t);let n=aA(t)._depGraph;e&&SA(e,t,n),TA(this,t,n)}}function hT(t,e){let n;switch(e.type){case"collection":n=dT(e);break;case"glyph":n=function(t){let e=new QA(t);return e}(e);break;case"axis":n=function(t){if("encoding"===t.axisType){return new YS(t.enc,t.scale,t.elems,t)}if("layout"===t.axisType){return new cT(t.elems,t.channel,t.attribute,t)}}(e);break;case"legend":n=function(t){let e="string"===t.attrType?new aT(t.enc,t):new lT(t.enc,t);return e}(e);break;case"composite":n=function(t){let e=new uT(t);return e}(e);break;default:n=fT(e)}return t.addChild(n),t._itemMap[n.id]=n,n}function fT(t){let e=null;switch(t.type){case Pw.Circle:e=new SS(t);break;case Pw.Line:var n="x1"in t?t.x1:0,r="y1"in t?t.y1:0,i="x2"in t?t.x2:100,s="y2"in t?t.y2:100;t.vertices=[[n,r],[i,s]],e=new kS(t);break;case Pw.Rect:var o="top"in t?t.top:0,a="left"in t?t.left:0,l="width"in t?t.width:50,c="height"in t?t.height:30;t.vertices=[[a,o],[a+l,o],[a+l,o+c],[a,o+c]],e=new PS(t);break;case Pw.SimpleText:e=new NS(t);break;case Pw.RichText:e=new DS(t);break;case Pw.Image:e=new TS(t);break;case Pw.Symbol:e=new CS(t);break;case Pw.BundledPath:case Pw.Chord:case Pw.Path:e=new dS(t);break;case Pw.Arrow:e=new OS(t);break;case Pw.Area:e=new ES(t);break;case Pw.Ring:e=new LS(t);break;case Pw.Arc:e=new mS(t);break;case Pw.BezierCurve:"vertices"in t||(t.vertices=[[0,100],[20,120],[80,180],[100,200]]),e=new AS(t);break;case Pw.Polygon:e=new IS(t)}return e&&e._updateBounds(),e}function dT(t){return new JA(t)}function pT(t){switch(t.type){case Pw.Collection:return function(t){let e=dT({});for(let n=0;n<t.children.length;n++){let r=t.children[n];e.addChild(pT(r))}if(e._classId=t.classId,t._layout){let n=t._layout.clone();e._layout=n,n.group=e}return e._updateBounds(),t.scene._itemMap[e.id]=e,e}(t);case Pw.Glyph:return function(t){let e=new QA;for(let n of t.children)e.addChild(pT(n));e._classId=t.classId,t.dataScope&&(e.dataScope=t.dataScope);return t.scene._itemMap[e.id]=e,e}(t);default:return function(t){let e=fT({type:t.type});t.copyPropertiesTo(e),e._classId=t.classId,e._bounds=t.bounds.clone(),t._refBounds||(t._refBounds=t.bounds.clone());if(e._refBounds=t._refBounds.clone(),t.vertices)for(let n=0;n<t.vertices.length;n++)t.vertices[n].dataScope&&(e.vertices[n].dataScope=t.vertices[n].dataScope);return t.scene._itemMap[e.id]=e,e}(t)}}class _T extends XE{constructor(t,e){super(t),this._elem=e}get element(){return this._elem}}class gT extends XE{constructor(t,e){super(t),this._item=e}get element(){return this._item}}class yT{constructor(t){this._id=t+"_"+Dw(),this._type=t,this._vars=[],this._edges=[]}get vars(){return this._vars}get edges(){return this._edges}run(){console.log("-",this._type)}}class mT{constructor(t,e,n=!0){this._id="e_"+Dw(),this._fromNode=t,this._toNode=e,this._isDirected=n}get id(){return this._id}get fromNode(){return this._fromNode}get toNode(){return this._toNode}get isDirected(){return this._isDirected}get operator(){return this._fromNode instanceof qE||this._fromNode instanceof yT?this._fromNode:this._toNode}}class bT extends XE{constructor(t,e){super(t),this._encs={},this._encs[e.channel+"_"+UA(e.element)]=e,this._initialized=!1}addLinkedEncoding(t){this._encs[t.channel+"_"+UA(t.element)]=t}getEncoding(t,e){let n=t+"_"+UA(e);return this._encs[n]}get encodings(){return Object.values(this._encs)}get initialized(){return this._initialized}set initialized(t){this._initialized=t}}class vT extends XE{constructor(t,e){super(t),this._encs=[e],this._valueMap={}}addLinkedEncoding(t){this._encs.push(t)}get encodings(){return this._encs}get attrValues(){return this._valueMap}set attrValues(t){this._valueMap=t}}function xT(t){if("number"!=typeof t.radius)throw new Error('Mascot: encode(..., "polarRadius", ...) needs an explicit {rangeExtent: N} (or {range: [...]}) option because the encoded shape has no fixed radius of its own -- e.g. it came from densify() on a "line" mark rather than a "circle".');return t.radius}class wT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof vT),e=this.outputVar,n=e.encodings,r=n[0],i=r.channel,s=r.attribute,o=t.encodings[0].dataTable.type(t.encodings[0].attribute),a=Object.values(t.attrValues);if("angle"===r.channel&&[Pw.Arc,Pw.Pie].indexOf(r.element.type)>=0)for(let e of t.encodings)for(let t of e.scales){let n=e.getElements(t).map(t=>e.attrValues[t.id]);t.domain=r._preferredDomain?r._preferredDomain:e.dataTable.tree?[0,e.dataTable.tree.getRoot()[s]]:this._getDomainForNumbers(n),console.log("domain for",s,t.domain)}else{let e;e=r._preferredDomain?r._preferredDomain:o==Vw.String||"text"===t.encodings[0].channel?this._getDomainForStrings(a):this._getDomainForNumbers(a);for(let n of t.encodings)for(let t of n.scales)t.domain=e.slice()}for(let t=0;t<r.scales.length;t++){let s=r.scales[t],o=r.getElements(s),a=this._buildRange(i,o,r,e);if(a)for(let e of n)e.scales[t].range=a}e.initialized=!0}_getDomainForNumbers(t){let e=this.outputVar.encodings[0],n=[et(t),Q(t)];if(e.includeZero&&n[0]>0&&(n=[0,Q(t)]),e.mapping)n=Object.keys(e.mapping),n=n.map(t=>parseFloat(t)),n.sort((t,e)=>t-e);else if("sequentialColor"===e.scales[0].type){if(n[0]<0&&n[1]>0){let t=Math.max(Math.abs(n[0]),Math.abs(n[1]));n=[-t,t]}}else if("angle"===e.channel){let e=Object.values(t).reduce((t,e)=>t+e,0);n=[0,e]}return n}_getDomainForStrings(t){let e,n=this.outputVar,r=n.encodings[0];return e="count"==n.encodings[0].aggregator?[0,Math.max(...t)]:Array.from(new Set(t)),r.mapping&&(e=Object.keys(r.mapping)),e}_buildRange(t,e,n,r){if(n._preferredRange)return n._preferredRange;if("x"===t)return this._buildXRange(e,n,r);if("y"===t)return this._buildYRange(e,n,r);if(["width","height","radius","area","fontSize","polarRadius","strokeWidth"].includes(t))return this._buildSizeRange(e,n,r);if(t.indexOf("Color")>0||"fillGradient"===t||"strokeGradient"===t)return this._buildColorRange(e,n);if("angle"===t)return this._buildAngleRange(e,n);if("polarAngle"===t)return[0,360];if("thickness"===t)return this._buildThicknessRange(e,n,r);if("src"===t||"path"===t){let t=n.scales[0].domain;return n.mapping?t.map(t=>n.mapping[t+""]):t.slice()}}_buildThicknessRange(t,e,n){let r=t.map(t=>t.outerRadius-t.innerRadius);return[0,n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:Math.max(...r)]}_buildAngleRange(t,e){return[0,360]}_buildColorRange(t,e){if(e.mapping){return e.scales[0].domain.map(t=>e.mapping[t+""])}if("sequentialColor"===e.scales[0].type){let t=this.outputVar,n=e.scales[0].domain;for(let r of t.encodings)if(!e.colorScheme)for(let t of r.scales){let e=t.domain;t._scale=Im(n[0]<0&&n[1]>0?rb:rv),t._scale.domain(e)}}if((qS.indexOf(e.colorScheme)>=0||$S.indexOf(e.colorScheme)>=0)&&"ordinalColor"===e.scales[0].type){let t=this.outputVar,n=e.scales[0].domain;for(let r of t.encodings)for(let t of r.scales){let r=t.domain;t._scale=t_(Nw[e.colorScheme][n.length]),t._scale.domain(r)}}}_buildSizeRange(t,e,n){let r,i;if(r=0,"vertexIndices"===t.type){let r=tA(t.groups[0].parent,t.groups[0].indices[0]);return i=n.initialized?e._elem2scale[r].rangeExtent:e._preferredRangeExtent?e._preferredRangeExtent:Math.max(...this._getVertexIndexSizeValues(t,e.channel)),[0,0+i]}return i=n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:Math.max(...t.map(t=>"radius"===e.channel?t.refBounds.width/2:"strokeWidth"===e.channel?t.strokeWidth:"polarRadius"===e.channel?xT(t.parent):"area"===e.channel?t.type===Pw.Circle?Math.PI*Math.pow(t.radius,2):t.width*t.height:"fontSize"===e.channel?parseFloat(t.fontSize):t.refBounds[e.channel])),[0,0+i]}_getVertexIndexSizeValues(t,e){let n=[];for(let r of t.groups){let t=r.parent._vertices;for(let i of r.indices)n.push("radius"===e?t._radii[i]:"strokeWidth"===e?t._strokeWidths[i]:"polarRadius"===e?xT(r.parent):"width"===e?t._widths[i]:"height"===e?t._heights[i]:0)}return n}_buildXRange(t,e,n){let r,i,s=e.scales[0].type;if("vertexIndices"===t.type){let s=t.groups[0].parent,o=tA(s,t.groups[0].indices[0]),a=s.refBounds?s.refBounds:s.bounds;return r=n.initialized?et(e._elem2scale[o].range):a.left,i=n.initialized?e._elem2scale[o].rangeExtent:e._preferredRangeExtent?e._preferredRangeExtent:a.width,e.flipScale?[r+i,r]:[r,r+i]}switch(t[0].type){case"vertex":case"segment":var o=t[0].parent.refBounds?t[0].parent.refBounds:t[0].parent.bounds;r=n.initialized?e.getRangeStart(t[0]):o.left,i=n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:o.width;break;default:r=n.initialized?e.getRangeStart(t[0]):e._preferredRangeStart?e._preferredRangeStart:lA(t[0]).bounds.left+t[0].bounds.width/2,i="band"===s?t[0].bounds.width*e.scales[0].domain.length:n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:Q([450,Q(t.map(t=>t.bounds.x))-et(t.map(t=>t.bounds.x))])}return e.flipScale?[r+i,r]:[r,r+i]}_buildYRange(t,e,n){let r,i;if(e.scales[0].type,"vertexIndices"===t.type){let s=t.groups[0].parent,o=tA(s,t.groups[0].indices[0]),a=s.refBounds?s.refBounds:s.bounds;return r=n.initialized?et(e._elem2scale[o].range):a.top,i=n.initialized?e._elem2scale[o].rangeExtent:e._preferredRangeExtent?e._preferredRangeExtent:a.height,e.flipScale?[r,r+i]:[r+i,r]}switch(t[0].type){case"vertex":case"segment":var s=t[0].parent.refBounds?t[0].parent.refBounds:t[0].parent.bounds;r=n.initialized?e.getRangeStart(t[0]):s.top,i=n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:s.height;break;default:r=n.initialized?e.getRangeStart(t[0]):lA(t[0]).bounds.top+t[0].bounds.height/2,i=n.initialized?e.getRangeExtent(t[0]):e._preferredRangeExtent?e._preferredRangeExtent:450}return e.flipScale?[r,r+i]:[r+i,r]}}class ET extends qE{constructor(t){super(t)}run(){super.run()}}class AT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof dA&&t.property==gA.AXIS_ORIENTATION).element;t.createTicksLabels(t._args),t instanceof YS?this._runForEncoding(t):t instanceof cT&&this._runForLayout(t),BE(t._path)}_runForLayout(t){let e=t.channel,n=t.elements[0].parent.layout&&t.elements[0].parent.layout.type==HE.STACK?VE(t.elements):DE(t.elements),r=[];if("x"===e){let e=t.orientation===GS?n.top-2:n.bottom+2;t._pathPos=t._posArg?t._posArg:e,r.push([n.left,t._pathPos]),r.push([n.right,t._pathPos]),t._path.vertices=r}else if("y"===e){let e=t.orientation===jS?n.left-2:n.right+2;t._pathPos=t._posArg?t._posArg:e,r.push([t._pathPos,n.top]),r.push([t._pathPos,n.bottom]),t._path.vertices=r}else if("angle"===e){let e=t.elements[0].parent.layout;e.type===HE.CLUSTER&&(t._path._x=e.x,t._path._y=e.y,t._path._radius=e.radius)}}_runForEncoding(t){let e=t.channel,n=t.elements,r=n[0].parent.layout&&n[0].parent.layout.type==HE.STACK?VE(n):DE(n),i=[],s=lA(n[0]);if(s&&s.clipMask&&(r=s.clipMask),"x"===e){let e,s,o=jA(n[0],"y");o?(e=Math.min(...o.getScale(n[0]).range,r.top),s=Math.max(...o.getScale(n[0]).range,r.bottom)):(e=r.top,s=r.bottom);let a=t.orientation===GS?e-2:s+2;t._pathPos=t._posArg?t._posArg:a,i.push([t.scale.range[0],t._pathPos]),i.push([t.scale.range[1],t._pathPos])}else if("width"===e){let e=t.orientation===GS?r.top-2:r.bottom+2;t._pathPos=t._posArg?t._posArg:e,i.push([r.left,t._pathPos]),i.push([r.right,t._pathPos])}else if("polarRadius"===e){let[e,n]=t.origin;t._pathPos=t._posArg?t._posArg:n,i.push([t.scale.range[0]+e,t._pathPos]),i.push([t.scale.range[1]+e,t._pathPos])}else{if("polarAngle"===e){let[e,n]=t.origin;return t._path._x=e,t._path._y=n,void(t._path._radius=t.radius)}if("y"===e){let e,s,o=jA(n[0],"x");o?(e=Math.min(...o.getScale(n[0]).range,r.left),s=Math.max(...o.getScale(n[0]).range,r.right)):(e=r.left,s=r.right);let a=t.orientation===jS?e-2:s+2;t._pathPos=t._posArg?t._posArg:a,i.push([t._pathPos,t.scale.range[0]]),i.push([t._pathPos,t.scale.range[1]])}else if("height"===e){let e=t.orientation===jS?r.left-2:r.right+2;t._pathPos=t._posArg?t._posArg:e,i.push([t._pathPos,r.bottom]),i.push([t._pathPos,r.top])}}t._path.vertices=i}}class ST extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof dA&&t.property==gA.AXIS_PATH_POSITION).element;t instanceof YS?this._runForEncoding(t):t instanceof cT&&this._runForLayout(t);let e=[];if("width"===t.channel||"x"===t.channel){let n=t._ticks.children.map(t=>t.vertices[0].x),r=[t._path.vertices[0].x,t._path.vertices[1].x];e.push([d3.min(n.concat(r)),t._path.vertices[0].y]),e.push([d3.max(n.concat(r)),t._path.vertices[0].y]),t._path.vertices=e}else if("height"===t.channel||"y"===t.channel){let n=t._ticks.children.map(t=>t.vertices[0].y),r=[t._path.vertices[0].y,t._path.vertices[1].y];e.push([t._pathPos,d3.min(n.concat(r))]),e.push([t._pathPos,d3.max(n.concat(r))]),t._path.vertices=e}for(let e of t._ticks.children)e._updateBounds();BE(t._ticks)}_runForLayout(t){let e=t.channel;if("x"==e){let e=t.orientation==FS?t._pathPos+t.tickOffset:t._pathPos-t.tickOffset,n=t.orientation==FS?t.tickSize:-t.tickSize;for(let[r,i]of t._ticks.children.entries()){let s=t.elements[r].bounds[t.tickAnchor];i.vertices=[[s,e],[s,e+n]]}}else if("y"===e){let e=t.orientation==jS?t._pathPos-t.tickOffset:t._pathPos+t.tickOffset,n=t.orientation==jS?-t.tickSize:t.tickSize;for(let[r,i]of t._ticks.children.entries()){let s=t.elements[r].bounds[t.tickAnchor];i.vertices=[[e,s],[e+n,s]]}}else if("angle"===e){let e=t.elements[0].parent.layout;if(e.type===HE.CLUSTER){let n=e._d3Root.leaves();const r=new Map(n.map(t=>[t.data[xE],[t.x,t.y]]));for(let[n,i]of t._ticks.children.entries()){let s=t.elements[n].datum[xE],o=vS(r.get(s)[0])-90;i.vertices=[[e.x+r.get(s)[1]+t.elements[n].bounds.width/2,e.y],[e.x+r.get(s)[1]+t.elements[n].bounds.width/2+t.tickSize,e.y]],i._rotate=[o,e.x,e.y]}}}}_runForEncoding(t){let e=t.channel,n=DE(t.elements);if("x"==e){let e=t.orientation==FS?t._pathPos+t.tickOffset:t._pathPos-t.tickOffset,n=t.orientation==FS?t.tickSize:-t.tickSize;for(let[r,i]of t._ticks.children.entries())i.vertices=[[t.scale.map(t._tickValues[r]),e],[t.scale.map(t._tickValues[r]),e+n]]}else if("width"==e){let e=t.orientation==FS?t._pathPos+t.tickOffset:t._pathPos-t.tickOffset,r=t.orientation==FS?t.tickSize:-t.tickSize;if(!!(t.isFlipped()||t.elements[0].type===Pw.Area&&"right"===t.elements[0].baseline))for(let[i,s]of t._ticks.children.entries())s.vertices=[[n.left+t.scale.rangeExtent-t.scale.map(t._tickValues[i]),e],[n.left+t.scale.rangeExtent-t.scale.map(t._tickValues[i]),e+r]];else for(let[i,s]of t._ticks.children.entries())s.vertices=[[t.scale.map(t._tickValues[i])+n.left,e],[t.scale.map(t._tickValues[i])+n.left,e+r]]}else if("y"===e){let e=t.orientation==jS?t._pathPos-t.tickOffset:t._pathPos+t.tickOffset,n=t.orientation==jS?-t.tickSize:t.tickSize;for(let[r,i]of t._ticks.children.entries())i.vertices=[[e,t.scale.map(t._tickValues[r])],[e+n,t.scale.map(t._tickValues[r])]]}else if("height"===e){let e=t.orientation==jS?t._pathPos-t.tickOffset:t._pathPos+t.tickOffset,r=t.orientation==jS?-t.tickSize:t.tickSize;if(!!(t.isFlipped()||t.elements[0].type===Pw.Area&&"top"===t.elements[0].baseline))for(let[i,s]of t._ticks.children.entries())s.vertices=[[e,n.top+t.scale.map(t._tickValues[i])],[e+r,n.top+t.scale.map(t._tickValues[i])]];else for(let[i,s]of t._ticks.children.entries()){let o=n.bottom-t.scale.map(t._tickValues[i]);s.vertices=[[e,o],[e+r,o]]}}else if("polarRadius"===e){let e=t.orientation==FS?t._pathPos+t.tickOffset:t._pathPos-t.tickOffset,n=t.orientation==FS?t.tickSize:-t.tickSize,[r]=t.origin;for(let[i,s]of t._ticks.children.entries())s.vertices=[[r+t.scale.map(t._tickValues[i]),e],[r+t.scale.map(t._tickValues[i]),e+n]]}else if("polarAngle"===e){let[e,n]=t.origin,r=t.radius-t.tickSize/2,i=t.radius+t.tickSize/2;for(let[s,o]of t._ticks.children.entries()){let a=t.scale.map(t._tickValues[s])*Math.PI/180;o.vertices=[[e+r*Math.cos(a),n-r*Math.sin(a)],[e+i*Math.cos(a),n-i*Math.sin(a)]]}}}}class TT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof dA&&t.property==gA.AXIS_PATH_POSITION).element;t instanceof YS?this._runForEncoding(t):t instanceof cT&&this._runForLayout(t);for(let e of t._labels.children)e._updateBounds();BE(t._labels)}_runForLayout(t){let e=t.channel;if("x"==e){let e=t.orientation==FS?t.labelOffset:-t.labelOffset,n=t.orientation==FS?[zE.CENTER,zE.TOP]:[zE.CENTER,zE.BOTTOM];for(let[r,i]of t._labels.children.entries()){let s=t.elements[r].bounds;i.x=s[t.tickAnchor],i._y=t._pathPos+e,i._anchor=n,t._labelRotation&&(i._rotate=[t._labelRotation,i.x,i.y],i._anchor=[zE.RIGHT,zE.MIDDLE])}}else if("y"===e){let e=t.orientation==jS?-t.labelOffset:t.labelOffset,n=t.orientation==jS?[zE.RIGHT,zE.MIDDLE]:[zE.LEFT,zE.MIDDLE];for(let[r,i]of t._labels.children.entries()){let s=t.elements[r].bounds;i.x=t._pathPos+e,i._y=t.tickAnchor==zE.MIDDLE?s.y:s[t.tickAnchor],i._anchor=n,t._labelRotation&&(i._rotate=[t._labelRotation,i.x,i.y],i._anchor=[zE.RIGHT,n[1]])}}else if("angle"===e){let e=t.elements[0].parent.layout;if(e.type===HE.CLUSTER){let n=e._d3Root.leaves();const r=new Map(n.map(t=>[t.data[xE],[t.x,t.y]]));let i=5;for(let[n,s]of t._labels.children.entries()){let o=t.elements[n].datum[xE];if(r.get(o)[0]<Math.PI){let a=vS(r.get(o)[0])-90;s._anchor=[zE.LEFT,zE.MIDDLE],s.x=e.x+r.get(o)[1]+t.elements[n].bounds.width/2+i,s._y=e.y,s._rotate=[a,e.x,e.y]}else{let a=vS(r.get(o)[0])+90;s._anchor=[zE.RIGHT,zE.MIDDLE],s.x=e.x-r.get(o)[1]-t.elements[n].bounds.width/2-i,s._y=e.y,s._rotate=[a,e.x,e.y]}}}}}_runForEncoding(t){let e=t.channel,n=DE(t.elements);if("x"==e){let e=t.orientation==FS?t.labelOffset:-t.labelOffset,n=t.orientation==FS?[zE.CENTER,zE.TOP]:[zE.CENTER,zE.BOTTOM];for(let[r,i]of t._labels.children.entries())i.x=t.scale.map(t.labelValues[r]),i._y=t._pathPos+e,i._anchor=n,t._labelRotation&&(i._rotate=[t._labelRotation,i.x,i.y],i._anchor=[zE.RIGHT,n[1]])}else if("width"===e){let e=t.orientation==FS?t.labelOffset:-t.labelOffset,r=t.orientation==FS?[zE.CENTER,zE.TOP]:[zE.CENTER,zE.BOTTOM],i=!!(t.isFlipped()||t.elements[0].type===Pw.Area&&"right"===t.elements[0].baseline);for(let[s,o]of t._labels.children.entries())o.x=i?n.left+t.scale.rangeExtent-t.scale.map(t.labelValues[s]):t.scale.map(t.labelValues[s])+n.left,o._y=t._pathPos+e,o._anchor=r,t._labelRotation&&(o._rotate=[t._labelRotation,o.x,o.y],o._anchor=[zE.RIGHT,r[1]])}else if("y"===e){let e=t.orientation==jS?-t.labelOffset:t.labelOffset,n=t.orientation==jS?[zE.RIGHT,zE.MIDDLE]:[zE.LEFT,zE.MIDDLE];for(let[r,i]of t._labels.children.entries())i.x=t._pathPos+e,i._y=t.scale.map(t.labelValues[r]),i._anchor=n,t._labelRotation&&(i._rotate=[t._labelRotation,i.x,i.y],i._anchor=[zE.RIGHT,n[1]])}else if("height"===e){let e=t.orientation==jS?-t.labelOffset:t.labelOffset,r=t.orientation==jS?[zE.RIGHT,zE.MIDDLE]:[zE.LEFT,zE.MIDDLE],i=t.elements[0].type===Pw.Area&&"top"===t.elements[0].baseline;for(let[s,o]of t._labels.children.entries())o.x=t._pathPos+e,o._y=i?n.top+t.scale.map(t.labelValues[s]):n.bottom-t.scale.map(t.labelValues[s]),o._anchor=r,t._labelRotation&&(o._rotate=[t._labelRotation,o.x,o.y],o._anchor=[zE.RIGHT,r[1]])}else if("polarRadius"==e){let e=t.orientation==FS?t.labelOffset:-t.labelOffset,n=t.orientation==FS?[zE.CENTER,zE.TOP]:[zE.CENTER,zE.BOTTOM],[r]=t.origin;for(let[i,s]of t._labels.children.entries())s.x=r+t.scale.map(t.labelValues[i]),s._y=t._pathPos+e,s._anchor=n,t._labelRotation&&(s._rotate=[t._labelRotation,s.x,s.y],s._anchor=[zE.RIGHT,n[1]])}else if("polarAngle"===e){let[e,n]=t.origin,r=t.radius+t.labelOffset;for(let[i,s]of t._labels.children.entries()){let o=t.scale.map(t.tickValues[i])*Math.PI/180;s.x=e+r*Math.cos(o),s._y=n-r*Math.sin(o),s._anchor=[zE.CENTER,zE.MIDDLE],t._labelRotation&&(s._rotate=[t._labelRotation,s.x,s.y])}}}}function CT(t,e){let n=t.getElements(e);return n&&"vertexIndices"===n.type?n.groups[0].parent:n[0]}class kT extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)return;let n=e._includeInvisible?t.children:t.children.filter(t=>"hidden"!==t.visibility);this.fillGrid(t,e,n),this.computeCellBounds(t,e,n),this.placeElements(t,e,n)}let n=cA(t,!0);for(let t of n)BE(t)}placeElements(t,e,n){let r=YA(t,"x"),i=YA(t,"y");for(let n=0;n<t.children.length;n++){let r=t.children[n],i=e.cellBounds[n];if(!i)continue;let s=0,o=0;switch(e._cellHorzAlignment){case zE.LEFT:s=i.left-r.refBounds.left;break;case zE.CENTER:s=i.x-r.refBounds.x;break;case zE.RIGHT:s=i.right-r.refBounds.right}switch(e._cellVertAlignment){case zE.TOP:o=i.top-r.refBounds.top;break;case zE.MIDDLE:o=i.y-r.refBounds.y;break;case zE.BOTTOM:o=i.bottom-r.refBounds.bottom}XA(r,s,o)}if(r.length>0)for(let t of r)for(let n of t.scales){let r=CT(t,n),i=e.getIndex(r);if(i<0||!e.cellBounds[i])continue;let s="point"===n.type?e.cellBounds[i].left+r.bounds.width/2:e.cellBounds[i].left,o=s+n.rangeExtent;n.range=n.range[0]<n.range[1]?[s,o]:[o,s]}if(i.length>0)for(let t of i)for(let n of t.scales){let r=CT(t,n),i=e.getIndex(r);if(i<0||!e.cellBounds[i])continue;let s="point"===n.type?e.cellBounds[i].top+r.bounds.height/2:e.cellBounds[i].top,o=s+n.rangeExtent;n.range=n.range[0]<n.range[1]?[s,o]:[o,s]}}fillGrid(t,e,n){let r=n.length,i=e._numCols?e._numCols:e._numRows?Math.ceil(r/e._numRows):1,s=e._numRows?e._numRows:Math.ceil(r/i);e._grid=new Array(s).fill(null).map(()=>new Array(i).fill(null));for(let o=0;o<r;o++){let r,a;switch(e._direction){case tS.RowFirst:r=Math.floor(o/i),a=o%i;break;case tS.ColumnFirst:r=o%s,a=Math.floor(o/s);break;default:throw new Error("Invalid fill direction. Use 'row_first' or 'column_first'.")}e._start.toLowerCase().includes("bottom")&&(r=s-1-r),e._start.toLowerCase().includes("right")&&(a=i-1-a);let l=t.children.indexOf(n[o]);e._grid[r][a]=l}}computeCellBounds(t,e,n){let r=n.map(t=>t.refBounds?t.refBounds:t.bounds),i=e._colGap,s=e._rowGap;if(void 0===e._left){let t=r.map(t=>t.left),n=r.map(t=>t.top);e._left=d3.min(t),e._top=d3.min(n)}let o=r.map(t=>t.width),a=r.map(t=>t.height),l=d3.max(o),c=d3.max(a);e._cellBounds=new Array(t.children.length).fill(null);let u=e._grid.length,h=u>0&&e._grid[0]?e._grid[0].length:0,f=e._rowOffset||0,d=e._colOffset||0;for(let n=0;n<u;n++)for(let r=0;r<h;r++){let o=e._grid[n][r];if(null==o||o>=t.children.length)continue;let a=e._left+(l+i)*r+(n%2==1?f:0),u=e._top+(c+s)*n+(r%2==1?d:0);e._cellBounds[o]=new PE(a,u,l,c)}}}function RT(t,e,n,r){return[n*Math.cos(bS(r))+t,e-n*Math.sin(bS(r))]}function MT(t,e,n,r){switch(e){case"x":NT(t,n);break;case"y":IT(t,n);break;case"width":!function(t,e){t.resize(e,t.height)}(t,n);break;case"height":!function(t,e){t.resize(t.width,e)}(t,n);break;case"radius":t.radius=n;break;case"strength":t._strength=n;break;case"area":t.type===Pw.Circle?t.radius=Math.sqrt(n/Math.PI):t.type===Pw.Rect&&t.resize(Math.sqrt(n),Math.sqrt(n)),t._updateBounds();break;case"text":t._text=n;break;case"curveMode":t.curveMode=n;break;case"baseline":t.baseline=n;break;case"angle":[Pw.Arc,Pw.Pie].includes(t.type)&&function(t,e){t._endAngle=xS(t._startAngle+e),t._sr=bS(t._startAngle),t._er=bS(t._endAngle),t.vertices[0].x=t._x+t._innerRadius*Math.cos(t._sr),t.vertices[0].y=t._y-t._innerRadius*Math.sin(t._sr),t.vertices[1].x=t._x+t._outerRadius*Math.cos(t._sr),t.vertices[1].y=t._y-t._outerRadius*Math.sin(t._sr),t.vertices[2].x=t._x+t._outerRadius*Math.cos(t._er),t.vertices[2].y=t._y-t._outerRadius*Math.sin(t._er),t.vertices[3].x=t._x+t._innerRadius*Math.cos(t._er),t.vertices[3].y=t._y-t._innerRadius*Math.sin(t._er)}(t,n);break;case"startAngle":!function(t,e){let n=t.angle;t._startAngle=e,t._endAngle=xS(t._startAngle+n),t._sr=bS(t._startAngle),t._er=bS(t._endAngle),t.vertices[0].x=t._x+t._innerRadius*Math.cos(t._sr),t.vertices[0].y=t._y-t._innerRadius*Math.sin(t._sr),t.vertices[1].x=t._x+t._outerRadius*Math.cos(t._sr),t.vertices[1].y=t._y-t._outerRadius*Math.sin(t._sr),t.vertices[2].x=t._x+t._outerRadius*Math.cos(t._er),t.vertices[2].y=t._y-t._outerRadius*Math.sin(t._er),t.vertices[3].x=t._x+t._innerRadius*Math.cos(t._er),t.vertices[3].y=t._y-t._innerRadius*Math.sin(t._er)}(t,n);break;case"thickness":!function(t,e){OT(t,t._innerRadius+e)}(t,n);break;case"innerRadius":!function(t,e){t._innerRadius=e,t.vertices[0].x=t._x+t._innerRadius*Math.cos(t._sr),t.vertices[0].y=t._y-t._innerRadius*Math.sin(t._sr),t.vertices[3].x=t._x+t._innerRadius*Math.cos(t._er),t.vertices[3].y=t._y-t._innerRadius*Math.sin(t._er)}(t,n);break;case"outerRadius":OT(t,n);break;case"polarAngle":
3
3
  // as the vertex-level version of this pairing, polarAngle must be
4
- t.polarAngle=n;break;case"polarRadius":{let e=ST(r&&r._preferredOrigin?r._preferredOrigin[0]:t.parent.x,r&&r._preferredOrigin?r._preferredOrigin[1]:t.parent.y,n,t.polarAngle);kT(t,e[0]),RT(t,e[1]);break}case"visibility":t.visibility=n;break;case"src":t.src=n;break;case"path":t.path=n;break;case"vxOpacity":if(t instanceof PA)for(let r of t.children)TT(r,e,n);else t.vxOpacity=n;break;default:if("vertex"===t.type)t[e]=n;else if(t instanceof PA)for(let r of t.children)TT(r,e,n);else{if(t.styles[e]==n)return;t.styles[e]=n}}"vertex"===t.type?t.parent._dirty=!0:t._dirty=!0}function CT(t,e){t._outerRadius=e,t.vertices[1].x=t._x+t._outerRadius*Math.cos(t._sr),t.vertices[1].y=t._y-t._outerRadius*Math.sin(t._sr),t.vertices[2].x=t._x+t._outerRadius*Math.cos(t._er),t.vertices[2].y=t._y-t._outerRadius*Math.sin(t._er)}function kT(t,e){"vertex"==t.type?t.x=e:HS(t,e-t.x,0)}function RT(t,e){"vertex"==t.type?t.y=e:HS(t,0,e-t.y)}class MT extends XE{constructor(t,e){super(t),this._result=e.evalResult,this._condEnc=e}get result(){return this._condEnc.evalResult}clearResult(){this._condEnc.evalResult={}}get conditionalEncoding(){return this._condEnc}}class OT extends qE{constructor(t){super(t)}storeValues(t,e){this._storedValues={};let n=JE(t);for(let t of n)this._storedValues[t.id]=t[e]}_restoreValue(t,e){let n=this._storedValues[t.id];t.styles?t.styles[e]!==n&&(t._dirty=!0,t.styles[e]=n):t[e]!==n&&(t._dirty=!0,t[e]=n)}run(){super.run();let t=this.inputVars.find(t=>t instanceof _T),e=this.outputVar,n=t?t.getEncoding(e.channel,e.element):null,r=e.channel,i=this.inputVars.filter(t=>t instanceof MT),s=i.length>0?i.map(t=>t.conditionalEncoding):[],o=s.length>0?s[0].eventContext:null,a=["x","y","width","height","radius"].includes(e.channel);if(t&&"vertex"===e.element.type)return this._runVertexIndexEncoding(n,r),void BE(e.element.parent);let l=JE(e.element),c=l[0].scene;for(let e of l){if(t){let t=n.getScale(e);this._doMapping(e,t,n.attrValues,n),a&&this._updateRefBounds(e,t,n)}else this._restoreValue(e,r);if(i.length>0){let t=s.map(t=>t.evalResult[e.id]).every(t=>t||void 0===t);s[0].stylingFunction(t,o,c.state,e)}}if(a){BE(["vertex","segment"].includes(e.element.type)?e.element.parent:e.element)}}_runVertexIndexEncoding(t,e){for(let n=0;n<t.scales.length;n++){let r=t.scales[n],i=t.getElements(r),s=[];for(let n of i.groups){n.parent._vertices;for(let i of n.indices){let s=tA(n.parent,i),o=t.attrValues[s],a="text"===e?o:r.map(o);this._setVertexIndexChannel(n.parent,i,e,a,t)}n.parent._dirty=!0,"x"!==e&&"y"!==e||s.includes(n.parent)||(this._updateVertexParentRefBounds(n.parent,e,r,t),s.push(n.parent))}}}_setVertexIndexChannel(t,e,n,r,i){let s=t._vertices;switch(n){case"x":s._xs[e]=r;break;case"y":s._ys[e]=r;break;case"polarRadius":{let n=s._polarAngles[e]*Math.PI/180,o=i&&i._preferredOrigin;if(!o&&"number"!=typeof t.radius)throw new Error('Mascot: encode(..., "polarRadius", ...) needs an explicit {origin: [x, y]} option because the encoded shape has no fixed center of its own -- e.g. it came from densify() on a "line" mark rather than a "circle".');let a=o?i._preferredOrigin[0]:t.x,l=o?i._preferredOrigin[1]:t.y;s._xs[e]=a+r*Math.cos(n),s._ys[e]=l-r*Math.sin(n);break}default:s.setProperty(e,n,r)}}_updateVertexParentRefBounds(t,e,n,r){let i=t.refBounds;"x"===e?t._refBounds=new PE(r.flipScale?n.range[1]:n.range[0],i.top,n.rangeExtent,i.height):"y"===e&&(t._refBounds=new PE(i.left,r.flipScale?n.range[0]:n.range[1],i.width,n.rangeExtent))}_updateRefBounds(t,e,n){switch(this.outputVar.channel){case"width":t._refBounds.setWidth(e.rangeExtent);break;case"height":t._refBounds.setHeight(e.rangeExtent);break;case"radius":t._refBounds.setWidth(2*e.rangeExtent,zE.CENTER),t._refBounds.setHeight(2*e.rangeExtent,zE.MIDDLE);break;case"x":if("vertex"==t.type||"segment"==t.type){let r=t.parent._refBounds;t.parent._refBounds=new PE(n.flipScale?e.range[1]:e.range[0],r.top,e.rangeExtent,r.height)}else if(t._refBounds)if("band"===e.type){let r=e.map(n.attrValues[t.id]),i=t._refBounds;t._refBounds=new PE(r-t.width/2,i.top,t.width,i.height)}else{let r=t.parent;for(;r&&(!r.layout||r.layout.type!==HE.GRID);)r=r.parent;if(r){let r=t._refBounds;t._refBounds=new PE(n.flipScale?e.range[1]:e.range[0],r.top,e.rangeExtent,r.height)}}break;case"y":if("vertex"==t.type||"segment"==t.type){let r=t.parent._refBounds;t.parent._refBounds=new PE(r.left,n.flipScale?e.range[0]:e.range[1],r.width,e.rangeExtent)}else if(t._refBounds){let r=t.parent;for(;r&&(!r.layout||r.layout.type!==HE.GRID);)r=r.parent;if(r){let r=t._refBounds,i=et(e.range);t._refBounds=new PE(r.left,n.flipScale?e.range[0]:i,r.width,e.rangeExtent)}}}}_doMapping(t,e,n,r){switch(this.outputVar.channel){case"width":e.domain[0]<0&&t instanceof yS?function(t,e,n){let r=t.refBounds.left+e.map(0),i=t.refBounds.left+e.map(n[t.id]);HS(t.leftSegment,r-t.leftSegment.x,0),HS(t.rightSegment,i-t.rightSegment.x,0)}(t,e,n):e.domain[0]<0&&t instanceof oS||(t.type===Pw.Area?function(t,e,n){let r=t.baseline;if(t.orientation===GA){let i=t._vertices.length/2;switch(r){case"left":$S(t,i,t._vertices.length,t.refBounds.left),XS(t,0,i,r=>t.refBounds.left+e.map(n[tA(t,r)]));break;case"right":XS(t,i,t._vertices.length,r=>t.refBounds.right-e.map(n[tA(t,r)])),$S(t,0,i,t.refBounds.right);break;case"center":console.log("center"),XS(t,i,t._vertices.length,r=>t.refBounds.center-e.map(n[tA(t,r)])/2),XS(t,0,i,r=>t.refBounds.center+e.map(n[tA(t,r)])/2)}}}(t,e,n):this._doStandardMapping(t,e,n,r));break;case"height":e.domain[0]<0&&t instanceof yS?function(t,e,n){let r=t.refBounds.bottom-e.map(0),i=t.refBounds.bottom-e.map(n[t.id]);HS(t.bottomSegment,0,r-t.bottomSegment.y),HS(t.topSegment,0,i-t.topSegment.y)}(t,e,n):e.domain[0]<0&&t instanceof oS?function(t,e,n){let r=t._vertices.length/2;ZS(t,0,r,r=>t.refBounds.bottom-e.map(n[tA(t,r)])),KS(t,r,t._vertices.length,t.refBounds.bottom-e.map(0))}(t,e,n):t.type===Pw.Area?function(t,e,n){let r=t.baseline;if(t.orientation===zA){let i=t._vertices.length/2;switch(r){case"top":ZS(t,i,t._vertices.length,r=>t.refBounds.top+e.map(n[tA(t,r)])),KS(t,0,i,t.refBounds.top);break;case"middle":ZS(t,0,i,r=>t.refBounds.middle-e.map(n[tA(t,r)])/2),ZS(t,i,t._vertices.length,r=>t.refBounds.middle+e.map(n[tA(t,r)])/2);break;default:ZS(t,0,i,r=>t.refBounds.bottom-e.map(n[tA(t,r)])),KS(t,i,t._vertices.length,t.refBounds.bottom)}}}(t,e,n):this._doStandardMapping(t,e,n,r);break;case"text":this._doTextMapping(t,n);break;case"fillGradient":!function(t,e,n,r){let i=t._vertices._ids.map((e,r)=>n[tA(t,r)]),s=d3.min(i),o=d3.max(i),a="horizontal"===t.orientation?new vS({x1:0,y1:100,x2:0,y2:0}):new vS({x1:0,y1:0,x2:100,y2:0});if(a.addStop(0,e.map(s),1),r._mapping){let t=Object.keys(r._mapping).map(t=>parseFloat(t)).sort();for(let n of t)n>s&&n<o&&a.addStop(100*(n-s)/(o-s),e.map(n),1)}else"divergingColor"===e.type&&a.addStop(100*-s/(o-s),e.map(0),1);"sequentialColor"===e.type&&a.addStop(100*-s/(o-s),e.map(0),1),a.addStop(100,e.map(o),1),t.fillColor=a}(t,e,n,r);break;case"strokeGradient":!function(t,e,n){let r=[];for(let i=0;i<t._vertices.length;i++)r.push(e.map(n[tA(t,i)]));t.strokeColor=new xS(r)}(t,e,n);break;default:this._doStandardMapping(t,e,n,r)}}_doTextMapping(t,e){TT(t,this.outputVar.channel,e[t.id])}_doStandardMapping(t,e,n,r){let i=this.outputVar.channel,s=e.map(n[t.id]);TT(t,i,s,r),t instanceof KA&&t.firstVertex&&t.firstVertex.shape&&"strokeColor"===i&&t.vertices.forEach(t=>t.fillColor=s)}_doCondEncoding(t,e){let n=t[0].scene;for(let r of t){let t=e.map(t=>t.evalResult[r.id]).every(t=>t||void 0===t),i=e[0].eventContext;e[0].stylingFunction(t,i,r,n)}}_updateElement(t,e,n,r){let i;"object"==typeof r&&t.triggerElement?"property"in r?i=t.triggerElement[r.property]:"attribute"in r&&(i=t.triggerElement.datum[r.attribute]):i=r,["x","y"].includes(n)&&"offset"in r&&(i+=r.offset),TT(e,n,i)}}class NT extends qE{constructor(t){super(t)}run(){let t=this.outputVar.element;t.updateValues(),t.scale?this._runForEncoding(t):this._runForLayout(t),BE(t)}_runForLayout(t){let e=t.channel,n=DE(t.elements),r=[];if("x"===e)for(let e=0;e<t.values.length;e++){let i=t.elements[e].refBounds;r.push({x1:i.x,y1:n.bottom,x2:i.x,y2:n.top})}else if("y"===e)for(let e=0;e<t.values.length;e++){let i=t.elements[e].refBounds;r.push({x1:n.left,y1:i.y,x2:n.right,y2:i.y})}t.lines=r,t._dirty=!0}_runForEncoding(t){let e=t.channel,n=DE(t.elements),r=[];if("x"===e){let e,i,s=VS(t.elements[0],"y");s?(e=Math.min(...s.getScale(t.elements[0]).range,n.top),i=Math.max(...s.getScale(t.elements[0]).range,n.bottom)):(e=n.top,i=n.bottom);for(let n of t.values)r.push({x1:t.scale.map(n),y1:i,x2:t.scale.map(n),y2:e})}else if("width"===e)for(let e of t.values)r.push({x1:t.scale.map(e)+n.left,y1:n.bottom,x2:t.scale.map(e)+n.left,y2:n.top});else if("y"===e){let e,i,s=VS(t.elements[0],"x");s?(e=Math.min(...s.getScale(t.elements[0]).range,n.left),i=Math.max(...s.getScale(t.elements[0]).range,n.right)):(e=n.left,i=n.right);for(let n of t.values)r.push({x1:e,y1:t.scale.map(n),x2:i,y2:t.scale.map(n)})}else if("height"===e)for(let e of t.values)r.push({x1:n.left,y1:n.bottom-t.scale.map(e),x2:n.right,y2:n.bottom-t.scale.map(e)});else if("polarRadius"===e){let[e,n]=t.origin;for(let i=0;i<t.values.length;i++)r.push({x:e,y:n,r:t.scale.map(t.values[i])})}else if("polarAngle"===e){let[e,n]=t.origin,i="radius"in t._args?t._args.radius:100;for(let s of t.values){let o=t.scale.map(s)*Math.PI/180;r.push({x1:e,y1:n,x2:e+i*Math.cos(o),y2:n-i*Math.sin(o)})}}t.lines=r,t._dirty=!0}}class IT extends qE{constructor(t){super(t)}run(){let t=this.outputVar.element;t.updatePoints(),t._dirty=!0,BE(t)}}class PT extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=cA(t)[0],n=JE(t.parent);for(let t of n){let n=t.layout;if(!n)return;switch(e.type){case Pw.Rect:case Pw.Circle:case Pw.Image:case Pw.Symbol:this._stackRects(t,n);break;case Pw.Area:t.children[0].orientation===zA?this._stackAreasVert(t,n):this._stackAreasHorz(t,n);break;case Pw.Arc:case Pw.Pie:e.parent.classId===t.classId&&this._stackArcs(t,n)}}BE(e)}_stackArcs(t,e){if(e.orientation===FA){let e=90;if((this._direction?this._direction:YA.Clockwise)===YA.Clockwise)for(let n of t.children){let t=iS(e-n.angle);TT(n,"startAngle",t),e=t}else for(let n of t.children){let t=iS(e+n.angle);TT(n,"startAngle",t),e=t}}else if(e.orientation===jA){let e=d3.min(t.children.map(t=>t.innerRadius));for(let n of t.children){let t=n.outerRadius-n.innerRadius;TT(n,"innerRadius",e),TT(n,"outerRadius",e+t),e=n._outerRadius}}}_stackAreasVert(t,e){let n=t.children.filter(t=>"visible"===t.visibility),r=t.bounds,i=e.vertCellAlignment===zE.TOP?r.top:r.bottom,s=e.vertCellAlignment===zE.TOP?1:-1;if(0===n.length)return;e.vertCellAlignment===zE.BOTTOM&&n.reverse();let o=n[0].vertices.length/2,a=new Array(o).fill(0);for(let t of n){for(let e=0;e<o;e++){let n=t.vertices[e],r=t.vertices[2*o-e-1],l=Math.abs(n.y-r.y),c=i+a[e]*s,u=i+(a[e]+l)*s;HS(n,0,c-n.y),HS(r,0,u-r.y),a[e]+=l}let e=t.bounds.bottom;t._updateBounds(),t._refBounds.translate(0,t.bounds.bottom-e)}if(e.vertCellAlignment===zE.MIDDLE)for(let t of n){for(let e=0;e<o;e++){let n=t.vertices[e],i=t.vertices[2*o-e-1],s=r.middle+a[e]/2;HS(n,0,s-r.bottom),HS(i,0,s-r.bottom)}let e=t.bounds.bottom;t._updateBounds(),t._refBounds.translate(0,t.bounds.bottom-e)}}_stackAreasHorz(t,e){}_stackRects(t,e){t.scene;let n=e._orientation,r=t.children.map(t=>t.bounds),i=r.map(t=>t.left),s=r.map(t=>t.top),o=r.map(t=>t.width),a=r.map(t=>t.height),l=null==e._left?d3.min(i):e._left,c=null==e._top?d3.min(s):e._top,u=d3.max(o),h=d3.max(a);if(n==GA)for(let n=0;n<t.children.length;n++){let r=t.children[n],i=0,s=c+r.bounds.height/2-r.bounds.y;c+=r.bounds.height+e._gap,HS(r,i,s),r._updateBounds();let o=0,a=0;if(!FS(r))switch(e._horzCellAlignment){case zE.LEFT:o=l-r.bounds.left;break;case zE.CENTER:o=l+u/2-r.bounds.x;break;case zE.RIGHT:o=l+u-r.bounds.right}HS(r,o,a)}else for(let n=0;n<t.children.length;n++){let r=t.children[n],i=l+r.bounds.width/2-r.bounds.x,s=0;l+=r.bounds.width+e._gap,HS(r,i,s),r._updateBounds();let o=0,a=0;if(!GS(r))switch(e._vertCellAlignment){case zE.TOP:a=c-r.bounds.top;break;case zE.MIDDLE:a=c+h/2-r.bounds.y;break;case zE.BOTTOM:a=c+h-r.bounds.bottom}HS(r,o,a)}}}class LT extends qE{constructor(t){super(t)}run(){super.run()}}class DT extends qE{constructor(t){super(t)}run(){let t=this._binConfig.attribute,e=this._binConfig.startAttr,n=this._binConfig.endAttr,r=this._binConfig.binIdAttr,i=this.inputVars[0].dataset,s=this.outputVar.dataset,o=i.values(t),a=J();null!=this._binConfig?.numBins&&(a=a.thresholds(this._binConfig.numBins));let l=a(o);this._binConfig.actualNumBins=l.length;let c=String(l.length-1).length,u=t=>String(t).padStart(c,"0"),h=this._findBin,f=o.map(t=>h(t,l).x0),d=o.map(t=>h(t,l).x1),p=o.map(t=>{let e=l.indexOf(h(t,l));return u(e)}),_=l.map((t,e)=>u(e));s.addAttr(e,Vw.Number,f),s.addAttr(n,Vw.Number,d),s.addAttr(r,Vw.String,p),s.order(r,_)}_findBin(t,e){for(let n of e)if(n.indexOf(t)>=0)return n}}class VT extends XE{constructor(t,e){super(t),this._dataset=e}get dataset(){return this._dataset}}class BT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof VT),e=this.outputVar.dataset;if(!t)return;let n=t.dataset,r=this._spec;if(!r.value)return void e.load(n.data.slice());let i=kE(r);e.load(n.data.filter(t=>i.testTuple(t)))}}function zT(t,e,n,r){let i=r.type(n);if(i!=Vw.String&&i!=Vw.Date&&i!=Vw.Integer)throw new Error("Repopulate only works on a string or date attribute: "+n+" is "+i);let s=JE(e);for(let t of s){let e=uE(t.dataScope?t.dataScope:cE(r),n,!0),i=t.children.length-e.length,s=e.length-t.children.length;for(let e=0;e<i;e++)t.removeChildAt(t.children.length-1);let o=t._children.length;for(let e=0;e<s;e++){let n=uT(t._children[e%o]);t.addChild(n)}t.children.forEach((t,n)=>t.dataScope=e[n])}}class GT extends qE{constructor(t){super(t),this._collection=null,this._area=null,this._repeatAttr=null}run(){if(super.run(),this._area&&this._repeatAttr){let t=this.inputVars[0];if(!t)return;let e=t.dataset;aA(this._area);return function(t,e,n,r){let i=r.type(n),s=cE(r),o=uE(s,n,i===Vw.Number);i!==Vw.Number&&i!==Vw.Date||o.sort((t,e)=>t.filters[n]>e.filters[n]?1:-1),1===o.length&&o.push(o[0]);let a=o.length,l=e.refBounds??e.bounds,{left:c,top:u,right:h,bottom:f}=l,d=h-c,p=f-u,_=e.orientation===GA,g=[];if(a>0){for(let t=0;t<a;t++)g.push(_?[h,u+t*p/(a-1)]:[c+t*d/(a-1),u]);for(let t=0;t<a;t++)g.push(_?[c,u+(a-1-t)*p/(a-1)]:[c+(a-1-t)*d/(a-1),f])}e.vertices=g;for(let t=0;t<e._vertices.length;t++){let n=t<a?o[t]:o[2*a-1-t];e._vertices.setDataScopeRef(t,n)}let y=e.classId??e.id,m=Math.floor(e._vertices.length/2);for(let t in e.scene._encodings)if(t===y)for(let n of Object.values(e.scene._encodings[t]))1===n._scales.length&&(n._elem2scale={[e.id]:n._scales[0]},n._elemGroups=[[e]]);else if(t===y+"_vAny"){let n=[];for(let t=0;t<e._vertices.length;t++)e._vertices.hasDataScope(t)&&n.push(t);let r=[{parent:e,indices:n}];for(let i of Object.values(e.scene._encodings[t]))if(1===i._scales.length){i._elem2scale={},i._elemGroups=[{type:"vertexIndices",groups:r}];for(let t of n)i._elem2scale[tA(e,t)]=i._scales[0]}}else if(t.startsWith(y+"_v")){let n=t===y+"_v0",r=n?0:m,i=n?m:e._vertices.length,s=[];for(let t=r;t<i;t++)e._vertices.hasDataScope(t)&&s.push(t);let o=[{parent:e,indices:s}];for(let n of Object.values(e.scene._encodings[t]))if(1===n._scales.length){n._elem2scale={},n._elemGroups=[{type:"vertexIndices",groups:o}];for(let t of s)n._elem2scale[tA(e,t)]=n._scales[0]}}e.dataScope=s}(0,this._area,this._repeatAttr,e),void(this.needsFullRender=!0)}if(!this._collection||!this._repeatAttr)return;let t=this.inputVars[0];if(!t)return;let e=t.dataset,n=this._collection;aA(n);n.dataScope=void 0,zT(0,n,this._repeatAttr,e),n.dataScope=cE(e);for(let t of LS(n.children[0]))t.refreshElementMappings();if(n.layout)for(let t of n.layout.refElements)t instanceof sT&&(t._elems=n.children.slice());this.needsFullRender=!0}}class FT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t.type===KE.AFFIXATION).affixation,e=t.base,n=t.element,r=JE(e),i=JE(n),s=t.channels,o=t.attribute;if(FE(n)&&FE(e)){let t=r.map(t=>t.datum[o]);i=i.filter(e=>t.includes(e.datum[o]));let e=(t,e)=>t.datum[o]<e.datum[o]?-1:t.datum[o]>e.datum[o]?1:0;i.sort(e),r.sort(e)}if(s.includes("x")||s.includes("y"))for(let e of s)this._handleXY(e,i,r,t.getElementAnchor(e),t.getBaseAnchor(e),t.getOffset(e));(s.includes("polarRadius")||s.includes("angle"))&&this._handlePolar(i,r,t);let a=cA(n,!0);for(let t of a)BE(t)}_handlePolar(t,e,n){let r="polarRadius",i=n.hasChannel(r)?n.getBaseAnchor(r):zE.MIDDLE,s=n.hasChannel(r)?n.getElementAnchor(r):zE.MIDDLE,o=n.hasChannel("angle")?n.getBaseAnchor("angle"):zE.CENTER;n.hasChannel("angle")?n.getElementAnchor("angle"):zE.CENTER;let a=n.hasChannel(r)?n.getOffset(r):0,l=n.hasChannel("angle")?n.getOffset("angle"):0;if([Pw.Arc,Pw.Ring].indexOf(e[0].type)>=0&&t[0].type==Pw.SimpleText)for(let n=0;n<t.length;n++){let r=e[n],s=t[n],l=i===zE.MIDDLE?(r.outerRadius+r.innerRadius)/2:i===zE.TOP?r.outerRadius-5:r.innerRadius+5;if(l+=a,r.type===Pw.Arc){let t=ST(r.x,r.y,l,r.startAngle),e=ST(r.x,r.y,l,r.endAngle);r.endAngle>=180&&r.endAngle<=360?s._textPath=["M",t[0],t[1],"A",l,l,r.angle,r.angle>=180?1:0,0,e[0],e[1]].join(" "):s._textPath=["M",e[0],e[1],"A",l,l,r.angle,r.angle>=180?1:0,1,t[0],t[1]].join(" ")}else if(r.type===Pw.Ring){let t=275,e=265,n=350,i=ST(r.x,r.y,l,t),o=ST(r.x,r.y,l,e);s._textPath=["M",o[0],o[1],"A",l,l,n,1,1,i[0],i[1]].join(" ")}s.textPathOffset=o===zE.LEFT?"0%":"50%"}else for(let n=0;n<t.length;n++){let r,c,u=e[n],h=t[n];u.type==Pw.Arc||u.type==Pw.Ring?(c="left"==o?u.endAngle+l:"center"==o?u.startAngle+u.angle/2+l:u.startAngle+l,r="top"==i?u.outerRadius+a:"bottom"==i?u.innerRadius+a:(u.outerRadius+u.innerRadius)/2+a):u.type==Pw.Circle&&(c=90,r="top"==i?u.radius+a:"bottom"==i?a:u.radius/2+a),HS(h,u.x-h.x,u.y-r-h.bounds[s]),h._rotate=[90-c,u.x,u.y]}}_handleXY(t,e,n,r,i,s){for(let o=0;o<e.length;o++){let a,l=n[o],c=e[o];if(JA(l)){a=ZA(l,[zE.LEFT,zE.TOP].includes(i)?0:[zE.CENTER,zE.MIDDLE].includes(i)?.5:1)[t]}else a=l.bounds[i]+s;e[0].type===Pw.SimpleText?(c.anchor["x"==t?0:1]=r,TT(c,t,a)):"x"==t?HS(c,a-c.bounds[r],0):HS(c,0,a-c.bounds[r])}}}class jT extends XE{constructor(t,e){super(t),this._affx=e}get affixation(){return this._affx}}class UT extends qE{constructor(t){super(t)}run(){let t=this.inputVars[0],e=this.outputVar,n=t.attribute,r=e.attribute,i=t.dataset,s=e.dataset,o=this.args,a=null!=o.min?o.min:i.summary(n).min,l=null!=o.max?o.max:i.summary(n).max,c=a,u=[];for(;c<l;)u.push(c),c+=o.interval;u.push(c);let h={},f={};if(o.groupBy)for(let t of i.data){let e=o.groupBy.map(e=>t[e]).join("-");e in h||(h[e]=[],f[e]=o.groupBy.map(e=>t[e])),h[e].push(t[n])}else h[""]=i.data.map(t=>t[n]),f[""]="";let d=[];for(let t in f){let e=YT(HT(o.bandwidth),u,h[t]);for(let i of e){let e={};""!==t&&o.groupBy.forEach((n,r)=>e[n]=f[t][r]),e[n]=i[0],e[r]=i[1],d.push(e)}}let p={};if(p[n]=i.type(n),p[r]=Vw.Number,o.groupBy)for(let t of o.groupBy)p[t]=i.type(t);s.initialize(d,s.url,p)}}function YT(t,e,n){return e.map(e=>[e,ct(n,n=>t(e-n))])}function HT(t){return e=>Math.abs(e/=t)<=1?.75*(1-e*e)/t:0}class WT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof VT);if(!t)return;let e=t.dataset,n=this.outputVar.dataset;this._spec.fn(e,n,this._spec)}}class qT extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)return;let n=t.children.map(t=>({name:t.id,radius:t.radius,itm:t})),r=n.reduce((t,e)=>t+Math.pow(e.radius,2),0),i=Math.sqrt(r);void 0===e._width&&(e._width=i),void 0===e._height&&(e._height=i);let s=Od({name:"root",children:n}).sum(t=>t.radius?t.radius:0).sort((t,e)=>e.value-t.value);rp().size([e._width,e._height]).radius(t=>t.value)(s);for(let t of s.children){let n=t.data.itm;HS(n,e._x-s.x+t.x-n.x,e._y-s.y+t.y-n.y)}}let n=cA(t,!0);for(let t of n)BE(t)}}class $T extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof dA&&t.property==gA.AXIS_PATH_POSITION).element;t instanceof RS?this._runForEncoding(t):t instanceof sT&&this._runForLayout(t),BE(t._title)}_runForEncoding(t){let e=t.channel,n=DE(t.elements);if("x"==e)t._title.x=(t.scale.range[0]+t.scale.range[1])/2,t._title._y=t.orientation==TS?t._pathPos+t.titleOffset:t._pathPos-t.titleOffset;else if("width"==e)t._title.x=n.left+t.scale.rangeExtent/2,t._title._y=t.orientation==TS?t._pathPos+t.titleOffset:t._pathPos-t.titleOffset;else if("y"===e)t._rotateYTitle?(t._title.x=t.orientation==CS?t._pathPos-t.titleOffset:t._pathPos+t.titleOffset,t._title._y=(t.scale.range[0]+t.scale.range[1])/2,t._title._rotate=t.orientation==CS?[-90,t._title._x,t._title._y]:[90,t._title._x,t._title._y]):(t._title.x=t.orientation==CS?t._pathPos-t.titleOffset:t._pathPos+t.titleOffset,t._title._y=d3.min([t.scale.range[0],t.scale.range[1]])-25,t._title._rotate=void 0);else if("height"===e)t._title.x=n.center,t._title._y=(n.top+n.bottom)/2-n.width/2-t.titleOffset,t._title._rotate=t.orientation==CS?[-90,n.center,n.middle]:[90,n.center,n.middle];else if("polarRadius"===e){let[e]=t.origin;t._title.x=e+t.scale.rangeExtent/2,t._title._y=t.orientation==TS?t._pathPos+t.titleOffset:t._pathPos-t.titleOffset,t._rotate&&(t._title._rotate=t._rotate.slice())}else if("polarAngle"===e){let[e,n]=t.origin;t._title.x=e,t._title._y=n-t.radius-t.titleOffset}}_runForLayout(t){let e=t.channel,n=t.elements[0].parent.layout&&t.elements[0].parent.layout.type==HE.STACK?VE(t.elements):DE(t.elements);if("x"==e)t._title.x=n.center,t._title._y=t.orientation==TS?t._pathPos+t.titleOffset:t._pathPos-t.titleOffset;else if("y"===e)t._title.x=n.center,t._title._y=n.middle-n.width/2-t.titleOffset,t._title._rotate=t.orientation==CS?[-90,n.center,n.middle]:[90,n.center,n.middle];else if("angle"===e){let e=t.elements[0].parent.layout;e.type===HE.CLUSTER&&(t._title.x=e.x,t._title._y=e.y)}}}class XT extends dT{constructor(t){super(t)}run(){super.run();let t,e=this.vars.find(t=>t.type===KE.ALIGNMENT).alignment,n=e.anchor,r=e.elements;n==zE.Top||n==zE.LEFT?t=et(r.map(t=>t.bounds[n])):n==zE.BOTTOM||n==zE.RIGHT?t=Q(r.map(t=>t.bounds[n])):n!=zE.CENTER&&n!=zE.MIDDLE||(t=ct(r.map(t=>t.bounds[n])));for(let i of r){let r=YS(i,e.channel);if(r){let s=t-i.bounds[n];HS(r,"x"===e.channel?s:0,"x"===e.channel?0:s)}}for(let t of r)BE(t)}}class KT extends XE{constructor(t,e){super(t),this._aln=e}get alignment(){return this._aln}}class ZT extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let n=bE(t.children[0]);if(!n)continue;let r=n.linkList.map(t=>({source:n.getNode(t.source),target:n.getNode(t.target)})),i=Ol(n.nodeList).force("charge",Nl().strength(-e._repulsion)).force("link",Tl(r).id(t=>t.id).distance(e._linkDistance)).force("x",Il()).force("y",Pl()).force("center",hl(e._x,e._y).strength(e._attraction));i.stop(),i.tick(e._iterations);for(let e=0;e<t.children.length;e++){let r=t.children[e],i=n.nodeList[e];HS(r,i.x-r.x,i.y-r.y)}}let n=cA(t,!0);for(let t of n)BE(t)}}class JT extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t);switch(t.type){case Pw.Arc:this._updateArcLinks(e);break;case Pw.BezierCurve:this._updateBezierLinks(e);break;case Pw.BundledPath:this._updateBundledLinks(e);break;case Pw.Chord:this._updateChordLinks(e);break;case Pw.Line:default:this._updateLineLinks(e)}BE(t)}_updateArcLinks(t){for(let e of t){let t=e.source.x<e.target.x?e.source:e.target,n=e.source.x<e.target.x?e.target:e.source;e._x=(t.x+n.x)/2,e._y=(t.y+n.y)/2,e._innerRadius=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))/2,e._outerRadius=e._innerRadius+e._thickness;let r=sS(t.x,t.y,e._x,e._y),i=sS(n.x,n.y,e._x,e._y);e.direction===YA.CLOCKWISE&&([r,i]=[i,r]),TT(e,"startAngle",r),TT(e,"angle",Math.abs(i-r))}}_updateBezierLinks(t){let e=this._inputVars[0].element,n=JE(e),r=e.parent.layout;r.type===HE.DIRECTED||r.type===HE.TIDYTREE?this._updateBezierLinksForDirectedGraph(n,t,r):r.type===HE.CLUSTER&&this._updateBezierLinksForClusteredGraph(n,t,r)}_updateBezierLinksForClusteredGraph(t,e,n){const r=n._d3Root.descendants(),i=new Map(r.map(t=>[QT(t),t])),s=new Map(r.map(t=>[t.data[xE],QT(t)]));if(n.isRadial()){const t=nx().angle(t=>t.x).radius(t=>t.y);for(let r of e){let e=r.source,o=r.target,a=e.datum[xE],l=o.datum[xE],c=i.get(s.get(a)),u=i.get(s.get(l));r._d=tS(t({source:c,target:u}),n.x,n.y)}}else if(n.orientation===GA){const t=ex().x(t=>t.x).y(t=>t.y);for(let r of e){let e=r.source,o=r.target,a=e.datum[xE],l=o.datum[xE],c=i.get(s.get(a)),u=i.get(s.get(l));r._d=tS(t({source:c,target:u}),n.left-n._x0,n.top)}}else if(n.orientation===zA){const t=tx().x(t=>t.y).y(t=>t.x);for(let r of e){let e=r.source,o=r.target,a=e.datum[xE],l=o.datum[xE],c=i.get(s.get(a)),u=i.get(s.get(l));r._d=tS(t({source:c,target:u}),n.left,n.top-n._x0)}}}_updateBezierLinksForDirectedGraph(t,e,n){let r={},i={},s={},o={};for(let e of t){i[e.id]=0,r[e.id]=0;let t=e.links.filter(t=>t.source===e),n=e.links.filter(t=>t.target===e);o[e.id]=n.map(t=>t.strokeWidth).reduce((t,e)=>t+e,0),s[e.id]=t.map(t=>t.strokeWidth).reduce((t,e)=>t+e,0)}const a=n.direction===UA.Left2Right||n.direction===UA.Right2Left;if(n.spreadLinks){const t=a?t=>t.bounds.y:t=>t.bounds.x,n=[...e].sort((e,n)=>t(e.target)-t(n.target));for(let t of n)t._outLane=r[t.source.id],r[t.source.id]+=t.strokeWidth;const s=[...e].sort((e,n)=>t(e.source)-t(n.source));for(let t of s)t._inLane=i[t.target.id],i[t.target.id]+=t.strokeWidth}for(let t of e){let e,r,i,l,c=t.source,u=t.target;n.spreadLinks?a?(e=c.bounds[t.sourceAnchor[0]]+t.sourceOffset[0],i=u.bounds[t.targetAnchor[0]]+t.targetOffset[0],r=c.bounds[t.sourceAnchor[1]]+t.sourceOffset[1]-s[c.id]/2+t._outLane+t.strokeWidth/2,l=u.bounds[t.targetAnchor[1]]+t.targetOffset[1]-o[u.id]/2+t._inLane+t.strokeWidth/2):(r=c.bounds[t.sourceAnchor[1]]+t.sourceOffset[1],l=u.bounds[t.targetAnchor[1]]+t.targetOffset[1],e=c.bounds[t.sourceAnchor[0]]+t.sourceOffset[0]-s[c.id]/2+t._outLane+t.strokeWidth/2,i=u.bounds[t.targetAnchor[0]]+t.targetOffset[0]-o[u.id]/2+t._inLane+t.strokeWidth/2):(e=c.bounds[t.sourceAnchor[0]]+t.sourceOffset[0],r=c.bounds[t.sourceAnchor[1]]+t.sourceOffset[1],i=u.bounds[t.targetAnchor[0]]+t.targetOffset[0],l=u.bounds[t.targetAnchor[1]]+t.targetOffset[1]),t.orientation===zA?t.vertices=[[e,r],[(e+i)/2,r],[e,l],[i,l]]:t.orientation===GA&&(t.vertices=[[e,r],[e,(r+l)/2],[i,r],[i,l]])}}_updateBundledLinks(t){let e=this._inputVars[0].element.parent.layout;if(e.type!==HE.CLUSTER)throw"Bundled links must work on a cluster layout";let n=e._d3Root.leaves();const r=new Map(n.map(t=>[QT(t),t])),i=new Map(n.map(t=>[t.data[xE],QT(t)])),s=Uv().curve(Vx.beta(t[0]._strength)).radius(t=>t.y).angle(t=>t.x);for(let n of t){let t=n.source.datum[xE],o=n.target.datum[xE],a=r.get(i.get(t)),l=r.get(i.get(o));(a.outgoing??=[]).push([a,l]),l.incoming??=[];let c=a.path(l);n._d=tS(s(c),e.x,e.y),n._dirty=!0}}_updateChordLinks(t){for(let e of t){let t=e.source,n=e.target,r=ST(t.x,t.y,t.innerRadius,t.startAngle),i=ST(t.x,t.y,t.innerRadius,t.endAngle),s=ST(n.x,n.y,n.innerRadius,n.startAngle),o=ST(n.x,n.y,n.innerRadius,n.endAngle);e._d=["M",r[0],r[1],"Q",t.x,t.y,o[0],o[1],"A",t.x,t.y,n.angle,n.angle>180?1:0,1,s[0],s[1],"Q",t.x,t.y,i[0],i[1],"A",t.x,t.y,t.angle,t.angle>180?1:0,1,r[0],r[1]].join(" "),e._dirty=!0}}_updateLineLinks(t){for(let e of t){let t=e.source,n=e.target;e.vertices[0].x=t.bounds.x,e.vertices[0].y=t.bounds.y,e.vertices[1].x=n.bounds.x,e.vertices[1].y=n.bounds.y,e._dirty=!0}}}function QT(t){return`${t.parent?QT(t.parent)+".":""}${t.data[xE]}`}var tC="\0";function eC(t,e){t[e]?t[e]++:t[e]=1}function nC(t,e){--t[e]||delete t[e]}function rC(t,e,n,r){var i=""+e,s=""+n;if(!t&&i>s){var o=i;i=s,s=o}return i+""+s+""+(void 0===r?"\0":r)}function iC(t,e){return rC(t,e.v,e.w,e.name)}var sC=class{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(t){t&&(this._isDirected=!Object.hasOwn(t,"directed")||t.directed,this._isMultigraph=!!Object.hasOwn(t,"multigraph")&&t.multigraph,this._isCompound=!!Object.hasOwn(t,"compound")&&t.compound),this._isCompound&&(this._parent={},this._children={},this._children[tC]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return this._defaultNodeLabelFn=t,"function"!=typeof t&&(this._defaultNodeLabelFn=()=>t),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var t=this;return this.nodes().filter(e=>0===Object.keys(t._in[e]).length)}sinks(){var t=this;return this.nodes().filter(e=>0===Object.keys(t._out[e]).length)}setNodes(t,e){var n=arguments,r=this;return t.forEach(function(t){n.length>1?r.setNode(t,e):r.setNode(t)}),this}setNode(t,e){return Object.hasOwn(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=tC,this._children[t]={},this._children[tC][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return Object.hasOwn(this._nodes,t)}removeNode(t){var e=this;if(Object.hasOwn(this._nodes,t)){var n=t=>e.removeEdge(e._edgeObjs[t]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(function(t){e.setParent(t)}),delete this._children[t]),Object.keys(this._in[t]).forEach(n),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(n),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(void 0===e)e=tC;else{for(var n=e+="";void 0!==n;n=this.parent(n))if(n===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}parent(t){if(this._isCompound){var e=this._parent[t];if(e!==tC)return e}}children(t=tC){if(this._isCompound){var e=this._children[t];if(e)return Object.keys(e)}else{if(t===tC)return this.nodes();if(this.hasNode(t))return[]}}predecessors(t){var e=this._preds[t];if(e)return Object.keys(e)}successors(t){var e=this._sucs[t];if(e)return Object.keys(e)}neighbors(t){var e=this.predecessors(t);if(e){const r=new Set(e);for(var n of this.successors(t))r.add(n);return Array.from(r.values())}}isLeaf(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length}filterNodes(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach(function([n,r]){t(n)&&e.setNode(n,r)}),Object.values(this._edgeObjs).forEach(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,n.edge(t))});var r={};function i(t){var s=n.parent(t);return void 0===s||e.hasNode(s)?(r[t]=s,s):s in r?r[s]:i(s)}return this._isCompound&&e.nodes().forEach(t=>e.setParent(t,i(t))),e}setDefaultEdgeLabel(t){return this._defaultEdgeLabelFn=t,"function"!=typeof t&&(this._defaultEdgeLabelFn=()=>t),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,e){var n=this,r=arguments;return t.reduce(function(t,i){return r.length>1?n.setEdge(t,i,e):n.setEdge(t,i),i}),this}setEdge(){var t,e,n,r,i=!1,s=arguments[0];"object"==typeof s&&null!==s&&"v"in s?(t=s.v,e=s.w,n=s.name,2===arguments.length&&(r=arguments[1],i=!0)):(t=s,e=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],i=!0)),t=""+t,e=""+e,void 0!==n&&(n=""+n);var o=rC(this._isDirected,t,e,n);if(Object.hasOwn(this._edgeLabels,o))return i&&(this._edgeLabels[o]=r),this;if(void 0!==n&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[o]=i?r:this._defaultEdgeLabelFn(t,e,n);var a=function(t,e,n,r){var i=""+e,s=""+n;if(!t&&i>s){var o=i;i=s,s=o}var a={v:i,w:s};r&&(a.name=r);return a}(this._isDirected,t,e,n);return t=a.v,e=a.w,Object.freeze(a),this._edgeObjs[o]=a,eC(this._preds[e],t),eC(this._sucs[t],e),this._in[e][o]=a,this._out[t][o]=a,this._edgeCount++,this}edge(t,e,n){var r=1===arguments.length?iC(this._isDirected,arguments[0]):rC(this._isDirected,t,e,n);return this._edgeLabels[r]}edgeAsObj(){const t=this.edge(...arguments);return"object"!=typeof t?{label:t}:t}hasEdge(t,e,n){var r=1===arguments.length?iC(this._isDirected,arguments[0]):rC(this._isDirected,t,e,n);return Object.hasOwn(this._edgeLabels,r)}removeEdge(t,e,n){var r=1===arguments.length?iC(this._isDirected,arguments[0]):rC(this._isDirected,t,e,n),i=this._edgeObjs[r];return i&&(t=i.v,e=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],nC(this._preds[e],t),nC(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this}inEdges(t,e){var n=this._in[t];if(n){var r=Object.values(n);return e?r.filter(t=>t.v===e):r}}outEdges(t,e){var n=this._out[t];if(n){var r=Object.values(n);return e?r.filter(t=>t.w===e):r}}nodeEdges(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))}},oC={Graph:sC,version:"2.2.4"},aC=sC,lC={write:function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:cC(t),edges:uC(t)};void 0!==t.graph()&&(e.value=structuredClone(t.graph()));return e},read:function(t){var e=new aC(t.options).setGraph(t.value);return t.nodes.forEach(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)}),t.edges.forEach(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),e}};function cC(t){return t.nodes().map(function(e){var n=t.node(e),r=t.parent(e),i={v:e};return void 0!==n&&(i.value=n),void 0!==r&&(i.parent=r),i})}function uC(t){return t.edges().map(function(e){var n=t.edge(e),r={v:e.v,w:e.w};return void 0!==e.name&&(r.name=e.name),void 0!==n&&(r.value=n),r})}var hC=function(t){var e,n={},r=[];function i(r){Object.hasOwn(n,r)||(n[r]=!0,e.push(r),t.successors(r).forEach(i),t.predecessors(r).forEach(i))}return t.nodes().forEach(function(t){e=[],i(t),e.length&&r.push(e)}),r};var fC=class{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(t){return t.key})}has(t){return Object.hasOwn(this._keyIndices,t)}priority(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority}min(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key}add(t,e){var n=this._keyIndices;if(t=String(t),!Object.hasOwn(n,t)){var r=this._arr,i=r.length;return n[t]=i,r.push({key:t,priority:e}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)}_heapify(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))}_decrease(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e}_swap(t,e){var n=this._arr,r=this._keyIndices,i=n[t],s=n[e];n[t]=s,n[e]=i,r[s.key]=t,r[i.key]=e}},dC=fC,pC=function(t,e,n,r){return function(t,e,n,r){var i,s,o={},a=new dC,l=function(t){var e=t.v!==i?t.v:t.w,r=o[e],l=n(t),c=s.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+l);c<r.distance&&(r.distance=c,r.predecessor=i,a.decrease(e,c))};t.nodes().forEach(function(t){var n=t===e?0:Number.POSITIVE_INFINITY;o[t]={distance:n},a.add(t,n)});for(;a.size()>0&&(i=a.removeMin(),(s=o[i]).distance!==Number.POSITIVE_INFINITY);)r(i).forEach(l);return o}(t,String(e),n||_C,r||function(e){return t.outEdges(e)})},_C=()=>1;var gC=pC,yC=function(t,e,n){return t.nodes().reduce(function(r,i){return r[i]=gC(t,i,e,n),r},{})};var mC=function(t){var e=0,n=[],r={},i=[];function s(o){var a=r[o]={onStack:!0,lowlink:e,index:e++};if(n.push(o),t.successors(o).forEach(function(t){Object.hasOwn(r,t)?r[t].onStack&&(a.lowlink=Math.min(a.lowlink,r[t].index)):(s(t),a.lowlink=Math.min(a.lowlink,r[t].lowlink))}),a.lowlink===a.index){var l,c=[];do{l=n.pop(),r[l].onStack=!1,c.push(l)}while(o!==l);i.push(c)}}return t.nodes().forEach(function(t){Object.hasOwn(r,t)||s(t)}),i};var bC=mC,vC=function(t){return bC(t).filter(function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])})};var xC=function(t,e,n){return function(t,e,n){var r={},i=t.nodes();return i.forEach(function(t){r[t]={},r[t][t]={distance:0},i.forEach(function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})}),n(t).forEach(function(n){var i=n.v===t?n.w:n.v,s=e(n);r[t][i]={distance:s,predecessor:t}})}),i.forEach(function(t){var e=r[t];i.forEach(function(n){var s=r[n];i.forEach(function(n){var r=s[t],i=e[n],o=s[n],a=r.distance+i.distance;a<o.distance&&(o.distance=a,o.predecessor=i.predecessor)})})}),r}(t,e||wC,n||function(e){return t.outEdges(e)})},wC=()=>1;function EC(t){var e={},n={},r=[];if(t.sinks().forEach(function i(s){if(Object.hasOwn(n,s))throw new AC;Object.hasOwn(e,s)||(n[s]=!0,e[s]=!0,t.predecessors(s).forEach(i),delete n[s],r.push(s))}),Object.keys(e).length!==t.nodeCount())throw new AC;return r}class AC extends Error{constructor(){super(...arguments)}}var SC=EC;EC.CycleException=AC;var TC=SC;var CC=function(t,e,n){Array.isArray(e)||(e=[e]);var r=t.isDirected()?e=>t.successors(e):e=>t.neighbors(e),i="post"===n?kC:RC,s=[],o={};return e.forEach(e=>{if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);i(e,r,o,s)}),s};function kC(t,e,n,r){for(var i=[[t,!1]];i.length>0;){var s=i.pop();s[1]?r.push(s[0]):Object.hasOwn(n,s[0])||(n[s[0]]=!0,i.push([s[0],!0]),MC(e(s[0]),t=>i.push([t,!1])))}}function RC(t,e,n,r){for(var i=[t];i.length>0;){var s=i.pop();Object.hasOwn(n,s)||(n[s]=!0,r.push(s),MC(e(s),t=>i.push(t)))}}function MC(t,e){for(var n=t.length;n--;)e(t[n],n,t);return t}var OC=CC;var NC=CC;var IC=sC,PC=fC,LC=function(t,e){var n,r=new IC,i={},s=new PC;function o(t){var r=t.v===n?t.w:t.v,o=s.priority(r);if(void 0!==o){var a=e(t);a<o&&(i[r]=n,s.decrease(r,a))}}if(0===t.nodeCount())return r;t.nodes().forEach(function(t){s.add(t,Number.POSITIVE_INFINITY),r.setNode(t)}),s.decrease(t.nodes()[0],0);var a=!1;for(;s.size()>0;){if(n=s.removeMin(),Object.hasOwn(i,n))r.setEdge(n,i[n]);else{if(a)throw new Error("Input graph is not connected: "+t);a=!0}t.nodeEdges(n).forEach(o)}return r};var DC={Graph:oC.Graph,json:lC,alg:{components:hC,dijkstra:pC,dijkstraAll:yC,findCycles:vC,floydWarshall:xC,isAcyclic:function(t){try{TC(t)}catch(t){if(t instanceof TC.CycleException)return!1;throw t}return!0},postorder:function(t,e){return OC(t,e,"post")},preorder:function(t,e){return NC(t,e,"pre")},prim:LC,tarjan:mC,topsort:SC},version:oC.version};function VC(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function BC(t,e){if("_next"!==t&&"_prev"!==t)return e}let zC=DC.Graph,GC=class{constructor(){let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,e=t._prev;if(e!==t)return VC(e),e}enqueue(t){let e=this._sentinel;t._prev&&t._next&&VC(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e}toString(){let t=[],e=this._sentinel,n=e._prev;for(;n!==e;)t.push(JSON.stringify(n,BC)),n=n._prev;return"["+t.join(", ")+"]"}};var FC=function(t,e){if(t.nodeCount()<=1)return[];let n=function(t,e){let n=new zC,r=0,i=0;t.nodes().forEach(t=>{n.setNode(t,{v:t,in:0,out:0})}),t.edges().forEach(t=>{let s=n.edge(t.v,t.w)||0,o=e(t),a=s+o;n.setEdge(t.v,t.w,a),i=Math.max(i,n.node(t.v).out+=o),r=Math.max(r,n.node(t.w).in+=o)});let s=function(t){const e=[];for(let n=0;n<t;n++)e.push(n);return e}(i+r+3).map(()=>new GC),o=r+1;return n.nodes().forEach(t=>{YC(s,o,n.node(t))}),{graph:n,buckets:s,zeroIdx:o}}(t,e||jC);return function(t,e,n){let r,i=[],s=e[e.length-1],o=e[0];for(;t.nodeCount();){for(;r=o.dequeue();)UC(t,e,n,r);for(;r=s.dequeue();)UC(t,e,n,r);if(t.nodeCount())for(let s=e.length-2;s>0;--s)if(r=e[s].dequeue(),r){i=i.concat(UC(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx).flatMap(e=>t.outEdges(e.v,e.w))};let jC=()=>1;function UC(t,e,n,r,i){let s=i?[]:void 0;return t.inEdges(r.v).forEach(r=>{let o=t.edge(r),a=t.node(r.v);i&&s.push({v:r.v,w:r.w}),a.out-=o,YC(e,n,a)}),t.outEdges(r.v).forEach(r=>{let i=t.edge(r),s=r.w,o=t.node(s);o.in-=i,YC(e,n,o)}),t.removeNode(r.v),s}function YC(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}let HC=DC.Graph;var WC={addBorderNode:function(t,e,n,r){let i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=r);return qC(t,"border",i,e)},addDummyNode:qC,applyWithChunking:XC,asNonCompoundGraph:function(t){let e=new HC({multigraph:t.isMultigraph()}).setGraph(t.graph());return t.nodes().forEach(n=>{t.children(n).length||e.setNode(n,t.node(n))}),t.edges().forEach(n=>{e.setEdge(n,t.edge(n))}),e},buildLayerMatrix:function(t){let e=QC(KC(t)+1).map(()=>[]);return t.nodes().forEach(n=>{let r=t.node(n),i=r.rank;void 0!==i&&(e[i][r.order]=n)}),e},intersectRect:function(t,e){let n,r,i=t.x,s=t.y,o=e.x-i,a=e.y-s,l=t.width/2,c=t.height/2;if(!o&&!a)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(a)*l>Math.abs(o)*c?(a<0&&(c=-c),n=c*o/a,r=c):(o<0&&(l=-l),n=l,r=l*a/o);return{x:i+n,y:s+r}},mapValues:function(t,e){let n=e;"string"==typeof e&&(n=t=>t[e]);return Object.entries(t).reduce((t,[e,r])=>(t[e]=n(r,e),t),{})},maxRank:KC,normalizeRanks:function(t){let e=t.nodes().map(e=>{let n=t.node(e).rank;return void 0===n?Number.MAX_VALUE:n}),n=XC(Math.min,e);t.nodes().forEach(e=>{let r=t.node(e);Object.hasOwn(r,"rank")&&(r.rank-=n)})},notime:function(t,e){return e()},partition:function(t,e){let n={lhs:[],rhs:[]};return t.forEach(t=>{e(t)?n.lhs.push(t):n.rhs.push(t)}),n},pick:function(t,e){const n={};for(const r of e)void 0!==t[r]&&(n[r]=t[r]);return n},predecessorWeights:function(t){let e=t.nodes().map(e=>{let n={};return t.inEdges(e).forEach(e=>{n[e.v]=(n[e.v]||0)+t.edge(e).weight}),n});return tk(t.nodes(),e)},range:QC,removeEmptyRanks:function(t){let e=t.nodes().map(e=>t.node(e).rank),n=XC(Math.min,e),r=[];t.nodes().forEach(e=>{let i=t.node(e).rank-n;r[i]||(r[i]=[]),r[i].push(e)});let i=0,s=t.graph().nodeRankFactor;Array.from(r).forEach((e,n)=>{void 0===e&&n%s!==0?--i:void 0!==e&&i&&e.forEach(e=>t.node(e).rank+=i)})},simplify:function(t){let e=(new HC).setGraph(t.graph());return t.nodes().forEach(n=>e.setNode(n,t.node(n))),t.edges().forEach(n=>{let r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),e},successorWeights:function(t){let e=t.nodes().map(e=>{let n={};return t.outEdges(e).forEach(e=>{n[e.w]=(n[e.w]||0)+t.edge(e).weight}),n});return tk(t.nodes(),e)},time:function(t,e){let n=Date.now();try{return e()}finally{console.log(t+" time: "+(Date.now()-n)+"ms")}},uniqueId:JC,zipObject:tk};function qC(t,e,n,r){for(var i=r;t.hasNode(i);)i=JC(r);return n.dummy=e,t.setNode(i,n),i}const $C=65535;function XC(t,e){if(e.length>$C){const n=function(t,e=$C){const n=[];for(let r=0;r<t.length;r+=e){const i=t.slice(r,r+e);n.push(i)}return n}(e);return t.apply(null,n.map(e=>t.apply(null,e)))}return t.apply(null,e)}function KC(t){const e=t.nodes().map(e=>{let n=t.node(e).rank;return void 0===n?Number.MIN_VALUE:n});return XC(Math.max,e)}let ZC=0;function JC(t){return t+""+ ++ZC}function QC(t,e,n=1){null==e&&(e=t,t=0);let r=t=>t<e;n<0&&(r=t=>e<t);const i=[];for(let e=t;r(e);e+=n)i.push(e);return i}function tk(t,e){return t.reduce((t,n,r)=>(t[n]=e[r],t),{})}let ek=FC,nk=WC.uniqueId;var rk={run:function(t){("greedy"===t.graph().acyclicer?ek(t,function(t){return e=>t.edge(e).weight}(t)):function(t){let e=[],n={},r={};function i(s){Object.hasOwn(r,s)||(r[s]=!0,n[s]=!0,t.outEdges(s).forEach(t=>{Object.hasOwn(n,t.w)?e.push(t):i(t.w)}),delete n[s])}return t.nodes().forEach(i),e}(t)).forEach(e=>{let n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,nk("rev"))})},undo:function(t){t.edges().forEach(e=>{let n=t.edge(e);if(n.reversed){t.removeEdge(e);let r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}})}};let ik=WC;var sk={run:function(t){t.graph().dummyChains=[],t.edges().forEach(e=>function(t,e){let n,r,i,s=e.v,o=t.node(s).rank,a=e.w,l=t.node(a).rank,c=e.name,u=t.edge(e),h=u.labelRank;if(l===o+1)return;for(t.removeEdge(e),i=0,++o;o<l;++i,++o)u.points=[],r={width:0,height:0,edgeLabel:u,edgeObj:e,rank:o},n=ik.addDummyNode(t,"edge",r,"_d"),o===h&&(r.width=u.width,r.height=u.height,r.dummy="edge-label",r.labelpos=u.labelpos),t.setEdge(s,n,{weight:u.weight},c),0===i&&t.graph().dummyChains.push(n),s=n;t.setEdge(s,a,{weight:u.weight},c)}(t,e))},undo:function(t){t.graph().dummyChains.forEach(e=>{let n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e)})}};const{applyWithChunking:ok}=WC;var ak={longestPath:function(t){var e={};t.sources().forEach(function n(r){var i=t.node(r);if(Object.hasOwn(e,r))return i.rank;e[r]=!0;let s=t.outEdges(r).map(e=>null==e?Number.POSITIVE_INFINITY:n(e.w)-t.edge(e).minlen);var o=ok(Math.min,s);return o===Number.POSITIVE_INFINITY&&(o=0),i.rank=o})},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};var lk=DC.Graph,ck=ak.slack,uk=function(t){var e,n,r=new lk({directed:!1}),i=t.nodes()[0],s=t.nodeCount();r.setNode(i,{});for(;hk(r,t)<s;)e=fk(r,t),n=r.hasNode(e.v)?ck(t,e):-ck(t,e),dk(r,t,n);return r};function hk(t,e){return t.nodes().forEach(function n(r){e.nodeEdges(r).forEach(i=>{var s=i.v,o=r===s?i.w:s;t.hasNode(o)||ck(e,i)||(t.setNode(o,{}),t.setEdge(r,o,{}),n(o))})}),t.nodeCount()}function fk(t,e){return e.edges().reduce((n,r)=>{let i=Number.POSITIVE_INFINITY;return t.hasNode(r.v)!==t.hasNode(r.w)&&(i=ck(e,r)),i<n[0]?[i,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function dk(t,e,n){t.nodes().forEach(t=>e.node(t).rank+=n)}var pk=uk,_k=ak.slack,gk=ak.longestPath,yk=DC.alg.preorder,mk=DC.alg.postorder,bk=WC.simplify,vk=xk;function xk(t){t=bk(t),gk(t);var e,n=pk(t);for(Ak(n),wk(n,t);e=Tk(n);)kk(n,t,e,Ck(n,t,e))}function wk(t,e){var n=mk(t,t.nodes());(n=n.slice(0,n.length-1)).forEach(n=>function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=Ek(t,e,n)}(t,e,n))}function Ek(t,e,n){var r=t.node(n).parent,i=!0,s=e.edge(n,r),o=0;return s||(i=!1,s=e.edge(r,n)),o=s.weight,e.nodeEdges(n).forEach(s=>{var a=s.v===n,l=a?s.w:s.v;if(l!==r){var c=a===i,u=e.edge(s).weight;if(o+=c?u:-u,function(t,e,n){return t.hasEdge(e,n)}(t,n,l)){var h=t.edge(n,l).cutvalue;o+=c?-h:h}}}),o}function Ak(t,e){arguments.length<2&&(e=t.nodes()[0]),Sk(t,{},1,e)}function Sk(t,e,n,r,i){var s=n,o=t.node(r);return e[r]=!0,t.neighbors(r).forEach(i=>{Object.hasOwn(e,i)||(n=Sk(t,e,n,i,r))}),o.low=s,o.lim=n++,i?o.parent=i:delete o.parent,n}function Tk(t){return t.edges().find(e=>t.edge(e).cutvalue<0)}function Ck(t,e,n){var r=n.v,i=n.w;e.hasEdge(r,i)||(r=n.w,i=n.v);var s=t.node(r),o=t.node(i),a=s,l=!1;s.lim>o.lim&&(a=o,l=!0);var c=e.edges().filter(e=>l===Rk(t,t.node(e.v),a)&&l!==Rk(t,t.node(e.w),a));return c.reduce((t,n)=>_k(e,n)<_k(e,t)?n:t)}function kk(t,e,n,r){var i=n.v,s=n.w;t.removeEdge(i,s),t.setEdge(r.v,r.w,{}),Ak(t),wk(t,e),function(t,e){var n=t.nodes().find(t=>!e.node(t).parent),r=yk(t,n);(r=r.slice(1)).forEach(n=>{var r=t.node(n).parent,i=e.edge(n,r),s=!1;i||(i=e.edge(r,n),s=!0),e.node(n).rank=e.node(r).rank+(s?i.minlen:-i.minlen)})}(t,e)}function Rk(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}xk.initLowLimValues=Ak,xk.initCutValues=wk,xk.calcCutValue=Ek,xk.leaveEdge=Tk,xk.enterEdge=Ck,xk.exchangeEdges=kk;var Mk=ak.longestPath,Ok=uk,Nk=vk,Ik=function(t){var e=t.graph().ranker;if(e instanceof Function)return e(t);switch(t.graph().ranker){case"network-simplex":default:Lk(t);break;case"tight-tree":!function(t){Mk(t),Ok(t)}(t);break;case"longest-path":Pk(t);case"none":}};var Pk=Mk;function Lk(t){Nk(t)}var Dk=function(t){let e=function(t){let e={},n=0;function r(i){let s=n;t.children(i).forEach(r),e[i]={low:s,lim:n++}}return t.children().forEach(r),e}(t);t.graph().dummyChains.forEach(n=>{let r=t.node(n),i=r.edgeObj,s=function(t,e,n,r){let i,s,o=[],a=[],l=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),o.push(i)}while(i&&(e[i].low>l||c>e[i].lim));s=i,i=r;for(;(i=t.parent(i))!==s;)a.push(i);return{path:o.concat(a.reverse()),lca:s}}(t,e,i.v,i.w),o=s.path,a=s.lca,l=0,c=o[l],u=!0;for(;n!==i.w;){if(r=t.node(n),u){for(;(c=o[l])!==a&&t.node(c).maxRank<r.rank;)l++;c===a&&(u=!1)}if(!u){for(;l<o.length-1&&t.node(c=o[l+1]).minRank<=r.rank;)l++;c=o[l]}t.setParent(n,c),n=t.successors(n)[0]}})};let Vk=WC;var Bk={run:function(t){let e=Vk.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var s=t.children(r);s&&s.length&&s.forEach(t=>n(t,i+1)),e[r]=i}return t.children().forEach(t=>n(t,1)),e}(t),r=Object.values(n),i=Vk.applyWithChunking(Math.max,r)-1,s=2*i+1;t.graph().nestingRoot=e,t.edges().forEach(e=>t.edge(e).minlen*=s);let o=function(t){return t.edges().reduce((e,n)=>e+t.edge(n).weight,0)}(t)+1;t.children().forEach(r=>zk(t,e,s,o,i,n,r)),t.graph().nodeRankFactor=s},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,t.edges().forEach(e=>{t.edge(e).nestingEdge&&t.removeEdge(e)})}};function zk(t,e,n,r,i,s,o){let a=t.children(o);if(!a.length)return void(o!==e&&t.setEdge(e,o,{weight:0,minlen:n}));let l=Vk.addBorderNode(t,"_bt"),c=Vk.addBorderNode(t,"_bb"),u=t.node(o);t.setParent(l,o),u.borderTop=l,t.setParent(c,o),u.borderBottom=c,a.forEach(a=>{zk(t,e,n,r,i,s,a);let u=t.node(a),h=u.borderTop?u.borderTop:a,f=u.borderBottom?u.borderBottom:a,d=u.borderTop?r:2*r,p=h!==f?1:i-s[o]+1;t.setEdge(l,h,{weight:d,minlen:p,nestingEdge:!0}),t.setEdge(f,c,{weight:d,minlen:p,nestingEdge:!0})}),t.parent(o)||t.setEdge(e,l,{weight:0,minlen:i+s[o]})}let Gk=WC;var Fk=function(t){t.children().forEach(function e(n){let r=t.children(n),i=t.node(n);if(r.length&&r.forEach(e),Object.hasOwn(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(let e=i.minRank,r=i.maxRank+1;e<r;++e)jk(t,"borderLeft","_bl",n,i,e),jk(t,"borderRight","_br",n,i,e)}})};function jk(t,e,n,r,i,s){let o={width:0,height:0,rank:s,borderType:e},a=i[e][s-1],l=Gk.addDummyNode(t,"border",o,n);i[e][s]=l,t.setParent(l,r),a&&t.setEdge(a,l,{weight:1})}function Uk(t){t.nodes().forEach(e=>Yk(t.node(e))),t.edges().forEach(e=>Yk(t.edge(e)))}function Yk(t){let e=t.width;t.width=t.height,t.height=e}function Hk(t){t.y=-t.y}function Wk(t){let e=t.x;t.x=t.y,t.y=e}let qk=WC;var $k=function(t){let e={},n=t.nodes().filter(e=>!t.children(e).length),r=n.map(e=>t.node(e).rank),i=qk.applyWithChunking(Math.max,r),s=qk.range(i+1).map(()=>[]);function o(n){if(e[n])return;e[n]=!0;let r=t.node(n);s[r.rank].push(n),t.successors(n).forEach(o)}let a=n.sort((e,n)=>t.node(e).rank-t.node(n).rank);return a.forEach(o),s};let Xk=WC.zipObject;function Kk(t,e,n){let r=Xk(n,n.map((t,e)=>e)),i=e.flatMap(e=>t.outEdges(e).map(e=>({pos:r[e.w],weight:t.edge(e).weight})).sort((t,e)=>t.pos-e.pos)),s=1;for(;s<n.length;)s<<=1;let o=2*s-1;s-=1;let a=new Array(o).fill(0),l=0;return i.forEach(t=>{let e=t.pos+s;a[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=a[e+1]),e=e-1>>1,a[e]+=t.weight;l+=t.weight*n}),l}let Zk=WC;var Jk=function(t,e){let n={};return t.forEach((t,e)=>{let r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)}),e.edges().forEach(t=>{let e=n[t.v],r=n[t.w];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(n[t.w]))}),function(t){let e=[];function n(t){return e=>{e.merged||(void 0===e.barycenter||void 0===t.barycenter||e.barycenter>=t.barycenter)&&function(t,e){let n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function r(e){return n=>{n.in.push(e),0===--n.indegree&&t.push(n)}}for(;t.length;){let i=t.pop();e.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return e.filter(t=>!t.merged).map(t=>Zk.pick(t,["vs","i","barycenter","weight"]))}(Object.values(n).filter(t=>!t.indegree))};let Qk=WC;var tR=function(t,e){let n=Qk.partition(t,t=>Object.hasOwn(t,"barycenter")),r=n.lhs,i=n.rhs.sort((t,e)=>e.i-t.i),s=[],o=0,a=0,l=0;r.sort((c=!!e,(t,e)=>t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:c?e.i-t.i:t.i-e.i)),l=eR(s,i,l),r.forEach(t=>{l+=t.vs.length,s.push(t.vs),o+=t.barycenter*t.weight,a+=t.weight,l=eR(s,i,l)});var c;let u={vs:s.flat(!0)};a&&(u.barycenter=o/a,u.weight=a);return u};function eR(t,e,n){let r;for(;e.length&&(r=e[e.length-1]).i<=n;)e.pop(),t.push(r.vs),n++;return n}let nR=function(t,e=[]){return e.map(e=>{let n=t.inEdges(e);if(n.length){let r=n.reduce((e,n)=>{let r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}},{sum:0,weight:0});return{v:e,barycenter:r.sum/r.weight,weight:r.weight}}return{v:e}})},rR=Jk,iR=tR;var sR=function t(e,n,r,i){let s=e.children(n),o=e.node(n),a=o?o.borderLeft:void 0,l=o?o.borderRight:void 0,c={};a&&(s=s.filter(t=>t!==a&&t!==l));let u=nR(e,s);u.forEach(n=>{if(e.children(n.v).length){let a=t(e,n.v,r,i);c[n.v]=a,Object.hasOwn(a,"barycenter")&&(o=a,void 0!==(s=n).barycenter?(s.barycenter=(s.barycenter*s.weight+o.barycenter*o.weight)/(s.weight+o.weight),s.weight+=o.weight):(s.barycenter=o.barycenter,s.weight=o.weight))}var s,o});let h=rR(u,r);!function(t,e){t.forEach(t=>{t.vs=t.vs.flatMap(t=>e[t]?e[t].vs:t)})}(h,c);let f=iR(h,i);if(a&&(f.vs=[a,f.vs,l].flat(!0),e.predecessors(a).length)){let t=e.node(e.predecessors(a)[0]),n=e.node(e.predecessors(l)[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+t.order+n.order)/(f.weight+2),f.weight+=2}return f};let oR=DC.Graph,aR=WC;var lR=function(t,e,n,r){r||(r=t.nodes());let i=function(t){var e;for(;t.hasNode(e=aR.uniqueId("_root")););return e}(t),s=new oR({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(e=>t.node(e));return r.forEach(r=>{let o=t.node(r),a=t.parent(r);(o.rank===e||o.minRank<=e&&e<=o.maxRank)&&(s.setNode(r),s.setParent(r,a||i),t[n](r).forEach(e=>{let n=e.v===r?e.w:e.v,i=s.edge(n,r),o=void 0!==i?i.weight:0;s.setEdge(n,r,{weight:t.edge(e).weight+o})}),Object.hasOwn(o,"minRank")&&s.setNode(r,{borderLeft:o.borderLeft[e],borderRight:o.borderRight[e]}))}),s};let cR=$k,uR=function(t,e){let n=0;for(let r=1;r<e.length;++r)n+=Kk(t,e[r-1],e[r]);return n},hR=sR,fR=lR,dR=function(t,e,n){let r,i={};n.forEach(n=>{let s,o,a=t.parent(n);for(;a;){if(s=t.parent(a),s?(o=i[s],i[s]=a):(o=r,r=a),o&&o!==a)return void e.setEdge(o,a);a=s}})},pR=DC.Graph,_R=WC;var gR=function t(e,n){if(n&&"function"==typeof n.customOrder)return void n.customOrder(e,t);let r=_R.maxRank(e),i=yR(e,_R.range(1,r+1),"inEdges"),s=yR(e,_R.range(r-1,-1,-1),"outEdges"),o=cR(e);if(bR(e,o),n&&n.disableOptimalOrderHeuristic)return;let a,l=Number.POSITIVE_INFINITY;for(let t=0,n=0;n<4;++t,++n){mR(t%2?i:s,t%4>=2),o=_R.buildLayerMatrix(e);let r=uR(e,o);r<l&&(n=0,a=Object.assign({},o),l=r)}bR(e,a)};function yR(t,e,n){const r=new Map,i=(t,e)=>{r.has(t)||r.set(t,[]),r.get(t).push(e)};for(const e of t.nodes()){const n=t.node(e);if("number"==typeof n.rank&&i(n.rank,e),"number"==typeof n.minRank&&"number"==typeof n.maxRank)for(let t=n.minRank;t<=n.maxRank;t++)t!==n.rank&&i(t,e)}return e.map(function(e){return fR(t,e,n,r.get(e)||[])})}function mR(t,e){let n=new pR;t.forEach(function(t){let r=t.graph().root,i=hR(t,r,n,e);i.vs.forEach((e,n)=>t.node(e).order=n),dR(t,n,i.vs)})}function bR(t,e){Object.values(e).forEach(e=>e.forEach((e,n)=>t.node(e).order=n))}let vR=DC.Graph,xR=WC;var wR=function(t){let e,n=xR.buildLayerMatrix(t),r=Object.assign(function(t,e){let n={};function r(e,r){let i=0,s=0,o=e.length,a=r[r.length-1];return r.forEach((e,l)=>{let c=function(t,e){if(t.node(e).dummy)return t.predecessors(e).find(e=>t.node(e).dummy)}(t,e),u=c?t.node(c).order:o;(c||e===a)&&(r.slice(s,l+1).forEach(e=>{t.predecessors(e).forEach(r=>{let s=t.node(r),o=s.order;!(o<i||u<o)||s.dummy&&t.node(e).dummy||ER(n,r,e)})}),s=l+1,i=u)}),r}return e.length&&e.reduce(r),n}(t,n),function(t,e){let n={};function r(e,r,i,s,o){let a;xR.range(r,i).forEach(r=>{a=e[r],t.node(a).dummy&&t.predecessors(a).forEach(e=>{let r=t.node(e);r.dummy&&(r.order<s||r.order>o)&&ER(n,e,a)})})}function i(e,n){let i,s=-1,o=0;return n.forEach((a,l)=>{if("border"===t.node(a).dummy){let e=t.predecessors(a);e.length&&(i=t.node(e[0]).order,r(n,o,l,s,i),o=l,s=i)}r(n,o,n.length,i,e.length)}),n}return e.length&&e.reduce(i),n}(t,n)),i={};["u","d"].forEach(s=>{e="u"===s?n:Object.values(n).reverse(),["l","r"].forEach(n=>{"r"===n&&(e=e.map(t=>Object.values(t).reverse()));let o=("u"===s?t.predecessors:t.successors).bind(t),a=function(t,e,n,r){let i={},s={},o={};return e.forEach(t=>{t.forEach((t,e)=>{i[t]=t,s[t]=t,o[t]=e})}),e.forEach(t=>{let e=-1;t.forEach(t=>{let a=r(t);if(a.length){a=a.sort((t,e)=>o[t]-o[e]);let r=(a.length-1)/2;for(let l=Math.floor(r),c=Math.ceil(r);l<=c;++l){let r=a[l];s[t]===t&&e<o[r]&&!AR(n,t,r)&&(s[r]=t,s[t]=i[t]=i[r],e=o[r])}}})}),{root:i,align:s}}(0,e,r,o),l=function(t,e,n,r,i){let s={},o=function(t,e,n,r){let i=new vR,s=t.graph(),o=function(t,e,n){return(r,i,s)=>{let o,a=r.node(i),l=r.node(s),c=0;if(c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":o=-a.width/2;break;case"r":o=a.width/2}if(o&&(c+=n?o:-o),o=0,c+=(a.dummy?e:t)/2,c+=(l.dummy?e:t)/2,c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":o=l.width/2;break;case"r":o=-l.width/2}return o&&(c+=n?o:-o),o=0,c}}(s.nodesep,s.edgesep,r);return e.forEach(e=>{let r;e.forEach(e=>{let s=n[e];if(i.setNode(s),r){var a=n[r],l=i.edge(a,s);i.setEdge(a,s,Math.max(o(t,e,r),l||0))}r=e})}),i}(t,e,n,i),a=i?"borderLeft":"borderRight";function l(t,e){let n=o.nodes(),r=n.pop(),i={};for(;r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}function c(t){s[t]=o.inEdges(t).reduce((t,e)=>Math.max(t,s[e.v]+o.edge(e)),0)}function u(e){let n=o.outEdges(e).reduce((t,e)=>Math.min(t,s[e.w]-o.edge(e)),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==a&&(s[e]=Math.max(s[e],n))}return l(c,o.predecessors.bind(o)),l(u,o.successors.bind(o)),Object.keys(r).forEach(t=>s[t]=s[n[t]]),s}(t,e,a.root,a.align,"r"===n);"r"===n&&(l=xR.mapValues(l,t=>-t)),i[s+n]=l})});let s=function(t,e){return Object.values(e).reduce((e,n)=>{let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([e,n])=>{let s=function(t,e){return t.node(e).width}(t,e)/2;r=Math.max(n+s,r),i=Math.min(n-s,i)});const s=r-i;return s<e[0]&&(e=[s,n]),e},[Number.POSITIVE_INFINITY,null])[1]}(t,i);return function(t,e){let n=Object.values(e),r=xR.applyWithChunking(Math.min,n),i=xR.applyWithChunking(Math.max,n);["u","d"].forEach(n=>{["l","r"].forEach(s=>{let o=n+s,a=t[o];if(a===e)return;let l=Object.values(a),c=r-xR.applyWithChunking(Math.min,l);"l"!==s&&(c=i-xR.applyWithChunking(Math.max,l)),c&&(t[o]=xR.mapValues(a,t=>t+c))})})}(i,s),function(t,e){return xR.mapValues(t.ul,(n,r)=>{if(e)return t[e.toLowerCase()][r];{let e=Object.values(t).map(t=>t[r]).sort((t,e)=>t-e);return(e[1]+e[2])/2}})}(i,t.graph().align)};function ER(t,e,n){if(e>n){let t=e;e=n,n=t}let r=t[e];r||(t[e]=r={}),r[n]=!0}function AR(t,e,n){if(e>n){let t=e;e=n,n=t}return!!t[e]&&Object.hasOwn(t[e],n)}let SR=WC,TR=wR;var CR=function(t){(function(t){let e=SR.buildLayerMatrix(t),n=t.graph().ranksep,r=0;e.forEach(e=>{const i=e.reduce((e,n)=>{const r=t.node(n).height;return e>r?e:r},0);e.forEach(e=>t.node(e).y=r+i/2),r+=i+n})})(t=SR.asNonCompoundGraph(t)),Object.entries(TR(t)).forEach(([e,n])=>t.node(e).x=n)};let kR=rk,RR=sk,MR=Ik,OR=WC.normalizeRanks,NR=Dk,IR=WC.removeEmptyRanks,PR=Bk,LR=Fk,DR={adjust:function(t){let e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||Uk(t)},undo:function(t){let e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){t.nodes().forEach(e=>Hk(t.node(e))),t.edges().forEach(e=>{let n=t.edge(e);n.points.forEach(Hk),Object.hasOwn(n,"y")&&Hk(n)})}(t);"lr"!==e&&"rl"!==e||(!function(t){t.nodes().forEach(e=>Wk(t.node(e))),t.edges().forEach(e=>{let n=t.edge(e);n.points.forEach(Wk),Object.hasOwn(n,"x")&&Wk(n)})}(t),Uk(t))}},VR=gR,BR=CR,zR=WC,GR=DC.Graph;var FR=function(t,e){let n=e&&e.debugTiming?zR.time:zR.notime;n("layout",()=>{let r=n(" buildLayoutGraph",()=>function(t){let e=new GR({multigraph:!0,compound:!0}),n=ZR(t.graph());return e.setGraph(Object.assign({},UR,KR(n,jR),zR.pick(n,YR))),t.nodes().forEach(n=>{const r=KR(ZR(t.node(n)),HR);Object.keys(WR).forEach(t=>{void 0===r[t]&&(r[t]=WR[t])}),e.setNode(n,r),e.setParent(n,t.parent(n))}),t.edges().forEach(n=>{let r=ZR(t.edge(n));e.setEdge(n,Object.assign({},$R,KR(r,qR),zR.pick(r,XR)))}),e}(t));n(" runLayout",()=>function(t,e,n){e(" makeSpaceForEdgeLabels",()=>function(t){let e=t.graph();e.ranksep/=2,t.edges().forEach(n=>{let r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)})}(t)),e(" removeSelfEdges",()=>function(t){t.edges().forEach(e=>{if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}})}(t)),e(" acyclic",()=>kR.run(t)),e(" nestingGraph.run",()=>PR.run(t)),e(" rank",()=>MR(zR.asNonCompoundGraph(t))),e(" injectEdgeLabelProxies",()=>function(t){t.edges().forEach(e=>{let n=t.edge(e);if(n.width&&n.height){let n=t.node(e.v),r={rank:(t.node(e.w).rank-n.rank)/2+n.rank,e:e};zR.addDummyNode(t,"edge-proxy",r,"_ep")}})}(t)),e(" removeEmptyRanks",()=>IR(t)),e(" nestingGraph.cleanup",()=>PR.cleanup(t)),e(" normalizeRanks",()=>OR(t)),e(" assignRankMinMax",()=>function(t){let e=0;t.nodes().forEach(n=>{let r=t.node(n);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,e=Math.max(e,r.maxRank))}),t.graph().maxRank=e}(t)),e(" removeEdgeLabelProxies",()=>function(t){t.nodes().forEach(e=>{let n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))})}(t)),e(" normalize.run",()=>RR.run(t)),e(" parentDummyChains",()=>NR(t)),e(" addBorderSegments",()=>LR(t)),e(" order",()=>VR(t,n)),e(" insertSelfEdges",()=>function(t){var e=zR.buildLayerMatrix(t);e.forEach(e=>{var n=0;e.forEach((e,r)=>{var i=t.node(e);i.order=r+n,(i.selfEdges||[]).forEach(e=>{zR.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:r+ ++n,e:e.e,label:e.label},"_se")}),delete i.selfEdges})})}(t)),e(" adjustCoordinateSystem",()=>DR.adjust(t)),e(" position",()=>BR(t)),e(" positionSelfEdges",()=>function(t){t.nodes().forEach(e=>{var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,s=r.y,o=n.x-i,a=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*o/3,y:s-a},{x:i+5*o/6,y:s-a},{x:i+o,y:s},{x:i+5*o/6,y:s+a},{x:i+2*o/3,y:s+a}],n.label.x=n.x,n.label.y=n.y}})}(t)),e(" removeBorderNodes",()=>function(t){t.nodes().forEach(e=>{if(t.children(e).length){let n=t.node(e),r=t.node(n.borderTop),i=t.node(n.borderBottom),s=t.node(n.borderLeft[n.borderLeft.length-1]),o=t.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-s.x),n.height=Math.abs(i.y-r.y),n.x=s.x+n.width/2,n.y=r.y+n.height/2}}),t.nodes().forEach(e=>{"border"===t.node(e).dummy&&t.removeNode(e)})}(t)),e(" normalize.undo",()=>RR.undo(t)),e(" fixupEdgeLabelCoords",()=>function(t){t.edges().forEach(e=>{let n=t.edge(e);if(Object.hasOwn(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}})}(t)),e(" undoCoordinateSystem",()=>DR.undo(t)),e(" translateGraph",()=>function(t){let e=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,s=t.graph(),o=s.marginx||0,a=s.marginy||0;function l(t){let s=t.x,o=t.y,a=t.width,l=t.height;e=Math.min(e,s-a/2),n=Math.max(n,s+a/2),r=Math.min(r,o-l/2),i=Math.max(i,o+l/2)}t.nodes().forEach(e=>l(t.node(e))),t.edges().forEach(e=>{let n=t.edge(e);Object.hasOwn(n,"x")&&l(n)}),e-=o,r-=a,t.nodes().forEach(n=>{let i=t.node(n);i.x-=e,i.y-=r}),t.edges().forEach(n=>{let i=t.edge(n);i.points.forEach(t=>{t.x-=e,t.y-=r}),Object.hasOwn(i,"x")&&(i.x-=e),Object.hasOwn(i,"y")&&(i.y-=r)}),s.width=n-e+o,s.height=i-r+a}(t)),e(" assignNodeIntersects",()=>function(t){t.edges().forEach(e=>{let n,r,i=t.edge(e),s=t.node(e.v),o=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=o,r=s),i.points.unshift(zR.intersectRect(s,n)),i.points.push(zR.intersectRect(o,r))})}(t)),e(" reversePoints",()=>function(t){t.edges().forEach(e=>{let n=t.edge(e);n.reversed&&n.points.reverse()})}(t)),e(" acyclic.undo",()=>kR.undo(t))}(r,n,e)),n(" updateInputGraph",()=>function(t,e){t.nodes().forEach(n=>{let r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,r.rank=i.rank,e.children(n).length&&(r.width=i.width,r.height=i.height))}),t.edges().forEach(n=>{let r=t.edge(n),i=e.edge(n);r.points=i.points,Object.hasOwn(i,"x")&&(r.x=i.x,r.y=i.y)}),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,r))})};let jR=["nodesep","edgesep","ranksep","marginx","marginy"],UR={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},YR=["acyclicer","ranker","rankdir","align"],HR=["width","height","rank"],WR={width:0,height:0},qR=["minlen","weight","width","height","labeloffset"],$R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},XR=["labelpos"];function KR(t,e){return zR.mapValues(zR.pick(t,e),Number)}function ZR(t){var e={};return t&&Object.entries(t).forEach(([t,n])=>{"string"==typeof t&&(t=t.toLowerCase()),e[t]=n}),e}let JR=WC,QR=DC.Graph;var tM={debugOrdering:function(t){let e=JR.buildLayerMatrix(t),n=new QR({compound:!0,multigraph:!0}).setGraph({});return t.nodes().forEach(e=>{n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)}),t.edges().forEach(t=>n.setEdge(t.v,t.w,{},t.name)),e.forEach((t,e)=>{let r="layer"+e;n.setNode(r,{rank:"same"}),t.reduce((t,e)=>(n.setEdge(t,e,{style:"invis"}),e))}),n}};var eM={graphlib:DC,layout:FR,debug:tM,util:{time:WC.time,notime:WC.notime},version:"1.1.8"};class nM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let r=bE(t.children[0]);if(!r)continue;var n=new eM.graphlib.Graph;n.setGraph({edgesep:e.edgeSep,nodesep:e.nodeSep,ranksep:e.rankSep}),n.setDefaultEdgeLabel(function(){return{}}),n.graph().rankdir=this._getDagreDirection(e.direction);let i=new Map;for(let e of t.children){let t=e.datum[xE];i.set(t,t+""),n.setNode(t,{label:e.text?e.text:"",width:e.bounds.width,height:e.bounds.height})}for(let t of r.linkList)n.setEdge(t.source,t.target);eM.layout(n);const s={};let o=d3.min(n.nodes().map(t=>n.node(t).y)),a=d3.min(n.nodes().map(t=>n.node(t).x)),l=e.left-a,c=e.top-o;for(const t of n.nodes())s[t]={x:n.node(t).x+l,y:n.node(t).y+c};for(let e of t.children){let t=e.datum[xE];HS(e,s[i.get(t)].x-e.x,s[i.get(t)].y-e.y)}}let r=cA(t,!0);for(let t of r)BE(t)}_getDagreDirection(t){switch(t){case UA.Left2Right:return"LR";case UA.Right2Left:return"RL";case UA.Top2Bottom:return"TB";case UA.Bottom2Top:return"BT"}}}class rM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let n=yE(t.children[0]);if(!n)continue;let r=Od(n._data),i=Math.max(...t.children.map(t=>t.bounds.width)),s=Math.max(...t.children.map(t=>t.bounds.height)),o=e.orientation==zA?[e.height,e.width]:[e.width,e.height],a=wp().nodeSize([i,s]).size(o)(r);this._apply(a,e,t)}BE(t)}_apply(t,e,n){let r,i,s=n.children.filter(e=>e.datum[xE]==t.data[xE])[0];switch(e.orientation){case zA:r=t.y+e.left,i=t.x+e.top;break;case GA:r=t.x+e.left,i=e.top+t.y}if(HS(s,r-s.x,i-s.y),t.children&&t.children.length>0)for(let r of t.children)this._apply(r,e,n)}}class iM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=this._inputVars.filter(t=>t.type===KE.PROPERTY&&t.property===gA.CHILDREN_ORDER)[0].element,n=e.layout,r=n.width?n.width:e.bounds.width,i=n.height?n.height:e.bounds.height,s=void 0===n.top?e.bounds.top:n.top,o=void 0===n.left?e.bounds.left:n.left,a=Od(e).sum(t=>t.type===Pw.Rect?t.width*t.height:0);Cp().size([r,i])(a),this._apply(a,o,s);let l=cA(t,!0);for(let t of l)BE(t)}_apply(t,e,n){if(t.data.type==Pw.Collection&&t.children)for(let r of t.children)this._apply(r,e,n);else t.data.type==Pw.Rect&&(t.data.resize(t.x1-t.x0,t.y1-t.y0),HS(t.data,t.x0+e-t.data.left,t.y0+n-t.data.top))}}class sM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){if(!t.layout)continue;if(0===t.children.length)continue;let e=yE(t.children[0]);if(!e)continue;let n={};for(let e of t.children)n[e.datum[xE]]=e;t.children[0].type===Pw.Rect?this._layoutRects(e.getRoot(),e,n):this._layoutArcs(e.getRoot(),e,n)}BE(t)}_layoutArcs(t,e,n){let r=e.getChildren(t);if(0===r.length)return;let i=n[t[xE]],s=!i||i.type!=Pw.Arc&&i.type!=Pw.Pie?60:i.startAngle;for(let t=0;t<r.length;t++){let i=r[t],o=n[i[xE]];if(o.type===Pw.Arc){let t=iS(s+o.angle);o.setAngles(s,t),s=t}this._layoutArcs(i,e,n)}}_layoutRects(t,e,n){let r=e.getChildren(t);if(0===r.length)return;let i,s,o=n[t[xE]];this._direction,i=o.left,s=o.bottom;for(let t=0;t<r.length;t++){let o=r[t],a=n[o[xE]];HS(a,i-a.left,s-a.top),i+=a.width,this._layoutRects(o,e,n)}}}class oM extends qE{constructor(t){super(t)}run(){super.run();let t=this.outputVar;t.clearResult();let e=this.inputVars.find(t=>void 0!==t.context),n=t.conditionalEncoding,r=e?e.context:void 0,i=aA(n.responderComponent).state,s=t.result;if(n.evalFunction){n.getResponderPeers().forEach(t=>s[t.id]=!!n.evalFunction(r,i,t))}}}class aM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let n=360/t.children.length;for(let[r,i]of t.children.entries()){i._rotate=void 0,i._markRotationOffset=void 0,i._updateBounds();let t=r*n,s=OE(e.x+e.radius,e.y,e.x,e.y,t);switch(HS(i,s.x-i.bounds.x,s.y-i.bounds.y),e.markRotation){case WA.INWARD:i._markRotationOffset=t+90;break;case WA.TANGENTIAL_CLOCKWISE:i._markRotationOffset=t;break;case WA.TANGENTIAL_COUNTERCLOCKWISE:i._markRotationOffset=t-180;break;case WA.UPRIGHT:break;case WA.OUTWARD:default:i._markRotationOffset=t-90}}}let n=cA(t,!0);for(let t of n)BE(t)}}class lM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let n of e){let e=n.layout;if(!e)continue;let r=Od(e._tree?e._tree._data:yE(n.children[0])._data);if(e.isRadial()){r=Rd().size([nS(e.angleExtent),e.radius])(r),e._d3Root=r;const t=new Map(r.descendants().map(t=>[t.data[xE],[t.x,t.y]]));for(let r of n.children){let n=r.datum[xE];HS(r,e.x-r.bounds.x,e.y-t.get(n)[1]-r.bounds.y),r._rotate=[rS(t.get(n)[0]),e.x,e.y]}}else if(e.orientation===GA){!e.width||e.width;let i=e.height?e.height:600;r=Rd().nodeSize([t.bounds.width+1,i/(r.height+1)])(r),e._d3Root=r;const s=new Map(r.descendants().map(t=>[t.data[xE],[t.x,t.y]]));let o=1/0,a=-o;r.each(t=>{t.x>a&&(a=t.x),t.x<o&&(o=t.x)}),e._x0=o;for(let t of n.children){let n=t.datum[xE];HS(t,s.get(n)[0]-o+e.left-t.bounds.x,s.get(n)[1]+e.top-t.bounds.y)}}else if(e.orientation===zA){!e.width||e.width;let i=e.height?e.height:600;r=Rd().nodeSize([t.bounds.height,i/(r.height+1)])(r),e._d3Root=r;const s=new Map(r.descendants().map(t=>[t.data[xE],[t.x,t.y]]));let o=1/0,a=-o;r.each(t=>{t.x>a&&(a=t.x),t.x<o&&(o=t.x)}),e._x0=o;for(let t of n.children){let n=t.datum[xE];HS(t,s.get(n)[1]+e.left-t.bounds.x,s.get(n)[0]-o+e.top-t.bounds.y)}}}let n=cA(t,!0);for(let t of n)BE(t)}}class cM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let n=e.direction===YA.ANTI_CLOCKWISE?-1:1;for(let[r,i]of t.children.entries()){i._rotate=void 0,i._markRotationOffset=void 0,i._updateBounds();let t=e.startRadius+e.radiusStep*r,s=e.startAngle+n*e.angleStep*r,o=OE(e.x+t,e.y,e.x,e.y,s);switch(HS(i,o.x-i.bounds.x,o.y-i.bounds.y),e.markRotation){case WA.INWARD:i._markRotationOffset=s+90;break;case WA.TANGENTIAL_CLOCKWISE:i._markRotationOffset=s;break;case WA.TANGENTIAL_COUNTERCLOCKWISE:i._markRotationOffset=s-180;break;case WA.UPRIGHT:break;case WA.OUTWARD:default:i._markRotationOffset=s-90}}}let n=cA(t,!0);for(let t of n)BE(t)}}class uM extends XE{constructor(t,e){super(t),this._cond=e}get context(){return this._cond}}class hM extends qE{constructor(t,e,n){super(t),this._fn=e,this._compnt=n}run(){super.run();let t=this.inputVars.find(t=>t instanceof uM),e=t?t.context:void 0,n=aA(this._compnt);if(this._fn(void 0,e,n?n.state:void 0,this._compnt),n)for(let t of this._outputVars){let e=t.element||t.stateContext;e&&e._scene&&(t.type===KE.CHANNEL?n.onChange(KE.CHANNEL,t.channel,e):t.type===KE.PROPERTY?n.onChange(KE.PROPERTY,t.property,e):t.type===KE.STATE&&n.onChange(KE.STATE,t.key,t.stateContext))}}}class fM extends XE{constructor(t,e,n,r=null){super(t),this._attribute=e,this._dataset=n,this._encoding=r}get attribute(){return this._attribute}get dataset(){return this._dataset}get encoding(){return this._encoding}}class dM extends qE{constructor(t){super(t)}run(){super.run();let t=this.outputVar,e=this.inputVars.find(t=>t instanceof fM),n=t.encodings[0].dataTable.type(e.attribute),r={};for(let e of t.encodings){let t=this._computeAttrValues(e,n);Object.assign(r,t)}t.attrValues=r}_computeAttrValues(t,e){if("vertex"===t.element.type)return this._computeVertexIndexAttrValues(t,e);let n=JE(t.element),r={};if(t.element.type===Pw.Area&&["width","height"].indexOf(t.channel)>=0||["fillGradient","strokeGradient"].indexOf(t.channel)>=0)for(let e of n)for(let n=0;n<e._vertices.length;n++)r[tA(e,n)]=e._vertices.hasDataScope(n)?e._vertices.aggregateDataScopeAttribute(n,t.attribute,t.aggregator):oE(e.dataScope,t.attribute,t.aggregator);else switch(e){case Vw.Boolean:break;case Vw.Date:for(let e of n)r[e.id]=iE(e.dataScope,t.attribute);break;case Vw.String:try{if("count"==t.aggregator)for(let e of n)r[e.id]=sE(e.dataScope,t.attribute).length;else for(let e of n)r[e.id]=iE(e.dataScope,t.attribute)}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t.attribute+" : "+e)}break;default:if(t.attribute.startsWith("parent.")||t.attribute.startsWith("child.")){let e=t.dataTable.tree.nodeTable,i=t.attribute.split(".")[0],s=t.attribute.split(".")[1];for(let t of n){let n=iE(t.dataScope,i);r[t.id]=iE(aE(cE(e),xE,n),s)}}else for(let e of n)r[e.id]=oE(e.dataScope,t.attribute,t.aggregator)}return t.attrValues=r,r}_computeVertexIndexAttrValues(t,e){let n={};for(let r of t.elementGroups)for(let i of r.groups)for(let r of i.indices){n[tA(i.parent,r)]=this._computeVertexIndexValue(i.parent,r,t,e)}return t.attrValues=n,n}_getVertexIndexContext(t,e,n){let r={type:"vertex",parent:t,index:e,_index:e,id:n};return Object.defineProperty(r,"dataScope",{get:()=>t._vertices.hasDataScope(e)?t._vertices.getDataScopeRef(e):t.dataScope}),Object.defineProperty(r,"datum",{get:()=>eE(r.dataScope)}),Object.defineProperty(r,"data",{get:()=>tE(r.dataScope)}),r}_computeVertexIndexValue(t,e,n,r){if(!t._vertices.hasDataScope(e))return this._computeValue(t.dataScope,n,r);if(n.attribute.startsWith("parent.")||n.attribute.startsWith("child."))return this._computeValue(t._vertices.getDataScopeRef(e),n,r);switch(r){case Vw.Boolean:return;case Vw.Date:return t._vertices.getDataScopeAttrVal(e,n.attribute);case Vw.String:return"count"==n.aggregator?t._vertices.getDataScopeAttributeValues(e,n.attribute).length:t._vertices.getDataScopeAttrVal(e,n.attribute);default:return t._vertices.aggregateDataScopeAttribute(e,n.attribute,n.aggregator)}}_computeValue(t,e,n){switch(n){case Vw.Boolean:return;case Vw.Date:return iE(t,e.attribute);case Vw.String:return"count"==e.aggregator?sE(t,e.attribute).length:iE(t,e.attribute);default:if(e.attribute.startsWith("parent.")||e.attribute.startsWith("child.")){let n=e.dataTable.tree.nodeTable,r=e.attribute.split(".")[0],i=e.attribute.split(".")[1],s=iE(t,r);return iE(aE(cE(n),xE,s),i)}return oE(t,e.attribute,e.aggregator)}}}class pM extends XE{constructor(t,e,n){super(t),this._key=e,this._stateContext=n}get key(){return this._key}get stateContext(){return this._stateContext}}class _M{constructor(){this._variables={},this._operators={},this._edges=[]}toJSON(){const t=this._edges.map(t=>({from:t.fromNode.id,to:t.toNode.id,isDirected:t.isDirected})),e={};for(const t in this._variables)e[t]=Object.values(this._variables[t]).map(t=>{let e={id:t.id,type:t.type,incoming:t.incomingEdges.map(t=>t.id),outgoing:t.outgoingEdges.map(t=>t.id),undirected:t.undirectedEdges.map(t=>t.id)};return"ChannelVar"===t.type?(e.channel=t.channel,e.element=t.element):"BoundsVar"===t.type||"DataScopeVar"===t.type?e.element=t.element:"dataValue"===t.type?(e.scale=t.scale,e.attrValues=t.attrValues):"FieldVar"===t.type?(e.field=t.field,e.dataset=t.dataset):"PropertyVar"===t.type?(e.property=t.property,e.element=t.element):t.type===KE.STATE?e.key=t.key:e.scale=t.scale,e});const n={};for(const t in this._operators)n[t]=Object.values(this._operators[t]).map(t=>{let e={id:t.id,type:t.type,inputVars:t.inputVars.map(t=>t.id),outputVar:t.outputVar?t.outputVar.id:null};return t.type===$E.DOMAIN_BUILDER?e.aggregator=t.aggregator:t.type===$E.SCALE_BUILDER&&(e.channel=t.channel),e});return{edges:t,variables:e,operators:n}}getVariable(t,...e){if(Object.values(KE).indexOf(t)<0)throw console.log(t),new Error("Variable Type Not Known");let n=this.findVariable(t,e);if(n)return n;switch(t){case KE.CHANNEL:n=new hA(t,e[0],e[1]),"vertex"!=e[1].type&&"segment"!=e[1].type||this._connectPathElement2Size(e[1],n);break;case KE.PROPERTY:n=new dA(t,e[0],e[1]);break;case KE.STATE:n=new pM(t,e[0],e[1]);break;case KE.ATTRIBUTE:n=new fM(t,e[0],e[1],e[2]||null);break;case KE.ITEMS:n=new VT(t,e[0]);break;case KE.ATTR_VALUE:n=new gT(t,e[0]);break;case KE.DATASCOPE:n=new fT(t,e[0]);break;case KE.BOUNDS:n=new hT(t,e[0]);break;case KE.SCALE:n=new _T(t,e[0]);break;case KE.AFFIXATION:n=new jT(t,e[0]);break;case KE.ALIGNMENT:n=new KT(t,e[0]);break;case KE.EVT_CTX:n=new uM(t,e[0],e[1]);break;case KE.CONDITION_RESULT:n=new MT(t,e[0])}return t in this._variables||(this._variables[t]={}),this._variables[t][n.id]=n,n}_connectPathElement2Size(t,e){let n=t.parent,r=e.channel,i=this.findVariable(KE.CHANNEL,["x"===r?"width":"height",n]);if(i){let t=i.incomingDataflow;t||(t=this.createOneWayDependency($E.CONDUIT)),this.connect(e,t),this.connect(t,i)}}findIncomingDataflowOperator(t,e){return e.incomingDataflow&&e.incomingDataflow.type===t?e.incomingDataflow:void 0}getIncomingDataflowOperator(t,e){let n=this.findIncomingDataflowOperator(t,e);return n||this.createOneWayDependency(t)}getOutgoingDataflowOperator(t,e){for(let n of e.outgoingEdges)if(n.toNode instanceof qE&&n.toNode.type===t)return n.toNode;return this.createOneWayDependency(t)}createOneWayDependency(t,...e){if(Object.values($E).indexOf(t)<0)throw new Error("Dependency Type Not Known");let n;switch(t){case $E.EVAL_BBOX:n=new bT(t);break;case $E.AFFIXER:n=new FT(t);break;case $E.DATA_EXTRACTOR:n=new dM(t,e[0]);break;case $E.SCALE_BUILDER:n=new mT(t,e[0]);break;case $E.ENCODER:n=new OT(t,e[0]);break;case $E.AXIS_PATH_PLACER:n=new vT(t);break;case $E.AXIS_TICKS_PLACER:n=new xT(t);break;case $E.AXIS_LABELS_PLACER:n=new wT(t);break;case $E.AXIS_TITLE_PLACER:n=new $T(t);break;case $E.LINK_PLACER:n=new JT(t);break;case $E.GRID_LAYOUT:n=new AT(t);break;case $E.STACK_LAYOUT:n=new PT(t);break;case $E.PACK_LAYOUT:n=new qT(t);break;case $E.FORCE_LAYOUT:n=new ZT(t);break;case $E.DIRECTED_LAYOUT:n=new nM(t);break;case $E.TIDY_TREE_LAYOUT:n=new rM(t);break;case $E.TREEMAP_LAYOUT:n=new iM(t);break;case $E.STRATA_LAYOUT:n=new sM(t);break;case $E.CIRCULAR_LAYOUT:n=new aM(t);break;case $E.CLUSTER_LAYOUT:n=new lM(t);break;case $E.SPIRAL_LAYOUT:n=new cM(t);break;case $E.GRIDLINES_PLACER:n=new NT(t);break;case $E.SPIRAL_TRAJECTORY_PLACER:n=new IT(t);break;case $E.BIN_TRANSFORMER:n=new DT(t);break;case $E.FILTER_TRANSFORMER:n=new BT(t);break;case $E.KDE_TRANSFORMER:n=new UT(t);break;case $E.CUSTOM_TRANSFORMER:n=new WT(t);break;case $E.REPOPULATE:n=new GT(t);break;case $E.TARGET_EVALUATOR:n=new oM(t);break;case $E.TARGET_UPDATER:n=new hM(t,e[0],e[1]);break;case $E.CONDUIT:default:n=new LT(t)}return t in this._operators||(this._operators[t]={}),this._operators[t][n.id]=n,n}createMultiWayDependency(t){if(Object.values($E).indexOf(t)<0)throw new Error("Dependency Type Not Known");let e;return $E.ALIGNER,e=new XT(t),t in this._operators||(this._operators[t]={}),this._operators[t][e.id]=e,e}connect(t,e,n=!0){if(t instanceof XE&&e instanceof qE){if(!e.inputVars.includes(t)){const r=new pT(t,e,n);return this._edges.push(r),t.outgoingEdges.push(r),e.inputVars.push(t),r}}else if(t instanceof qE&&e instanceof XE){if(!t.outputVars.includes(e)){const r=new pT(t,e,n);return this._edges.push(r),t.outputVars.push(e),e.incomingEdges.push(r),r}}else if(t instanceof XE&&e instanceof dT){if(!e.vars.includes(t)){const n=new pT(t,e,!1);return this._edges.push(n),e.vars.push(t),e.edges.push(t),t.undirectedEdges.push(n),n}}else{if(!(t instanceof dT&&e instanceof XE))throw new Error("An edge must connect a variable and an operator.");if(!t.vars.includes(e)){const n=new pT(e,t,!1);return this._edges.push(n),t.vars.push(e),t.edges.push(e),e.undirectedEdges.push(n),n}}}disconnectChannelVarFromBBoxOperator(t){let e=this.getOutgoingDataflowOperator($E.EVAL_BBOX,t),n=t.outgoingEdges.find(n=>n.fromNode===t&&n.toNode===e);n&&this.disconnect(t,e,n)}disconnect(t,e,n){if(t instanceof XE&&e instanceof qE){let r=t.outgoingEdges.findIndex(t=>t===n);r>=0&&(this._edges.splice(this._edges.indexOf(n),1),t.outgoingEdges.splice(r,1));let i=e.inputVars.findIndex(e=>e==t);i>=0&&e.inputVars.splice(i,1)}else if(t instanceof qE&&e instanceof XE){let r=e.incomingEdges.findIndex(t=>t===n);r>=0&&(this._edges.splice(this._edges.indexOf(n),1),e.incomingEdges.splice(r,1));let i=t.outputVars.findIndex(t=>t===e);i>=0&&t.outputVars.splice(i,1)}}deleteVariable(t){for(let e=t.incomingEdges.length-1;e>=0;e--){let n=t.incomingEdges[e],r=n.fromNode;this.disconnect(r,t,n),r.isIsolated()&&delete this._operators[r.type][r.id]}for(let e=t.outgoingEdges.length-1;e>=0;e--){let n=t.outgoingEdges[e],r=n.toNode;this.disconnect(t,r,n),r.isIsolated()&&delete this._operators[r.type][r.id]}delete this._variables[t.type][t.id]}deleteOperator(t){for(let e=t.outputVars.length-1;e>=0;e--){let n=t.outputVars[e],r=n.incomingEdges.find(e=>e.fromNode===t&&e.toNode===n);this.disconnect(t,n,r),n.isIsolated()&&delete this._variables[n.type][n.id]}for(let e=t.inputVars.length-1;e>=0;e--){let n=t.inputVars[e],r=n.outgoingEdges.find(e=>e.fromNode===n&&e.toNode===t);this.disconnect(n,t,r),n.isIsolated()&&delete this._variables[n.type][n.id]}delete this._operators[t.type][t.id]}addInteraction(t){}_dfs(t,e,n){if(t&&0!==t.outgoingEdges.length)for(let r of t.outgoingEdges)r.isDirected&&(e.push(r.toNode),this._dfs(r.toNode.outputVars[0],e.slice(),n));else n.push(e)}getOperatorsOnPath(t,e,n,...r){let i=this.findVariable(t,r);if(i){for(let t of i.outgoingEdges)if(t.isDirected){let r=t.toNode,i=e.indexOf(r);-1!==i&&e.splice(i,1),e.push(r);for(let t of r.outputVars)switch(t.type){case KE.ITEMS:this.getOperatorsOnPath(t.type,e,n,t.dataset);break;case KE.ATTRIBUTE:this.getOperatorsOnPath(t.type,e,n,t.attribute,t.dataset);break;case KE.DATASCOPE:case KE.BOUNDS:this.getOperatorsOnPath(t.type,e,n,t.element);break;case KE.CHANNEL:this.getOperatorsOnPath(t.type,e,n,t.channel,t.element);break;case KE.PROPERTY:this.getOperatorsOnPath(t.type,e,n,t.property,t.element);break;case KE.STATE:this.getOperatorsOnPath(t.type,e,n,t.key,t.stateContext);break;case KE.SCALE:case KE.ATTR_VALUE:this.getOperatorsOnPath(t.type,e,n,t.encodings[0]);break;case KE.CONDITION_RESULT:this.getOperatorsOnPath(t.type,e,n,t.conditionalEncoding)}}for(let t of i.undirectedEdges)n.push(t.operator)}else console.warn("Unable to find variables matching the described change: ",t,r)}findVariable(t,e){if(!(t in this._variables))return null;let n=Object.values(this._variables[t]);switch(t){case KE.CHANNEL:return n.find(t=>t.channel==e[0]&&BS(t.element)==BS(e[1]));case KE.PROPERTY:return n.find(t=>t.property==e[0]&&t.element==e[1]);case KE.STATE:return n.find(t=>t.key==e[0]&&t.stateContext==e[1]);case KE.AFFIXATION:return n.find(t=>t.affixation==e[0]);case KE.ATTRIBUTE:return e[2]?n.find(t=>t.attribute==e[0]&&t.dataset==e[1]&&t.encoding===e[2]):n.find(t=>t.attribute==e[0]&&t.dataset==e[1]&&!t.encoding);case KE.ITEMS:return n.find(t=>t.dataset==e[0]);case KE.ATTR_VALUE:case KE.SCALE:return n.find(t=>t.encodings.includes(e[0]));case KE.EVT_CTX:return n.find(t=>t.context===e[0]);case KE.CONDITION_RESULT:return n.find(t=>t.conditionalEncoding==e[0]);case KE.DATASCOPE:default:return e[0].classId?n.find(t=>BS(t.element)==BS(e[0])):n.find(t=>t.element.id==e[0].id)}}findVariablesByElement(t){let e={};for(let n in this._variables){let r=Object.values(this._variables[n]).filter(e=>e.element&&BS(e.element)==BS(t));r.length>0&&(e[n]=r)}return e}}class gM{constructor(t={}){this._attribute=t.attribute??null,this._numBins=t.numBins??null}get attribute(){return this._attribute}set attribute(t){this._attribute=t}get numBins(){return this._numBins}set numBins(t){this._numBins=t}get startAttr(){return this._attribute+"_bin_start"}get endAttr(){return this._attribute+"_bin_end"}get binIdAttr(){return this._attribute+"_bin_id"}}class yM{constructor(t={}){this._attribute=t.attribute??null,this._newAttribute=t.newAttribute??null,this._groupBy=t.groupBy??null,this._min=t.min??null,this._max=t.max??null,this._interval=t.interval??null,this._bandwidth=t.bandwidth??null}get attribute(){return this._attribute}set attribute(t){this._attribute=t}get newAttribute(){return this._newAttribute}set newAttribute(t){this._newAttribute=t}get groupBy(){return this._groupBy}set groupBy(t){this._groupBy=t}get min(){return this._min}set min(t){this._min=t}get max(){return this._max}set max(t){this._max=t}get interval(){return this._interval}set interval(t){this._interval=t}get bandwidth(){return this._bandwidth}set bandwidth(t){this._bandwidth=t}}class mM{constructor(t={}){this._attribute=t.attribute??null,this._type=t.type??null,this._value=t.value??null}get attribute(){return this._attribute}set attribute(t){this._attribute=t}get type(){return this._type}set type(t){this._type=t}get value(){return this._value}set value(t){this._value=t}}class bM{constructor(t,e){this._fn=t,e&&Object.assign(this,e)}get fn(){return this._fn}}class vM extends KA{constructor(t,e){super(e||{}),this._type=Pw.Trajectory,this._id=this._type+Dw(),this._collection=t,this._args=e||{},this._samplesPerStep="samplesPerStep"in this._args?this._args.samplesPerStep:12,this._extendPastLast="extendPastLast"in this._args?this._args.extendPastLast:0,"strokeColor"in this.styles||(this.styles.strokeColor="#bbb"),this._points=[]}get type(){return this._type}get id(){return this._id}get collection(){return this._collection}get samplesPerStep(){return this._samplesPerStep}set samplesPerStep(t){this._samplesPerStep=t}get extendPastLast(){return this._extendPastLast}set extendPastLast(t){this._extendPastLast=t}get points(){return this._points}updatePoints(){let t=this._collection?this._collection.layout:void 0,e=this._collection?this._collection.children.length:0;if(!t||0===e)return void(this._points=[]);let n=t.direction===YA.ANTI_CLOCKWISE?-1:1,r=e-1+this._extendPastLast;if(r<=0){let e=OE(t.x+t.startRadius,t.y,t.x,t.y,t.startAngle);return void(this._points=[e])}let i=Math.max(1,Math.round(r*this._samplesPerStep)),s=[];for(let e=0;e<=i;e++){let o=r*(e/i),a=t.startRadius+t.radiusStep*o,l=t.startAngle+n*t.angleStep*o;s.push(OE(t.x+a,t.y,t.x,t.y,l))}this._points=s}getSVGPathData(){if(0===this._points.length)return"";let t="M "+this._points[0].x+" "+this._points[0].y+" ";for(let e=1;e<this._points.length;e++)t+="L "+this._points[e].x+" "+this._points[e].y+" ";return t}_updateBounds(){if(0===this._points.length)return void(this._bounds=new PE(0,0,0,0));let t=this._points.map(t=>t.x),e=this._points.map(t=>t.y),n=Math.min(...t),r=Math.max(...t),i=Math.min(...e),s=Math.max(...e);this._bounds=new PE(n,i,r-n,s-i)}}class xM extends PA{constructor(t){super(),this._itemMap={},this._type=Pw.Scene,this._id=t&&t.id?t.id:this._type+Dw(),t&&t.fillColor&&(this.fillColor=t.fillColor),this._encodings={},this._relations=[],this._triggers={},this._condEncodings={},this._stateContext=new ZE(this),this._stateContext.__scene__=this,this._depGraph=new _M,this._renderers=[]}get depGraph(){return this._depGraph}get interactionTriggers(){return this._triggers}getConditionalEncodings(t){return this._condEncodings[t]||[]}_clearInteractionCaches(){for(let t in this._condEncodings)for(let e of this._condEncodings[t])e.clearResponderPeers()}get state(){return this._stateContext}mark(t,e){if(Object.values(Iw).indexOf(t)<0)throw new Error("Mascot does not allow directly creating a "+t);let n=void 0===e?{}:e;n.type=t;let r=aT(this,n);return null!==r&&(r._classId=r.id,this.addChild(r),this._itemMap[r.id]=r,mA(r,this._depGraph),EA(this,r,this._depGraph)),r}glyph(...t){let e=[];for(let n of t)e.push([n.parent,n]);let n=aT(this,{type:Pw.Glyph,children:t});if(null!==n){n._classId=n.id;for(let t of e)wA(t[0],t[1],this._depGraph);AA(n,this._depGraph),EA(this,n,this._depGraph)}return n}composite(){let t=aT(this,{type:Pw.Composite});return null!==t&&(t._classId=t.id,this.addChild(t),this._itemMap[t.id]=t,xA(t,this._depGraph),EA(this,t,this._depGraph)),t}_addAttributeEncoding(t){let e=BS(t.element);e in this._encodings||(this._encodings[e]={}),this._encodings[e][t.channel]=t}get tables(){let t={},e=this.children.filter(t=>t.type===Pw.Collection);for(let n of e){let e=n.dataScope?Jw(n.dataScope):null;e&&!(e.id in t)&&(t[e.id]=e)}return t}onChange(t,...e){if(Object.values(KE).indexOf(t)<0)throw new Error("Unknown Variable Type: "+t);let n=[],r=[],i=[];this._depGraph.getOperatorsOnPath(t,n,r,...e);let s=!1;for(let t of n)t.run(),t.needsFullRender&&(s=!0),i=i.concat(t.outputVars.filter(t=>t.type===KE.CHANNEL||t.type===KE.PROPERTY));for(let t of r)t.run();const o={};for(let t of i){let e="vertex"===t.element.type||"segment"===t.element.type?t.element.parent:t.element;e.id in o||(o[e.id]=[]);let n=t.channel||t.property;o[e.id].includes(n)||o[e.id].push(n)}if(s){for(const t of this._renderers)t._render(this);for(const t of this._renderers)t._renderChanges(this,o)}else for(const t of this._renderers)t._renderChanges(this,o);return o}gridlines(t,e,n){let r=n||{},i="rowId"==e?_E:e,s=r.element?VS(r.element,t):DS(i,t,this);if(s){s.attribute!==i&&console.warn("Cannot create a "+t+" axis for "+e);let n=[];if("x"==t)for(let t of s.scales)n.push({scale:t,elems:s.getNormalizedElements(t)});else if("width"==t){let t=lA(s.element),e=s.scales[0];if(t.layout&&t.layout.type==HE.GRID&&t.layout.numCols>1){let r=t.layout.getElementsByCol(!0);for(let t of r)n.push({scale:e,elems:t})}else n.push({scale:s.scales[0],elems:s.getNormalizedElements(s.scales[0])})}else if("y"==t){let t=lA(s.element);if(t.layout&&t.layout.type==HE.GRID&&t.layout.numRows>1){let e=t.layout.getElementsByRow(!0,s.element);for(let t of e)n.push({scale:s.getScale(t[0]),elems:t})}else n.push({scale:s.scales[0],elems:s.getNormalizedElements(s.scales[0])})}else if("height"==t){let t=lA(s.element),e=s.scales[0];if(t.layout&&t.layout.type==HE.GRID&&t.layout.numRows>1){let r=t.layout.getElementsByRow(!0,s.element);for(let t of r)n.push({scale:e,elems:t})}else n.push({scale:e,elems:s.getNormalizedElements(e)})}else if("polarRadius"==t||"polarAngle"==t){let t=r.element?r.element:s.element;!("origin"in r)&&s.origin&&(r.origin=s.origin),n.push({scale:s.scales[0],elems:JE(t,t.parent)})}for(let t of n){let e=new jS(s.channel,s.attribute,t.scale,t.elems,r);this.addChild(e),this._itemMap[e.id]=e,s.addRefElement(e),IA(e,this._depGraph),EA(this,e,this._depGraph)}}else{let n=r.element?r.element:iA(this,e);if(!n)return void console.warn("Cannot create "+t+" gridlines for "+e);let i=sA(n.parent);if(!i.layout)return void console.warn("Cannot create "+t+" gridlines for "+e);let s=JE(i);for(let n of s){let i=[];n.layout.type==HE.GRID&&n.layout.numRows>1&&"x"==t?i=n.layout.getElementsByRow():n.layout.type==HE.GRID&&n.layout.numCols>1&&"y"==t?i=n.layout.getElementsByCol():i.push(n.children);for(let s of i){let i=new jS(t,e,null,s,r);this.addChild(i),this._itemMap[i.id]=i,n.layout.addRefElement(i),IA(i,this._depGraph),EA(this,i,this._depGraph)}}}}trajectory(t,e){let n=e||{},r=sA(t);if(!r||!r.layout||r.layout.type!==HE.SPIRAL)return void console.warn("Cannot create a trajectory: element is not inside a collection with a spiral layout");let i=new vM(r,n);return this.addChild(i),this._itemMap[i.id]=i,r.layout.addRefElement(i),function(t,e){let n=e.getVariable(KE.BOUNDS,lA(t.collection)),r=e.getVariable(KE.PROPERTY,gA.TRAJECTORY_POSITION,t),i=e.createOneWayDependency($E.SPIRAL_TRAJECTORY_PLACER);e.connect(n,i),e.connect(i,r),i.run();let s=e.getVariable(KE.BOUNDS,t),o=e.getIncomingDataflowOperator($E.EVAL_BBOX,s);e.connect(r,o),e.connect(o,s)}(i,this._depGraph),EA(this,i,this._depGraph),BE(i),this.onChange(KE.PROPERTY,gA.TRAJECTORY_POSITION,i),i}axis(t,e,n){let r=n||{},i="rowId"==e?_E:e,s=[],o=r.element?VS(r.element,t):DS(i,t,this);if(o){o.attribute!==i&&console.warn("Cannot create a "+t+" axis for "+i);let e=[];if("x"==t||"width"==t){let t=lA(r.element?r.element:o.element);if(t.layout&&t.layout.type==HE.GRID&&t.layout.numCols>1){let n=t.layout.getElementsByCell(!0,o.element);for(let t of n)e.push({scale:o.getScale(t[0]),elems:t})}else e.push({scale:o.scales[0],elems:o.getNormalizedElements(o.scales[0])})}else if("y"==t||"height"==t){let t=lA(r.element?r.element:o.element);if(t.layout&&t.layout.type==HE.GRID&&t.layout.numRows>1){let n=t.layout.getElementsByCell(!0,o.element);for(let t of n)e.push({scale:o.getScale(t[0]),elems:t})}else e.push({scale:o.scales[0],elems:o.getNormalizedElements(o.scales[0])})}else if("polarRadius"==t||"polarAngle"==t){let t=r.element?r.element:o.element;!("origin"in r)&&o.origin&&(r.origin=o.origin),e.push({scale:o.scales[0],elems:JE(t,t.parent)})}for(let t of e){let e=Object.assign({},r);e.scale=t.scale,e.elems=t.elems,e.type="axis",e.axisType="encoding",e.enc=o,e.rawArgs=r;let n=aT(this,e);s.push(n),o.addRefElement(n),NA(n,this._depGraph),EA(this,n,this._depGraph),this.onChange(KE.PROPERTY,gA.AXIS_PATH_POSITION,n)}}else{let e=r.element?r.element:iA(this,i);if(!e)return void console.warn("Cannot create a "+t+" axis for "+i);let n=sA(e.parent);if(!n.layout)return void console.warn("Cannot create a "+t+" axis for "+i);let o=JE(n);for(let e of o){let n=[];e.layout.type==HE.GRID&&e.layout.numRows>1&&"x"==t?n=e.layout.getElementsByRow():e.layout.type==HE.GRID&&e.layout.numCols>1&&"y"==t?n=e.layout.getElementsByCol():n.push(e.children);for(let o of n){let n=Object.assign({},r);n.elems=o.slice(),n.type="axis",n.axisType="layout",n.channel=t,n.attribute=i;let a=aT(this,n);s.push(a),e.layout.addRefElement(a),OA(a,this._depGraph),EA(this,a,this._depGraph),this.onChange(KE.PROPERTY,gA.AXIS_PATH_POSITION,a)}}}return s.length>1?s:s[0]}legend(t,e,n){let r=n||{},i="rowId"==e?_E:e,s=r.element?VS(r.element,t):DS(i,t,this);if(s){s.attribute!==e&&console.warn("Cannot create a "+t+" legend for "+e);let n=pE(s.element).type(e);r.type="legend",r.enc=s,r.attrType=n;let i=aT(this,r);!function(t,e){let n=e.getVariable(KE.BOUNDS,t),r=e.getVariable(KE.PROPERTY,gA.LEGEND_POSITION,t),i=e.getIncomingDataflowOperator($E.EVAL_BBOX,n);e.connect(r,i),e.connect(i,n)}(i,this._depGraph),EA(this,i,this._depGraph),BE(i),this.onChange(KE.PROPERTY,gA.LEGEND_POSITION,i)}else console.warn("Cannot create a "+t+" legend for "+i)}mask(t){let e=lA(t),n=e||t;n.clipMask||n.createClipMask()}setLayout(t,e){if(t.layout&&(TA(t,t.layout,this._depGraph),e.type===HE.TREEMAP)){let e=t.firstChild;for(;e&&e.type===Pw.Collection&&e.layout;)TA(e,e.layout,this._depGraph),e=e.firstChild}if(JE(t).forEach(t=>{let n=e?e.clone():e;t._layout=n,n&&(n.group=t)}),CA(t,e,this._depGraph),t.children&&t.children.length>0){let e=cA(t,!0);for(let t of e)this.onChange(KE.CHANNEL,"x",t)}}derive(t,e){let n=t.clone();return e._scene=this,e instanceof gM?(!function(t,e,n,r){let i=r.getVariable(KE.ITEMS,e),s=r.getVariable(KE.ITEMS,n),o=r.createOneWayDependency($E.BIN_TRANSFORMER);r.connect(i,o),r.connect(o,s);let a=r.getVariable(KE.PROPERTY,gA.NUM_BINS,t);r.connect(a,o),o._binConfig=t,o.run()}(e,t,n,this._depGraph),n._binTransform=e):e instanceof yM?function(t,e,n,r){let i=r.getVariable(KE.ATTRIBUTE,t.attribute,e),s=r.getVariable(KE.ATTRIBUTE,t.newAttribute,n),o=r.getVariable(KE.ITEMS,n),a=r.createOneWayDependency($E.KDE_TRANSFORMER);a.args=t,r.connect(i,a),r.connect(a,s),r.connect(a,o),a.run()}(e,t,n,this._depGraph):e instanceof mM?function(t,e,n,r){let i=r.getVariable(KE.ITEMS,e),s=r.getVariable(KE.ITEMS,n),o=r.createOneWayDependency($E.FILTER_TRANSFORMER);o._spec=t,r.connect(i,o),r.connect(o,s);let a=r.getVariable(KE.PROPERTY,"value",t);r.connect(a,o),o.run()}(e,t,n,this._depGraph):e instanceof bM&&function(t,e,n,r){let i=r.getVariable(KE.ITEMS,e),s=r.getVariable(KE.ITEMS,n),o=r.createOneWayDependency($E.CUSTOM_TRANSFORMER);o._spec=t,r.connect(i,o),r.connect(o,s);for(let e of Object.keys(t)){if(e.startsWith("_"))continue;let n=r.getVariable(KE.PROPERTY,e,t);r.connect(n,o)}o.run()}(e,t,n,this._depGraph),n}getElement(t){return this._itemMap[t]}getAxis(t,e){return DS(t,e,this).refElements[0]}}function wM(t,e){return Xw(e[t.dt],t.attr2value||t.filters||{},t.rowIds)}class EM extends UE{constructor(t){super(),this.type=HE.DIRECTED,this._top="top"in t?t.top:0,this._left="left"in t?t.left:0,this._nodeSep="nodeSep"in t?t.nodeSep:100,this._edgeSep="edgeSep"in t?t.edgeSep:50,this._rankSep="rankSep"in t?t.rankSep:50,this._spreadLinks=!("spreadLinks"in t)||t.spreadLinks,this._direction="direction"in t?t.direction:UA.Top2Bottom}clone(){return new EM({top:this._top,left:this._left,nodeSep:this._nodeSep,edgeSep:this._edgeSep,rankSep:this._rankSep,spreadLinks:this._spreadLinks,direction:this._direction})}get top(){return this._top}get left(){return this._left}get nodeSep(){return this._nodeSep}get edgeSep(){return this._edgeSep}get rankSep(){return this._rankSep}get spreadLinks(){return this._spreadLinks}get direction(){return this._direction}}class AM extends UE{constructor(t){super(),this.type=HE.FORCE,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._iterations="iterations"in t?t.iterations:1,this._repulsion="repulsion"in t?t.repulsion:30,this._attraction="attraction"in t?t.attraction:1,this._linkDistance="linkDistance"in t?t.linkDistance:30}clone(){return new AM({x:this._x,y:this._y,iterations:this._iterations,repulsion:this._repulsion,attraction:this._attraction,linkDistance:this._linkDistance})}}class SM extends UE{constructor(t){super(),this.type=HE.PACKING,this._x="x"in t?t.x:400,this._y="y"in t?t.y:400,this._width=t.width,this._height=t.height}clone(){return new SM({x:this._x,y:this._y,width:this._width,height:this._height})}}class TM extends UE{constructor(t){super(),this.type=HE.STACK,this._orientation=t.orientation,this._direction=t.direction,this._left=t.left,this._top=t.top,this._horzCellAlignment="horzCellAlignment"in t&&t.horzCellAlignment?t.horzCellAlignment:zE.LEFT,this._vertCellAlignment="vertCellAlignment"in t&&t.vertCellAlignment?t.vertCellAlignment:zE.BOTTOM,this._gap="gap"in t?t.gap:0}clone(){let t=new TM({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return t._horzCellAlignment=this._horzCellAlignment,t._vertCellAlignment=this._vertCellAlignment,t}get horzCellAlignment(){return this._horzCellAlignment}get vertCellAlignment(){return this._vertCellAlignment}get orientation(){return this._orientation}set horzCellAlignment(t){this._horzCellAlignment=t}set vertCellAlignment(t){this._vertCellAlignment=t}set orientation(t){this._orientation=t}}class CM extends UE{constructor(t){super(),this.type=HE.STRATA,this._direction=t.direction,this._gap="gap"in t?t.gap:0}clone(){return new CM({direction:this._direction,gap:this._gap})}}class kM extends UE{constructor(t){super(),this.type=HE.TIDYTREE,this._width="width"in t?t.width:500,this._height="height"in t?t.height:500,this._left="left"in t?t.left:100,this._top="top"in t?t.top:100,this._orientation="orientation"in t?t.orientation:zA}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}get orientation(){return this._orientation}clone(){return new kM({width:this._width,height:this._height,top:this._top,left:this._left,orientation:this._orientation})}}class RM extends UE{constructor(t){super(),this.type=HE.TREEMAP,this._width=t.width,this._height=t.height,this._left=t.left,this._top=t.top}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}clone(){return new RM({width:this._width,height:this._height,top:this._top,left:this._left})}}class MM extends UE{constructor(t){super(),t=t||{},this.type=HE.SPIRAL,this._x="x"in t?t.x:100,this._y="y"in t?t.y:100,this._startRadius="startRadius"in t?t.startRadius:0,this._radiusStep="radiusStep"in t?t.radiusStep:8,this._startAngle="startAngle"in t?t.startAngle:90,this._angleStep="angleStep"in t?t.angleStep:40,this._direction="direction"in t?t.direction:YA.CLOCKWISE,this._markRotation="markRotation"in t?t.markRotation:this._direction===YA.CLOCKWISE?WA.TANGENTIAL_CLOCKWISE:WA.TANGENTIAL_COUNTERCLOCKWISE}get x(){return this._x}get y(){return this._y}get startRadius(){return this._startRadius}set startRadius(t){this._startRadius=t}get radiusStep(){return this._radiusStep}set radiusStep(t){this._radiusStep=t}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=t}get angleStep(){return this._angleStep}set angleStep(t){this._angleStep=t}get direction(){return this._direction}set direction(t){this._direction=t}get markRotation(){return this._markRotation}set markRotation(t){this._markRotation=t}clone(){return new MM({x:this._x,y:this._y,startRadius:this._startRadius,radiusStep:this._radiusStep,startAngle:this._startAngle,angleStep:this._angleStep,direction:this._direction,markRotation:this._markRotation})}}class OM extends UE{constructor(t){super(),this.type=HE.CIRCULAR,this._x="x"in t?t.x:100,this._y="y"in t?t.y:100,this._radius="radius"in t?t.radius:100,this._markRotation="markRotation"in t?t.markRotation:WA.INWARD}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}get markRotation(){return this._markRotation}set markRotation(t){this._markRotation=t}clone(){return new OM({x:this._x,y:this._y,radius:this._radius,markRotation:this._markRotation})}}function NM(t){switch(t.type){case HE.GRID:return function(t){let e=new eT(t.args);"left"in t&&(e._left=t.left);"top"in t&&(e._top=t.top);"cellBounds"in t&&(e._cellBounds=t.cellBounds.map(t=>IM(t)));"grid"in t&&(e._grid=t.grid);return e}(t);case HE.STACK:return function(t){let e=new TM(t.args);return e}(t);case HE.PACKING:return function(t){let e=new SM(t.args);return e}(t);case HE.FORCE:return function(t){return new AM(t.args)}(t);case HE.DIRECTED:return function(t){return new EM(t.args)}(t);case HE.TIDYTREE:return function(t){return new kM(t.args)}(t);case HE.TREEMAP:return function(t){return new RM(t.args)}(t);case HE.STRATA:return function(t){return new CM(t.args)}(t);case HE.SPIRAL:return function(t){return new MM(t.args)}(t);case HE.CIRCULAR:return function(t){return new OM(t.args)}(t);default:return void console.warn("unsupported layout type for deserialization:",t.type)}}function IM(t){return new PE(t.x-t.width/2,t.y-t.height/2,t.width,t.height)}function PM(t,e,n){t.type===Pw.Pie&&(t.type=Pw.Arc),t.args.type=t.type;let r=aT(e,t.args);return t.id&&(r._id=t.id),t.classId&&(r._classId=t.classId),t.dataScope&&(r.dataScope=wM(t.dataScope,n)),t.bounds&&(r._bounds=IM(t.bounds)),t.refBounds&&(r._refBounds=IM(t.refBounds)),function(t,e,n,r){if(t.vertices){const n=[];for(let e of t.vertices){const t=LM(e,r);n.push(t)}e.vertices=n}e.vertexCounter=t.vertexCounter,e.segmentCounter=t.segmentCounter,e.curveMode=t.curveMode}(t,r,0,n),r}function LM(t,e){let n={type:"vertex",id:t.id,x:t.x,y:t.y,shape:t.shape,width:t.width,height:t.height,radius:t.radius,fillColor:t.fillColor,opacity:t.opacity,strokeWidth:t.strokeWidth,strokeColor:t.strokeColor};return t.dataScope&&(n.dataScope=wM(t.dataScope,e)),"polarAngle"in t&&(n.polarAngle=t.polarAngle),n}function DM(t){let e={};e.fillColor=t.fillColor;let n=new xM(e);console.log("======== deserialization =========");let r={};if(t.tables)for(let e in t.tables){let n=t.tables[e];r[e]=new fE(n.data,n.url,n.attributeTypes),r[e]._id=n.id}let i={};if(t.scales)for(let e in t.scales)i[e]=GM(t.scales[e]);if(n.scales=i,zM(t,n,n,r),BM(t,n),t.encodings){let e={};for(let i of t.encodings){let t=FM(i,n,r);e[t.id]=t}for(let t in e){n._addAttributeEncoding(e[t]);let r=e[t]._baseEnc?e[e[t]._baseEnc]:void 0;MA(e[t],n._depGraph,r),r?n.onChange(KE.ATTR_VALUE,e[t]):n.onChange(KE.CHANNEL,e[t].channel,e[t].element)}}if(t.axes)for(let e of t.axes){let t=e.args?e.args:{};t.tickValues&&Object.values(r)[0].type(e.attr)===Vw.Date&&(t.tickValues=t.tickValues.map(t=>new Date(new Date(t).toISOString()))),e.id&&(t.id=e.id),n.axis(e.channel,e.attr,t)}if(t.gridlines)for(let e of t.gridlines)n.gridlines(e.channel,e.attr,e.args);if(t.trajectories)for(let e of t.trajectories){let t=n._itemMap[e.collectionId];t&&n.trajectory(t,e.args)}return t.bounds&&(n._bounds=IM(t.bounds)),delete n.scales,n}function VM(t,e,n,r){if(t.type===Pw.Collection){let i=aT(n,{type:Pw.Collection,id:t.id});t.classId&&(i._classId=t.classId),e.addChild(i),vA(i,n._depGraph),EA(e,i,n._depGraph),zM(t,i,n,r)}else if(t.type===Pw.Glyph){let i=aT(n,{type:Pw.Glyph,id:t.id});t.classId&&(i._classId=t.classId),e.addChild(i),AA(i,n._depGraph),EA(e,i,n._depGraph),zM(t,i,n,r)}else if(t.type===Pw.Composite){let i=aT(n,{type:Pw.Composite,id:t.id});e.addChild(i),n._itemMap[i.id]=i,xA(i,n._depGraph),EA(e,i,n._depGraph),zM(t,i,n,r),i._bounds=IM(t.bounds)}else if(t.type===Pw.Axis){let i=new AS({});e.addChild(i),function(t,e,n,r){t.id&&(e._id=t.id);if(e._children=[],t.labels){let i=new PA;zM(t.labels,i,n,r),e._labels=i,e._children.push(i)}t.path&&(e._path=VM(t.path,e,n,r));if(t.ticks){let i=new PA;zM(t.ticks,i,n,r),e._ticks=i,e._children.push(i)}t.title&&(e._title=VM(t.title,e,n,r))}(t,i,n,r),n._itemMap[i.id]=i}else if(Object.values(jE).includes(t.type)){let i=PM(t,n,r);return n._itemMap[i.id]=i,e.addChild(i),mA(i,n._depGraph),EA(e,i,n._depGraph),i}}function BM(t,e,n){if(t.children)for(let n of t.children)BM(n,e);else if(Object.values(jE).includes(t.type)){let n=e._itemMap[t.id];t.links&&(n.links=t.links.map(t=>e._itemMap[t])),t.source&&(n.source=e._itemMap[t.source]),t.target&&(n.target=e._itemMap[t.target])}}function zM(t,e,n,r){if(t.id&&(e._id=t.id),t.classId&&(e._classId=t.classId),t.dataScope&&(e.dataScope=wM(t.dataScope,r)),t.bounds&&(e._bounds=IM(t.bounds)),e._sortBy=t.sortBy,t.children)for(let i of t.children)VM(i,e,n,r);t.layout&&(e._layout=NM(t.layout),e._layout.group=e,CA(e,e._layout,n._depGraph))}function GM(t){let e=new MS(t.type,t.args);return e._id=t.id,e.domain=t.domain,e.range=t.range,e}function FM(t,e,n){let r=jM(t.element,t.elementType,e);r||console.warn("element not created:",t.element,t.elementType);let i=t.args?t.args:{};t.table&&(i.table=n[t.table]);let s=new US(r,t.channel,t.attr,t.aggregator?t.aggregator:"sum",i);if(s._id=t.id,t.scales&&(s._scales=t.scales.map(t=>e.scales[t])),i.baseEnc&&(s._baseEnc=t.args.baseEnc),t.elemGroups&&(s._elemGroups=t.elemGroups.map(t=>t.map(t=>jM(t,r.type,e)))),t.elem2scale){s._elem2scale={};for(let n in t.elem2scale)s._elem2scale[n]=e.scales[t.elem2scale[n]]}return i.startAngle&&(s.startAngle=i.startAngle),s}function jM(t,e,n){if("vertex"===e){let e=t.split("_v_");return n._itemMap[e[0]].vertices.find(e=>e.id===t)}if("segment"===e){let e=t.split("_s_");return n._itemMap[e[0]].segments.find(t=>t._id===parseInt(e[1]))}return n._itemMap[t]}function UM(t){let e={};return e.id=t._id,e.data=t._rawData,e.attributeTypes=t._attrTypes,e.url=t.url,e}function YM(t){let e={};return e.dt=t.dataTable.id,e.attr2value=Object.assign({},t.filters),t.rowIds&&(e.rowIds=t.rowIds.slice()),e}function HM(t,e){e.vertices=[];for(let n=0;n<t._vertices.length;n++)e.vertices.push(WM(t._vertices,n));e.vertexCounter=t.vertexCounter,e.segmentCounter=t.segmentCounter,e.curveMode=t.curveMode}function WM(t,e){let n={type:"vertex"};return n.id=t._ids[e],n.x=t._xs[e],n.y=t._ys[e],t.hasDataScope(e)&&(n.dataScope=YM(t.getDataScopeRef(e))),void 0!==t._polarAngles[e]&&(n.polarAngle=t._polarAngles[e]),n.shape=t._shapes[e],n.width=t._widths[e],n.height=t._heights[e],n.radius=t._radii[e],n.fillColor=t._fillColors[e],n.opacity=t._opacities[e],n.strokeWidth=t._strokeWidths[e],n.strokeColor=t._strokeColors[e],n}function qM(t){return t.type===Pw.Scene?function(t){let e=KM(t,{});e.fillColor=t.fillColor,e.scales={},e.encodings=[];for(let n in t._encodings)for(let r in t._encodings[n]){let i=t._encodings[n][r];i._forLegend||e.encodings.push(XM(i));for(let t of i._scales)t.id in e.scales||(e.scales[t.id]=$M(t))}e.tables={};let n=function(t){let e={};for(let n in t._encodings)for(let r in t._encodings[n]){let i=t._encodings[n][r];i.dataTable.id in e||i._forLegend||(e[i.dataTable.id]=i.dataTable)}for(let n of t.children)if(![Pw.Axis,Pw.Legend,Pw.Gridlines].includes(n.type)){if(n.dataScope){let t=Jw(n.dataScope);e[t.id]=t;break}if(n.children&&n.children.length>0){let t=n.firstChild;for(;t;){if(t.dataScope){let n=Jw(t.dataScope);e[n.id]=n;break}t=t.children&&t.children.length>0?t.firstChild:void 0}}}return e}(t);for(let t in n)e.tables[t]=UM(n[t]);return console.log("======== serialization ========="),console.log(e),e}(t):[Pw.Collection,Pw.Glyph,Pw.Composite].includes(t.type)?KM(t,{}):t instanceof AS?ZM(t,{}):t instanceof GE?function(t){let e={args:{}};e.type=t.type,e.id=t.id,t.classId&&(e.classId=t.classId),t.dataScope&&(e.dataScope=YM(t.dataScope)),t.bounds&&(e.bounds=t.bounds.toJSON()),t.refBounds&&(e.refBounds=t.refBounds.toJSON()),t.links&&(e.links=t.links.map(t=>t.id)),t.source&&(e.source=t.source.id),t.target&&(e.target=t.target.id);for(let n in t.styles)n.indexOf("Color")>0&&t.styles[n]instanceof vS?e.args[n]=t.styles[n].toJSON():e.args[n]=t.styles[n];switch(t.type){case Pw.Arc:case Pw.Pie:!function(t,e){e.args.x=t._x,e.args.y=t._y,e.args.innerRadius=t._innerRadius,e.args.outerRadius=t._outerRadius,e.args.startAngle=t._startAngle,e.args.endAngle=t._endAngle,e.args.direction=t._direction,e.args.thickness=t._thickness}(t,e),HM(t,e);break;case Pw.Area:!function(t,e){e.args.baseline=t._baseline,e.args.orientation=t._orientation}(t,e),HM(t,e);break;case Pw.Circle:!function(t,e){e.args.x=t.x,e.args.y=t.y,e.args.radius=t.radius}(t,e);break;case Pw.Image:break;case Pw.Symbol:!function(t,e){e.args.x=t.x,e.args.y=t.y,e.args.width=t.width,e.args.height=t.height,e.args.path=t.path,e.args.viewBox=t.viewBox}(t,e);break;case Pw.Line:case Pw.Path:case Pw.BezierCurve:HM(t,e);break;case Pw.SimpleText:!function(t,e){e.args.x=t._x,e.args.y=t._y,e.args.text=t._text,e.args.anchor=t._anchor,t._backgroundColor&&(e.args.backgroundColor=t._backgroundColor),t._borderWidth&&(e.args.borderWidth=t._borderWidth),t._borderColor&&(e.args.borderColor=t._borderColor)}(t,e);break;case Pw.Polygon:!function(t,e){e.args.x=t._x,e.args.y=t._y,e.args.radius=t._radius}(t,e),HM(t,e);break;case Pw.Rect:!function(t,e){e.args.width=t.width,e.args.height=t.height,e.args.top=t.top,e.args.left=t.left}(t,e),HM(t,e);case Pw.Ring:}return e}(t):(console.warn("unsupported serialization",t.type),{type:t.type})}function $M(t){let e={};return e.type=t.type,e.id=t.id,t._args&&(e.args=t._args),e.domain=t.domain,e.range=t.range,e}function XM(t){let e={};e.id=t._id,e.element=t._elem.id,e.elementType=t._elem.type,e.channel=t._channel,e.attr=t._attribute,e.aggregator=t._aggregator,e.table=t._table.id,e.args={},e.args.includeZero=t._includeZero,e.args.flipScale=t._flipScale,e.args.mapping=t._mapping,e.args.rangeExtent=t._preferredRangeExtent,e.args.domain=t._preferredDomain,e.args.scaleType=t._scaleType,e.args.scheme=t._colorScheme,t._baseEnc&&(e.args.baseEnc=t._baseEnc.id),e.scales=t._scales.map(t=>t.id),e.elemGroups=t._elemGroups.map(t=>t.map(t=>t.id)),e.elem2scale={};for(let n in t._elem2scale)e.elem2scale[n]=t._elem2scale[n].id;return"angle"==t.channel&&(e.args.startAngle=t.startAngle),e}function KM(t,e){if(e.id=t.id,e.type=t.type,t.classId&&(e.classId=t.classId),t.dataScope&&(e.dataScope=YM(t.dataScope)),e.bounds=t.bounds.toJSON(),t._layout&&(e.layout=function(t){switch(t.type){case HE.GRID:return function(t){let e={args:{}};return e.type=t.type,e.args.numCols=t._numCols,e.args.numRows=t._numRows,e.args.start=t._start,e.args.direction=t._direction,e.args.colGap=t._colGap,e.args.rowGap=t._rowGap,e.args.horzCellAlignment=t._cellHorzAlignment,e.args.vertCellAlignment=t._cellVertAlignment,e.args.rowOffset=t._rowOffset,e.args.colOffset=t._colOffset,e.left=t._left,e.top=t._top,e.group=t.group.id,e}(t);case HE.STACK:return function(t){let e={args:{}};return e.type=t.type,e.args.orientation=t._orientation,e.args.direction=t._direction,e.args.left=t._left,e.args.top=t._top,e.args.horzCellAlignment=t._horzCellAlignment,e.args.vertCellAlignment=t._vertCellAlignment,e.args.gap=t._gap,e.group=t.group.id,e}(t);case HE.PACKING:return function(t){let e={args:{}};return e.type=t.type,e.args.x=t._x,e.args.y=t._y,e.args.width=t._width,e.args.height=t._height,e.group=t.group.id,e}(t);case HE.FORCE:return function(t){let e={args:{}};return e.type=t.type,e.args.x=t._x,e.args.y=t._y,e.args.iterations=t._iterations,e.args.repulsion=t._repulsion,e.args.attraction=t._attraction,e.args.linkDistance=t._linkDistance,e.group=t.group.id,e}(t);case HE.CLUSTER:return function(t){let e={args:{}};return e.type=t.type,e.args.size=t._size,e.args.rootX=t._rootX,e.args.rootY=t._rootY,e}(t);case HE.DIRECTED:return function(t){let e={args:{}};return e.type=t.type,e.args.left=t._left,e.args.top=t._top,e.args.width=t._width,e.args.height=t._height,e.args.edgeSep=t._edgeSep,e.args.spreadLinks=t._spreadLinks,e.args.direction=t._direction,e}(t);case HE.TIDYTREE:return function(t){let e={args:{}};return e.type=t.type,e.args.left=t._left,e.args.top=t._top,e.args.width=t._width,e.args.height=t._height,e.args.orientation=t._orientation,e}(t);case HE.TREEMAP:return function(t){let e={args:{}};return e.type=t.type,e.args.left=t._left,e.args.top=t._top,e.args.width=t._width,e.args.height=t._height,e}(t);case HE.STRATA:return function(t){let e={args:{}};return e.type=t.type,e.args.direction=t._direction,e.args.gap=t._gap,e}(t);case HE.SPIRAL:return function(t){let e={args:{}};return e.type=t.type,e.args.x=t._x,e.args.y=t._y,e.args.startRadius=t._startRadius,e.args.radiusStep=t._radiusStep,e.args.startAngle=t._startAngle,e.args.angleStep=t._angleStep,e.args.direction=t._direction,e.args.markRotation=t._markRotation,e.group=t.group.id,e}(t);case HE.CIRCULAR:return function(t){let e={args:{}};return e.type=t.type,e.args.x=t._x,e.args.y=t._y,e.args.radius=t._radius,e.args.markRotation=t._markRotation,e.group=t.group.id,e}(t);default:throw new Error("unknow layout type "+t.type)}}(t._layout)),e.children=[],t.children.length>0)for(let n of t.children)n instanceof AS?ZM(n,e):n instanceof jS?JM(n,e):n instanceof vM?QM(n,e):e.children.push(qM(n));return e.sortBy=t._sortBy,e}function ZM(t,e){e.axes??=[];let n={};n.type=t._type,n.id=t._id,n.attr=t._attribute,n.channel=t._channel,n.args={},n.args.orientation=t._orientation,n.args.strokeColor=t._strokeColor,n.args.textColor=t._textColor,n.args.fontSize=t._fontSize,n.args.tickOffset=t._tickOffset,n.args.tickSize=t._tickSize,n.args.tickAnchor=t._tickAnchor,n.args.tickVisible=t._tickVisible,n.args.pathVisible=t._pathVisible,n.args.labelOffset=t._labelOffset,n.args.labelFormat=t._labelFormat,n.args.titleOffset=t._titleOffset,n.args.title=t._titleText,n.args.rotateTitle=t._rotateTitle,n.args.titleVisible=t._showTitle,n.args.labelRotation=t._labelRotation,e.axes.push(n)}function JM(t,e){e.gridlines??=[];let n={};n.type=t._type,n.id=t._id,n.attr=t._attribute,n.channel=t._channel,n.args=t._args,e.gridlines.push(n)}function QM(t,e){e.trajectories??=[];let n={};n.type=t._type,n.id=t._id,n.collectionId=t.collection.id,n.args=t._args,e.trajectories.push(n)}function tO(t,e){return void 0===t&&void 0===e||void 0!==t&&void 0!==e}function eO(t,e){const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&(0===n.length||n.every(t=>r.includes(t)))}function nO(t,e){if(!tO(t.layout,e.layout))return console.log("Not both defined or undefined:",t.bounds,e.bounds),!1;let n=t.layout,r=e.layout;if(!n&&!r)return!0;if(n.type!==r.type)return console.log("layout types are different:",n,r),!1;switch(n.type){case HE.GRID:return function(t,e){t._cellBounds.length!==e._cellBounds.length&&console.log("cell bounds length different:",t,e);for(let n=0;n<t._cellBounds;n++)if(!iO(t._cellBounds[n],e._cellBounds[n]))return console.log("cell bounds not equal:",t,e),!1;for(let n=0;n<t._grid.length;n++)for(let r=0;r<t._grid[n].length;r++)if(t._grid[n][r]!==e._grid[n][r])return console.log("grid not equal",t,e),!1;return t._numCols===e._numCols&&t._numRows===e._numRows&&t._start===e._start&&t._direction===e._direction&&t._rowGap===e._rowGap&&t._colGap===e._colGap&&t._cellHorzAlignment===e._cellHorzAlignment&&t._cellVertAlignment===e._cellVertAlignment&&t._rowOffset===e._rowOffset&&t._colOffset===e._colOffset&&t._left===e._left&&t._top===e._top}(n,r);case HE.STACK:return function(t,e){return t._orientation===e._orientation&&t._direction===e._direction&&t._left===e._left&&t._top===e._top&&t._horzCellAlignment===e._horzCellAlignment&&t._vertCellAlignment===e._vertCellAlignment&&t._gap===e._gap}(n,r);case HE.PACKING:return function(t,e){return t._x===e._x&&t._y===e._y&&t._width===e._width&&t._height===e._height}(n,r);case HE.FORCE:return function(t,e){return t._x===e._x&&t._y===e._y&&t._iterations===e._iterations&&t._repulsion===e._repulsion&&t._attraction===e._attraction&&t._linkDistance===e._linkDistance}(n,r);case HE.DIRECTED:return function(t,e){return t._width===e._width&&t._height===e._height&&t._top===e._top&&t._left===e._left&&t._edgeSep===e._edgeSep&&t._spreadLinks===e._spreadLinks&&t._direction===e._direction}(n,r);case HE.TIDYTREE:return function(t,e){return t._width===e._width&&t._height===e._height&&t._top===e._top&&t._left===e._left&&t._orientation===e._orientation}(n,r);case HE.STRATA:return function(t,e){return t._direction===e._direction&&t._gap===e._gap}(n,r);case HE.TREEMAP:return function(t,e){return t._width===e._width&&t._height===e._height&&t._top===e._top&&t._left===e._left}(n,r);case HE.SPIRAL:return function(t,e){return t._x===e._x&&t._y===e._y&&t._startRadius===e._startRadius&&t._radiusStep===e._radiusStep&&t._startAngle===e._startAngle&&t._angleStep===e._angleStep&&t._direction===e._direction&&t._markRotation===e._markRotation}(n,r);case HE.CIRCULAR:return function(t,e){return t._x===e._x&&t._y===e._y&&t._radius===e._radius&&t._markRotation===e._markRotation}(n,r);default:return!1}}function rO(t,e){if(!tO(t.bounds,e.bounds))return console.log("Not both defined or undefined:",t.bounds,e.bounds),!1;let n=t.bounds,r=e.bounds;return!n&&!r||iO(n,r)}function iO(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function sO(t,e){if(!tO(t,e))return console.log("Not both defined or undefined:",t,e),!1;if(t.type!==e.type)return console.log("Different mark types:",t,e),!1;if(t.id!==e.id)return console.log("id not equal:",t,e),!1;if(t.classId!==e.classId)return console.log("class id not equal:",t,e),!1;if(!aO(t,e))return console.log("DataScopes not equal",t,e),!1;if(!rO(t,e))return console.log("Bounds not equal",t,e),!1;if(!tO(t.links,e.links))return console.log("Not both defined or undefined: links ",t.links,e.links),!1;if(!tO(t.source,e.source))return console.log("Not both defined or undefined: source ",t.source,e.source),!1;if(!tO(t.target,e.target))return console.log("Not both defined or undefined: links ",t.target,e.target),!1;if(t.links&&e.links&&t.links.length!==e.links.length)return console.log("unequal number of links",t,e),!1;if(t.source&&e.source&&!sO(t.source,e.source))return console.log("different sources",t.source,e.source),!1;if(t.target&&e.target&&!sO(t.target,e.target))return console.log("different targets",t.target,e.target),!1;switch(t.type){case Pw.Arc:case Pw.Pie:return oO(t,e)?t.x===e.x&&t.y===e.y&&t.innerRadius===e.innerRadius&&t.outerRadius===e.outerRadius&&t.startAngle===e.startAngle&&t.endAngle===e.endAngle&&t.direction===e.direction&&t.thickness===e.thickness:(console.log("vertices not equal:",t,e),!1);case Pw.Area:return oO(t,e)?t.baseline===e.baseline&&t.orientation===e.orientation:(console.log("vertices not equal:",t,e),!1);case Pw.Circle:return t.x===e.x&&t.y===e.y&&t.radius===e.radius;case Pw.Image:return console.warn("not implemented"),!0;case Pw.Symbol:return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height&&t.path===e.path&&JSON.stringify(t.viewBox)===JSON.stringify(e.viewBox);case Pw.Line:case Pw.Path:case Pw.BezierCurve:return!!oO(t,e)||(console.log("vertices not equal:",t,e),!1);case Pw.SimpleText:return t.x===e.x&&t.y===e.y&&t.text===e.text&&t.anchor[0]===e.anchor[0]&&t.anchor[1]===e.anchor[1];case Pw.Polygon:return oO(t,e)?t.x===e.x&&t.y===e.y&&t.radius===e.radius:(console.log("vertices not equal:",t,e),!1);case Pw.Rect:return oO(t,e)?t.width===e.width&&t.height===e.height&&t.top===e.top&&t.left===e.left:(console.log("vertices not equal:",t,e),!1);case Pw.Ring:default:return console.warn("not implemented"),!0}}function oO(t,e){if(t.vertices.length!==e.vertices.length)return console.log("unequal number of vertices:",t,e),!1;for(let n=0;n<t.vertices.length;n++){let r=t.vertices[n],i=e.vertices[n];return r.id!==i.id?(console.log("vertex id not equal:",r,i),!1):r.x!==i.x||r.y!==i.y?(console.log("vertex position not equal:",r,i),!1):aO(r,i)?r._polarAngle===i._polarAngle&&r.shape===i.shape&&r.width===i.width&&r.height==i.height&&r.radius==i.radius&&r.fillColor==i.fillColor&&r.opacity==i.opacity&&r.strokeWidth==i.strokeWidth&&r.strokeColor==i.strokeColor:(console.log("vertex data scopes not equal:",r.dataScope,i.dataScope),!1)}}function aO(t,e){if(!tO(t.dataScope,e.dataScope))return console.log("Not both defined or undefined:",t.dataScope,e.dataScope),!1;if(!t.dataScope&&!e.dataScope)return!0;let n=t.dataScope,r=e.dataScope,i=n.filters||{},s=r.filters||{};if(!eO(i,s))return!1;for(let t in i)if(i[t]!==s[t])return!1;return n.dataTable.id===r.dataTable.id&&tE(n).length===tE(r).length}function lO(t,e){return t.type!==e.type&&console.log("Different types:",t.type,e.type),[Pw.Collection,Pw.Glyph,Pw.Composite].includes(t.type)?cO(t,e):t instanceof GE?sO(t,e):void 0}function cO(t,e){let n=t.children.filter(t=>!Object.values(Lw).includes(t.type)),r=e.children.filter(t=>!Object.values(Lw).includes(t.type));if(n.length!==r.length)return console.log("children length not equal:",n,r),!1;if(t.id!==e.id)return console.log("id not equal:",t,e),!1;if(t.classId!==e.classId)return console.log("class id not equal:",t,e),!1;if(!aO(t,e))return console.log("DataScopes not equal",t.dataScope,e.dataScope),!1;if(!rO(t,e))return console.log("Bounds not equal",t,e),!1;if(!nO(t,e))return console.log("Layouts not equal",t,e),!1;if(!function(t,e){if(!eO(t,e))return console.log("different keys",t,e),!1;for(let n in t)if(t[n]!==e[n])return!1;return!0}(t._sortBy,e._sortBy))return console.log("SortBy not equal",t,e),!1;for(let t=0;t<n.length;t++)if(!lO(n[t],r[t]))return console.log("Not equal",n[t],r[t]),!1;return!0}class uO extends UE{constructor(t){super(),this.type=HE.CLUSTER,this._isRadial="radial"in t&&t.radial,this._angleExtent="angleExtent"in t?t.angleExtent:360,this._radius="radius"in t?t.radius:300,this._rootX="x"in t?t.x:300,this._rootY="y"in t?t.y:300,this._orientation="orientation"in t?t.orientation:zA,this._width="width"in t?t.width:800,this._height="height"in t?t.height:600,this._left="left"in t?t.left:60,this._top="top"in t?t.top:100,this._tree="tree"in t?t.tree:void 0}get radius(){return this._radius}get angleExtent(){return this._angleExtent}get x(){return this._rootX}get y(){return this._rootY}get width(){return this._width}get height(){return this._height}get left(){return this._left}get top(){return this._top}isRadial(){return this._isRadial}get orientation(){return this._orientation}clone(){return new uO({radius:this._radius,angleExtent:this._angleExtent,x:this._rootX,y:this._rootY,radial:this._isRadial,orientation:this._orientation,left:this._left,top:this._top,width:this._width,height:this._height,tree:this._tree})}}function hO(t){return t.type===Pw.Collection&&!(t.children.length<2)}function fO(t,e,n,r,i,s,o,a,l,c){let u=n.map(t=>r.getParent(t)).filter((t,e,n)=>n.findIndex(e=>e[xE]===t[xE])===e);if(u=u.filter(t=>t!==r.getRoot()),0===u.length)return;let h=[];for(let n of u){let u,f,d,p=e.filter(t=>r.getParent(r.getNode(t.datum[xE]))===n);if(p[0].type===Pw.Circle){let t=p.map(t=>NE(o,a,t.bounds.x,t.bounds.y)-t.radius),e=p.map(t=>NE(o,a,t.bounds.x,t.bounds.y)+t.radius);d=l===HA.OUTWARD?d3.max(e):d3.min(t)-c;let n=p.map(t=>sS(t.bounds.x,t.bounds.y,o,a)),r=p.map(t=>sS(o+NE(o,a,t.bounds.x,t.bounds.y),a-t.radius,o,a)),i=n.map((t,e)=>t-r[e]),s=n.map((t,e)=>t+r[e]),h=i.concat(s);u=d3.min(h),f=d3.max(h)}else p[0].type===Pw.Arc&&(u=360,f=-360,p.forEach(t=>{let e=t.startAngle,n=t.endAngle;n<e&&(n+=360),u=d3.min([u,e]),f=d3.max([f,n])}),u=iS(u),f=iS(f),d=l===HA.OUTWARD?d3.max(p.map(t=>t.outerRadius)):d3.min(p.map(t=>t.innerRadius))-c);let _=aT(t,{type:"arc",innerRadius:d,outerRadius:d+c,x:o,y:a,startAngle:iS(u),endAngle:iS(f),strokeColor:e[0].strokeColor,fillColor:e[0].fillColor,strokeWidth:e[0].strokeWidth,opacity:e[0].opacity});_._updateBounds(),_.dataScope=r.getNodeDataScopeRef(n),_._classId=s,i.addChild(_),h.push(_)}fO(t,h,u,r,i,s,o,a,l,c)}function dO(t,e,n,r,i,s,o,a,l){l&&(t.dataScope=i.getNodeDataScopeRef(s),t._classId=e);let c=i.getChildren(s);if(0===c.length)return;let u=t.type===Pw.Circle||t.type===Pw.Ring?60:t.startAngle,h=(t.type===Pw.Circle||t.type===Pw.Ring?360:t.angle)/c.length;for(let s=0;s<c.length;s++){let l,f;f=n===HA.OUTWARD?t.type===Pw.Circle?t.radius:t.outerRadius:t.type===Pw.Circle?t.radius-r:t.innerRadius-r,l=aT(a,360===h?{type:"ring",innerRadius:f,outerRadius:f+r,x:t.x,y:t.y,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}:{type:"arc",innerRadius:f,outerRadius:f+r,x:t.x,y:t.y,startAngle:iS(u+h*s),endAngle:iS(u+h*(s+1)),strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}),l._updateBounds(),l.dataScope=i.getNodeDataScopeRef(c[s]),l._classId=e+"_strata",o.addChild(l),dO(l,e,n,r,i,c[s],o,a)}}function pO(t,e,n,r,i,s,o,a,l){l&&(t.dataScope=i.getNodeDataScopeRef(s),t._classId=e,o.addChild(t));let c,u,h,f=i.getChildren(s);if(0!==f.length){c=t.left,u=t.bottom,h=t.width/f.length;for(let s=0;s<f.length;s++){let a=uT(t);HS(a,c-a.left,u-a.top),a.resize(h,r),a._updateBounds(),c+=h,a.dataScope=i.getNodeDataScopeRef(f[s]),a._classId=e,o.addChild(a),pO(a,e,n,r,i,f[s],o)}}}class _O{constructor(t,e,n){this._elems=t,this._channel=e,this._anchor=n}get elements(){return this._elems}get channel(){return this._channel}get anchor(){return this._anchor}}class gO{constructor(t,e){this._elem=t,this._base=e,this._id=yO(t,e),this._channels={},this._attribute=void 0}get id(){return this._id}get element(){return this._elem}get base(){return this._base}get channels(){return Object.keys(this._channels)}addChannel(t,e){let n={};n.elemAnchor="elementAnchor"in e?e.elementAnchor:"x"==t||"angle"==t?zE.CENTER:zE.MIDDLE,n.baseAnchor="baseAnchor"in e?e.baseAnchor:"x"==t||"angle"==t?zE.CENTER:zE.MIDDLE,n.offset="offset"in e?e.offset:0,"attribute"in e&&(this._attribute=e.attribute),this._channels[t]=n}hasChannel(t){return t in this._channels}getElementAnchor(t){return this._channels[t].elemAnchor}getBaseAnchor(t){return this._channels[t].baseAnchor}getOffset(t){return this._channels[t].offset}get attribute(){return this._attribute?this._attribute:_E}}function yO(t,e){return(t.classId?t.classId:t.id)+":"+(e.classId?e.classId:e.id)}function mO(t,e,n,r){t.vertices[0].dataScope&&Jw(t.vertices[0].dataScope).has(e)?function(t,e,n,r){let i;if(e===_E)i=(t,n)=>parseInt(iE(t.dataScope,e).substring(1))-parseInt(iE(n.dataScope,e).substring(1));else{switch(Jw(t.vertices[0].dataScope).type(e)){case Vw.Date:break;case Vw.Number:case Vw.Integer:i=(t,n)=>oE(t.dataScope,e)-oE(n.dataScope,e);break;case Vw.String:i=r?(t,n)=>r.indexOf(iE(t.dataScope,e))-r.indexOf(iE(n.dataScope,e)):(t,n)=>iE(t.dataScope,e)<iE(n.dataScope,e)?-1:1}}t.vertices.sort(i),n&&t.vertices.reverse()}(t,e,n,r):function(t,e,n){let r=(t,n)=>t[e]-n[e];t.vertices.sort(r),n&&t.vertices.reverse()}(t,e,n),t._sortBy={property:e,descending:n,vals:r}}class bO{constructor(){this._vals={},this._vals.elements=[]}set(t,e){this._vals[t]=e}get(t){return this._vals[t]}clear(){this._vals={},this._vals.elements=[]}}class vO{constructor(t,e,n,r){this._respCompnt=e.object,this._respProps=e.properties||e.channels,this._responderEval=n,this._efxFn=r,this._evtCtx=t,this._evalResult={},this._responderPeers=void 0}get responderComponent(){return this._respCompnt}getResponderPeers(){if(!this._responderPeers){let t=Array.isArray(this._respCompnt)?this._respCompnt:[this._respCompnt];this._responderPeers=t.map(t=>JE(t)).flat()}return this._responderPeers}clearResponderPeers(){this._responderPeers=void 0}get responderProperties(){return this._respProps}get eventContext(){return this._evtCtx}get evalResult(){return this._evalResult}set evalResult(t){this._evalResult=t}get evalFunction(){return this._responderEval}get stylingFunction(){return this._efxFn}}class xO{constructor(t,e,n,r){this._id=t,this._event=n,this._source=e,this._evtCtx=new bO,this._cumulative=r}get id(){return this._id}get event(){return this._event}get eventContext(){return this._evtCtx}get source(){return this._source}isCumulative(){return this._cumulative}isMouseDriven(){return["brush","brushX","brushY","click","hover"].includes(this._event)}isKeyboardDriven(){return["keydown","keyup"].includes(this._event)}isWidgetDriven(){return["change","input"].includes(this._event)}isStateDriven(){return null!==this._source&&"object"==typeof this._source&&"stateVar"===this._source.type}}exports.activate=function(t,e,n,r,i){const s=aA(e.object);!function(t,e,n,r,i){if(!("event"in t)||!("source"in t))throw"Source and event must be specified in the trigger";if(!("object"in e))throw"Responder object must be specified";if(Array.isArray(r)){if(!r.every(t=>"function"==typeof t))throw"Updater must be a function";if(i&&!Array.isArray(i))throw"An array of effect setters must be accompanied by an array of animation effects";if(i&&Array.isArray(i)&&i.length!==r.length)throw"the length of effect setters is not equal to the length of animation effects"}else if("function"!=typeof r)throw"Updater must be a function"}(t,e,0,r,i);let o=t.event,a=function(t){let e="string"==typeof t.source?t.source:Array.isArray(t.source)?t.source.map(t=>t.classId||t.id).join("_"):"stateVar"===t.source.type?"state:"+t.source.key:t.source.classId?t.source.classId:t.source.id;return[e,t.event].join("-")}(t);o=0===o.indexOf("brush")?"brush":0===o.indexOf("drag")?"drag":o,o in s._triggers||(s._triggers[o]={}),a in s._triggers[o]||(s._triggers[o][a]=new xO(a,t.source,t.event,t.cumulative));let l=s._triggers[o][a].eventContext,c=new vO(l,e,n,r);return a in s._condEncodings||(s._condEncodings[a]=[]),s._condEncodings[a].push(c),function(t,e,n,r,i){let s=e.responderComponent,o=i&&i.source&&"stateVar"===i.source.type?r.getVariable(KE.STATE,i.source.key,i.source.stateContext):r.getVariable(KE.EVT_CTX,t),a=n.properties?n.properties:n.channels;if(e.evalFunction){let t=r.getVariable(KE.CONDITION_RESULT,e),n=r.findIncomingDataflowOperator($E.TARGET_EVALUATOR,t);n||(n=r.createOneWayDependency($E.TARGET_EVALUATOR,e.evalFunction)),r.connect(o,n),r.connect(n,t);for(let e of a){let n=Array.isArray(s)?s:[s];for(let i of n){let n=r.getVariable(KE.CHANNEL,e,i),s=n.incomingDataflow;if(s&&s.type===$E.ENCODER&&s.outputVar.channel===e)r.connect(t,s);else if(!s){let s=r.createOneWayDependency($E.ENCODER);r.connect(t,s),r.connect(s,n),s.storeValues(i,e)}}}}else{let t=r.createOneWayDependency($E.TARGET_UPDATER,e.stylingFunction,s);for(let e of a){let n;n=s instanceof ZE?r.getVariable(KE.STATE,e,s):Object.values(fA).includes(e)?r.getVariable(KE.CHANNEL,e,s):r.getVariable(KE.PROPERTY,pA(e),s),r.connect(o,t),r.connect(t,n)}}}(l,c,e,s._depGraph,t),s._triggers[o][a]},exports.affix=function(t,e,n,r){let i=aA(t);Jw(t.dataScope)!==Jw(e.dataScope)&&console.warn("Affix: elements and base elements are not created from the same table");let s=yO(t,e),o=i._relations.find(t=>t.id===s);o||(o=new gO(t,e),i._relations.push(o)),o.addChannel(n,r||{}),function(t,e){let n=e.getVariable(KE.AFFIXATION,t),r=e.getOutgoingDataflowOperator($E.AFFIXER,n);e.connect(n,r);for(let n of t.channels){let i=e.getVariable(KE.CHANNEL,n,t.element),s=e.getVariable(KE.CHANNEL,n,t.base);e.connect(s,r),e.connect(r,i)}r.run()}(o,i._depGraph)},exports.align=function(t,e,n){let r=aA(t[0]),i=new _O(t,e,n);!function(t,e){let n=e.createMultiWayDependency($E.ALIGNER),r=e.getVariable(KE.ALIGNMENT,t);e.connect(r,n);for(let r of t.elements){let i=e.getVariable(KE.CHANNEL,t.channel,r);e.connect(i,n)}n.run()}(i,r._depGraph),r._relations.push(i)},exports.attach=function(t,e){if(t.type==Pw.Glyph)for(let e of t.children)e._refBounds||(e._refBounds=e.bounds.clone());t.dataScope=cE(e)},exports.canClassify=hO,exports.canDensify=function(t){if([Pw.Line,Pw.Circle,Pw.Rect,Pw.Area].indexOf(t.type)<0)return!1;if(t.dataScope){let e=JE(t,t.scene);for(let t of e)if(nE(t.dataScope)>1)return!0;return!1}return!0},exports.canDivide=function(t){if([Pw.Line,Pw.Circle,Pw.Rect,Pw.Area,Pw.Ring,Pw.Pie,Pw.Path].indexOf(t.type)<0)return!1;if(t.type===Pw.Path&&(t.closed||!t.firstVertex.dataScope))return!1;if(t.dataScope){let e=JE(t);for(let t of e)if(nE(t.dataScope)>1)return!0;return!1}return!0},exports.canRepeat=tT,exports.classify=function(t,e){let n=aA(t),r=e||{};if(console.log("------ classify by",r.attribute," ----"),!hO(t))throw new Error("The "+t.type+" is not classifiable");return function(t,e,n,r){let i=JE(e);for(let e of i){let i,s={},o=e.children;for(let t of o){let e=iE(t.dataScope,n);e in s||(s[e]=[]),s[e].push(t)}let a=pE(o[0]);for(let o in s){let l=aT(t,{type:Pw.Collection});e.addChild(l),void 0===i&&(i=l.id),l._classId=i,l.dataScope=aE(e.dataScope?e.dataScope:cE(a),n,o);for(let t of s[o])l.addChild(t);r&&(l._layout=r.clone(),l._layout.group=l)}}}(n,t,r.attribute,r.layout),wA(t,t.firstChild.firstChild,n._depGraph),vA(t.firstChild,n._depGraph),EA(t.firstChild,t.firstChild.firstChild,n._depGraph),EA(t,t.firstChild,n._depGraph),n.onChange(KE.CHANNEL,"width",t.firstChild.firstChild),t.firstChild},exports.connect=function(t,e){let n=aA(t[0]),r={};t.forEach(t=>r[iE(t.dataScope,xE)]=t);let i=Jw(e[0].dataScope),s=i.tree?"parent":"source",o=i.tree?"child":"target";for(let e of t)e.links=[];for(let t of e){let e=iE(t.dataScope,s),n=iE(t.dataScope,o),i=r[e],a=r[n];t.source=i,t.target=a,i.links.push(t),a.links.push(t)}kA(t.find(t=>t.links.length>0),n._depGraph),n.onChange(KE.CHANNEL,"x",t[0])},exports.csv=async function(t){return async function(t){let e=await wE("GET",t),n=Da(e.trim(),Za);return new fE(n,t)}(t)},exports.csvString=function(t){return function(t){let e=Da(t.trim(),Za);return new fE(e,"fromString")}(t)},exports.deserialize=function(t){return DM(t)},exports.findElements=rA,exports.getLeafMarks=cA,exports.getPeers=JE,exports.graphJSON=async function(t){return async function(t){let e=await wE("GET",t);return new mE(JSON.parse(e),t)}(t)},exports.isEqual=function(t,e){return function(t,e){return t.fillColor!==e.fillColor?(console.log("fillColor not equal:",t,e),!1):cO(t,e)}(t,e)},exports.isMark=FE,exports.isRefElement=function(t){return t.type===Pw.Axis||t.type===Pw.Legend||t.type===Pw.Gridlines},exports.layout=function(t,e){let n=e||{};switch(t.toLowerCase()){case HE.STACK:return new TM(n);case HE.PACKING:return new SM(n);case HE.FORCE:return new AM(n);case HE.DIRECTED:return new EM(n);case HE.TIDYTREE:return new kM(n);case HE.TREEMAP:return new RM(n);case HE.CIRCULAR:return new OM(n);case HE.CLUSTER:return new uO(n);case HE.SPIRAL:return new MM(n);case HE.GRID:default:return new eT(n)}},exports.repopulate=function(t,e,n){t.dataScope=void 0;let r=aA(t),i=t;for(let t in n){zT(r,i,n[t],e);let s=LS(i.children[0]);for(let t of s)PS(t,r);let o=JE(i);for(let t of o)if(t.layout){for(let e of t.layout.refElements)ES(e,r),bA(e,r._depGraph);t.layout.clearRefElements()}i=i.children[0]}t.dataScope=cE(e),r.onChange(KE.CHANNEL,"width",t.children[0])},exports.scene=function(t){return new xM(t)},exports.serialize=function(t){return qM(t)},exports.sortChildren=function(t,e,n,r){let i=aA(t);if(t instanceof PA)!function(t,e,n,r){t.dataScope&&Jw(t.dataScope).has(e)?function(t,e,n,r){if(!Jw(t.dataScope).has(e))return void console.warn("Cannot order collection children by an non-existent attribute",e);let i;if(e===_E)i=(t,n)=>parseInt(iE(t.dataScope,e).substring(1))-parseInt(iE(n.dataScope,e).substring(1));else{switch(Jw(t.children[0].dataScope).type(e)){case Vw.Date:break;case Vw.Number:case Vw.Integer:i=(t,n)=>oE(t.dataScope,e)-oE(n.dataScope,e);break;case Vw.String:i=r?(t,n)=>r.indexOf(iE(t.dataScope,e))-r.indexOf(iE(n.dataScope,e)):(t,n)=>iE(t.dataScope,e)<iE(n.dataScope,e)?-1:1}}t.children.sort(i),n&&t.children.reverse()}(t,e,n,r):function(t,e,n){let r;switch(e){case"x":case"y":case"width":case"height":r=(t,n)=>t.bounds[e]-n.bounds[e];break;default:r=(t,n)=>t[e]-n[e]}t._children.sort(r),n&&t.children.reverse()}(t,e,n);t._sortBy={property:e,descending:n,vals:r}}(t,e,n,r),i.onChange(KE.PROPERTY,gA.CHILDREN_ORDER,t);else if(t instanceof KA){let i=JE(t);for(let t of i)mO(t,e,n,r)}},exports.stratify=function(t,e,n){if(!(e instanceof gE||Array.isArray(e)&&e.every(t=>t instanceof gE)))throw"Cannot stratify on a non-tree dataset";if(![Pw.Circle,Pw.Rect,Pw.Ring].includes(t.type))throw"Cannot stratify elements that are not rects, circles, or rings";let r=aA(t),i=n||{},s=i.direction,o=i.size,a=t.parent,l=function(t,e,n,r,i,s){switch(e.type){case Pw.Circle:case Pw.Ring:return function(t,e,n,r,i,s){let o,a=n||HA.OUTWARD,l=i||50;if(a!==HA.INWARD&&a!==HA.OUTWARD)throw"Unknown direction to stratify";let c,u=JE(e,t),h=Array.isArray(s)?s:[s];if(r){let n=aT(t,{type:Pw.Collection});n.dataScope=void 0,null==c&&(c=n.id),n._classId=c;let r=u.map(t=>h[0].getNode(t.datum[xE]));fO(t,u,r,h[0],n,e.classId?e.classId:e.id,400,350,a,l),o=n}else u.forEach((n,r)=>{let i=aT(t,{type:Pw.Collection});i.dataScope=void 0,null==c&&(c=i.id),i._classId=c;let s=n.parent;dO(n,e.id,a,l,h[r],h[r].getRoot(),i,t,!0),i._layout=new CM({direction:a}),i._layout.group=i,s.addChild(i),n===e&&(o=i)});return o}(t,e,n,r,i,s);case Pw.Rect:return function(t,e,n,r,i,s){let o,a,l=n||UA.Top2Bottom,c=i||50;if(!Object.values(UA).includes(l))throw"Unknown direction to stratify";return JE(e).forEach(n=>{let r=aT(t,{type:Pw.Collection});r.dataScope=void 0,null==a&&(a=r.id),r._classId=a;let i=n.parent;pO(n,e.id,l,c,s,s.getRoot(),r,t,!0),r._layout=new CM({direction:l}),r._layout.group=r,i.addChild(r),n===e&&(o=r)}),o}(t,e,n,0,i,s)}}(r,t,s,i.startFromLeaf,o,e);return wA(a,t,r._depGraph),vA(l,r._depGraph),l.children.length>0&&EA(l,l.firstChild,r._depGraph),EA(l.parent,l,r._depGraph),l},exports.table=function(t){return new fE(t,"")},exports.transform=function(t,e){switch(t){case"kde":return new yM(e);case"filter":return new mM(e);default:return new gM(e)}},exports.treeJSON=async function(t){return async function(t){let e=await wE("GET",t);return new gE(JSON.parse(e),t)}(t)},exports.update=function(t,e){if(!t)throw new Error("update: target is required");if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("update: patch must be an object");if(YE(t)){let n=t.group?[t.group]:[],r=[];for(let t of n)r=r.concat(JE(t));0===r.length&&(r=n);for(let t of r)if(t.layout)for(const[n,r]of Object.entries(e))t.layout[n]=r;let i=aA(t);if(i)for(let t of n)t.firstChild&&i.onChange(KE.CHANNEL,"width",t.firstChild);return}let n=JE(t),r=aA(t);for(const[i,s]of Object.entries(e))if("layout"!==i)for(let t of n)TT(t,i,s);else if(r&&"function"==typeof r.setLayout)r.setLayout(t,s);else for(let t of n)t.layout=s;if("width"in e&&n.forEach(t=>{t._refBounds&&t._refBounds.setWidth(e.width)}),"height"in e&&n.forEach(t=>{t._refBounds&&t._refBounds.setHeight(e.height)}),r)for(let n in e)"layout"!==n&&(["vertex","segment"].includes(t.type)&&!["x","y"].includes(n)||(Object.values(fA).includes(n)?r.onChange(KE.CHANNEL,n,t):r.onChange(KE.PROPERTY,n,t)))};
4
+ t.polarAngle=n;break;case"polarRadius":{let e=RT(r&&r._preferredOrigin?r._preferredOrigin[0]:t.parent.x,r&&r._preferredOrigin?r._preferredOrigin[1]:t.parent.y,n,t.polarAngle);NT(t,e[0]),IT(t,e[1]);break}case"visibility":t.visibility=n;break;case"src":t.src=n;break;case"path":t.path=n;break;case"vxOpacity":if(t instanceof ZA)for(let r of t.children)MT(r,e,n);else t.vxOpacity=n;break;default:if("vertex"===t.type)t[e]=n;else if(t instanceof ZA)for(let r of t.children)MT(r,e,n);else{if(t.styles[e]==n)return;t.styles[e]=n}}"vertex"===t.type?t.parent._dirty=!0:t._dirty=!0}function OT(t,e){t._outerRadius=e,t.vertices[1].x=t._x+t._outerRadius*Math.cos(t._sr),t.vertices[1].y=t._y-t._outerRadius*Math.sin(t._sr),t.vertices[2].x=t._x+t._outerRadius*Math.cos(t._er),t.vertices[2].y=t._y-t._outerRadius*Math.sin(t._er)}function NT(t,e){"vertex"==t.type?t.x=e:XA(t,e-t.x,0)}function IT(t,e){"vertex"==t.type?t.y=e:XA(t,0,e-t.y)}class PT extends XE{constructor(t,e){super(t),this._result=e.evalResult,this._condEnc=e}get result(){return this._condEnc.evalResult}clearResult(){this._condEnc.evalResult={}}get conditionalEncoding(){return this._condEnc}}class LT extends qE{constructor(t){super(t)}storeValues(t,e){this._storedValues={};let n=JE(t);for(let t of n)this._storedValues[t.id]=t[e]}_restoreValue(t,e){let n=this._storedValues[t.id];t[e]!==n&&MT(t,e,n)}run(){super.run();let t=this.inputVars.find(t=>t instanceof bT),e=this.outputVar,n=t?t.getEncoding(e.channel,e.element):null,r=e.channel,i=this.inputVars.filter(t=>t instanceof PT),s=i.length>0?i.map(t=>t.conditionalEncoding):[],o=s.length>0?s[0].eventContext:null,a=["x","y","width","height","radius"].includes(e.channel);if(t&&"vertex"===e.element.type)return this._runVertexIndexEncoding(n,r),void BE(e.element.parent);let l=JE(e.element),c=l[0].scene;for(let e of l){if(t){let t=n.getScale(e);this._doMapping(e,t,n.attrValues,n),a&&this._updateRefBounds(e,t,n)}else this._restoreValue(e,r);if(i.length>0){let t=s.map(t=>t.evalResult[e.id]).every(t=>t||void 0===t);s[0].stylingFunction(t,o,c.state,e)}}if(a){BE(["vertex","segment"].includes(e.element.type)?e.element.parent:e.element)}}_runVertexIndexEncoding(t,e){for(let n=0;n<t.scales.length;n++){let r=t.scales[n],i=t.getElements(r),s=[];for(let n of i.groups){n.parent._vertices;for(let i of n.indices){let s=tA(n.parent,i),o=t.attrValues[s],a="text"===e?o:r.map(o);this._setVertexIndexChannel(n.parent,i,e,a,t)}n.parent._dirty=!0,"x"!==e&&"y"!==e||s.includes(n.parent)||(this._updateVertexParentRefBounds(n.parent,e,r,t),s.push(n.parent))}}}_setVertexIndexChannel(t,e,n,r,i){let s=t._vertices;switch(n){case"x":s._xs[e]=r;break;case"y":s._ys[e]=r;break;case"polarRadius":{let n=s._polarAngles[e]*Math.PI/180,o=i&&i._preferredOrigin;if(!o&&"number"!=typeof t.radius)throw new Error('Mascot: encode(..., "polarRadius", ...) needs an explicit {origin: [x, y]} option because the encoded shape has no fixed center of its own -- e.g. it came from densify() on a "line" mark rather than a "circle".');let a=o?i._preferredOrigin[0]:t.x,l=o?i._preferredOrigin[1]:t.y;s._xs[e]=a+r*Math.cos(n),s._ys[e]=l-r*Math.sin(n);break}default:s.setProperty(e,n,r)}}_updateVertexParentRefBounds(t,e,n,r){let i=t.refBounds;"x"===e?t._refBounds=new PE(r.flipScale?n.range[1]:n.range[0],i.top,n.rangeExtent,i.height):"y"===e&&(t._refBounds=new PE(i.left,r.flipScale?n.range[0]:n.range[1],i.width,n.rangeExtent))}_updateRefBounds(t,e,n){switch(this.outputVar.channel){case"width":t._refBounds.setWidth(e.rangeExtent);break;case"height":t._refBounds.setHeight(e.rangeExtent);break;case"radius":t._refBounds.setWidth(2*e.rangeExtent,zE.CENTER),t._refBounds.setHeight(2*e.rangeExtent,zE.MIDDLE);break;case"x":if("vertex"==t.type||"segment"==t.type){let r=t.parent._refBounds;t.parent._refBounds=new PE(n.flipScale?e.range[1]:e.range[0],r.top,e.rangeExtent,r.height)}else if(t._refBounds)if("band"===e.type){let r=e.map(n.attrValues[t.id]),i=t._refBounds;t._refBounds=new PE(r-t.width/2,i.top,t.width,i.height)}else{let r=t.parent;for(;r&&(!r.layout||r.layout.type!==HE.GRID);)r=r.parent;if(r){let r=t._refBounds;t._refBounds=new PE(n.flipScale?e.range[1]:e.range[0],r.top,e.rangeExtent,r.height)}}break;case"y":if("vertex"==t.type||"segment"==t.type){let r=t.parent._refBounds;t.parent._refBounds=new PE(r.left,n.flipScale?e.range[0]:e.range[1],r.width,e.rangeExtent)}else if(t._refBounds){let r=t.parent;for(;r&&(!r.layout||r.layout.type!==HE.GRID);)r=r.parent;if(r){let r=t._refBounds,i=et(e.range);t._refBounds=new PE(r.left,n.flipScale?e.range[0]:i,r.width,e.rangeExtent)}}}}_doMapping(t,e,n,r){switch(this.outputVar.channel){case"width":e.domain[0]<0&&t instanceof PS?function(t,e,n){let r=t.refBounds.left+e.map(0),i=t.refBounds.left+e.map(n[t.id]);XA(t.leftSegment,r-t.leftSegment.x,0),XA(t.rightSegment,i-t.rightSegment.x,0)}(t,e,n):e.domain[0]<0&&t instanceof ES||(t.type===Pw.Area?function(t,e,n){let r=t.baseline;if(t.orientation===rS){let i=t._vertices.length/2;switch(r){case"left":JS(t,i,t._vertices.length,t.refBounds.left),QS(t,0,i,r=>t.refBounds.left+e.map(n[tA(t,r)]));break;case"right":QS(t,i,t._vertices.length,r=>t.refBounds.right-e.map(n[tA(t,r)])),JS(t,0,i,t.refBounds.right);break;case"center":console.log("center"),QS(t,i,t._vertices.length,r=>t.refBounds.center-e.map(n[tA(t,r)])/2),QS(t,0,i,r=>t.refBounds.center+e.map(n[tA(t,r)])/2)}}}(t,e,n):this._doStandardMapping(t,e,n,r));break;case"height":e.domain[0]<0&&t instanceof PS?function(t,e,n){let r=t.refBounds.bottom-e.map(0),i=t.refBounds.bottom-e.map(n[t.id]);XA(t.bottomSegment,0,r-t.bottomSegment.y),XA(t.topSegment,0,i-t.topSegment.y)}(t,e,n):e.domain[0]<0&&t instanceof ES?function(t,e,n){let r=t._vertices.length/2;eT(t,0,r,r=>t.refBounds.bottom-e.map(n[tA(t,r)])),tT(t,r,t._vertices.length,t.refBounds.bottom-e.map(0))}(t,e,n):t.type===Pw.Area?function(t,e,n){let r=t.baseline;if(t.orientation===nS){let i=t._vertices.length/2;switch(r){case"top":eT(t,i,t._vertices.length,r=>t.refBounds.top+e.map(n[tA(t,r)])),tT(t,0,i,t.refBounds.top);break;case"middle":eT(t,0,i,r=>t.refBounds.middle-e.map(n[tA(t,r)])/2),eT(t,i,t._vertices.length,r=>t.refBounds.middle+e.map(n[tA(t,r)])/2);break;default:eT(t,0,i,r=>t.refBounds.bottom-e.map(n[tA(t,r)])),tT(t,i,t._vertices.length,t.refBounds.bottom)}}}(t,e,n):this._doStandardMapping(t,e,n,r);break;case"text":this._doTextMapping(t,n);break;case"fillGradient":!function(t,e,n,r){let i=t._vertices._ids.map((e,r)=>n[tA(t,r)]),s=d3.min(i),o=d3.max(i),a="horizontal"===t.orientation?new VS({x1:0,y1:100,x2:0,y2:0}):new VS({x1:0,y1:0,x2:100,y2:0});if(a.addStop(0,e.map(s),1),r._mapping){let t=Object.keys(r._mapping).map(t=>parseFloat(t)).sort();for(let n of t)n>s&&n<o&&a.addStop(100*(n-s)/(o-s),e.map(n),1)}else"divergingColor"===e.type&&a.addStop(100*-s/(o-s),e.map(0),1);"sequentialColor"===e.type&&a.addStop(100*-s/(o-s),e.map(0),1),a.addStop(100,e.map(o),1),t.fillColor=a}(t,e,n,r);break;case"strokeGradient":!function(t,e,n){let r=[];for(let i=0;i<t._vertices.length;i++)r.push(e.map(n[tA(t,i)]));t.strokeColor=new BS(r)}(t,e,n);break;default:this._doStandardMapping(t,e,n,r)}}_doTextMapping(t,e){MT(t,this.outputVar.channel,e[t.id])}_doStandardMapping(t,e,n,r){let i=this.outputVar.channel,s=e.map(n[t.id]);MT(t,i,s,r),t instanceof dS&&t.firstVertex&&t.firstVertex.shape&&"strokeColor"===i&&t.vertices.forEach(t=>t.fillColor=s)}_doCondEncoding(t,e){let n=t[0].scene;for(let r of t){let t=e.map(t=>t.evalResult[r.id]).every(t=>t||void 0===t),i=e[0].eventContext;e[0].stylingFunction(t,i,r,n)}}_updateElement(t,e,n,r){let i;"object"==typeof r&&t.triggerElement?"property"in r?i=t.triggerElement[r.property]:"attribute"in r&&(i=t.triggerElement.datum[r.attribute]):i=r,["x","y"].includes(n)&&"offset"in r&&(i+=r.offset),MT(e,n,i)}}class DT extends qE{constructor(t){super(t)}run(){let t=this.outputVar.element;t.updateValues(),t.scale?this._runForEncoding(t):this._runForLayout(t),BE(t)}_runForLayout(t){let e=t.channel,n=DE(t.elements),r=[];if("x"===e)for(let e=0;e<t.values.length;e++){let i=t.elements[e].refBounds;r.push({x1:i.x,y1:n.bottom,x2:i.x,y2:n.top})}else if("y"===e)for(let e=0;e<t.values.length;e++){let i=t.elements[e].refBounds;r.push({x1:n.left,y1:i.y,x2:n.right,y2:i.y})}t.lines=r,t._dirty=!0}_runForEncoding(t){let e=t.channel,n=DE(t.elements),r=[];if("x"===e){let e,i,s=jA(t.elements[0],"y");s?(e=Math.min(...s.getScale(t.elements[0]).range,n.top),i=Math.max(...s.getScale(t.elements[0]).range,n.bottom)):(e=n.top,i=n.bottom);for(let n of t.values)r.push({x1:t.scale.map(n),y1:i,x2:t.scale.map(n),y2:e})}else if("width"===e)for(let e of t.values)r.push({x1:t.scale.map(e)+n.left,y1:n.bottom,x2:t.scale.map(e)+n.left,y2:n.top});else if("y"===e){let e,i,s=jA(t.elements[0],"x");s?(e=Math.min(...s.getScale(t.elements[0]).range,n.left),i=Math.max(...s.getScale(t.elements[0]).range,n.right)):(e=n.left,i=n.right);for(let n of t.values)r.push({x1:e,y1:t.scale.map(n),x2:i,y2:t.scale.map(n)})}else if("height"===e)for(let e of t.values)r.push({x1:n.left,y1:n.bottom-t.scale.map(e),x2:n.right,y2:n.bottom-t.scale.map(e)});else if("polarRadius"===e){let[e,n]=t.origin;for(let i=0;i<t.values.length;i++)r.push({x:e,y:n,r:t.scale.map(t.values[i])})}else if("polarAngle"===e){let[e,n]=t.origin,i="radius"in t._args?t._args.radius:100;for(let s of t.values){let o=t.scale.map(s)*Math.PI/180;r.push({x1:e,y1:n,x2:e+i*Math.cos(o),y2:n-i*Math.sin(o)})}}t.lines=r,t._dirty=!0}}class VT extends qE{constructor(t){super(t)}run(){let t=this.outputVar.element;t.updatePoints(),t._dirty=!0,BE(t)}}class BT extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=cA(t)[0],n=JE(t.parent);for(let t of n){let n=t.layout;if(!n)return;switch(e.type){case Pw.Rect:case Pw.Circle:case Pw.Image:case Pw.Symbol:this._stackRects(t,n);break;case Pw.Area:t.children[0].orientation===nS?this._stackAreasVert(t,n):this._stackAreasHorz(t,n);break;case Pw.Arc:case Pw.Pie:e.parent.classId===t.classId&&this._stackArcs(t,n)}}BE(e)}_stackArcs(t,e){if(e.orientation===iS){let e=90;if((this._direction?this._direction:aS.Clockwise)===aS.Clockwise)for(let n of t.children){let t=xS(e-n.angle);MT(n,"startAngle",t),e=t}else for(let n of t.children){let t=xS(e+n.angle);MT(n,"startAngle",t),e=t}}else if(e.orientation===sS){let e=d3.min(t.children.map(t=>t.innerRadius));for(let n of t.children){let t=n.outerRadius-n.innerRadius;MT(n,"innerRadius",e),MT(n,"outerRadius",e+t),e=n._outerRadius}}}_stackAreasVert(t,e){let n=t.children.filter(t=>"visible"===t.visibility),r=t.bounds,i=e.vertCellAlignment===zE.TOP?r.top:r.bottom,s=e.vertCellAlignment===zE.TOP?1:-1;if(0===n.length)return;e.vertCellAlignment===zE.BOTTOM&&n.reverse();let o=n[0].vertices.length/2,a=new Array(o).fill(0);for(let t of n){for(let e=0;e<o;e++){let n=t.vertices[e],r=t.vertices[2*o-e-1],l=Math.abs(n.y-r.y),c=i+a[e]*s,u=i+(a[e]+l)*s;XA(n,0,c-n.y),XA(r,0,u-r.y),a[e]+=l}let e=t.bounds.bottom;t._updateBounds(),t._refBounds.translate(0,t.bounds.bottom-e)}if(e.vertCellAlignment===zE.MIDDLE)for(let t of n){for(let e=0;e<o;e++){let n=t.vertices[e],i=t.vertices[2*o-e-1],s=r.middle+a[e]/2;XA(n,0,s-r.bottom),XA(i,0,s-r.bottom)}let e=t.bounds.bottom;t._updateBounds(),t._refBounds.translate(0,t.bounds.bottom-e)}}_stackAreasHorz(t,e){}_stackRects(t,e){t.scene;let n=e._orientation,r=t.children.map(t=>t.bounds),i=r.map(t=>t.left),s=r.map(t=>t.top),o=r.map(t=>t.width),a=r.map(t=>t.height),l=null==e._left?d3.min(i):e._left,c=null==e._top?d3.min(s):e._top,u=d3.max(o),h=d3.max(a);if(n==rS)for(let n=0;n<t.children.length;n++){let r=t.children[n],i=0,s=c+r.bounds.height/2-r.bounds.y;c+=r.bounds.height+e._gap,XA(r,i,s),r._updateBounds();let o=0,a=0;if(!WA(r))switch(e._horzCellAlignment){case zE.LEFT:o=l-r.bounds.left;break;case zE.CENTER:o=l+u/2-r.bounds.x;break;case zE.RIGHT:o=l+u-r.bounds.right}XA(r,o,a)}else for(let n=0;n<t.children.length;n++){let r=t.children[n],i=l+r.bounds.width/2-r.bounds.x,s=0;l+=r.bounds.width+e._gap,XA(r,i,s),r._updateBounds();let o=0,a=0;if(!HA(r))switch(e._vertCellAlignment){case zE.TOP:a=c-r.bounds.top;break;case zE.MIDDLE:a=c+h/2-r.bounds.y;break;case zE.BOTTOM:a=c+h-r.bounds.bottom}XA(r,o,a)}}}class zT extends qE{constructor(t){super(t)}run(){super.run()}}class GT extends qE{constructor(t){super(t)}run(){let t=this._binConfig.attribute,e=this._binConfig.startAttr,n=this._binConfig.endAttr,r=this._binConfig.binIdAttr,i=this.inputVars[0].dataset,s=this.outputVar.dataset,o=i.values(t),a=J();null!=this._binConfig?.numBins&&(a=a.thresholds(this._binConfig.numBins));let l=a(o);this._binConfig.actualNumBins=l.length;let c=String(l.length-1).length,u=t=>String(t).padStart(c,"0"),h=this._findBin,f=o.map(t=>h(t,l).x0),d=o.map(t=>h(t,l).x1),p=o.map(t=>{let e=l.indexOf(h(t,l));return u(e)}),_=l.map((t,e)=>u(e));s.addAttr(e,Vw.Number,f),s.addAttr(n,Vw.Number,d),s.addAttr(r,Vw.String,p),s.order(r,_)}_findBin(t,e){for(let n of e)if(n.indexOf(t)>=0)return n}}class FT extends XE{constructor(t,e){super(t),this._dataset=e}get dataset(){return this._dataset}}class jT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof FT),e=this.outputVar.dataset;if(!t)return;let n=t.dataset,r=this._spec;if(!r.value)return void e.load(n.data.slice());let i=kE(r);e.load(n.data.filter(t=>i.testTuple(t)))}}function UT(t,e,n,r){let i=r.type(n);if(i!=Vw.String&&i!=Vw.Date&&i!=Vw.Integer)throw new Error("Repopulate only works on a string or date attribute: "+n+" is "+i);let s=JE(e);for(let t of s){let e=uE(t.dataScope?t.dataScope:cE(r),n,!0),i=t.children.length-e.length,s=e.length-t.children.length;for(let e=0;e<i;e++)t.removeChildAt(t.children.length-1);let o=t._children.length;for(let e=0;e<s;e++){let n=pT(t._children[e%o]);t.addChild(n)}t.children.forEach((t,n)=>t.dataScope=e[n])}}class YT extends qE{constructor(t){super(t),this._collection=null,this._area=null,this._repeatAttr=null}run(){if(super.run(),this._area&&this._repeatAttr){let t=this.inputVars[0];if(!t)return;let e=t.dataset;aA(this._area);return function(t,e,n,r){let i=r.type(n),s=cE(r),o=uE(s,n,i===Vw.Number);i!==Vw.Number&&i!==Vw.Date||o.sort((t,e)=>t.filters[n]>e.filters[n]?1:-1),1===o.length&&o.push(o[0]);let a=o.length,l=e.refBounds??e.bounds,{left:c,top:u,right:h,bottom:f}=l,d=h-c,p=f-u,_=e.orientation===rS,g=[];if(a>0){for(let t=0;t<a;t++)g.push(_?[h,u+t*p/(a-1)]:[c+t*d/(a-1),u]);for(let t=0;t<a;t++)g.push(_?[c,u+(a-1-t)*p/(a-1)]:[c+(a-1-t)*d/(a-1),f])}e.vertices=g;for(let t=0;t<e._vertices.length;t++){let n=t<a?o[t]:o[2*a-1-t];e._vertices.setDataScopeRef(t,n)}let y=e.classId??e.id,m=Math.floor(e._vertices.length/2);for(let t in e.scene._encodings)if(t===y)for(let n of Object.values(e.scene._encodings[t]))1===n._scales.length&&(n._elem2scale={[e.id]:n._scales[0]},n._elemGroups=[[e]]);else if(t===y+"_vAny"){let n=[];for(let t=0;t<e._vertices.length;t++)e._vertices.hasDataScope(t)&&n.push(t);let r=[{parent:e,indices:n}];for(let i of Object.values(e.scene._encodings[t]))if(1===i._scales.length){i._elem2scale={},i._elemGroups=[{type:"vertexIndices",groups:r}];for(let t of n)i._elem2scale[tA(e,t)]=i._scales[0]}}else if(t.startsWith(y+"_v")){let n=t===y+"_v0",r=n?0:m,i=n?m:e._vertices.length,s=[];for(let t=r;t<i;t++)e._vertices.hasDataScope(t)&&s.push(t);let o=[{parent:e,indices:s}];for(let n of Object.values(e.scene._encodings[t]))if(1===n._scales.length){n._elem2scale={},n._elemGroups=[{type:"vertexIndices",groups:o}];for(let t of s)n._elem2scale[tA(e,t)]=n._scales[0]}}e.dataScope=s}(0,this._area,this._repeatAttr,e),void(this.needsFullRender=!0)}if(!this._collection||!this._repeatAttr)return;let t=this.inputVars[0];if(!t)return;let e=t.dataset,n=this._collection;aA(n);n.dataScope=void 0,UT(0,n,this._repeatAttr,e),n.dataScope=cE(e);for(let t of GA(n.children[0]))t.refreshElementMappings();if(n.layout)for(let t of n.layout.refElements)t instanceof cT&&(t._elems=n.children.slice());this.needsFullRender=!0}}class HT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t.type===KE.AFFIXATION).affixation,e=t.base,n=t.element,r=JE(e),i=JE(n),s=t.channels,o=t.attribute;if(i.length!==r.length)throw new Error(`affix: cannot pair ${i.length} ${n.type} element(s) with ${r.length} ${e.type} base element(s); the element and the base must have the same number of instances. Check that the base is the element that repeats once per affixed element (for example, the collection returned by divide() rather than the outer collection returned by repeat()).`);if(FE(n)&&FE(e)){let t=r.map(t=>t.datum[o]);i=i.filter(e=>t.includes(e.datum[o]));let e=(t,e)=>t.datum[o]<e.datum[o]?-1:t.datum[o]>e.datum[o]?1:0;i.sort(e),r.sort(e)}if(s.includes("x")||s.includes("y"))for(let e of s)this._handleXY(e,i,r,t.getElementAnchor(e),t.getBaseAnchor(e),t.getOffset(e));(s.includes("polarRadius")||s.includes("angle"))&&this._handlePolar(i,r,t);let a=cA(n,!0);for(let t of a)BE(t)}_handlePolar(t,e,n){let r="polarRadius",i=n.hasChannel(r)?n.getBaseAnchor(r):zE.MIDDLE,s=n.hasChannel(r)?n.getElementAnchor(r):zE.MIDDLE,o=n.hasChannel("angle")?n.getBaseAnchor("angle"):zE.CENTER;n.hasChannel("angle")?n.getElementAnchor("angle"):zE.CENTER;let a=n.hasChannel(r)?n.getOffset(r):0,l=n.hasChannel("angle")?n.getOffset("angle"):0;if([Pw.Arc,Pw.Ring].indexOf(e[0].type)>=0&&t[0].type==Pw.SimpleText)for(let n=0;n<t.length;n++){let r=e[n],s=t[n],l=i===zE.MIDDLE?(r.outerRadius+r.innerRadius)/2:i===zE.TOP?r.outerRadius-5:r.innerRadius+5;if(l+=a,r.type===Pw.Arc){let t=RT(r.x,r.y,l,r.startAngle),e=RT(r.x,r.y,l,r.endAngle);r.endAngle>=180&&r.endAngle<=360?s._textPath=["M",t[0],t[1],"A",l,l,r.angle,r.angle>=180?1:0,0,e[0],e[1]].join(" "):s._textPath=["M",e[0],e[1],"A",l,l,r.angle,r.angle>=180?1:0,1,t[0],t[1]].join(" ")}else if(r.type===Pw.Ring){let t=275,e=265,n=350,i=RT(r.x,r.y,l,t),o=RT(r.x,r.y,l,e);s._textPath=["M",o[0],o[1],"A",l,l,n,1,1,i[0],i[1]].join(" ")}s.textPathOffset=o===zE.LEFT?"0%":"50%"}else for(let n=0;n<t.length;n++){let r,c,u=e[n],h=t[n];u.type==Pw.Arc||u.type==Pw.Ring?(c="left"==o?u.endAngle+l:"center"==o?u.startAngle+u.angle/2+l:u.startAngle+l,r="top"==i?u.outerRadius+a:"bottom"==i?u.innerRadius+a:(u.outerRadius+u.innerRadius)/2+a):u.type==Pw.Circle&&(c=90,r="top"==i?u.radius+a:"bottom"==i?a:u.radius/2+a),XA(h,u.x-h.x,u.y-r-h.bounds[s]),h._rotate=[90-c,u.x,u.y]}}_handleXY(t,e,n,r,i,s){for(let o=0;o<e.length;o++){let a,l=n[o],c=e[o];if(_S(l)){a=pS(l,[zE.LEFT,zE.TOP].includes(i)?0:[zE.CENTER,zE.MIDDLE].includes(i)?.5:1)[t]}else a=l.bounds[i]+s;e[0].type===Pw.SimpleText?(c.anchor["x"==t?0:1]=r,MT(c,t,a)):"x"==t?XA(c,a-c.bounds[r],0):XA(c,0,a-c.bounds[r])}}}class WT extends XE{constructor(t,e){super(t),this._affx=e}get affixation(){return this._affx}}class qT extends qE{constructor(t){super(t)}run(){let t=this.inputVars[0],e=this.outputVar,n=t.attribute,r=e.attribute,i=t.dataset,s=e.dataset,o=this.args,a=null!=o.min?o.min:i.summary(n).min,l=null!=o.max?o.max:i.summary(n).max,c=a,u=[];for(;c<l;)u.push(c),c+=o.interval;u.push(c);let h={},f={};if(o.groupBy)for(let t of i.data){let e=o.groupBy.map(e=>t[e]).join("-");e in h||(h[e]=[],f[e]=o.groupBy.map(e=>t[e])),h[e].push(t[n])}else h[""]=i.data.map(t=>t[n]),f[""]="";let d=[];for(let t in f){let e=$T(XT(o.bandwidth),u,h[t]);for(let i of e){let e={};""!==t&&o.groupBy.forEach((n,r)=>e[n]=f[t][r]),e[n]=i[0],e[r]=i[1],d.push(e)}}let p={};if(p[n]=i.type(n),p[r]=Vw.Number,o.groupBy)for(let t of o.groupBy)p[t]=i.type(t);s.initialize(d,s.url,p)}}function $T(t,e,n){return e.map(e=>[e,ct(n,n=>t(e-n))])}function XT(t){return e=>Math.abs(e/=t)<=1?.75*(1-e*e)/t:0}class KT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof FT);if(!t)return;let e=t.dataset,n=this.outputVar.dataset;this._spec.fn(e,n,this._spec)}}class ZT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof FT),e=this.outputVar.dataset;if(!t)return;let n=t.dataset,r=this._spec,i=n.attrs().filter(t=>t!==_E),s=r.valueVars?r.valueVars.slice():null,o=r.idVars?r.idVars.slice():null;if(!s&&!o)return void console.warn("unpivot transform requires idVars and/or valueVars to be specified");s||(s=i.filter(t=>!o.includes(t))),o||(o=i.filter(t=>!s.includes(t)));let a=[];for(let t of n.data)for(let e of s){let n={};for(let e of o)n[e]=t[e];n[r.varName]=e,n[r.valueName]=t[e],a.push(n)}e.initialize(a,e.url)}}class JT extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)return;let n=t.children.map(t=>({name:t.id,radius:t.radius,itm:t})),r=n.reduce((t,e)=>t+Math.pow(e.radius,2),0),i=Math.sqrt(r);void 0===e._width&&(e._width=i),void 0===e._height&&(e._height=i);let s=Od({name:"root",children:n}).sum(t=>t.radius?t.radius:0).sort((t,e)=>e.value-t.value);rp().size([e._width,e._height]).radius(t=>t.value)(s);for(let t of s.children){let n=t.data.itm;XA(n,e._x-s.x+t.x-n.x,e._y-s.y+t.y-n.y)}}let n=cA(t,!0);for(let t of n)BE(t)}}class QT extends qE{constructor(t){super(t)}run(){super.run();let t=this.inputVars.find(t=>t instanceof dA&&t.property==gA.AXIS_PATH_POSITION).element;t instanceof YS?this._runForEncoding(t):t instanceof cT&&this._runForLayout(t),BE(t._title)}_runForEncoding(t){let e=t.channel,n=DE(t.elements);if("x"==e)t._title.x=(t.scale.range[0]+t.scale.range[1])/2,t._title._y=t.orientation==FS?t._pathPos+t.titleOffset:t._pathPos-t.titleOffset;else if("width"==e)t._title.x=n.left+t.scale.rangeExtent/2,t._title._y=t.orientation==FS?t._pathPos+t.titleOffset:t._pathPos-t.titleOffset;else if("y"===e)t._rotateYTitle?(t._title.x=t.orientation==jS?t._pathPos-t.titleOffset:t._pathPos+t.titleOffset,t._title._y=(t.scale.range[0]+t.scale.range[1])/2,t._title._rotate=t.orientation==jS?[-90,t._title._x,t._title._y]:[90,t._title._x,t._title._y]):(t._title.x=t.orientation==jS?t._pathPos-t.titleOffset:t._pathPos+t.titleOffset,t._title._y=d3.min([t.scale.range[0],t.scale.range[1]])-25,t._title._rotate=void 0);else if("height"===e)t._title.x=n.center,t._title._y=(n.top+n.bottom)/2-n.width/2-t.titleOffset,t._title._rotate=t.orientation==jS?[-90,n.center,n.middle]:[90,n.center,n.middle];else if("polarRadius"===e){let[e]=t.origin;t._title.x=e+t.scale.rangeExtent/2,t._title._y=t.orientation==FS?t._pathPos+t.titleOffset:t._pathPos-t.titleOffset,t._rotate&&(t._title._rotate=t._rotate.slice())}else if("polarAngle"===e){let[e,n]=t.origin;t._title.x=e,t._title._y=n-t.radius-t.titleOffset}}_runForLayout(t){let e=t.channel,n=t.elements[0].parent.layout&&t.elements[0].parent.layout.type==HE.STACK?VE(t.elements):DE(t.elements);if("x"==e)t._title.x=n.center,t._title._y=t.orientation==FS?t._pathPos+t.titleOffset:t._pathPos-t.titleOffset;else if("y"===e)t._title.x=n.center,t._title._y=n.middle-n.width/2-t.titleOffset,t._title._rotate=t.orientation==jS?[-90,n.center,n.middle]:[90,n.center,n.middle];else if("angle"===e){let e=t.elements[0].parent.layout;e.type===HE.CLUSTER&&(t._title.x=e.x,t._title._y=e.y)}}}class tC extends yT{constructor(t){super(t)}run(){super.run();let t,e=this.vars.find(t=>t.type===KE.ALIGNMENT).alignment,n=e.anchor,r=e.elements;n==zE.Top||n==zE.LEFT?t=et(r.map(t=>t.bounds[n])):n==zE.BOTTOM||n==zE.RIGHT?t=Q(r.map(t=>t.bounds[n])):n!=zE.CENTER&&n!=zE.MIDDLE||(t=ct(r.map(t=>t.bounds[n])));for(let i of r){let r=qA(i,e.channel);if(r){let s=t-i.bounds[n];XA(r,"x"===e.channel?s:0,"x"===e.channel?0:s)}}for(let t of r)BE(t)}}class eC extends XE{constructor(t,e){super(t),this._aln=e}get alignment(){return this._aln}}class nC extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let n=bE(t.children[0]);if(!n)continue;let r=n.linkList.map(t=>({source:n.getNode(t.source),target:n.getNode(t.target)})),i=Ol(n.nodeList).force("charge",Nl().strength(-e._repulsion)).force("link",Tl(r).id(t=>t.id).distance(e._linkDistance)).force("x",Il()).force("y",Pl()).force("center",hl(e._x,e._y).strength(e._attraction));i.stop(),i.tick(e._iterations);for(let e=0;e<t.children.length;e++){let r=t.children[e],i=n.nodeList[e];XA(r,i.x-r.x,i.y-r.y)}}let n=cA(t,!0);for(let t of n)BE(t)}}class rC extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t);switch(t.type){case Pw.Arc:this._updateArcLinks(e);break;case Pw.BezierCurve:this._updateBezierLinks(e);break;case Pw.BundledPath:this._updateBundledLinks(e);break;case Pw.Chord:this._updateChordLinks(e);break;case Pw.Line:default:this._updateLineLinks(e)}BE(t)}_updateArcLinks(t){for(let e of t){let t=e.source.x<e.target.x?e.source:e.target,n=e.source.x<e.target.x?e.target:e.source;e._x=(t.x+n.x)/2,e._y=(t.y+n.y)/2,e._innerRadius=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))/2,e._outerRadius=e._innerRadius+e._thickness;let r=wS(t.x,t.y,e._x,e._y),i=wS(n.x,n.y,e._x,e._y);e.direction===aS.CLOCKWISE&&([r,i]=[i,r]),MT(e,"startAngle",r),MT(e,"angle",Math.abs(i-r))}}_updateBezierLinks(t){let e=this._inputVars[0].element,n=JE(e),r=e.parent.layout;r.type===HE.DIRECTED||r.type===HE.TIDYTREE?this._updateBezierLinksForDirectedGraph(n,t,r):r.type===HE.CLUSTER&&this._updateBezierLinksForClusteredGraph(n,t,r)}_updateBezierLinksForClusteredGraph(t,e,n){const r=n._d3Root.descendants(),i=new Map(r.map(t=>[iC(t),t])),s=new Map(r.map(t=>[t.data[xE],iC(t)]));if(n.isRadial()){const t=nx().angle(t=>t.x).radius(t=>t.y);for(let r of e){let e=r.source,o=r.target,a=e.datum[xE],l=o.datum[xE],c=i.get(s.get(a)),u=i.get(s.get(l));r._d=yS(t({source:c,target:u}),n.x,n.y)}}else if(n.orientation===rS){const t=ex().x(t=>t.x).y(t=>t.y);for(let r of e){let e=r.source,o=r.target,a=e.datum[xE],l=o.datum[xE],c=i.get(s.get(a)),u=i.get(s.get(l));r._d=yS(t({source:c,target:u}),n.left-n._x0,n.top)}}else if(n.orientation===nS){const t=tx().x(t=>t.y).y(t=>t.x);for(let r of e){let e=r.source,o=r.target,a=e.datum[xE],l=o.datum[xE],c=i.get(s.get(a)),u=i.get(s.get(l));r._d=yS(t({source:c,target:u}),n.left,n.top-n._x0)}}}_updateBezierLinksForDirectedGraph(t,e,n){let r={},i={},s={},o={};for(let e of t){i[e.id]=0,r[e.id]=0;let t=e.links.filter(t=>t.source===e),n=e.links.filter(t=>t.target===e);o[e.id]=n.map(t=>t.strokeWidth).reduce((t,e)=>t+e,0),s[e.id]=t.map(t=>t.strokeWidth).reduce((t,e)=>t+e,0)}const a=n.direction===oS.Left2Right||n.direction===oS.Right2Left;if(n.spreadLinks){const t=a?t=>t.bounds.y:t=>t.bounds.x,n=[...e].sort((e,n)=>t(e.target)-t(n.target));for(let t of n)t._outLane=r[t.source.id],r[t.source.id]+=t.strokeWidth;const s=[...e].sort((e,n)=>t(e.source)-t(n.source));for(let t of s)t._inLane=i[t.target.id],i[t.target.id]+=t.strokeWidth}for(let t of e){let e,r,i,l,c=t.source,u=t.target;n.spreadLinks?a?(e=c.bounds[t.sourceAnchor[0]]+t.sourceOffset[0],i=u.bounds[t.targetAnchor[0]]+t.targetOffset[0],r=c.bounds[t.sourceAnchor[1]]+t.sourceOffset[1]-s[c.id]/2+t._outLane+t.strokeWidth/2,l=u.bounds[t.targetAnchor[1]]+t.targetOffset[1]-o[u.id]/2+t._inLane+t.strokeWidth/2):(r=c.bounds[t.sourceAnchor[1]]+t.sourceOffset[1],l=u.bounds[t.targetAnchor[1]]+t.targetOffset[1],e=c.bounds[t.sourceAnchor[0]]+t.sourceOffset[0]-s[c.id]/2+t._outLane+t.strokeWidth/2,i=u.bounds[t.targetAnchor[0]]+t.targetOffset[0]-o[u.id]/2+t._inLane+t.strokeWidth/2):(e=c.bounds[t.sourceAnchor[0]]+t.sourceOffset[0],r=c.bounds[t.sourceAnchor[1]]+t.sourceOffset[1],i=u.bounds[t.targetAnchor[0]]+t.targetOffset[0],l=u.bounds[t.targetAnchor[1]]+t.targetOffset[1]),t.orientation===nS?t.vertices=[[e,r],[(e+i)/2,r],[e,l],[i,l]]:t.orientation===rS&&(t.vertices=[[e,r],[e,(r+l)/2],[i,r],[i,l]])}}_updateBundledLinks(t){let e=this._inputVars[0].element.parent.layout;if(e.type!==HE.CLUSTER)throw"Bundled links must work on a cluster layout";let n=e._d3Root;if(!n)return void console.warn("cluster layout was not placed; skipping bundled link routing");let r=n.leaves();const i=new Map(r.map(t=>[iC(t),t])),s=new Map(r.map(t=>[t.data[xE],iC(t)])),o=Uv().curve(Vx.beta(t[0]._strength)).radius(t=>t.y).angle(t=>t.x);for(let n of t){let t=n.source.datum[xE],r=n.target.datum[xE],a=i.get(s.get(t)),l=i.get(s.get(r)),c=a.path(l);n._d=yS(o(c),e.x,e.y),n._dirty=!0}}_updateChordLinks(t){for(let e of t){let t=e.source,n=e.target,r=RT(t.x,t.y,t.innerRadius,t.startAngle),i=RT(t.x,t.y,t.innerRadius,t.endAngle),s=RT(n.x,n.y,n.innerRadius,n.startAngle),o=RT(n.x,n.y,n.innerRadius,n.endAngle);e._d=["M",r[0],r[1],"Q",t.x,t.y,o[0],o[1],"A",t.x,t.y,n.angle,n.angle>180?1:0,1,s[0],s[1],"Q",t.x,t.y,i[0],i[1],"A",t.x,t.y,t.angle,t.angle>180?1:0,1,r[0],r[1]].join(" "),e._dirty=!0}}_updateLineLinks(t){for(let e of t){let t=e.source,n=e.target;e.vertices[0].x=t.bounds.x,e.vertices[0].y=t.bounds.y,e.vertices[1].x=n.bounds.x,e.vertices[1].y=n.bounds.y,e._dirty=!0}}}function iC(t){return`${t.parent?iC(t.parent)+".":""}${t.data[xE]}`}var sC="\0";function oC(t,e){t[e]?t[e]++:t[e]=1}function aC(t,e){--t[e]||delete t[e]}function lC(t,e,n,r){var i=""+e,s=""+n;if(!t&&i>s){var o=i;i=s,s=o}return i+""+s+""+(void 0===r?"\0":r)}function cC(t,e){return lC(t,e.v,e.w,e.name)}var uC=class{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(t){t&&(this._isDirected=!Object.hasOwn(t,"directed")||t.directed,this._isMultigraph=!!Object.hasOwn(t,"multigraph")&&t.multigraph,this._isCompound=!!Object.hasOwn(t,"compound")&&t.compound),this._isCompound&&(this._parent={},this._children={},this._children[sC]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return this._defaultNodeLabelFn=t,"function"!=typeof t&&(this._defaultNodeLabelFn=()=>t),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var t=this;return this.nodes().filter(e=>0===Object.keys(t._in[e]).length)}sinks(){var t=this;return this.nodes().filter(e=>0===Object.keys(t._out[e]).length)}setNodes(t,e){var n=arguments,r=this;return t.forEach(function(t){n.length>1?r.setNode(t,e):r.setNode(t)}),this}setNode(t,e){return Object.hasOwn(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=sC,this._children[t]={},this._children[sC][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return Object.hasOwn(this._nodes,t)}removeNode(t){var e=this;if(Object.hasOwn(this._nodes,t)){var n=t=>e.removeEdge(e._edgeObjs[t]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(function(t){e.setParent(t)}),delete this._children[t]),Object.keys(this._in[t]).forEach(n),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(n),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(void 0===e)e=sC;else{for(var n=e+="";void 0!==n;n=this.parent(n))if(n===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}parent(t){if(this._isCompound){var e=this._parent[t];if(e!==sC)return e}}children(t=sC){if(this._isCompound){var e=this._children[t];if(e)return Object.keys(e)}else{if(t===sC)return this.nodes();if(this.hasNode(t))return[]}}predecessors(t){var e=this._preds[t];if(e)return Object.keys(e)}successors(t){var e=this._sucs[t];if(e)return Object.keys(e)}neighbors(t){var e=this.predecessors(t);if(e){const r=new Set(e);for(var n of this.successors(t))r.add(n);return Array.from(r.values())}}isLeaf(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length}filterNodes(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach(function([n,r]){t(n)&&e.setNode(n,r)}),Object.values(this._edgeObjs).forEach(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,n.edge(t))});var r={};function i(t){var s=n.parent(t);return void 0===s||e.hasNode(s)?(r[t]=s,s):s in r?r[s]:i(s)}return this._isCompound&&e.nodes().forEach(t=>e.setParent(t,i(t))),e}setDefaultEdgeLabel(t){return this._defaultEdgeLabelFn=t,"function"!=typeof t&&(this._defaultEdgeLabelFn=()=>t),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,e){var n=this,r=arguments;return t.reduce(function(t,i){return r.length>1?n.setEdge(t,i,e):n.setEdge(t,i),i}),this}setEdge(){var t,e,n,r,i=!1,s=arguments[0];"object"==typeof s&&null!==s&&"v"in s?(t=s.v,e=s.w,n=s.name,2===arguments.length&&(r=arguments[1],i=!0)):(t=s,e=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],i=!0)),t=""+t,e=""+e,void 0!==n&&(n=""+n);var o=lC(this._isDirected,t,e,n);if(Object.hasOwn(this._edgeLabels,o))return i&&(this._edgeLabels[o]=r),this;if(void 0!==n&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[o]=i?r:this._defaultEdgeLabelFn(t,e,n);var a=function(t,e,n,r){var i=""+e,s=""+n;if(!t&&i>s){var o=i;i=s,s=o}var a={v:i,w:s};r&&(a.name=r);return a}(this._isDirected,t,e,n);return t=a.v,e=a.w,Object.freeze(a),this._edgeObjs[o]=a,oC(this._preds[e],t),oC(this._sucs[t],e),this._in[e][o]=a,this._out[t][o]=a,this._edgeCount++,this}edge(t,e,n){var r=1===arguments.length?cC(this._isDirected,arguments[0]):lC(this._isDirected,t,e,n);return this._edgeLabels[r]}edgeAsObj(){const t=this.edge(...arguments);return"object"!=typeof t?{label:t}:t}hasEdge(t,e,n){var r=1===arguments.length?cC(this._isDirected,arguments[0]):lC(this._isDirected,t,e,n);return Object.hasOwn(this._edgeLabels,r)}removeEdge(t,e,n){var r=1===arguments.length?cC(this._isDirected,arguments[0]):lC(this._isDirected,t,e,n),i=this._edgeObjs[r];return i&&(t=i.v,e=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],aC(this._preds[e],t),aC(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this}inEdges(t,e){var n=this._in[t];if(n){var r=Object.values(n);return e?r.filter(t=>t.v===e):r}}outEdges(t,e){var n=this._out[t];if(n){var r=Object.values(n);return e?r.filter(t=>t.w===e):r}}nodeEdges(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))}},hC={Graph:uC,version:"2.2.4"},fC=uC,dC={write:function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:pC(t),edges:_C(t)};void 0!==t.graph()&&(e.value=structuredClone(t.graph()));return e},read:function(t){var e=new fC(t.options).setGraph(t.value);return t.nodes.forEach(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)}),t.edges.forEach(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),e}};function pC(t){return t.nodes().map(function(e){var n=t.node(e),r=t.parent(e),i={v:e};return void 0!==n&&(i.value=n),void 0!==r&&(i.parent=r),i})}function _C(t){return t.edges().map(function(e){var n=t.edge(e),r={v:e.v,w:e.w};return void 0!==e.name&&(r.name=e.name),void 0!==n&&(r.value=n),r})}var gC=function(t){var e,n={},r=[];function i(r){Object.hasOwn(n,r)||(n[r]=!0,e.push(r),t.successors(r).forEach(i),t.predecessors(r).forEach(i))}return t.nodes().forEach(function(t){e=[],i(t),e.length&&r.push(e)}),r};var yC=class{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(t){return t.key})}has(t){return Object.hasOwn(this._keyIndices,t)}priority(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority}min(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key}add(t,e){var n=this._keyIndices;if(t=String(t),!Object.hasOwn(n,t)){var r=this._arr,i=r.length;return n[t]=i,r.push({key:t,priority:e}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)}_heapify(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))}_decrease(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e}_swap(t,e){var n=this._arr,r=this._keyIndices,i=n[t],s=n[e];n[t]=s,n[e]=i,r[s.key]=t,r[i.key]=e}},mC=yC,bC=function(t,e,n,r){return function(t,e,n,r){var i,s,o={},a=new mC,l=function(t){var e=t.v!==i?t.v:t.w,r=o[e],l=n(t),c=s.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+l);c<r.distance&&(r.distance=c,r.predecessor=i,a.decrease(e,c))};t.nodes().forEach(function(t){var n=t===e?0:Number.POSITIVE_INFINITY;o[t]={distance:n},a.add(t,n)});for(;a.size()>0&&(i=a.removeMin(),(s=o[i]).distance!==Number.POSITIVE_INFINITY);)r(i).forEach(l);return o}(t,String(e),n||vC,r||function(e){return t.outEdges(e)})},vC=()=>1;var xC=bC,wC=function(t,e,n){return t.nodes().reduce(function(r,i){return r[i]=xC(t,i,e,n),r},{})};var EC=function(t){var e=0,n=[],r={},i=[];function s(o){var a=r[o]={onStack:!0,lowlink:e,index:e++};if(n.push(o),t.successors(o).forEach(function(t){Object.hasOwn(r,t)?r[t].onStack&&(a.lowlink=Math.min(a.lowlink,r[t].index)):(s(t),a.lowlink=Math.min(a.lowlink,r[t].lowlink))}),a.lowlink===a.index){var l,c=[];do{l=n.pop(),r[l].onStack=!1,c.push(l)}while(o!==l);i.push(c)}}return t.nodes().forEach(function(t){Object.hasOwn(r,t)||s(t)}),i};var AC=EC,SC=function(t){return AC(t).filter(function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])})};var TC=function(t,e,n){return function(t,e,n){var r={},i=t.nodes();return i.forEach(function(t){r[t]={},r[t][t]={distance:0},i.forEach(function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})}),n(t).forEach(function(n){var i=n.v===t?n.w:n.v,s=e(n);r[t][i]={distance:s,predecessor:t}})}),i.forEach(function(t){var e=r[t];i.forEach(function(n){var s=r[n];i.forEach(function(n){var r=s[t],i=e[n],o=s[n],a=r.distance+i.distance;a<o.distance&&(o.distance=a,o.predecessor=i.predecessor)})})}),r}(t,e||CC,n||function(e){return t.outEdges(e)})},CC=()=>1;function kC(t){var e={},n={},r=[];if(t.sinks().forEach(function i(s){if(Object.hasOwn(n,s))throw new RC;Object.hasOwn(e,s)||(n[s]=!0,e[s]=!0,t.predecessors(s).forEach(i),delete n[s],r.push(s))}),Object.keys(e).length!==t.nodeCount())throw new RC;return r}class RC extends Error{constructor(){super(...arguments)}}var MC=kC;kC.CycleException=RC;var OC=MC;var NC=function(t,e,n){Array.isArray(e)||(e=[e]);var r=t.isDirected()?e=>t.successors(e):e=>t.neighbors(e),i="post"===n?IC:PC,s=[],o={};return e.forEach(e=>{if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);i(e,r,o,s)}),s};function IC(t,e,n,r){for(var i=[[t,!1]];i.length>0;){var s=i.pop();s[1]?r.push(s[0]):Object.hasOwn(n,s[0])||(n[s[0]]=!0,i.push([s[0],!0]),LC(e(s[0]),t=>i.push([t,!1])))}}function PC(t,e,n,r){for(var i=[t];i.length>0;){var s=i.pop();Object.hasOwn(n,s)||(n[s]=!0,r.push(s),LC(e(s),t=>i.push(t)))}}function LC(t,e){for(var n=t.length;n--;)e(t[n],n,t);return t}var DC=NC;var VC=NC;var BC=uC,zC=yC,GC=function(t,e){var n,r=new BC,i={},s=new zC;function o(t){var r=t.v===n?t.w:t.v,o=s.priority(r);if(void 0!==o){var a=e(t);a<o&&(i[r]=n,s.decrease(r,a))}}if(0===t.nodeCount())return r;t.nodes().forEach(function(t){s.add(t,Number.POSITIVE_INFINITY),r.setNode(t)}),s.decrease(t.nodes()[0],0);var a=!1;for(;s.size()>0;){if(n=s.removeMin(),Object.hasOwn(i,n))r.setEdge(n,i[n]);else{if(a)throw new Error("Input graph is not connected: "+t);a=!0}t.nodeEdges(n).forEach(o)}return r};var FC={Graph:hC.Graph,json:dC,alg:{components:gC,dijkstra:bC,dijkstraAll:wC,findCycles:SC,floydWarshall:TC,isAcyclic:function(t){try{OC(t)}catch(t){if(t instanceof OC.CycleException)return!1;throw t}return!0},postorder:function(t,e){return DC(t,e,"post")},preorder:function(t,e){return VC(t,e,"pre")},prim:GC,tarjan:EC,topsort:MC},version:hC.version};function jC(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function UC(t,e){if("_next"!==t&&"_prev"!==t)return e}let YC=FC.Graph,HC=class{constructor(){let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,e=t._prev;if(e!==t)return jC(e),e}enqueue(t){let e=this._sentinel;t._prev&&t._next&&jC(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e}toString(){let t=[],e=this._sentinel,n=e._prev;for(;n!==e;)t.push(JSON.stringify(n,UC)),n=n._prev;return"["+t.join(", ")+"]"}};var WC=function(t,e){if(t.nodeCount()<=1)return[];let n=function(t,e){let n=new YC,r=0,i=0;t.nodes().forEach(t=>{n.setNode(t,{v:t,in:0,out:0})}),t.edges().forEach(t=>{let s=n.edge(t.v,t.w)||0,o=e(t),a=s+o;n.setEdge(t.v,t.w,a),i=Math.max(i,n.node(t.v).out+=o),r=Math.max(r,n.node(t.w).in+=o)});let s=function(t){const e=[];for(let n=0;n<t;n++)e.push(n);return e}(i+r+3).map(()=>new HC),o=r+1;return n.nodes().forEach(t=>{XC(s,o,n.node(t))}),{graph:n,buckets:s,zeroIdx:o}}(t,e||qC);return function(t,e,n){let r,i=[],s=e[e.length-1],o=e[0];for(;t.nodeCount();){for(;r=o.dequeue();)$C(t,e,n,r);for(;r=s.dequeue();)$C(t,e,n,r);if(t.nodeCount())for(let s=e.length-2;s>0;--s)if(r=e[s].dequeue(),r){i=i.concat($C(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx).flatMap(e=>t.outEdges(e.v,e.w))};let qC=()=>1;function $C(t,e,n,r,i){let s=i?[]:void 0;return t.inEdges(r.v).forEach(r=>{let o=t.edge(r),a=t.node(r.v);i&&s.push({v:r.v,w:r.w}),a.out-=o,XC(e,n,a)}),t.outEdges(r.v).forEach(r=>{let i=t.edge(r),s=r.w,o=t.node(s);o.in-=i,XC(e,n,o)}),t.removeNode(r.v),s}function XC(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}let KC=FC.Graph;var ZC={addBorderNode:function(t,e,n,r){let i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=r);return JC(t,"border",i,e)},addDummyNode:JC,applyWithChunking:tk,asNonCompoundGraph:function(t){let e=new KC({multigraph:t.isMultigraph()}).setGraph(t.graph());return t.nodes().forEach(n=>{t.children(n).length||e.setNode(n,t.node(n))}),t.edges().forEach(n=>{e.setEdge(n,t.edge(n))}),e},buildLayerMatrix:function(t){let e=ik(ek(t)+1).map(()=>[]);return t.nodes().forEach(n=>{let r=t.node(n),i=r.rank;void 0!==i&&(e[i][r.order]=n)}),e},intersectRect:function(t,e){let n,r,i=t.x,s=t.y,o=e.x-i,a=e.y-s,l=t.width/2,c=t.height/2;if(!o&&!a)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(a)*l>Math.abs(o)*c?(a<0&&(c=-c),n=c*o/a,r=c):(o<0&&(l=-l),n=l,r=l*a/o);return{x:i+n,y:s+r}},mapValues:function(t,e){let n=e;"string"==typeof e&&(n=t=>t[e]);return Object.entries(t).reduce((t,[e,r])=>(t[e]=n(r,e),t),{})},maxRank:ek,normalizeRanks:function(t){let e=t.nodes().map(e=>{let n=t.node(e).rank;return void 0===n?Number.MAX_VALUE:n}),n=tk(Math.min,e);t.nodes().forEach(e=>{let r=t.node(e);Object.hasOwn(r,"rank")&&(r.rank-=n)})},notime:function(t,e){return e()},partition:function(t,e){let n={lhs:[],rhs:[]};return t.forEach(t=>{e(t)?n.lhs.push(t):n.rhs.push(t)}),n},pick:function(t,e){const n={};for(const r of e)void 0!==t[r]&&(n[r]=t[r]);return n},predecessorWeights:function(t){let e=t.nodes().map(e=>{let n={};return t.inEdges(e).forEach(e=>{n[e.v]=(n[e.v]||0)+t.edge(e).weight}),n});return sk(t.nodes(),e)},range:ik,removeEmptyRanks:function(t){let e=t.nodes().map(e=>t.node(e).rank),n=tk(Math.min,e),r=[];t.nodes().forEach(e=>{let i=t.node(e).rank-n;r[i]||(r[i]=[]),r[i].push(e)});let i=0,s=t.graph().nodeRankFactor;Array.from(r).forEach((e,n)=>{void 0===e&&n%s!==0?--i:void 0!==e&&i&&e.forEach(e=>t.node(e).rank+=i)})},simplify:function(t){let e=(new KC).setGraph(t.graph());return t.nodes().forEach(n=>e.setNode(n,t.node(n))),t.edges().forEach(n=>{let r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),e},successorWeights:function(t){let e=t.nodes().map(e=>{let n={};return t.outEdges(e).forEach(e=>{n[e.w]=(n[e.w]||0)+t.edge(e).weight}),n});return sk(t.nodes(),e)},time:function(t,e){let n=Date.now();try{return e()}finally{console.log(t+" time: "+(Date.now()-n)+"ms")}},uniqueId:rk,zipObject:sk};function JC(t,e,n,r){for(var i=r;t.hasNode(i);)i=rk(r);return n.dummy=e,t.setNode(i,n),i}const QC=65535;function tk(t,e){if(e.length>QC){const n=function(t,e=QC){const n=[];for(let r=0;r<t.length;r+=e){const i=t.slice(r,r+e);n.push(i)}return n}(e);return t.apply(null,n.map(e=>t.apply(null,e)))}return t.apply(null,e)}function ek(t){const e=t.nodes().map(e=>{let n=t.node(e).rank;return void 0===n?Number.MIN_VALUE:n});return tk(Math.max,e)}let nk=0;function rk(t){return t+""+ ++nk}function ik(t,e,n=1){null==e&&(e=t,t=0);let r=t=>t<e;n<0&&(r=t=>e<t);const i=[];for(let e=t;r(e);e+=n)i.push(e);return i}function sk(t,e){return t.reduce((t,n,r)=>(t[n]=e[r],t),{})}let ok=WC,ak=ZC.uniqueId;var lk={run:function(t){("greedy"===t.graph().acyclicer?ok(t,function(t){return e=>t.edge(e).weight}(t)):function(t){let e=[],n={},r={};function i(s){Object.hasOwn(r,s)||(r[s]=!0,n[s]=!0,t.outEdges(s).forEach(t=>{Object.hasOwn(n,t.w)?e.push(t):i(t.w)}),delete n[s])}return t.nodes().forEach(i),e}(t)).forEach(e=>{let n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,ak("rev"))})},undo:function(t){t.edges().forEach(e=>{let n=t.edge(e);if(n.reversed){t.removeEdge(e);let r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}})}};let ck=ZC;var uk={run:function(t){t.graph().dummyChains=[],t.edges().forEach(e=>function(t,e){let n,r,i,s=e.v,o=t.node(s).rank,a=e.w,l=t.node(a).rank,c=e.name,u=t.edge(e),h=u.labelRank;if(l===o+1)return;for(t.removeEdge(e),i=0,++o;o<l;++i,++o)u.points=[],r={width:0,height:0,edgeLabel:u,edgeObj:e,rank:o},n=ck.addDummyNode(t,"edge",r,"_d"),o===h&&(r.width=u.width,r.height=u.height,r.dummy="edge-label",r.labelpos=u.labelpos),t.setEdge(s,n,{weight:u.weight},c),0===i&&t.graph().dummyChains.push(n),s=n;t.setEdge(s,a,{weight:u.weight},c)}(t,e))},undo:function(t){t.graph().dummyChains.forEach(e=>{let n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e)})}};const{applyWithChunking:hk}=ZC;var fk={longestPath:function(t){var e={};t.sources().forEach(function n(r){var i=t.node(r);if(Object.hasOwn(e,r))return i.rank;e[r]=!0;let s=t.outEdges(r).map(e=>null==e?Number.POSITIVE_INFINITY:n(e.w)-t.edge(e).minlen);var o=hk(Math.min,s);return o===Number.POSITIVE_INFINITY&&(o=0),i.rank=o})},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};var dk=FC.Graph,pk=fk.slack,_k=function(t){var e,n,r=new dk({directed:!1}),i=t.nodes()[0],s=t.nodeCount();r.setNode(i,{});for(;gk(r,t)<s;)e=yk(r,t),n=r.hasNode(e.v)?pk(t,e):-pk(t,e),mk(r,t,n);return r};function gk(t,e){return t.nodes().forEach(function n(r){e.nodeEdges(r).forEach(i=>{var s=i.v,o=r===s?i.w:s;t.hasNode(o)||pk(e,i)||(t.setNode(o,{}),t.setEdge(r,o,{}),n(o))})}),t.nodeCount()}function yk(t,e){return e.edges().reduce((n,r)=>{let i=Number.POSITIVE_INFINITY;return t.hasNode(r.v)!==t.hasNode(r.w)&&(i=pk(e,r)),i<n[0]?[i,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function mk(t,e,n){t.nodes().forEach(t=>e.node(t).rank+=n)}var bk=_k,vk=fk.slack,xk=fk.longestPath,wk=FC.alg.preorder,Ek=FC.alg.postorder,Ak=ZC.simplify,Sk=Tk;function Tk(t){t=Ak(t),xk(t);var e,n=bk(t);for(Rk(n),Ck(n,t);e=Ok(n);)Ik(n,t,e,Nk(n,t,e))}function Ck(t,e){var n=Ek(t,t.nodes());(n=n.slice(0,n.length-1)).forEach(n=>function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=kk(t,e,n)}(t,e,n))}function kk(t,e,n){var r=t.node(n).parent,i=!0,s=e.edge(n,r),o=0;return s||(i=!1,s=e.edge(r,n)),o=s.weight,e.nodeEdges(n).forEach(s=>{var a=s.v===n,l=a?s.w:s.v;if(l!==r){var c=a===i,u=e.edge(s).weight;if(o+=c?u:-u,function(t,e,n){return t.hasEdge(e,n)}(t,n,l)){var h=t.edge(n,l).cutvalue;o+=c?-h:h}}}),o}function Rk(t,e){arguments.length<2&&(e=t.nodes()[0]),Mk(t,{},1,e)}function Mk(t,e,n,r,i){var s=n,o=t.node(r);return e[r]=!0,t.neighbors(r).forEach(i=>{Object.hasOwn(e,i)||(n=Mk(t,e,n,i,r))}),o.low=s,o.lim=n++,i?o.parent=i:delete o.parent,n}function Ok(t){return t.edges().find(e=>t.edge(e).cutvalue<0)}function Nk(t,e,n){var r=n.v,i=n.w;e.hasEdge(r,i)||(r=n.w,i=n.v);var s=t.node(r),o=t.node(i),a=s,l=!1;s.lim>o.lim&&(a=o,l=!0);var c=e.edges().filter(e=>l===Pk(t,t.node(e.v),a)&&l!==Pk(t,t.node(e.w),a));return c.reduce((t,n)=>vk(e,n)<vk(e,t)?n:t)}function Ik(t,e,n,r){var i=n.v,s=n.w;t.removeEdge(i,s),t.setEdge(r.v,r.w,{}),Rk(t),Ck(t,e),function(t,e){var n=t.nodes().find(t=>!e.node(t).parent),r=wk(t,n);(r=r.slice(1)).forEach(n=>{var r=t.node(n).parent,i=e.edge(n,r),s=!1;i||(i=e.edge(r,n),s=!0),e.node(n).rank=e.node(r).rank+(s?i.minlen:-i.minlen)})}(t,e)}function Pk(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}Tk.initLowLimValues=Rk,Tk.initCutValues=Ck,Tk.calcCutValue=kk,Tk.leaveEdge=Ok,Tk.enterEdge=Nk,Tk.exchangeEdges=Ik;var Lk=fk.longestPath,Dk=_k,Vk=Sk,Bk=function(t){var e=t.graph().ranker;if(e instanceof Function)return e(t);switch(t.graph().ranker){case"network-simplex":default:Gk(t);break;case"tight-tree":!function(t){Lk(t),Dk(t)}(t);break;case"longest-path":zk(t);case"none":}};var zk=Lk;function Gk(t){Vk(t)}var Fk=function(t){let e=function(t){let e={},n=0;function r(i){let s=n;t.children(i).forEach(r),e[i]={low:s,lim:n++}}return t.children().forEach(r),e}(t);t.graph().dummyChains.forEach(n=>{let r=t.node(n),i=r.edgeObj,s=function(t,e,n,r){let i,s,o=[],a=[],l=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),o.push(i)}while(i&&(e[i].low>l||c>e[i].lim));s=i,i=r;for(;(i=t.parent(i))!==s;)a.push(i);return{path:o.concat(a.reverse()),lca:s}}(t,e,i.v,i.w),o=s.path,a=s.lca,l=0,c=o[l],u=!0;for(;n!==i.w;){if(r=t.node(n),u){for(;(c=o[l])!==a&&t.node(c).maxRank<r.rank;)l++;c===a&&(u=!1)}if(!u){for(;l<o.length-1&&t.node(c=o[l+1]).minRank<=r.rank;)l++;c=o[l]}t.setParent(n,c),n=t.successors(n)[0]}})};let jk=ZC;var Uk={run:function(t){let e=jk.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var s=t.children(r);s&&s.length&&s.forEach(t=>n(t,i+1)),e[r]=i}return t.children().forEach(t=>n(t,1)),e}(t),r=Object.values(n),i=jk.applyWithChunking(Math.max,r)-1,s=2*i+1;t.graph().nestingRoot=e,t.edges().forEach(e=>t.edge(e).minlen*=s);let o=function(t){return t.edges().reduce((e,n)=>e+t.edge(n).weight,0)}(t)+1;t.children().forEach(r=>Yk(t,e,s,o,i,n,r)),t.graph().nodeRankFactor=s},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,t.edges().forEach(e=>{t.edge(e).nestingEdge&&t.removeEdge(e)})}};function Yk(t,e,n,r,i,s,o){let a=t.children(o);if(!a.length)return void(o!==e&&t.setEdge(e,o,{weight:0,minlen:n}));let l=jk.addBorderNode(t,"_bt"),c=jk.addBorderNode(t,"_bb"),u=t.node(o);t.setParent(l,o),u.borderTop=l,t.setParent(c,o),u.borderBottom=c,a.forEach(a=>{Yk(t,e,n,r,i,s,a);let u=t.node(a),h=u.borderTop?u.borderTop:a,f=u.borderBottom?u.borderBottom:a,d=u.borderTop?r:2*r,p=h!==f?1:i-s[o]+1;t.setEdge(l,h,{weight:d,minlen:p,nestingEdge:!0}),t.setEdge(f,c,{weight:d,minlen:p,nestingEdge:!0})}),t.parent(o)||t.setEdge(e,l,{weight:0,minlen:i+s[o]})}let Hk=ZC;var Wk=function(t){t.children().forEach(function e(n){let r=t.children(n),i=t.node(n);if(r.length&&r.forEach(e),Object.hasOwn(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(let e=i.minRank,r=i.maxRank+1;e<r;++e)qk(t,"borderLeft","_bl",n,i,e),qk(t,"borderRight","_br",n,i,e)}})};function qk(t,e,n,r,i,s){let o={width:0,height:0,rank:s,borderType:e},a=i[e][s-1],l=Hk.addDummyNode(t,"border",o,n);i[e][s]=l,t.setParent(l,r),a&&t.setEdge(a,l,{weight:1})}function $k(t){t.nodes().forEach(e=>Xk(t.node(e))),t.edges().forEach(e=>Xk(t.edge(e)))}function Xk(t){let e=t.width;t.width=t.height,t.height=e}function Kk(t){t.y=-t.y}function Zk(t){let e=t.x;t.x=t.y,t.y=e}let Jk=ZC;var Qk=function(t){let e={},n=t.nodes().filter(e=>!t.children(e).length),r=n.map(e=>t.node(e).rank),i=Jk.applyWithChunking(Math.max,r),s=Jk.range(i+1).map(()=>[]);function o(n){if(e[n])return;e[n]=!0;let r=t.node(n);s[r.rank].push(n),t.successors(n).forEach(o)}let a=n.sort((e,n)=>t.node(e).rank-t.node(n).rank);return a.forEach(o),s};let tR=ZC.zipObject;function eR(t,e,n){let r=tR(n,n.map((t,e)=>e)),i=e.flatMap(e=>t.outEdges(e).map(e=>({pos:r[e.w],weight:t.edge(e).weight})).sort((t,e)=>t.pos-e.pos)),s=1;for(;s<n.length;)s<<=1;let o=2*s-1;s-=1;let a=new Array(o).fill(0),l=0;return i.forEach(t=>{let e=t.pos+s;a[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=a[e+1]),e=e-1>>1,a[e]+=t.weight;l+=t.weight*n}),l}let nR=ZC;var rR=function(t,e){let n={};return t.forEach((t,e)=>{let r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)}),e.edges().forEach(t=>{let e=n[t.v],r=n[t.w];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(n[t.w]))}),function(t){let e=[];function n(t){return e=>{e.merged||(void 0===e.barycenter||void 0===t.barycenter||e.barycenter>=t.barycenter)&&function(t,e){let n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function r(e){return n=>{n.in.push(e),0===--n.indegree&&t.push(n)}}for(;t.length;){let i=t.pop();e.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return e.filter(t=>!t.merged).map(t=>nR.pick(t,["vs","i","barycenter","weight"]))}(Object.values(n).filter(t=>!t.indegree))};let iR=ZC;var sR=function(t,e){let n=iR.partition(t,t=>Object.hasOwn(t,"barycenter")),r=n.lhs,i=n.rhs.sort((t,e)=>e.i-t.i),s=[],o=0,a=0,l=0;r.sort((c=!!e,(t,e)=>t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:c?e.i-t.i:t.i-e.i)),l=oR(s,i,l),r.forEach(t=>{l+=t.vs.length,s.push(t.vs),o+=t.barycenter*t.weight,a+=t.weight,l=oR(s,i,l)});var c;let u={vs:s.flat(!0)};a&&(u.barycenter=o/a,u.weight=a);return u};function oR(t,e,n){let r;for(;e.length&&(r=e[e.length-1]).i<=n;)e.pop(),t.push(r.vs),n++;return n}let aR=function(t,e=[]){return e.map(e=>{let n=t.inEdges(e);if(n.length){let r=n.reduce((e,n)=>{let r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}},{sum:0,weight:0});return{v:e,barycenter:r.sum/r.weight,weight:r.weight}}return{v:e}})},lR=rR,cR=sR;var uR=function t(e,n,r,i){let s=e.children(n),o=e.node(n),a=o?o.borderLeft:void 0,l=o?o.borderRight:void 0,c={};a&&(s=s.filter(t=>t!==a&&t!==l));let u=aR(e,s);u.forEach(n=>{if(e.children(n.v).length){let a=t(e,n.v,r,i);c[n.v]=a,Object.hasOwn(a,"barycenter")&&(o=a,void 0!==(s=n).barycenter?(s.barycenter=(s.barycenter*s.weight+o.barycenter*o.weight)/(s.weight+o.weight),s.weight+=o.weight):(s.barycenter=o.barycenter,s.weight=o.weight))}var s,o});let h=lR(u,r);!function(t,e){t.forEach(t=>{t.vs=t.vs.flatMap(t=>e[t]?e[t].vs:t)})}(h,c);let f=cR(h,i);if(a&&(f.vs=[a,f.vs,l].flat(!0),e.predecessors(a).length)){let t=e.node(e.predecessors(a)[0]),n=e.node(e.predecessors(l)[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+t.order+n.order)/(f.weight+2),f.weight+=2}return f};let hR=FC.Graph,fR=ZC;var dR=function(t,e,n,r){r||(r=t.nodes());let i=function(t){var e;for(;t.hasNode(e=fR.uniqueId("_root")););return e}(t),s=new hR({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(e=>t.node(e));return r.forEach(r=>{let o=t.node(r),a=t.parent(r);(o.rank===e||o.minRank<=e&&e<=o.maxRank)&&(s.setNode(r),s.setParent(r,a||i),t[n](r).forEach(e=>{let n=e.v===r?e.w:e.v,i=s.edge(n,r),o=void 0!==i?i.weight:0;s.setEdge(n,r,{weight:t.edge(e).weight+o})}),Object.hasOwn(o,"minRank")&&s.setNode(r,{borderLeft:o.borderLeft[e],borderRight:o.borderRight[e]}))}),s};let pR=Qk,_R=function(t,e){let n=0;for(let r=1;r<e.length;++r)n+=eR(t,e[r-1],e[r]);return n},gR=uR,yR=dR,mR=function(t,e,n){let r,i={};n.forEach(n=>{let s,o,a=t.parent(n);for(;a;){if(s=t.parent(a),s?(o=i[s],i[s]=a):(o=r,r=a),o&&o!==a)return void e.setEdge(o,a);a=s}})},bR=FC.Graph,vR=ZC;var xR=function t(e,n){if(n&&"function"==typeof n.customOrder)return void n.customOrder(e,t);let r=vR.maxRank(e),i=wR(e,vR.range(1,r+1),"inEdges"),s=wR(e,vR.range(r-1,-1,-1),"outEdges"),o=pR(e);if(AR(e,o),n&&n.disableOptimalOrderHeuristic)return;let a,l=Number.POSITIVE_INFINITY;for(let t=0,n=0;n<4;++t,++n){ER(t%2?i:s,t%4>=2),o=vR.buildLayerMatrix(e);let r=_R(e,o);r<l&&(n=0,a=Object.assign({},o),l=r)}AR(e,a)};function wR(t,e,n){const r=new Map,i=(t,e)=>{r.has(t)||r.set(t,[]),r.get(t).push(e)};for(const e of t.nodes()){const n=t.node(e);if("number"==typeof n.rank&&i(n.rank,e),"number"==typeof n.minRank&&"number"==typeof n.maxRank)for(let t=n.minRank;t<=n.maxRank;t++)t!==n.rank&&i(t,e)}return e.map(function(e){return yR(t,e,n,r.get(e)||[])})}function ER(t,e){let n=new bR;t.forEach(function(t){let r=t.graph().root,i=gR(t,r,n,e);i.vs.forEach((e,n)=>t.node(e).order=n),mR(t,n,i.vs)})}function AR(t,e){Object.values(e).forEach(e=>e.forEach((e,n)=>t.node(e).order=n))}let SR=FC.Graph,TR=ZC;var CR=function(t){let e,n=TR.buildLayerMatrix(t),r=Object.assign(function(t,e){let n={};function r(e,r){let i=0,s=0,o=e.length,a=r[r.length-1];return r.forEach((e,l)=>{let c=function(t,e){if(t.node(e).dummy)return t.predecessors(e).find(e=>t.node(e).dummy)}(t,e),u=c?t.node(c).order:o;(c||e===a)&&(r.slice(s,l+1).forEach(e=>{t.predecessors(e).forEach(r=>{let s=t.node(r),o=s.order;!(o<i||u<o)||s.dummy&&t.node(e).dummy||kR(n,r,e)})}),s=l+1,i=u)}),r}return e.length&&e.reduce(r),n}(t,n),function(t,e){let n={};function r(e,r,i,s,o){let a;TR.range(r,i).forEach(r=>{a=e[r],t.node(a).dummy&&t.predecessors(a).forEach(e=>{let r=t.node(e);r.dummy&&(r.order<s||r.order>o)&&kR(n,e,a)})})}function i(e,n){let i,s=-1,o=0;return n.forEach((a,l)=>{if("border"===t.node(a).dummy){let e=t.predecessors(a);e.length&&(i=t.node(e[0]).order,r(n,o,l,s,i),o=l,s=i)}r(n,o,n.length,i,e.length)}),n}return e.length&&e.reduce(i),n}(t,n)),i={};["u","d"].forEach(s=>{e="u"===s?n:Object.values(n).reverse(),["l","r"].forEach(n=>{"r"===n&&(e=e.map(t=>Object.values(t).reverse()));let o=("u"===s?t.predecessors:t.successors).bind(t),a=function(t,e,n,r){let i={},s={},o={};return e.forEach(t=>{t.forEach((t,e)=>{i[t]=t,s[t]=t,o[t]=e})}),e.forEach(t=>{let e=-1;t.forEach(t=>{let a=r(t);if(a.length){a=a.sort((t,e)=>o[t]-o[e]);let r=(a.length-1)/2;for(let l=Math.floor(r),c=Math.ceil(r);l<=c;++l){let r=a[l];s[t]===t&&e<o[r]&&!RR(n,t,r)&&(s[r]=t,s[t]=i[t]=i[r],e=o[r])}}})}),{root:i,align:s}}(0,e,r,o),l=function(t,e,n,r,i){let s={},o=function(t,e,n,r){let i=new SR,s=t.graph(),o=function(t,e,n){return(r,i,s)=>{let o,a=r.node(i),l=r.node(s),c=0;if(c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":o=-a.width/2;break;case"r":o=a.width/2}if(o&&(c+=n?o:-o),o=0,c+=(a.dummy?e:t)/2,c+=(l.dummy?e:t)/2,c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":o=l.width/2;break;case"r":o=-l.width/2}return o&&(c+=n?o:-o),o=0,c}}(s.nodesep,s.edgesep,r);return e.forEach(e=>{let r;e.forEach(e=>{let s=n[e];if(i.setNode(s),r){var a=n[r],l=i.edge(a,s);i.setEdge(a,s,Math.max(o(t,e,r),l||0))}r=e})}),i}(t,e,n,i),a=i?"borderLeft":"borderRight";function l(t,e){let n=o.nodes(),r=n.pop(),i={};for(;r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}function c(t){s[t]=o.inEdges(t).reduce((t,e)=>Math.max(t,s[e.v]+o.edge(e)),0)}function u(e){let n=o.outEdges(e).reduce((t,e)=>Math.min(t,s[e.w]-o.edge(e)),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==a&&(s[e]=Math.max(s[e],n))}return l(c,o.predecessors.bind(o)),l(u,o.successors.bind(o)),Object.keys(r).forEach(t=>s[t]=s[n[t]]),s}(t,e,a.root,a.align,"r"===n);"r"===n&&(l=TR.mapValues(l,t=>-t)),i[s+n]=l})});let s=function(t,e){return Object.values(e).reduce((e,n)=>{let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([e,n])=>{let s=function(t,e){return t.node(e).width}(t,e)/2;r=Math.max(n+s,r),i=Math.min(n-s,i)});const s=r-i;return s<e[0]&&(e=[s,n]),e},[Number.POSITIVE_INFINITY,null])[1]}(t,i);return function(t,e){let n=Object.values(e),r=TR.applyWithChunking(Math.min,n),i=TR.applyWithChunking(Math.max,n);["u","d"].forEach(n=>{["l","r"].forEach(s=>{let o=n+s,a=t[o];if(a===e)return;let l=Object.values(a),c=r-TR.applyWithChunking(Math.min,l);"l"!==s&&(c=i-TR.applyWithChunking(Math.max,l)),c&&(t[o]=TR.mapValues(a,t=>t+c))})})}(i,s),function(t,e){return TR.mapValues(t.ul,(n,r)=>{if(e)return t[e.toLowerCase()][r];{let e=Object.values(t).map(t=>t[r]).sort((t,e)=>t-e);return(e[1]+e[2])/2}})}(i,t.graph().align)};function kR(t,e,n){if(e>n){let t=e;e=n,n=t}let r=t[e];r||(t[e]=r={}),r[n]=!0}function RR(t,e,n){if(e>n){let t=e;e=n,n=t}return!!t[e]&&Object.hasOwn(t[e],n)}let MR=ZC,OR=CR;var NR=function(t){(function(t){let e=MR.buildLayerMatrix(t),n=t.graph().ranksep,r=0;e.forEach(e=>{const i=e.reduce((e,n)=>{const r=t.node(n).height;return e>r?e:r},0);e.forEach(e=>t.node(e).y=r+i/2),r+=i+n})})(t=MR.asNonCompoundGraph(t)),Object.entries(OR(t)).forEach(([e,n])=>t.node(e).x=n)};let IR=lk,PR=uk,LR=Bk,DR=ZC.normalizeRanks,VR=Fk,BR=ZC.removeEmptyRanks,zR=Uk,GR=Wk,FR={adjust:function(t){let e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||$k(t)},undo:function(t){let e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){t.nodes().forEach(e=>Kk(t.node(e))),t.edges().forEach(e=>{let n=t.edge(e);n.points.forEach(Kk),Object.hasOwn(n,"y")&&Kk(n)})}(t);"lr"!==e&&"rl"!==e||(!function(t){t.nodes().forEach(e=>Zk(t.node(e))),t.edges().forEach(e=>{let n=t.edge(e);n.points.forEach(Zk),Object.hasOwn(n,"x")&&Zk(n)})}(t),$k(t))}},jR=xR,UR=NR,YR=ZC,HR=FC.Graph;var WR=function(t,e){let n=e&&e.debugTiming?YR.time:YR.notime;n("layout",()=>{let r=n(" buildLayoutGraph",()=>function(t){let e=new HR({multigraph:!0,compound:!0}),n=nM(t.graph());return e.setGraph(Object.assign({},$R,eM(n,qR),YR.pick(n,XR))),t.nodes().forEach(n=>{const r=eM(nM(t.node(n)),KR);Object.keys(ZR).forEach(t=>{void 0===r[t]&&(r[t]=ZR[t])}),e.setNode(n,r),e.setParent(n,t.parent(n))}),t.edges().forEach(n=>{let r=nM(t.edge(n));e.setEdge(n,Object.assign({},QR,eM(r,JR),YR.pick(r,tM)))}),e}(t));n(" runLayout",()=>function(t,e,n){e(" makeSpaceForEdgeLabels",()=>function(t){let e=t.graph();e.ranksep/=2,t.edges().forEach(n=>{let r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)})}(t)),e(" removeSelfEdges",()=>function(t){t.edges().forEach(e=>{if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}})}(t)),e(" acyclic",()=>IR.run(t)),e(" nestingGraph.run",()=>zR.run(t)),e(" rank",()=>LR(YR.asNonCompoundGraph(t))),e(" injectEdgeLabelProxies",()=>function(t){t.edges().forEach(e=>{let n=t.edge(e);if(n.width&&n.height){let n=t.node(e.v),r={rank:(t.node(e.w).rank-n.rank)/2+n.rank,e:e};YR.addDummyNode(t,"edge-proxy",r,"_ep")}})}(t)),e(" removeEmptyRanks",()=>BR(t)),e(" nestingGraph.cleanup",()=>zR.cleanup(t)),e(" normalizeRanks",()=>DR(t)),e(" assignRankMinMax",()=>function(t){let e=0;t.nodes().forEach(n=>{let r=t.node(n);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,e=Math.max(e,r.maxRank))}),t.graph().maxRank=e}(t)),e(" removeEdgeLabelProxies",()=>function(t){t.nodes().forEach(e=>{let n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))})}(t)),e(" normalize.run",()=>PR.run(t)),e(" parentDummyChains",()=>VR(t)),e(" addBorderSegments",()=>GR(t)),e(" order",()=>jR(t,n)),e(" insertSelfEdges",()=>function(t){var e=YR.buildLayerMatrix(t);e.forEach(e=>{var n=0;e.forEach((e,r)=>{var i=t.node(e);i.order=r+n,(i.selfEdges||[]).forEach(e=>{YR.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:r+ ++n,e:e.e,label:e.label},"_se")}),delete i.selfEdges})})}(t)),e(" adjustCoordinateSystem",()=>FR.adjust(t)),e(" position",()=>UR(t)),e(" positionSelfEdges",()=>function(t){t.nodes().forEach(e=>{var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,s=r.y,o=n.x-i,a=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*o/3,y:s-a},{x:i+5*o/6,y:s-a},{x:i+o,y:s},{x:i+5*o/6,y:s+a},{x:i+2*o/3,y:s+a}],n.label.x=n.x,n.label.y=n.y}})}(t)),e(" removeBorderNodes",()=>function(t){t.nodes().forEach(e=>{if(t.children(e).length){let n=t.node(e),r=t.node(n.borderTop),i=t.node(n.borderBottom),s=t.node(n.borderLeft[n.borderLeft.length-1]),o=t.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-s.x),n.height=Math.abs(i.y-r.y),n.x=s.x+n.width/2,n.y=r.y+n.height/2}}),t.nodes().forEach(e=>{"border"===t.node(e).dummy&&t.removeNode(e)})}(t)),e(" normalize.undo",()=>PR.undo(t)),e(" fixupEdgeLabelCoords",()=>function(t){t.edges().forEach(e=>{let n=t.edge(e);if(Object.hasOwn(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}})}(t)),e(" undoCoordinateSystem",()=>FR.undo(t)),e(" translateGraph",()=>function(t){let e=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,s=t.graph(),o=s.marginx||0,a=s.marginy||0;function l(t){let s=t.x,o=t.y,a=t.width,l=t.height;e=Math.min(e,s-a/2),n=Math.max(n,s+a/2),r=Math.min(r,o-l/2),i=Math.max(i,o+l/2)}t.nodes().forEach(e=>l(t.node(e))),t.edges().forEach(e=>{let n=t.edge(e);Object.hasOwn(n,"x")&&l(n)}),e-=o,r-=a,t.nodes().forEach(n=>{let i=t.node(n);i.x-=e,i.y-=r}),t.edges().forEach(n=>{let i=t.edge(n);i.points.forEach(t=>{t.x-=e,t.y-=r}),Object.hasOwn(i,"x")&&(i.x-=e),Object.hasOwn(i,"y")&&(i.y-=r)}),s.width=n-e+o,s.height=i-r+a}(t)),e(" assignNodeIntersects",()=>function(t){t.edges().forEach(e=>{let n,r,i=t.edge(e),s=t.node(e.v),o=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=o,r=s),i.points.unshift(YR.intersectRect(s,n)),i.points.push(YR.intersectRect(o,r))})}(t)),e(" reversePoints",()=>function(t){t.edges().forEach(e=>{let n=t.edge(e);n.reversed&&n.points.reverse()})}(t)),e(" acyclic.undo",()=>IR.undo(t))}(r,n,e)),n(" updateInputGraph",()=>function(t,e){t.nodes().forEach(n=>{let r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,r.rank=i.rank,e.children(n).length&&(r.width=i.width,r.height=i.height))}),t.edges().forEach(n=>{let r=t.edge(n),i=e.edge(n);r.points=i.points,Object.hasOwn(i,"x")&&(r.x=i.x,r.y=i.y)}),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,r))})};let qR=["nodesep","edgesep","ranksep","marginx","marginy"],$R={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},XR=["acyclicer","ranker","rankdir","align"],KR=["width","height","rank"],ZR={width:0,height:0},JR=["minlen","weight","width","height","labeloffset"],QR={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},tM=["labelpos"];function eM(t,e){return YR.mapValues(YR.pick(t,e),Number)}function nM(t){var e={};return t&&Object.entries(t).forEach(([t,n])=>{"string"==typeof t&&(t=t.toLowerCase()),e[t]=n}),e}let rM=ZC,iM=FC.Graph;var sM={debugOrdering:function(t){let e=rM.buildLayerMatrix(t),n=new iM({compound:!0,multigraph:!0}).setGraph({});return t.nodes().forEach(e=>{n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)}),t.edges().forEach(t=>n.setEdge(t.v,t.w,{},t.name)),e.forEach((t,e)=>{let r="layer"+e;n.setNode(r,{rank:"same"}),t.reduce((t,e)=>(n.setEdge(t,e,{style:"invis"}),e))}),n}};var oM={graphlib:FC,layout:WR,debug:sM,util:{time:ZC.time,notime:ZC.notime},version:"1.1.8"};class aM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let r=bE(t.children[0]);if(!r)continue;var n=new oM.graphlib.Graph;n.setGraph({edgesep:e.edgeSep,nodesep:e.nodeSep,ranksep:e.rankSep}),n.setDefaultEdgeLabel(function(){return{}}),n.graph().rankdir=this._getDagreDirection(e.direction);let i=new Map;for(let e of t.children){let t=e.datum[xE];i.set(t,t+""),n.setNode(t,{label:e.text?e.text:"",width:e.bounds.width,height:e.bounds.height})}for(let t of r.linkList)n.setEdge(t.source,t.target);oM.layout(n);const s={};let o=d3.min(n.nodes().map(t=>n.node(t).y)),a=d3.min(n.nodes().map(t=>n.node(t).x)),l=e.left-a,c=e.top-o;for(const t of n.nodes())s[t]={x:n.node(t).x+l,y:n.node(t).y+c};for(let e of t.children){let t=e.datum[xE];XA(e,s[i.get(t)].x-e.x,s[i.get(t)].y-e.y)}}let r=cA(t,!0);for(let t of r)BE(t)}_getDagreDirection(t){switch(t){case oS.Left2Right:return"LR";case oS.Right2Left:return"RL";case oS.Top2Bottom:return"TB";case oS.Bottom2Top:return"BT"}}}class lM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let n=yE(t.children[0]);if(!n)continue;let r=Od(n._data),i=Math.max(...t.children.map(t=>t.bounds.width)),s=Math.max(...t.children.map(t=>t.bounds.height)),o=e.orientation==nS?[e.height,e.width]:[e.width,e.height],a=wp().nodeSize([i,s]).size(o)(r);this._apply(a,e,t)}BE(t)}_apply(t,e,n){let r,i,s=n.children.filter(e=>e.datum[xE]==t.data[xE])[0];switch(e.orientation){case nS:r=t.y+e.left,i=t.x+e.top;break;case rS:r=t.x+e.left,i=e.top+t.y}if(XA(s,r-s.x,i-s.y),t.children&&t.children.length>0)for(let r of t.children)this._apply(r,e,n)}}class cM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=this._inputVars.filter(t=>t.type===KE.PROPERTY&&t.property===gA.CHILDREN_ORDER)[0].element,n=e.layout,r=n.width?n.width:e.bounds.width,i=n.height?n.height:e.bounds.height,s=void 0===n.top?e.bounds.top:n.top,o=void 0===n.left?e.bounds.left:n.left,a=Od(e).sum(t=>t.type===Pw.Rect?t.width*t.height:0);Cp().size([r,i])(a),this._apply(a,o,s);let l=cA(t,!0);for(let t of l)BE(t)}_apply(t,e,n){if(t.data.type==Pw.Collection&&t.children)for(let r of t.children)this._apply(r,e,n);else t.data.type==Pw.Rect&&(t.data.resize(t.x1-t.x0,t.y1-t.y0),XA(t.data,t.x0+e-t.data.left,t.y0+n-t.data.top))}}class uM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){if(!t.layout)continue;if(0===t.children.length)continue;let e=yE(t.children[0]);if(!e)continue;let n={};for(let e of t.children)n[e.datum[xE]]=e;t.children[0].type===Pw.Rect?this._layoutRects(e.getRoot(),e,n):this._layoutArcs(e.getRoot(),e,n)}BE(t)}_layoutArcs(t,e,n){let r=e.getChildren(t);if(0===r.length)return;let i=n[t[xE]],s=!i||i.type!=Pw.Arc&&i.type!=Pw.Pie?60:i.startAngle;for(let t=0;t<r.length;t++){let i=r[t],o=n[i[xE]];if(o.type===Pw.Arc){let t=xS(s+o.angle);o.setAngles(s,t),s=t}this._layoutArcs(i,e,n)}}_layoutRects(t,e,n){let r=e.getChildren(t);if(0===r.length)return;let i,s,o=n[t[xE]];this._direction,i=o.left,s=o.bottom;for(let t=0;t<r.length;t++){let o=r[t],a=n[o[xE]];XA(a,i-a.left,s-a.top),i+=a.width,this._layoutRects(o,e,n)}}}class hM extends qE{constructor(t){super(t)}run(){super.run();let t=this.outputVar;t.clearResult();let e=this.inputVars.find(t=>void 0!==t.context),n=t.conditionalEncoding,r=e?e.context:void 0,i=aA(n.responderComponent).state,s=t.result;if(n.evalFunction){n.getResponderPeers().forEach(t=>s[t.id]=!!n.evalFunction(r,i,t))}}}class fM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let n=360/t.children.length;for(let[r,i]of t.children.entries()){i._rotate=void 0,i._markRotationOffset=void 0,i._updateBounds();let t=r*n,s=OE(e.x+e.radius,e.y,e.x,e.y,t);switch(XA(i,s.x-i.bounds.x,s.y-i.bounds.y),e.markRotation){case cS.INWARD:i._markRotationOffset=t+90;break;case cS.TANGENTIAL_CLOCKWISE:i._markRotationOffset=t;break;case cS.TANGENTIAL_COUNTERCLOCKWISE:i._markRotationOffset=t-180;break;case cS.UPRIGHT:break;case cS.OUTWARD:default:i._markRotationOffset=t-90}}}let n=cA(t,!0);for(let t of n)BE(t)}}class dM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let n of e){let e=n.layout;if(!e)continue;let r=e._tree??yE(n.children[0]);if(!r){console.warn("cluster layout has no tree; skipping placement for",n.id);continue}let i=Od(r._data);if(e.isRadial()){i=Rd().size([bS(e.angleExtent),e.radius])(i),e._d3Root=i;const t=new Map(i.descendants().map(t=>[t.data[xE],[t.x,t.y]]));for(let r of n.children){let n=r.datum[xE];r._rotate=void 0,r._bounds=void 0,XA(r,e.x-r.bounds.x,e.y-t.get(n)[1]-r.bounds.y),r._rotate=[vS(t.get(n)[0]),e.x,e.y]}}else if(e.orientation===rS){!e.width||e.width;let r=e.height?e.height:600;i=Rd().nodeSize([t.bounds.width+1,r/(i.height+1)])(i),e._d3Root=i;const s=new Map(i.descendants().map(t=>[t.data[xE],[t.x,t.y]]));let o=1/0,a=-o;i.each(t=>{t.x>a&&(a=t.x),t.x<o&&(o=t.x)}),e._x0=o;for(let t of n.children){let n=t.datum[xE];XA(t,s.get(n)[0]-o+e.left-t.bounds.x,s.get(n)[1]+e.top-t.bounds.y)}}else if(e.orientation===nS){!e.width||e.width;let r=e.height?e.height:600;i=Rd().nodeSize([t.bounds.height,r/(i.height+1)])(i),e._d3Root=i;const s=new Map(i.descendants().map(t=>[t.data[xE],[t.x,t.y]]));let o=1/0,a=-o;i.each(t=>{t.x>a&&(a=t.x),t.x<o&&(o=t.x)}),e._x0=o;for(let t of n.children){let n=t.datum[xE];XA(t,s.get(n)[1]+e.left-t.bounds.x,s.get(n)[0]-o+e.top-t.bounds.y)}}}let n=cA(t,!0);for(let t of n)BE(t)}}class pM extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let n=e.direction===aS.ANTI_CLOCKWISE?-1:1;for(let[r,i]of t.children.entries()){i._rotate=void 0,i._markRotationOffset=void 0,i._updateBounds();let t=e.startRadius+e.radiusStep*r,s=e.startAngle+n*e.angleStep*r,o=OE(e.x+t,e.y,e.x,e.y,s);switch(XA(i,o.x-i.bounds.x,o.y-i.bounds.y),e.markRotation){case cS.INWARD:i._markRotationOffset=s+90;break;case cS.TANGENTIAL_CLOCKWISE:i._markRotationOffset=s;break;case cS.TANGENTIAL_COUNTERCLOCKWISE:i._markRotationOffset=s-180;break;case cS.UPRIGHT:break;case cS.OUTWARD:default:i._markRotationOffset=s-90}}}let n=cA(t,!0);for(let t of n)BE(t)}}class _M extends qE{constructor(t){super(t)}run(){super.run();let t=this._outputVars[0].element,e=JE(t.parent);for(let t of e){let e=t.layout;if(!e)continue;let n=t.children.filter(t=>"hidden"!==t.visibility),r=e.compute(n,e);if(r&&"object"==typeof r)for(let t of n){let e=r[t.id];if(!e||"number"!=typeof e.x||"number"!=typeof e.y)continue;let n=t.refBounds?t.refBounds:t.bounds,i=e.x-n.x,s=e.y-n.y;(i||s)&&XA(t,i,s)}}let n=cA(t,!0);for(let t of n)BE(t)}}class gM extends XE{constructor(t,e){super(t),this._cond=e}get context(){return this._cond}}class yM extends qE{constructor(t,e,n,r){super(t),this._fn=e,this._compnt=n,this._resolveDynamically=r}run(){super.run();let t=this.inputVars.find(t=>t instanceof gM),e=t?t.context:void 0,n=this._resolveDynamically?function(t){let e=t?t.get("element"):void 0;for(;e&&e.parent&&e.parent.type!==Pw.Collection;)e=e.parent;return e}(e):this._compnt;if(!n)return;let r=aA(this._compnt);if(this._fn(void 0,e,r?r.state:void 0,n),r)for(let t of this._outputVars){let e=t.element||t.stateContext;e&&e._scene&&(t.type===KE.CHANNEL?r.onChange(KE.CHANNEL,t.channel,e):t.type===KE.PROPERTY?r.onChange(KE.PROPERTY,t.property,e):t.type===KE.STATE&&r.onChange(KE.STATE,t.key,t.stateContext))}}}class mM extends XE{constructor(t,e,n,r=null){super(t),this._attribute=e,this._dataset=n,this._encoding=r}get attribute(){return this._attribute}get dataset(){return this._dataset}get encoding(){return this._encoding}}class bM extends qE{constructor(t){super(t)}run(){super.run();let t=this.outputVar,e=this.inputVars.find(t=>t instanceof mM),n=t.encodings[0].dataTable.type(e.attribute),r={};for(let e of t.encodings){let t=this._computeAttrValues(e,n);Object.assign(r,t)}t.attrValues=r}_computeAttrValues(t,e){if("vertex"===t.element.type)return this._computeVertexIndexAttrValues(t,e);let n=JE(t.element),r={};if(t.element.type===Pw.Area&&["width","height"].indexOf(t.channel)>=0||["fillGradient","strokeGradient"].indexOf(t.channel)>=0)for(let e of n)for(let n=0;n<e._vertices.length;n++)r[tA(e,n)]=e._vertices.hasDataScope(n)?e._vertices.aggregateDataScopeAttribute(n,t.attribute,t.aggregator):oE(e.dataScope,t.attribute,t.aggregator);else switch(e){case Vw.Boolean:break;case Vw.Date:for(let e of n)r[e.id]=iE(e.dataScope,t.attribute);break;case Vw.String:try{if("count"==t.aggregator)for(let e of n)r[e.id]=sE(e.dataScope,t.attribute).length;else for(let e of n)r[e.id]=iE(e.dataScope,t.attribute)}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t.attribute+" : "+e)}break;default:if(t.attribute.startsWith("parent.")||t.attribute.startsWith("child.")){let e=t.dataTable.tree.nodeTable,i=t.attribute.split(".")[0],s=t.attribute.split(".")[1];for(let t of n){let n=iE(t.dataScope,i);r[t.id]=iE(aE(cE(e),xE,n),s)}}else for(let e of n)r[e.id]=oE(e.dataScope,t.attribute,t.aggregator)}return t.attrValues=r,r}_computeVertexIndexAttrValues(t,e){let n={};for(let r of t.elementGroups)for(let i of r.groups)for(let r of i.indices){n[tA(i.parent,r)]=this._computeVertexIndexValue(i.parent,r,t,e)}return t.attrValues=n,n}_getVertexIndexContext(t,e,n){let r={type:"vertex",parent:t,index:e,_index:e,id:n};return Object.defineProperty(r,"dataScope",{get:()=>t._vertices.hasDataScope(e)?t._vertices.getDataScopeRef(e):t.dataScope}),Object.defineProperty(r,"datum",{get:()=>eE(r.dataScope)}),Object.defineProperty(r,"data",{get:()=>tE(r.dataScope)}),r}_computeVertexIndexValue(t,e,n,r){if(!t._vertices.hasDataScope(e))return this._computeValue(t.dataScope,n,r);if(n.attribute.startsWith("parent.")||n.attribute.startsWith("child."))return this._computeValue(t._vertices.getDataScopeRef(e),n,r);switch(r){case Vw.Boolean:return;case Vw.Date:return t._vertices.getDataScopeAttrVal(e,n.attribute);case Vw.String:return"count"==n.aggregator?t._vertices.getDataScopeAttributeValues(e,n.attribute).length:t._vertices.getDataScopeAttrVal(e,n.attribute);default:return t._vertices.aggregateDataScopeAttribute(e,n.attribute,n.aggregator)}}_computeValue(t,e,n){switch(n){case Vw.Boolean:return;case Vw.Date:return iE(t,e.attribute);case Vw.String:return"count"==e.aggregator?sE(t,e.attribute).length:iE(t,e.attribute);default:if(e.attribute.startsWith("parent.")||e.attribute.startsWith("child.")){let n=e.dataTable.tree.nodeTable,r=e.attribute.split(".")[0],i=e.attribute.split(".")[1],s=iE(t,r);return iE(aE(cE(n),xE,s),i)}return oE(t,e.attribute,e.aggregator)}}}class vM extends XE{constructor(t,e,n){super(t),this._key=e,this._stateContext=n}get key(){return this._key}get stateContext(){return this._stateContext}}class xM{constructor(){this._variables={},this._operators={},this._edges=[]}toJSON(){const t=this._edges.map(t=>({from:t.fromNode.id,to:t.toNode.id,isDirected:t.isDirected})),e={};for(const t in this._variables)e[t]=Object.values(this._variables[t]).map(t=>{let e={id:t.id,type:t.type,incoming:t.incomingEdges.map(t=>t.id),outgoing:t.outgoingEdges.map(t=>t.id),undirected:t.undirectedEdges.map(t=>t.id)};return"ChannelVar"===t.type?(e.channel=t.channel,e.element=t.element):"BoundsVar"===t.type||"DataScopeVar"===t.type?e.element=t.element:"dataValue"===t.type?(e.scale=t.scale,e.attrValues=t.attrValues):"FieldVar"===t.type?(e.field=t.field,e.dataset=t.dataset):"PropertyVar"===t.type?(e.property=t.property,e.element=t.element):t.type===KE.STATE?e.key=t.key:e.scale=t.scale,e});const n={};for(const t in this._operators)n[t]=Object.values(this._operators[t]).map(t=>{let e={id:t.id,type:t.type,inputVars:t.inputVars.map(t=>t.id),outputVar:t.outputVar?t.outputVar.id:null};return t.type===$E.DOMAIN_BUILDER?e.aggregator=t.aggregator:t.type===$E.SCALE_BUILDER&&(e.channel=t.channel),e});return{edges:t,variables:e,operators:n}}getVariable(t,...e){if(Object.values(KE).indexOf(t)<0)throw console.log(t),new Error("Variable Type Not Known");let n=this.findVariable(t,e);if(n)return n;switch(t){case KE.CHANNEL:n=new hA(t,e[0],e[1]),"vertex"!=e[1].type&&"segment"!=e[1].type||this._connectPathElement2Size(e[1],n);break;case KE.PROPERTY:n=new dA(t,e[0],e[1]);break;case KE.STATE:n=new vM(t,e[0],e[1]);break;case KE.ATTRIBUTE:n=new mM(t,e[0],e[1],e[2]||null);break;case KE.ITEMS:n=new FT(t,e[0]);break;case KE.ATTR_VALUE:n=new vT(t,e[0]);break;case KE.DATASCOPE:n=new gT(t,e[0]);break;case KE.BOUNDS:n=new _T(t,e[0]);break;case KE.SCALE:n=new bT(t,e[0]);break;case KE.AFFIXATION:n=new WT(t,e[0]);break;case KE.ALIGNMENT:n=new eC(t,e[0]);break;case KE.EVT_CTX:n=new gM(t,e[0],e[1]);break;case KE.CONDITION_RESULT:n=new PT(t,e[0])}return t in this._variables||(this._variables[t]={}),this._variables[t][n.id]=n,n}_connectPathElement2Size(t,e){let n=t.parent,r=e.channel,i=this.findVariable(KE.CHANNEL,["x"===r?"width":"height",n]);if(i){let t=i.incomingDataflow;t||(t=this.createOneWayDependency($E.CONDUIT)),this.connect(e,t),this.connect(t,i)}}findIncomingDataflowOperator(t,e){return e.incomingDataflow&&e.incomingDataflow.type===t?e.incomingDataflow:void 0}getIncomingDataflowOperator(t,e){let n=this.findIncomingDataflowOperator(t,e);return n||this.createOneWayDependency(t)}getOutgoingDataflowOperator(t,e){for(let n of e.outgoingEdges)if(n.toNode instanceof qE&&n.toNode.type===t)return n.toNode;return this.createOneWayDependency(t)}createOneWayDependency(t,...e){if(Object.values($E).indexOf(t)<0)throw new Error("Dependency Type Not Known");let n;switch(t){case $E.EVAL_BBOX:n=new ET(t);break;case $E.AFFIXER:n=new HT(t);break;case $E.DATA_EXTRACTOR:n=new bM(t,e[0]);break;case $E.SCALE_BUILDER:n=new wT(t,e[0]);break;case $E.ENCODER:n=new LT(t,e[0]);break;case $E.AXIS_PATH_PLACER:n=new AT(t);break;case $E.AXIS_TICKS_PLACER:n=new ST(t);break;case $E.AXIS_LABELS_PLACER:n=new TT(t);break;case $E.AXIS_TITLE_PLACER:n=new QT(t);break;case $E.LINK_PLACER:n=new rC(t);break;case $E.GRID_LAYOUT:n=new kT(t);break;case $E.STACK_LAYOUT:n=new BT(t);break;case $E.PACK_LAYOUT:n=new JT(t);break;case $E.FORCE_LAYOUT:n=new nC(t);break;case $E.DIRECTED_LAYOUT:n=new aM(t);break;case $E.TIDY_TREE_LAYOUT:n=new lM(t);break;case $E.TREEMAP_LAYOUT:n=new cM(t);break;case $E.STRATA_LAYOUT:n=new uM(t);break;case $E.CIRCULAR_LAYOUT:n=new fM(t);break;case $E.CLUSTER_LAYOUT:n=new dM(t);break;case $E.SPIRAL_LAYOUT:n=new pM(t);break;case $E.CUSTOM_LAYOUT:n=new _M(t);break;case $E.GRIDLINES_PLACER:n=new DT(t);break;case $E.SPIRAL_TRAJECTORY_PLACER:n=new VT(t);break;case $E.BIN_TRANSFORMER:n=new GT(t);break;case $E.FILTER_TRANSFORMER:n=new jT(t);break;case $E.KDE_TRANSFORMER:n=new qT(t);break;case $E.CUSTOM_TRANSFORMER:n=new KT(t);break;case $E.UNPIVOT_TRANSFORMER:n=new ZT(t);break;case $E.REPOPULATE:n=new YT(t);break;case $E.TARGET_EVALUATOR:n=new hM(t);break;case $E.TARGET_UPDATER:n=new yM(t,e[0],e[1],e[2]);break;case $E.CONDUIT:default:n=new zT(t)}return t in this._operators||(this._operators[t]={}),this._operators[t][n.id]=n,n}createMultiWayDependency(t){if(Object.values($E).indexOf(t)<0)throw new Error("Dependency Type Not Known");let e;return $E.ALIGNER,e=new tC(t),t in this._operators||(this._operators[t]={}),this._operators[t][e.id]=e,e}connect(t,e,n=!0){if(t instanceof XE&&e instanceof qE){if(!e.inputVars.includes(t)){const r=new mT(t,e,n);return this._edges.push(r),t.outgoingEdges.push(r),e.inputVars.push(t),r}}else if(t instanceof qE&&e instanceof XE){if(!t.outputVars.includes(e)){const r=new mT(t,e,n);return this._edges.push(r),t.outputVars.push(e),e.incomingEdges.push(r),r}}else if(t instanceof XE&&e instanceof yT){if(!e.vars.includes(t)){const n=new mT(t,e,!1);return this._edges.push(n),e.vars.push(t),e.edges.push(t),t.undirectedEdges.push(n),n}}else{if(!(t instanceof yT&&e instanceof XE))throw new Error("An edge must connect a variable and an operator.");if(!t.vars.includes(e)){const n=new mT(e,t,!1);return this._edges.push(n),t.vars.push(e),t.edges.push(e),e.undirectedEdges.push(n),n}}}disconnectChannelVarFromBBoxOperator(t){let e=this.getOutgoingDataflowOperator($E.EVAL_BBOX,t),n=t.outgoingEdges.find(n=>n.fromNode===t&&n.toNode===e);n&&this.disconnect(t,e,n)}disconnect(t,e,n){if(t instanceof XE&&e instanceof qE){let r=t.outgoingEdges.findIndex(t=>t===n);r>=0&&(this._edges.splice(this._edges.indexOf(n),1),t.outgoingEdges.splice(r,1));let i=e.inputVars.findIndex(e=>e==t);i>=0&&e.inputVars.splice(i,1)}else if(t instanceof qE&&e instanceof XE){let r=e.incomingEdges.findIndex(t=>t===n);r>=0&&(this._edges.splice(this._edges.indexOf(n),1),e.incomingEdges.splice(r,1));let i=t.outputVars.findIndex(t=>t===e);i>=0&&t.outputVars.splice(i,1)}}deleteVariable(t){for(let e=t.incomingEdges.length-1;e>=0;e--){let n=t.incomingEdges[e],r=n.fromNode;this.disconnect(r,t,n),r.isIsolated()&&delete this._operators[r.type][r.id]}for(let e=t.outgoingEdges.length-1;e>=0;e--){let n=t.outgoingEdges[e],r=n.toNode;this.disconnect(t,r,n),r.isIsolated()&&delete this._operators[r.type][r.id]}delete this._variables[t.type][t.id]}deleteOperator(t){for(let e=t.outputVars.length-1;e>=0;e--){let n=t.outputVars[e],r=n.incomingEdges.find(e=>e.fromNode===t&&e.toNode===n);this.disconnect(t,n,r),n.isIsolated()&&delete this._variables[n.type][n.id]}for(let e=t.inputVars.length-1;e>=0;e--){let n=t.inputVars[e],r=n.outgoingEdges.find(e=>e.fromNode===n&&e.toNode===t);this.disconnect(n,t,r),n.isIsolated()&&delete this._variables[n.type][n.id]}delete this._operators[t.type][t.id]}addInteraction(t){}_dfs(t,e,n){if(t&&0!==t.outgoingEdges.length)for(let r of t.outgoingEdges)r.isDirected&&(e.push(r.toNode),this._dfs(r.toNode.outputVars[0],e.slice(),n));else n.push(e)}getOperatorsOnPath(t,e,n,...r){let i=this.findVariable(t,r);if(i){for(let t of i.outgoingEdges)if(t.isDirected){let r=t.toNode,i=e.indexOf(r);-1!==i&&e.splice(i,1),e.push(r);for(let t of r.outputVars)switch(t.type){case KE.ITEMS:this.getOperatorsOnPath(t.type,e,n,t.dataset);break;case KE.ATTRIBUTE:this.getOperatorsOnPath(t.type,e,n,t.attribute,t.dataset);break;case KE.DATASCOPE:case KE.BOUNDS:this.getOperatorsOnPath(t.type,e,n,t.element);break;case KE.CHANNEL:this.getOperatorsOnPath(t.type,e,n,t.channel,t.element);break;case KE.PROPERTY:this.getOperatorsOnPath(t.type,e,n,t.property,t.element);break;case KE.STATE:this.getOperatorsOnPath(t.type,e,n,t.key,t.stateContext);break;case KE.SCALE:case KE.ATTR_VALUE:this.getOperatorsOnPath(t.type,e,n,t.encodings[0]);break;case KE.CONDITION_RESULT:this.getOperatorsOnPath(t.type,e,n,t.conditionalEncoding)}}for(let t of i.undirectedEdges)n.push(t.operator)}else console.warn("Unable to find variables matching the described change: ",t,r)}findVariable(t,e){if(!(t in this._variables))return null;let n=Object.values(this._variables[t]);switch(t){case KE.CHANNEL:return n.find(t=>t.channel==e[0]&&UA(t.element)==UA(e[1]));case KE.PROPERTY:return n.find(t=>t.property==e[0]&&t.element==e[1]);case KE.STATE:return n.find(t=>t.key==e[0]&&t.stateContext==e[1]);case KE.AFFIXATION:return n.find(t=>t.affixation==e[0]);case KE.ATTRIBUTE:return e[2]?n.find(t=>t.attribute==e[0]&&t.dataset==e[1]&&t.encoding===e[2]):n.find(t=>t.attribute==e[0]&&t.dataset==e[1]&&!t.encoding);case KE.ITEMS:return n.find(t=>t.dataset==e[0]);case KE.ATTR_VALUE:case KE.SCALE:return n.find(t=>t.encodings.includes(e[0]));case KE.EVT_CTX:return n.find(t=>t.context===e[0]);case KE.CONDITION_RESULT:return n.find(t=>t.conditionalEncoding==e[0]);case KE.DATASCOPE:default:return e[0].classId?n.find(t=>UA(t.element)==UA(e[0])):n.find(t=>t.element.id==e[0].id)}}findVariablesByElement(t){let e={};for(let n in this._variables){let r=Object.values(this._variables[n]).filter(e=>e.element&&UA(e.element)==UA(t));r.length>0&&(e[n]=r)}return e}}class wM{constructor(t={}){this._attribute=t.attribute??null,this._numBins=t.numBins??null}get attribute(){return this._attribute}set attribute(t){this._attribute=t}get numBins(){return this._numBins}set numBins(t){this._numBins=t}get startAttr(){return this._attribute+"_bin_start"}get endAttr(){return this._attribute+"_bin_end"}get binIdAttr(){return this._attribute+"_bin_id"}}class EM{constructor(t={}){this._attribute=t.attribute??null,this._newAttribute=t.newAttribute??null,this._groupBy=t.groupBy??null,this._min=t.min??null,this._max=t.max??null,this._interval=t.interval??null,this._bandwidth=t.bandwidth??null}get attribute(){return this._attribute}set attribute(t){this._attribute=t}get newAttribute(){return this._newAttribute}set newAttribute(t){this._newAttribute=t}get groupBy(){return this._groupBy}set groupBy(t){this._groupBy=t}get min(){return this._min}set min(t){this._min=t}get max(){return this._max}set max(t){this._max=t}get interval(){return this._interval}set interval(t){this._interval=t}get bandwidth(){return this._bandwidth}set bandwidth(t){this._bandwidth=t}}class AM{constructor(t={}){this._attribute=t.attribute??null,this._type=t.type??null,this._value=t.value??null}get attribute(){return this._attribute}set attribute(t){this._attribute=t}get type(){return this._type}set type(t){this._type=t}get value(){return this._value}set value(t){this._value=t}}class SM{constructor(t,e){this._fn=t,e&&Object.assign(this,e)}get fn(){return this._fn}}class TM{constructor(t={}){this._idVars=t.idVars??null,this._valueVars=t.valueVars??null,this._varName=t.varName??"attribute",this._valueName=t.valueName??"value"}get idVars(){return this._idVars}set idVars(t){this._idVars=t}get valueVars(){return this._valueVars}set valueVars(t){this._valueVars=t}get varName(){return this._varName}set varName(t){this._varName=t}get valueName(){return this._valueName}set valueName(t){this._valueName=t}}class CM extends dS{constructor(t,e){super(e||{}),this._type=Pw.Trajectory,this._id=this._type+Dw(),this._collection=t,this._args=e||{},this._samplesPerStep="samplesPerStep"in this._args?this._args.samplesPerStep:12,this._extendPastLast="extendPastLast"in this._args?this._args.extendPastLast:0,"strokeColor"in this.styles||(this.styles.strokeColor="#bbb"),this._points=[]}get type(){return this._type}get id(){return this._id}get collection(){return this._collection}get samplesPerStep(){return this._samplesPerStep}set samplesPerStep(t){this._samplesPerStep=t}get extendPastLast(){return this._extendPastLast}set extendPastLast(t){this._extendPastLast=t}get points(){return this._points}updatePoints(){let t=this._collection?this._collection.layout:void 0,e=this._collection?this._collection.children.length:0;if(!t||0===e)return void(this._points=[]);let n=t.direction===aS.ANTI_CLOCKWISE?-1:1,r=e-1+this._extendPastLast;if(r<=0){let e=OE(t.x+t.startRadius,t.y,t.x,t.y,t.startAngle);return void(this._points=[e])}let i=Math.max(1,Math.round(r*this._samplesPerStep)),s=[];for(let e=0;e<=i;e++){let o=r*(e/i),a=t.startRadius+t.radiusStep*o,l=t.startAngle+n*t.angleStep*o;s.push(OE(t.x+a,t.y,t.x,t.y,l))}this._points=s}getSVGPathData(){if(0===this._points.length)return"";let t="M "+this._points[0].x+" "+this._points[0].y+" ";for(let e=1;e<this._points.length;e++)t+="L "+this._points[e].x+" "+this._points[e].y+" ";return t}_updateBounds(){if(0===this._points.length)return void(this._bounds=new PE(0,0,0,0));let t=this._points.map(t=>t.x),e=this._points.map(t=>t.y),n=Math.min(...t),r=Math.max(...t),i=Math.min(...e),s=Math.max(...e);this._bounds=new PE(n,i,r-n,s-i)}}class kM extends ZA{constructor(t){super(),this._itemMap={},this._type=Pw.Scene,this._id=t&&t.id?t.id:this._type+Dw(),t&&t.fillColor&&(this.fillColor=t.fillColor),this._encodings={},this._relations=[],this._triggers={},this._condEncodings={},this._stateContext=new ZE(this),this._stateContext.__scene__=this,this._depGraph=new xM,this._renderers=[]}get depGraph(){return this._depGraph}get interactionTriggers(){return this._triggers}getConditionalEncodings(t){return this._condEncodings[t]||[]}_clearInteractionCaches(){for(let t in this._condEncodings)for(let e of this._condEncodings[t])e.clearResponderPeers()}get state(){return this._stateContext}mark(t,e){if(Object.values(Iw).indexOf(t)<0)throw new Error("Mascot does not allow directly creating a "+t);let n=void 0===e?{}:e;n.type=t;let r=hT(this,n);return null!==r&&(r._classId=r.id,this.addChild(r),this._itemMap[r.id]=r,xA(r,this._depGraph),TA(this,r,this._depGraph)),r}glyph(...t){let e=[];for(let n of t)e.push([n.parent,n]);let n=hT(this,{type:Pw.Glyph,children:t});if(null!==n){n._classId=n.id;for(let t of e)SA(t[0],t[1],this._depGraph);CA(n,this._depGraph),TA(this,n,this._depGraph)}return n}composite(){let t=hT(this,{type:Pw.Composite});return null!==t&&(t._classId=t.id,this.addChild(t),this._itemMap[t.id]=t,AA(t,this._depGraph),TA(this,t,this._depGraph)),t}_addAttributeEncoding(t){let e=UA(t.element);e in this._encodings||(this._encodings[e]={}),this._encodings[e][t.channel]=t}get tables(){let t={},e=this.children.filter(t=>t.type===Pw.Collection);for(let n of e){let e=n.dataScope?Jw(n.dataScope):null;e&&!(e.id in t)&&(t[e.id]=e)}return t}onChange(t,...e){if(Object.values(KE).indexOf(t)<0)throw new Error("Unknown Variable Type: "+t);let n=[],r=[],i=[];this._depGraph.getOperatorsOnPath(t,n,r,...e);let s=!1;for(let t of n)t.run(),t.needsFullRender&&(s=!0),i=i.concat(t.outputVars.filter(t=>t.type===KE.CHANNEL||t.type===KE.PROPERTY));for(let t of r)t.run();const o={};for(let t of i){let e="vertex"===t.element.type||"segment"===t.element.type?t.element.parent:t.element;e.id in o||(o[e.id]=[]);let n=t.channel||t.property;o[e.id].includes(n)||o[e.id].push(n)}if(s){for(const t of this._renderers)t._render(this);for(const t of this._renderers)t._renderChanges(this,o)}else for(const t of this._renderers)t._renderChanges(this,o);return o}gridlines(t,e,n){let r=n||{},i="rowId"==e?_E:e,s=r.element?jA(r.element,t):FA(i,t,this);if(s){s.attribute!==i&&console.warn("Cannot create a "+t+" axis for "+e);let n=[];if("x"==t)for(let t of s.scales)n.push({scale:t,elems:s.getNormalizedElements(t)});else if("width"==t){let t=lA(s.element),e=s.scales[0];if(t.layout&&t.layout.type==HE.GRID&&t.layout.numCols>1){let r=t.layout.getElementsByCol(!0);for(let t of r)n.push({scale:e,elems:t})}else n.push({scale:s.scales[0],elems:s.getNormalizedElements(s.scales[0])})}else if("y"==t){let t=lA(s.element);if(t.layout&&t.layout.type==HE.GRID&&t.layout.numRows>1){let e=t.layout.getElementsByRow(!0,s.element);for(let t of e)n.push({scale:s.getScale(t[0]),elems:t})}else n.push({scale:s.scales[0],elems:s.getNormalizedElements(s.scales[0])})}else if("height"==t){let t=lA(s.element),e=s.scales[0];if(t.layout&&t.layout.type==HE.GRID&&t.layout.numRows>1){let r=t.layout.getElementsByRow(!0,s.element);for(let t of r)n.push({scale:e,elems:t})}else n.push({scale:e,elems:s.getNormalizedElements(e)})}else if("polarRadius"==t||"polarAngle"==t){let t=r.element?r.element:s.element;!("origin"in r)&&s.origin&&(r.origin=s.origin),n.push({scale:s.scales[0],elems:JE(t,t.parent)})}for(let t of n){let e=new XS(s.channel,s.attribute,t.scale,t.elems,r);this.addChild(e),this._itemMap[e.id]=e,s.addRefElement(e),DA(e,this._depGraph),TA(this,e,this._depGraph)}}else{let n=r.element?r.element:iA(this,e);if(!n)return void console.warn("Cannot create "+t+" gridlines for "+e);let i=sA(n.parent);if(!i.layout)return void console.warn("Cannot create "+t+" gridlines for "+e);let s=JE(i);for(let n of s){let i=[];n.layout.type==HE.GRID&&n.layout.numRows>1&&"x"==t?i=n.layout.getElementsByRow():n.layout.type==HE.GRID&&n.layout.numCols>1&&"y"==t?i=n.layout.getElementsByCol():i.push(n.children);for(let s of i){let i=new XS(t,e,null,s,r);this.addChild(i),this._itemMap[i.id]=i,n.layout.addRefElement(i),DA(i,this._depGraph),TA(this,i,this._depGraph)}}}}trajectory(t,e){let n=e||{},r=sA(t);if(!r||!r.layout||r.layout.type!==HE.SPIRAL)return void console.warn("Cannot create a trajectory: element is not inside a collection with a spiral layout");let i=new CM(r,n);return this.addChild(i),this._itemMap[i.id]=i,r.layout.addRefElement(i),function(t,e){let n=e.getVariable(KE.BOUNDS,lA(t.collection)),r=e.getVariable(KE.PROPERTY,gA.TRAJECTORY_POSITION,t),i=e.createOneWayDependency($E.SPIRAL_TRAJECTORY_PLACER);e.connect(n,i),e.connect(i,r),i.run();let s=e.getVariable(KE.BOUNDS,t),o=e.getIncomingDataflowOperator($E.EVAL_BBOX,s);e.connect(r,o),e.connect(o,s)}(i,this._depGraph),TA(this,i,this._depGraph),BE(i),this.onChange(KE.PROPERTY,gA.TRAJECTORY_POSITION,i),i}axis(t,e,n){let r=n||{},i="rowId"==e?_E:e,s=[],o=r.element?jA(r.element,t):FA(i,t,this);if(o){o.attribute!==i&&console.warn("Cannot create a "+t+" axis for "+i);let e=[];if("x"==t||"width"==t){let t=lA(r.element?r.element:o.element);if(t.layout&&t.layout.type==HE.GRID&&t.layout.numCols>1){let n=t.layout.getElementsByCell(!0,o.element);for(let t of n)e.push({scale:o.getScale(t[0]),elems:t})}else e.push({scale:o.scales[0],elems:o.getNormalizedElements(o.scales[0])})}else if("y"==t||"height"==t){let t=lA(r.element?r.element:o.element);if(t.layout&&t.layout.type==HE.GRID&&t.layout.numRows>1){let n=t.layout.getElementsByCell(!0,o.element);for(let t of n)e.push({scale:o.getScale(t[0]),elems:t})}else e.push({scale:o.scales[0],elems:o.getNormalizedElements(o.scales[0])})}else if("polarRadius"==t||"polarAngle"==t){let t=r.element?r.element:o.element;!("origin"in r)&&o.origin&&(r.origin=o.origin),e.push({scale:o.scales[0],elems:JE(t,t.parent)})}for(let t of e){let e=Object.assign({},r);e.scale=t.scale,e.elems=t.elems,e.type="axis",e.axisType="encoding",e.enc=o,e.rawArgs=r;let n=hT(this,e);s.push(n),o.addRefElement(n),LA(n,this._depGraph),TA(this,n,this._depGraph),this.onChange(KE.PROPERTY,gA.AXIS_PATH_POSITION,n)}}else{let e=r.element?r.element:iA(this,i);if(!e)return void console.warn("Cannot create a "+t+" axis for "+i);let n=sA(e.parent);if(!n.layout)return void console.warn("Cannot create a "+t+" axis for "+i);let o=JE(n);for(let e of o){let n=[];e.layout.type==HE.GRID&&e.layout.numRows>1&&"x"==t?n=e.layout.getElementsByRow():e.layout.type==HE.GRID&&e.layout.numCols>1&&"y"==t?n=e.layout.getElementsByCol():n.push(e.children);for(let o of n){let n=Object.assign({},r);n.elems=o.slice(),n.type="axis",n.axisType="layout",n.channel=t,n.attribute=i;let a=hT(this,n);s.push(a),e.layout.addRefElement(a),PA(a,this._depGraph),TA(this,a,this._depGraph),this.onChange(KE.PROPERTY,gA.AXIS_PATH_POSITION,a)}}}return s.length>1?s:s[0]}legend(t,e,n){let r=n||{},i="rowId"==e?_E:e,s=r.element?jA(r.element,t):FA(i,t,this);if(s){s.attribute!==e&&console.warn("Cannot create a "+t+" legend for "+e);let n=pE(s.element).type(e);r.type="legend",r.enc=s,r.attrType=n;let i=hT(this,r);!function(t,e){let n=e.getVariable(KE.BOUNDS,t),r=e.getVariable(KE.PROPERTY,gA.LEGEND_POSITION,t),i=e.getIncomingDataflowOperator($E.EVAL_BBOX,n);e.connect(r,i),e.connect(i,n)}(i,this._depGraph),TA(this,i,this._depGraph),BE(i),this.onChange(KE.PROPERTY,gA.LEGEND_POSITION,i)}else console.warn("Cannot create a "+t+" legend for "+i)}mask(t){let e=lA(t),n=e||t;n.clipMask||n.createClipMask()}setLayout(t,e){if(t.layout&&(RA(t,t.layout,this._depGraph),e.type===HE.TREEMAP)){let e=t.firstChild;for(;e&&e.type===Pw.Collection&&e.layout;)RA(e,e.layout,this._depGraph),e=e.firstChild}if(JE(t).forEach(t=>{let n=e?e.clone():e;t._layout=n,n&&(n.group=t)}),MA(t,e,this._depGraph),t.children&&t.children.length>0){let e=cA(t,!0);for(let t of e)this.onChange(KE.CHANNEL,"x",t)}}derive(t,e){let n=t.clone();return e._scene=this,e instanceof wM?(!function(t,e,n,r){let i=r.getVariable(KE.ITEMS,e),s=r.getVariable(KE.ITEMS,n),o=r.createOneWayDependency($E.BIN_TRANSFORMER);r.connect(i,o),r.connect(o,s);let a=r.getVariable(KE.PROPERTY,gA.NUM_BINS,t);r.connect(a,o),o._binConfig=t,o.run()}(e,t,n,this._depGraph),n._binTransform=e):e instanceof EM?function(t,e,n,r){let i=r.getVariable(KE.ATTRIBUTE,t.attribute,e),s=r.getVariable(KE.ATTRIBUTE,t.newAttribute,n),o=r.getVariable(KE.ITEMS,n),a=r.createOneWayDependency($E.KDE_TRANSFORMER);a.args=t,r.connect(i,a),r.connect(a,s),r.connect(a,o),a.run()}(e,t,n,this._depGraph):e instanceof AM?function(t,e,n,r){let i=r.getVariable(KE.ITEMS,e),s=r.getVariable(KE.ITEMS,n),o=r.createOneWayDependency($E.FILTER_TRANSFORMER);o._spec=t,r.connect(i,o),r.connect(o,s);let a=r.getVariable(KE.PROPERTY,"value",t);r.connect(a,o),o.run()}(e,t,n,this._depGraph):e instanceof SM?function(t,e,n,r){let i=r.getVariable(KE.ITEMS,e),s=r.getVariable(KE.ITEMS,n),o=r.createOneWayDependency($E.CUSTOM_TRANSFORMER);o._spec=t,r.connect(i,o),r.connect(o,s);for(let e of Object.keys(t)){if(e.startsWith("_"))continue;let n=r.getVariable(KE.PROPERTY,e,t);r.connect(n,o)}o.run()}(e,t,n,this._depGraph):e instanceof TM&&function(t,e,n,r){let i=r.getVariable(KE.ITEMS,e),s=r.getVariable(KE.ITEMS,n),o=r.createOneWayDependency($E.UNPIVOT_TRANSFORMER);o._spec=t,r.connect(i,o),r.connect(o,s);let a=r.getVariable(KE.PROPERTY,"valueVars",t);r.connect(a,o);let l=r.getVariable(KE.PROPERTY,"idVars",t);r.connect(l,o),o.run()}(e,t,n,this._depGraph),n}getElement(t){return this._itemMap[t]}getAxis(t,e){return FA(t,e,this).refElements[0]}}function RM(t,e){return Xw(e[t.dt],t.attr2value||t.filters||{},t.rowIds)}class MM extends UE{constructor(t){super(),this.type=HE.CLUSTER,this._isRadial="radial"in t&&t.radial,this._angleExtent="angleExtent"in t?t.angleExtent:360,this._radius="radius"in t?t.radius:300,this._rootX="x"in t?t.x:300,this._rootY="y"in t?t.y:300,this._orientation="orientation"in t?t.orientation:nS,this._width="width"in t?t.width:800,this._height="height"in t?t.height:600,this._left="left"in t?t.left:60,this._top="top"in t?t.top:100,this._tree="tree"in t?t.tree:void 0}get radius(){return this._radius}get angleExtent(){return this._angleExtent}get x(){return this._rootX}get y(){return this._rootY}get width(){return this._width}get height(){return this._height}get left(){return this._left}get top(){return this._top}isRadial(){return this._isRadial}get orientation(){return this._orientation}clone(){return new MM({radius:this._radius,angleExtent:this._angleExtent,x:this._rootX,y:this._rootY,radial:this._isRadial,orientation:this._orientation,left:this._left,top:this._top,width:this._width,height:this._height,tree:this._tree})}}class OM extends UE{constructor(t){super(),this.type=HE.DIRECTED,this._top="top"in t?t.top:0,this._left="left"in t?t.left:0,this._nodeSep="nodeSep"in t?t.nodeSep:100,this._edgeSep="edgeSep"in t?t.edgeSep:50,this._rankSep="rankSep"in t?t.rankSep:50,this._spreadLinks=!("spreadLinks"in t)||t.spreadLinks,this._direction="direction"in t?t.direction:oS.Top2Bottom}clone(){return new OM({top:this._top,left:this._left,nodeSep:this._nodeSep,edgeSep:this._edgeSep,rankSep:this._rankSep,spreadLinks:this._spreadLinks,direction:this._direction})}get top(){return this._top}get left(){return this._left}get nodeSep(){return this._nodeSep}get edgeSep(){return this._edgeSep}get rankSep(){return this._rankSep}get spreadLinks(){return this._spreadLinks}get direction(){return this._direction}}class NM extends UE{constructor(t){super(),this.type=HE.FORCE,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._iterations="iterations"in t?t.iterations:1,this._repulsion="repulsion"in t?t.repulsion:30,this._attraction="attraction"in t?t.attraction:1,this._linkDistance="linkDistance"in t?t.linkDistance:30}clone(){return new NM({x:this._x,y:this._y,iterations:this._iterations,repulsion:this._repulsion,attraction:this._attraction,linkDistance:this._linkDistance})}}class IM extends UE{constructor(t){super(),this.type=HE.PACKING,this._x="x"in t?t.x:400,this._y="y"in t?t.y:400,this._width=t.width,this._height=t.height}clone(){return new IM({x:this._x,y:this._y,width:this._width,height:this._height})}}class PM extends UE{constructor(t){super(),this.type=HE.STACK,this._orientation=t.orientation,this._direction=t.direction,this._left=t.left,this._top=t.top,this._horzCellAlignment="horzCellAlignment"in t&&t.horzCellAlignment?t.horzCellAlignment:zE.LEFT,this._vertCellAlignment="vertCellAlignment"in t&&t.vertCellAlignment?t.vertCellAlignment:zE.BOTTOM,this._gap="gap"in t?t.gap:0}clone(){let t=new PM({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return t._horzCellAlignment=this._horzCellAlignment,t._vertCellAlignment=this._vertCellAlignment,t}get horzCellAlignment(){return this._horzCellAlignment}get vertCellAlignment(){return this._vertCellAlignment}get orientation(){return this._orientation}set horzCellAlignment(t){this._horzCellAlignment=t}set vertCellAlignment(t){this._vertCellAlignment=t}set orientation(t){this._orientation=t}}class LM extends UE{constructor(t){super(),this.type=HE.STRATA,this._direction=t.direction,this._gap="gap"in t?t.gap:0}clone(){return new LM({direction:this._direction,gap:this._gap})}}class DM extends UE{constructor(t){super(),this.type=HE.TIDYTREE,this._width="width"in t?t.width:500,this._height="height"in t?t.height:500,this._left="left"in t?t.left:100,this._top="top"in t?t.top:100,this._orientation="orientation"in t?t.orientation:nS}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}get orientation(){return this._orientation}clone(){return new DM({width:this._width,height:this._height,top:this._top,left:this._left,orientation:this._orientation})}}class VM extends UE{constructor(t){super(),this.type=HE.TREEMAP,this._width=t.width,this._height=t.height,this._left=t.left,this._top=t.top}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}clone(){return new VM({width:this._width,height:this._height,top:this._top,left:this._left})}}class BM extends UE{constructor(t){super(),t=t||{},this.type=HE.SPIRAL,this._x="x"in t?t.x:100,this._y="y"in t?t.y:100,this._startRadius="startRadius"in t?t.startRadius:0,this._radiusStep="radiusStep"in t?t.radiusStep:8,this._startAngle="startAngle"in t?t.startAngle:90,this._angleStep="angleStep"in t?t.angleStep:40,this._direction="direction"in t?t.direction:aS.CLOCKWISE,this._markRotation="markRotation"in t?t.markRotation:this._direction===aS.CLOCKWISE?cS.TANGENTIAL_CLOCKWISE:cS.TANGENTIAL_COUNTERCLOCKWISE}get x(){return this._x}get y(){return this._y}get startRadius(){return this._startRadius}set startRadius(t){this._startRadius=t}get radiusStep(){return this._radiusStep}set radiusStep(t){this._radiusStep=t}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=t}get angleStep(){return this._angleStep}set angleStep(t){this._angleStep=t}get direction(){return this._direction}set direction(t){this._direction=t}get markRotation(){return this._markRotation}set markRotation(t){this._markRotation=t}clone(){return new BM({x:this._x,y:this._y,startRadius:this._startRadius,radiusStep:this._radiusStep,startAngle:this._startAngle,angleStep:this._angleStep,direction:this._direction,markRotation:this._markRotation})}}class zM extends UE{constructor(t){super(),this.type=HE.CIRCULAR,this._x="x"in t?t.x:100,this._y="y"in t?t.y:100,this._radius="radius"in t?t.radius:100,this._markRotation="markRotation"in t?t.markRotation:cS.INWARD}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}get markRotation(){return this._markRotation}set markRotation(t){this._markRotation=t}clone(){return new zM({x:this._x,y:this._y,radius:this._radius,markRotation:this._markRotation})}}class GM extends UE{constructor(t={}){if(super(),this.type=HE.CUSTOM,"function"!=typeof t.compute)throw new Error("CustomLayout requires a compute(children, layout) => {[id]: {x, y}} function");this._compute=t.compute,this._params="params"in t?t.params:{}}get compute(){return this._compute}set compute(t){if("function"!=typeof t)throw new Error("CustomLayout.compute must be a function");this._compute=t}get params(){return this._params}set params(t){this._params=t}clone(){return new GM({compute:this._compute,params:this._params})}}function FM(t){switch(t.type){case HE.GRID:return function(t){let e=new sT(t.args);"left"in t&&(e._left=t.left);"top"in t&&(e._top=t.top);"cellBounds"in t&&(e._cellBounds=t.cellBounds.map(t=>jM(t)));"grid"in t&&(e._grid=t.grid);return e}(t);case HE.STACK:return function(t){let e=new PM(t.args);return e}(t);case HE.PACKING:return function(t){let e=new IM(t.args);return e}(t);case HE.FORCE:return function(t){return new NM(t.args)}(t);case HE.DIRECTED:return function(t){return new OM(t.args)}(t);case HE.TIDYTREE:return function(t){return new DM(t.args)}(t);case HE.TREEMAP:return function(t){return new VM(t.args)}(t);case HE.STRATA:return function(t){return new LM(t.args)}(t);case HE.SPIRAL:return function(t){return new BM(t.args)}(t);case HE.CIRCULAR:return function(t){return new zM(t.args)}(t);case HE.CLUSTER:return function(t){let e=Object.assign({},t.args);!("x"in e)&&"rootX"in e&&(e.x=e.rootX);!("y"in e)&&"rootY"in e&&(e.y=e.rootY);e.tree&&(e.tree=new gE(e.tree.data,e.tree.url));return new MM(e)}(t);case HE.CUSTOM:return function(t){return console.warn("CustomLayout.compute cannot be restored from serialized data; set layout.compute manually after deserialization."),new GM({compute:()=>null,params:t.args?t.args.params:{}})}(t);default:return void console.warn("unsupported layout type for deserialization:",t.type)}}function jM(t){return new PE(t.x-t.width/2,t.y-t.height/2,t.width,t.height)}function UM(t,e,n){t.type===Pw.Pie&&(t.type=Pw.Arc),t.args.type=t.type;let r=hT(e,t.args);return t.id&&(r._id=t.id),t.classId&&(r._classId=t.classId),t.dataScope&&(r.dataScope=RM(t.dataScope,n)),t.bounds&&(r._bounds=jM(t.bounds)),t.refBounds&&(r._refBounds=jM(t.refBounds)),function(t,e,n,r){if(t.vertices){const n=[];for(let e of t.vertices){const t=YM(e,r);n.push(t)}e.vertices=n}e.vertexCounter=t.vertexCounter,e.segmentCounter=t.segmentCounter,e.curveMode=t.curveMode}(t,r,0,n),r}function YM(t,e){let n={type:"vertex",id:t.id,x:t.x,y:t.y,shape:t.shape,width:t.width,height:t.height,radius:t.radius,fillColor:t.fillColor,opacity:t.opacity,strokeWidth:t.strokeWidth,strokeColor:t.strokeColor};return t.dataScope&&(n.dataScope=RM(t.dataScope,e)),"polarAngle"in t&&(n.polarAngle=t.polarAngle),n}function HM(t){let e={};e.fillColor=t.fillColor;let n=new kM(e);console.log("======== deserialization =========");let r={};if(t.tables)for(let e in t.tables){let n=t.tables[e];r[e]=new fE(n.data,n.url,n.attributeTypes),r[e]._id=n.id}let i={};if(t.scales)for(let e in t.scales)i[e]=KM(t.scales[e]);n.scales=i,n._pendingLayouts=[],$M(t,n,n,r),qM(t,n);for(let{group:t,layout:e}of n._pendingLayouts)MA(t,e,n._depGraph);for(let{group:t}of n._pendingLayouts){let e=t.children[0];e&&e.links&&n.onChange(KE.CHANNEL,"x",e)}if(delete n._pendingLayouts,t.encodings){let e={};for(let i of t.encodings){let t=ZM(i,n,r);e[t.id]=t}for(let t in e){n._addAttributeEncoding(e[t]);let r=e[t]._baseEnc?e[e[t]._baseEnc]:void 0;IA(e[t],n._depGraph,r),r?n.onChange(KE.ATTR_VALUE,e[t]):n.onChange(KE.CHANNEL,e[t].channel,e[t].element)}}if(t.axes)for(let e of t.axes){let t=e.args?e.args:{};t.tickValues&&Object.values(r)[0].type(e.attr)===Vw.Date&&(t.tickValues=t.tickValues.map(t=>new Date(new Date(t).toISOString()))),e.id&&(t.id=e.id),XM(t,n),n.axis(e.channel,e.attr,t)}if(t.gridlines)for(let e of t.gridlines){let t=e.args?e.args:{};XM(t,n),n.gridlines(e.channel,e.attr,t)}if(t.legends)for(let e of t.legends)n.legend(e.channel,e.attr,e.args);if(t.trajectories)for(let e of t.trajectories){let t=n._itemMap[e.collectionId];t&&n.trajectory(t,e.args)}return t.bounds&&(n._bounds=jM(t.bounds)),delete n.scales,n}function WM(t,e,n,r){if(t.type===Pw.Collection){let i=hT(n,{type:Pw.Collection,id:t.id});t.classId&&(i._classId=t.classId),e.addChild(i),EA(i,n._depGraph),TA(e,i,n._depGraph),$M(t,i,n,r)}else if(t.type===Pw.Glyph){let i=hT(n,{type:Pw.Glyph,id:t.id});t.classId&&(i._classId=t.classId),e.addChild(i),CA(i,n._depGraph),TA(e,i,n._depGraph),$M(t,i,n,r)}else if(t.type===Pw.Composite){let i=hT(n,{type:Pw.Composite,id:t.id});e.addChild(i),n._itemMap[i.id]=i,AA(i,n._depGraph),TA(e,i,n._depGraph),$M(t,i,n,r),i._bounds=jM(t.bounds)}else if(t.type===Pw.Axis){let i=new zS({});e.addChild(i),function(t,e,n,r){t.id&&(e._id=t.id);if(e._children=[],t.labels){let i=new ZA;$M(t.labels,i,n,r),e._labels=i,e._children.push(i)}t.path&&(e._path=WM(t.path,e,n,r));if(t.ticks){let i=new ZA;$M(t.ticks,i,n,r),e._ticks=i,e._children.push(i)}t.title&&(e._title=WM(t.title,e,n,r))}(t,i,n,r),n._itemMap[i.id]=i}else if(Object.values(jE).includes(t.type)){let i=UM(t,n,r);return n._itemMap[i.id]=i,e.addChild(i),xA(i,n._depGraph),TA(e,i,n._depGraph),i}}function qM(t,e,n){if(t.children)for(let n of t.children)qM(n,e);else if(Object.values(jE).includes(t.type)){let n=e._itemMap[t.id];t.links&&(n.links=t.links.map(t=>e._itemMap[t])),t.source&&(n.source=e._itemMap[t.source]),t.target&&(n.target=e._itemMap[t.target])}}function $M(t,e,n,r){if(t.id&&(e._id=t.id),t.classId&&(e._classId=t.classId),t.dataScope&&(e.dataScope=RM(t.dataScope,r)),t.bounds&&(e._bounds=jM(t.bounds)),e._sortBy=t.sortBy,t.children)for(let i of t.children)WM(i,e,n,r);if(t.layout){let r=FM(t.layout);r&&(e._layout=r,r.group=e,n._pendingLayouts?n._pendingLayouts.push({group:e,layout:r}):MA(e,r,n._depGraph))}}function XM(t,e){if("string"!=typeof t.element)return;let n=t.element,r=n.includes("_v_")?"vertex":n.includes("_s_")?"segment":void 0,i=r?n.split("vertex"===r?"_v_":"_s_")[0]:n,s=e._itemMap[i]?QM(n,r,e):void 0;s||console.warn("element not created:",n),t.element=s}function KM(t){let e=new HS(t.type,t.args);return e._id=t.id,e.domain=t.domain,e.range=t.range,e}function ZM(t,e,n){let r=QM(t.element,t.elementType,e);r||console.warn("element not created:",t.element,t.elementType);let i=t.args?t.args:{};t.table&&(i.table=n[t.table]);let s=new KS(r,t.channel,t.attr,t.aggregator?t.aggregator:"sum",i);if(s._id=t.id,t.scales&&(s._scales=t.scales.map(t=>e.scales[t])),i.baseEnc&&(s._baseEnc=t.args.baseEnc),t.elemGroups&&(s._elemGroups=t.elemGroups.map(n=>"vertex"===t.elementType?{type:"vertexIndices",groups:JM(n,e)}:n.map(t=>QM(t,r.type,e)))),t.elem2scale){s._elem2scale={};for(let n in t.elem2scale)s._elem2scale[n]=e.scales[t.elem2scale[n]]}return i.startAngle&&(s.startAngle=i.startAngle),s}function JM(t,e){let n=[],r=new Map;for(let i of t){let t=QM(i,"vertex",e);if(!t){console.warn("vertex not created:",i);continue}let s=r.get(t.parent);s||(s={parent:t.parent,indices:[]},r.set(t.parent,s),n.push(s)),s.indices.push(t._index)}return n}function QM(t,e,n){if("vertex"===e){let e=t.split("_v_");return n._itemMap[e[0]].vertices.find(e=>e.id===t)}if("segment"===e){let e=t.split("_s_");return n._itemMap[e[0]].segments.find(t=>t._id===parseInt(e[1]))}return n._itemMap[t]}function tO(t){let e={};return e.id=t._id,e.data=t._rawData,e.attributeTypes=t._attrTypes,e.url=t.url,e}function eO(t){let e={};return e.dt=t.dataTable.id,e.attr2value=Object.assign({},t.filters),t.rowIds&&(e.rowIds=t.rowIds.slice()),e}function nO(t){switch(t.type){case HE.GRID:return function(t){let e={args:{}};return e.type=t.type,e.args.numCols=t._numCols,e.args.numRows=t._numRows,e.args.start=t._start,e.args.direction=t._direction,e.args.colGap=t._colGap,e.args.rowGap=t._rowGap,e.args.horzCellAlignment=t._cellHorzAlignment,e.args.vertCellAlignment=t._cellVertAlignment,e.args.rowOffset=t._rowOffset,e.args.colOffset=t._colOffset,e.left=t._left,e.top=t._top,e.group=t.group.id,e}(t);case HE.STACK:return function(t){let e={args:{}};return e.type=t.type,e.args.orientation=t._orientation,e.args.direction=t._direction,e.args.left=t._left,e.args.top=t._top,e.args.horzCellAlignment=t._horzCellAlignment,e.args.vertCellAlignment=t._vertCellAlignment,e.args.gap=t._gap,e.group=t.group.id,e}(t);case HE.PACKING:return function(t){let e={args:{}};return e.type=t.type,e.args.x=t._x,e.args.y=t._y,e.args.width=t._width,e.args.height=t._height,e.group=t.group.id,e}(t);case HE.FORCE:return function(t){let e={args:{}};return e.type=t.type,e.args.x=t._x,e.args.y=t._y,e.args.iterations=t._iterations,e.args.repulsion=t._repulsion,e.args.attraction=t._attraction,e.args.linkDistance=t._linkDistance,e.group=t.group.id,e}(t);case HE.CLUSTER:return function(t){let e={args:{}};e.type=t.type,e.args.radial=t._isRadial,e.args.angleExtent=t._angleExtent,e.args.radius=t._radius,e.args.x=t._rootX,e.args.y=t._rootY,e.args.orientation=t._orientation,e.args.width=t._width,e.args.height=t._height,e.args.left=t._left,e.args.top=t._top,t._tree&&(e.args.tree={data:t._tree._data,url:t._tree.url});return e}(t);case HE.DIRECTED:return function(t){let e={args:{}};return e.type=t.type,e.args.left=t._left,e.args.top=t._top,e.args.width=t._width,e.args.height=t._height,e.args.edgeSep=t._edgeSep,e.args.spreadLinks=t._spreadLinks,e.args.direction=t._direction,e}(t);case HE.TIDYTREE:return function(t){let e={args:{}};return e.type=t.type,e.args.left=t._left,e.args.top=t._top,e.args.width=t._width,e.args.height=t._height,e.args.orientation=t._orientation,e}(t);case HE.TREEMAP:return function(t){let e={args:{}};return e.type=t.type,e.args.left=t._left,e.args.top=t._top,e.args.width=t._width,e.args.height=t._height,e}(t);case HE.STRATA:return function(t){let e={args:{}};return e.type=t.type,e.args.direction=t._direction,e.args.gap=t._gap,e}(t);case HE.SPIRAL:return function(t){let e={args:{}};return e.type=t.type,e.args.x=t._x,e.args.y=t._y,e.args.startRadius=t._startRadius,e.args.radiusStep=t._radiusStep,e.args.startAngle=t._startAngle,e.args.angleStep=t._angleStep,e.args.direction=t._direction,e.args.markRotation=t._markRotation,e.group=t.group.id,e}(t);case HE.CIRCULAR:return function(t){let e={args:{}};return e.type=t.type,e.args.x=t._x,e.args.y=t._y,e.args.radius=t._radius,e.args.markRotation=t._markRotation,e.group=t.group.id,e}(t);case HE.CUSTOM:return function(t){console.warn("CustomLayout's compute function cannot be serialized; only params will be saved. Reattach compute() after deserializing.");let e={args:{}};return e.type=t.type,e.args.params=t.params,e.group=t.group.id,e}(t);default:throw new Error("unknow layout type "+t.type)}}function rO(t,e){e.vertices=[];for(let n=0;n<t._vertices.length;n++)e.vertices.push(iO(t._vertices,n));e.vertexCounter=t.vertexCounter,e.segmentCounter=t.segmentCounter,e.curveMode=t.curveMode}function iO(t,e){let n={type:"vertex"};return n.id=t._ids[e],n.x=t._xs[e],n.y=t._ys[e],t.hasDataScope(e)&&(n.dataScope=eO(t.getDataScopeRef(e))),void 0!==t._polarAngles[e]&&(n.polarAngle=t._polarAngles[e]),n.shape=t._shapes[e],n.width=t._widths[e],n.height=t._heights[e],n.radius=t._radii[e],n.fillColor=t._fillColors[e],n.opacity=t._opacities[e],n.strokeWidth=t._strokeWidths[e],n.strokeColor=t._strokeColors[e],n}function sO(t){return t.type===Pw.Scene?function(t){let e=lO(t,{});e.fillColor=t.fillColor,e.scales={},e.encodings=[];for(let n in t._encodings)for(let r in t._encodings[n]){let i=t._encodings[n][r];i._forLegend||e.encodings.push(aO(i));for(let t of i._scales)t.id in e.scales||(e.scales[t.id]=oO(t))}e.tables={};let n=function(t){let e={};for(let n in t._encodings)for(let r in t._encodings[n]){let i=t._encodings[n][r];i.dataTable.id in e||i._forLegend||(e[i.dataTable.id]=i.dataTable)}for(let n of t.children)if(![Pw.Axis,Pw.Legend,Pw.Gridlines].includes(n.type)){if(n.dataScope){let t=Jw(n.dataScope);e[t.id]=t;break}if(n.children&&n.children.length>0){let t=n.firstChild;for(;t;){if(t.dataScope){let n=Jw(t.dataScope);e[n.id]=n;break}t=t.children&&t.children.length>0?t.firstChild:void 0}}}return e}(t);for(let t in n)e.tables[t]=tO(n[t]);return console.log("======== serialization ========="),console.log(e),e}(t):[Pw.Collection,Pw.Glyph,Pw.Composite].includes(t.type)?lO(t,{}):t instanceof zS?cO(t,{}):t instanceof GE?function(t){let e={args:{}};e.type=t.type,e.id=t.id,t.classId&&(e.classId=t.classId),t.dataScope&&(e.dataScope=eO(t.dataScope)),t.bounds&&(e.bounds=t.bounds.toJSON()),t.refBounds&&(e.refBounds=t.refBounds.toJSON()),t.links&&(e.links=t.links.map(t=>t.id)),t.source&&(e.source=t.source.id),t.target&&(e.target=t.target.id);for(let n in t.styles)n.indexOf("Color")>0&&t.styles[n]instanceof VS?e.args[n]=t.styles[n].toJSON():e.args[n]=t.styles[n];switch(void 0!==t.strength&&(e.args.strength=t.strength),t.type){case Pw.Arc:case Pw.Pie:!function(t,e){e.args.x=t._x,e.args.y=t._y,e.args.innerRadius=t._innerRadius,e.args.outerRadius=t._outerRadius,e.args.startAngle=t._startAngle,e.args.endAngle=t._endAngle,e.args.direction=t._direction,e.args.thickness=t._thickness}(t,e),rO(t,e);break;case Pw.Area:!function(t,e){e.args.baseline=t._baseline,e.args.orientation=t._orientation}(t,e),rO(t,e);break;case Pw.Circle:!function(t,e){e.args.x=t.x,e.args.y=t.y,e.args.radius=t.radius}(t,e);break;case Pw.Image:break;case Pw.Symbol:!function(t,e){e.args.x=t.x,e.args.y=t.y,e.args.width=t.width,e.args.height=t.height,e.args.path=t.path,e.args.viewBox=t.viewBox}(t,e);break;case Pw.Line:case Pw.Path:case Pw.BezierCurve:rO(t,e);break;case Pw.SimpleText:!function(t,e){e.args.x=t._x,e.args.y=t._y,e.args.text=t._text,e.args.anchor=t._anchor,t._backgroundColor&&(e.args.backgroundColor=t._backgroundColor),t._borderWidth&&(e.args.borderWidth=t._borderWidth),t._borderColor&&(e.args.borderColor=t._borderColor)}(t,e);break;case Pw.Polygon:!function(t,e){e.args.x=t._x,e.args.y=t._y,e.args.radius=t._radius}(t,e),rO(t,e);break;case Pw.Rect:!function(t,e){e.args.width=t.width,e.args.height=t.height,e.args.top=t.top,e.args.left=t.left}(t,e),rO(t,e);case Pw.Ring:}return e}(t):(console.warn("unsupported serialization",t.type),{type:t.type})}function oO(t){let e={};return e.type=t.type,e.id=t.id,t._args&&(e.args=t._args),e.domain=t.domain,e.range=t.range,e}function aO(t){let e={};e.id=t._id,e.element=t._elem.id,e.elementType=t._elem.type,e.channel=t._channel,e.attr=t._attribute,e.aggregator=t._aggregator,e.table=t._table.id,e.args={},e.args.includeZero=t._includeZero,e.args.flipScale=t._flipScale,e.args.mapping=t._mapping,e.args.rangeExtent=t._preferredRangeExtent,e.args.domain=t._preferredDomain,e.args.scaleType=t._scaleType,e.args.scheme=t._colorScheme,t._baseEnc&&(e.args.baseEnc=t._baseEnc.id),e.scales=t._scales.map(t=>t.id),e.elemGroups=t._elemGroups.map(t=>"vertexIndices"===t.type?t.groups.flatMap(({parent:t,indices:e})=>e.map(e=>tA(t,e))):t.map(t=>t.id)),e.elem2scale={};for(let n in t._elem2scale)e.elem2scale[n]=t._elem2scale[n].id;return"angle"==t.channel&&(e.args.startAngle=t.startAngle),e}function lO(t,e){if(e.id=t.id,e.type=t.type,t.classId&&(e.classId=t.classId),t.dataScope&&(e.dataScope=eO(t.dataScope)),e.bounds=t.bounds.toJSON(),t._layout&&(e.layout=nO(t._layout)),e.children=[],t.children.length>0)for(let n of t.children)n instanceof zS?cO(n,e):n instanceof XS?uO(n,e):n instanceof CM?fO(n,e):n instanceof oT?hO(n,e):e.children.push(sO(n));return e.sortBy=t._sortBy,e}function cO(t,e){e.axes??=[];let n={};n.type=t._type,n.id=t._id,n.attr=t._attribute,n.channel=t._channel,n.args={},n.args.orientation=t._orientation,n.args.strokeColor=t._strokeColor,n.args.textColor=t._textColor,n.args.fontSize=t._fontSize,n.args.tickOffset=t._tickOffset,n.args.tickSize=t._tickSize,n.args.tickAnchor=t._tickAnchor,n.args.tickVisible=t._tickVisible,n.args.pathVisible=t._pathVisible,n.args.labelOffset=t._labelOffset,n.args.labelFormat=t._labelFormat,n.args.titleOffset=t._titleOffset,n.args.title=t._titleText,n.args.rotateTitle=t._rotateTitle,n.args.titleVisible=t._showTitle,n.args.labelRotation=t._labelRotation,t._args&&t._args.element&&(n.args.element=t._args.element.id??t._args.element),e.axes.push(n)}function uO(t,e){e.gridlines??=[];let n={};n.type=t._type,n.id=t._id,n.attr=t._attribute,n.channel=t._channel,n.args=function(t){let e=Object.assign({},t);e.element&&(e.element=e.element.id??e.element);return e}(t._args),e.gridlines.push(n)}function hO(t,e){e.legends??=[];let n={};n.type=t._type,n.id=t._id,n.attr=t.attribute,n.channel=t.channel,n.args={},n.args.textColor=t._textColor,n.args.strokeColor=t._strokeColor,n.args.fontSize=t._fontSize,n.args.x=t._x,n.args.y=t._y,n.args.showTitle=t._showTitle,n.args.orientation=t._orientation,n.args.numberFormat=t._numberFormat,void 0!==t._numCols&&(n.args.numCols=t._numCols),void 0!==t._numRows&&(n.args.numRows=t._numRows),e.legends.push(n)}function fO(t,e){e.trajectories??=[];let n={};n.type=t._type,n.id=t._id,n.collectionId=t.collection.id,n.args=t._args,e.trajectories.push(n)}function dO(t,e){return void 0===t&&void 0===e||void 0!==t&&void 0!==e}function pO(t,e){const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&(0===n.length||n.every(t=>r.includes(t)))}function _O(t,e){if(!dO(t.layout,e.layout))return console.log("Not both defined or undefined:",t.bounds,e.bounds),!1;let n=t.layout,r=e.layout;if(!n&&!r)return!0;if(n.type!==r.type)return console.log("layout types are different:",n,r),!1;switch(n.type){case HE.GRID:return function(t,e){t._cellBounds.length!==e._cellBounds.length&&console.log("cell bounds length different:",t,e);for(let n=0;n<t._cellBounds;n++)if(!yO(t._cellBounds[n],e._cellBounds[n]))return console.log("cell bounds not equal:",t,e),!1;for(let n=0;n<t._grid.length;n++)for(let r=0;r<t._grid[n].length;r++)if(t._grid[n][r]!==e._grid[n][r])return console.log("grid not equal",t,e),!1;return t._numCols===e._numCols&&t._numRows===e._numRows&&t._start===e._start&&t._direction===e._direction&&t._rowGap===e._rowGap&&t._colGap===e._colGap&&t._cellHorzAlignment===e._cellHorzAlignment&&t._cellVertAlignment===e._cellVertAlignment&&t._rowOffset===e._rowOffset&&t._colOffset===e._colOffset&&t._left===e._left&&t._top===e._top}(n,r);case HE.STACK:return function(t,e){return t._orientation===e._orientation&&t._direction===e._direction&&t._left===e._left&&t._top===e._top&&t._horzCellAlignment===e._horzCellAlignment&&t._vertCellAlignment===e._vertCellAlignment&&t._gap===e._gap}(n,r);case HE.PACKING:return function(t,e){return t._x===e._x&&t._y===e._y&&t._width===e._width&&t._height===e._height}(n,r);case HE.FORCE:return function(t,e){return t._x===e._x&&t._y===e._y&&t._iterations===e._iterations&&t._repulsion===e._repulsion&&t._attraction===e._attraction&&t._linkDistance===e._linkDistance}(n,r);case HE.DIRECTED:return function(t,e){return t._width===e._width&&t._height===e._height&&t._top===e._top&&t._left===e._left&&t._edgeSep===e._edgeSep&&t._spreadLinks===e._spreadLinks&&t._direction===e._direction}(n,r);case HE.TIDYTREE:return function(t,e){return t._width===e._width&&t._height===e._height&&t._top===e._top&&t._left===e._left&&t._orientation===e._orientation}(n,r);case HE.STRATA:return function(t,e){return t._direction===e._direction&&t._gap===e._gap}(n,r);case HE.TREEMAP:return function(t,e){return t._width===e._width&&t._height===e._height&&t._top===e._top&&t._left===e._left}(n,r);case HE.SPIRAL:return function(t,e){return t._x===e._x&&t._y===e._y&&t._startRadius===e._startRadius&&t._radiusStep===e._radiusStep&&t._startAngle===e._startAngle&&t._angleStep===e._angleStep&&t._direction===e._direction&&t._markRotation===e._markRotation}(n,r);case HE.CIRCULAR:return function(t,e){return t._x===e._x&&t._y===e._y&&t._radius===e._radius&&t._markRotation===e._markRotation}(n,r);default:return!1}}function gO(t,e){if(!dO(t.bounds,e.bounds))return console.log("Not both defined or undefined:",t.bounds,e.bounds),!1;let n=t.bounds,r=e.bounds;return!n&&!r||yO(n,r)}function yO(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function mO(t,e){if(!dO(t,e))return console.log("Not both defined or undefined:",t,e),!1;if(t.type!==e.type)return console.log("Different mark types:",t,e),!1;if(t.id!==e.id)return console.log("id not equal:",t,e),!1;if(t.classId!==e.classId)return console.log("class id not equal:",t,e),!1;if(!vO(t,e))return console.log("DataScopes not equal",t,e),!1;if(!gO(t,e))return console.log("Bounds not equal",t,e),!1;if(!dO(t.links,e.links))return console.log("Not both defined or undefined: links ",t.links,e.links),!1;if(!dO(t.source,e.source))return console.log("Not both defined or undefined: source ",t.source,e.source),!1;if(!dO(t.target,e.target))return console.log("Not both defined or undefined: links ",t.target,e.target),!1;if(t.links&&e.links&&t.links.length!==e.links.length)return console.log("unequal number of links",t,e),!1;if(t.source&&e.source&&!mO(t.source,e.source))return console.log("different sources",t.source,e.source),!1;if(t.target&&e.target&&!mO(t.target,e.target))return console.log("different targets",t.target,e.target),!1;switch(t.type){case Pw.Arc:case Pw.Pie:return bO(t,e)?t.x===e.x&&t.y===e.y&&t.innerRadius===e.innerRadius&&t.outerRadius===e.outerRadius&&t.startAngle===e.startAngle&&t.endAngle===e.endAngle&&t.direction===e.direction&&t.thickness===e.thickness:(console.log("vertices not equal:",t,e),!1);case Pw.Area:return bO(t,e)?t.baseline===e.baseline&&t.orientation===e.orientation:(console.log("vertices not equal:",t,e),!1);case Pw.Circle:return t.x===e.x&&t.y===e.y&&t.radius===e.radius;case Pw.Image:return console.warn("not implemented"),!0;case Pw.Symbol:return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height&&t.path===e.path&&JSON.stringify(t.viewBox)===JSON.stringify(e.viewBox);case Pw.Line:case Pw.Path:case Pw.BezierCurve:return!!bO(t,e)||(console.log("vertices not equal:",t,e),!1);case Pw.SimpleText:return t.x===e.x&&t.y===e.y&&t.text===e.text&&t.anchor[0]===e.anchor[0]&&t.anchor[1]===e.anchor[1];case Pw.Polygon:return bO(t,e)?t.x===e.x&&t.y===e.y&&t.radius===e.radius:(console.log("vertices not equal:",t,e),!1);case Pw.Rect:return bO(t,e)?t.width===e.width&&t.height===e.height&&t.top===e.top&&t.left===e.left:(console.log("vertices not equal:",t,e),!1);case Pw.Ring:default:return console.warn("not implemented"),!0}}function bO(t,e){if(t.vertices.length!==e.vertices.length)return console.log("unequal number of vertices:",t,e),!1;for(let n=0;n<t.vertices.length;n++){let r=t.vertices[n],i=e.vertices[n];return r.id!==i.id?(console.log("vertex id not equal:",r,i),!1):r.x!==i.x||r.y!==i.y?(console.log("vertex position not equal:",r,i),!1):vO(r,i)?r._polarAngle===i._polarAngle&&r.shape===i.shape&&r.width===i.width&&r.height==i.height&&r.radius==i.radius&&r.fillColor==i.fillColor&&r.opacity==i.opacity&&r.strokeWidth==i.strokeWidth&&r.strokeColor==i.strokeColor:(console.log("vertex data scopes not equal:",r.dataScope,i.dataScope),!1)}}function vO(t,e){if(!dO(t.dataScope,e.dataScope))return console.log("Not both defined or undefined:",t.dataScope,e.dataScope),!1;if(!t.dataScope&&!e.dataScope)return!0;let n=t.dataScope,r=e.dataScope,i=n.filters||{},s=r.filters||{};if(!pO(i,s))return!1;for(let t in i)if(i[t]!==s[t])return!1;return n.dataTable.id===r.dataTable.id&&tE(n).length===tE(r).length}function xO(t,e){return t.type!==e.type&&console.log("Different types:",t.type,e.type),[Pw.Collection,Pw.Glyph,Pw.Composite].includes(t.type)?wO(t,e):t instanceof GE?mO(t,e):void 0}function wO(t,e){let n=t.children.filter(t=>!Object.values(Lw).includes(t.type)),r=e.children.filter(t=>!Object.values(Lw).includes(t.type));if(n.length!==r.length)return console.log("children length not equal:",n,r),!1;if(t.id!==e.id)return console.log("id not equal:",t,e),!1;if(t.classId!==e.classId)return console.log("class id not equal:",t,e),!1;if(!vO(t,e))return console.log("DataScopes not equal",t.dataScope,e.dataScope),!1;if(!gO(t,e))return console.log("Bounds not equal",t,e),!1;if(!_O(t,e))return console.log("Layouts not equal",t,e),!1;if(!function(t,e){if(!pO(t,e))return console.log("different keys",t,e),!1;for(let n in t)if(t[n]!==e[n])return!1;return!0}(t._sortBy,e._sortBy))return console.log("SortBy not equal",t,e),!1;for(let t=0;t<n.length;t++)if(!xO(n[t],r[t]))return console.log("Not equal",n[t],r[t]),!1;return!0}function EO(t){return t.type===Pw.Collection&&!(t.children.length<2)}function AO(t,e,n,r,i,s,o,a,l,c){let u=n.map(t=>r.getParent(t)).filter((t,e,n)=>n.findIndex(e=>e[xE]===t[xE])===e);if(u=u.filter(t=>t!==r.getRoot()),0===u.length)return;let h=[];for(let n of u){let u,f,d,p=e.filter(t=>r.getParent(r.getNode(t.datum[xE]))===n);if(p[0].type===Pw.Circle){let t=p.map(t=>NE(o,a,t.bounds.x,t.bounds.y)-t.radius),e=p.map(t=>NE(o,a,t.bounds.x,t.bounds.y)+t.radius);d=l===lS.OUTWARD?d3.max(e):d3.min(t)-c;let n=p.map(t=>wS(t.bounds.x,t.bounds.y,o,a)),r=p.map(t=>wS(o+NE(o,a,t.bounds.x,t.bounds.y),a-t.radius,o,a)),i=n.map((t,e)=>t-r[e]),s=n.map((t,e)=>t+r[e]),h=i.concat(s);u=d3.min(h),f=d3.max(h)}else p[0].type===Pw.Arc&&(u=360,f=-360,p.forEach(t=>{let e=t.startAngle,n=t.endAngle;n<e&&(n+=360),u=d3.min([u,e]),f=d3.max([f,n])}),u=xS(u),f=xS(f),d=l===lS.OUTWARD?d3.max(p.map(t=>t.outerRadius)):d3.min(p.map(t=>t.innerRadius))-c);let _=hT(t,{type:"arc",innerRadius:d,outerRadius:d+c,x:o,y:a,startAngle:xS(u),endAngle:xS(f),strokeColor:e[0].strokeColor,fillColor:e[0].fillColor,strokeWidth:e[0].strokeWidth,opacity:e[0].opacity});_._updateBounds(),_.dataScope=r.getNodeDataScopeRef(n),_._classId=s,i.addChild(_),h.push(_)}AO(t,h,u,r,i,s,o,a,l,c)}function SO(t,e,n,r,i,s,o,a,l){l&&(t.dataScope=i.getNodeDataScopeRef(s),t._classId=e);let c=i.getChildren(s);if(0===c.length)return;let u=t.type===Pw.Circle||t.type===Pw.Ring?60:t.startAngle,h=(t.type===Pw.Circle||t.type===Pw.Ring?360:t.angle)/c.length;for(let s=0;s<c.length;s++){let l,f;f=n===lS.OUTWARD?t.type===Pw.Circle?t.radius:t.outerRadius:t.type===Pw.Circle?t.radius-r:t.innerRadius-r,l=hT(a,360===h?{type:"ring",innerRadius:f,outerRadius:f+r,x:t.x,y:t.y,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}:{type:"arc",innerRadius:f,outerRadius:f+r,x:t.x,y:t.y,startAngle:xS(u+h*s),endAngle:xS(u+h*(s+1)),strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}),l._updateBounds(),l.dataScope=i.getNodeDataScopeRef(c[s]),l._classId=e+"_strata",o.addChild(l),SO(l,e,n,r,i,c[s],o,a)}}function TO(t,e,n,r,i,s,o,a,l){l&&(t.dataScope=i.getNodeDataScopeRef(s),t._classId=e,o.addChild(t));let c,u,h,f=i.getChildren(s);if(0!==f.length){c=t.left,u=t.bottom,h=t.width/f.length;for(let s=0;s<f.length;s++){let a=pT(t);XA(a,c-a.left,u-a.top),a.resize(h,r),a._updateBounds(),c+=h,a.dataScope=i.getNodeDataScopeRef(f[s]),a._classId=e,o.addChild(a),TO(a,e,n,r,i,f[s],o)}}}class CO{constructor(t,e,n){this._elems=t,this._channel=e,this._anchor=n}get elements(){return this._elems}get channel(){return this._channel}get anchor(){return this._anchor}}class kO{constructor(t,e){this._elem=t,this._base=e,this._id=RO(t,e),this._channels={},this._attribute=void 0}get id(){return this._id}get element(){return this._elem}get base(){return this._base}get channels(){return Object.keys(this._channels)}addChannel(t,e){let n={};n.elemAnchor="elementAnchor"in e?e.elementAnchor:"x"==t||"angle"==t?zE.CENTER:zE.MIDDLE,n.baseAnchor="baseAnchor"in e?e.baseAnchor:"x"==t||"angle"==t?zE.CENTER:zE.MIDDLE,n.offset="offset"in e?e.offset:0,"attribute"in e&&(this._attribute=e.attribute),this._channels[t]=n}hasChannel(t){return t in this._channels}getElementAnchor(t){return this._channels[t].elemAnchor}getBaseAnchor(t){return this._channels[t].baseAnchor}getOffset(t){return this._channels[t].offset}get attribute(){return this._attribute?this._attribute:_E}}function RO(t,e){return(t.classId?t.classId:t.id)+":"+(e.classId?e.classId:e.id)}function MO(t,e,n,r){t.vertices[0].dataScope&&Jw(t.vertices[0].dataScope).has(e)?function(t,e,n,r){let i;if(e===_E)i=(t,n)=>parseInt(iE(t.dataScope,e).substring(1))-parseInt(iE(n.dataScope,e).substring(1));else{switch(Jw(t.vertices[0].dataScope).type(e)){case Vw.Date:break;case Vw.Number:case Vw.Integer:i=(t,n)=>oE(t.dataScope,e)-oE(n.dataScope,e);break;case Vw.String:i=r?(t,n)=>r.indexOf(iE(t.dataScope,e))-r.indexOf(iE(n.dataScope,e)):(t,n)=>iE(t.dataScope,e)<iE(n.dataScope,e)?-1:1}}t.vertices.sort(i),n&&t.vertices.reverse()}(t,e,n,r):function(t,e,n){let r=(t,n)=>t[e]-n[e];t.vertices.sort(r),n&&t.vertices.reverse()}(t,e,n),t._sortBy={property:e,descending:n,vals:r}}class OO{constructor(t,e,n,r){this._respCompnt=e.object,this._respProps=e.properties||e.channels,this._responderEval=n,this._efxFn=r,this._evtCtx=t,this._evalResult={},this._responderPeers=void 0}get responderComponent(){return this._respCompnt}getResponderPeers(){if(!this._responderPeers){let t=Array.isArray(this._respCompnt)?this._respCompnt:[this._respCompnt];this._responderPeers=t.map(t=>JE(t)).flat()}return this._responderPeers}clearResponderPeers(){this._responderPeers=void 0}get responderProperties(){return this._respProps}get eventContext(){return this._evtCtx}get evalResult(){return this._evalResult}set evalResult(t){this._evalResult=t}get evalFunction(){return this._responderEval}get stylingFunction(){return this._efxFn}}exports.activate=function(t,e,n,r,i){const s=aA(e.object===bA?t.source:e.object);!function(t,e,n,r,i){if(!("event"in t)||!("source"in t))throw"Source and event must be specified in the trigger";if(!("object"in e))throw"Responder object must be specified";if(Array.isArray(r)){if(!r.every(t=>"function"==typeof t))throw"Updater must be a function";if(i&&!Array.isArray(i))throw"An array of effect setters must be accompanied by an array of animation effects";if(i&&Array.isArray(i)&&i.length!==r.length)throw"the length of effect setters is not equal to the length of animation effects"}else if("function"!=typeof r)throw"Updater must be a function"}(t,e,0,r,i);let o=t.event,a=function(t){let e="string"==typeof t.source?t.source:Array.isArray(t.source)?t.source.map(t=>t.classId||t.id).join("_"):"stateVar"===t.source.type?"state:"+t.source.key:t.source.classId?t.source.classId:t.source.id;return[e,t.event].join("-")}(t);o=0===o.indexOf("brush")?"brush":0===o.indexOf("drag")?"drag":o,o in s._triggers||(s._triggers[o]={}),a in s._triggers[o]||(s._triggers[o][a]=new mA(a,t.source,t.event,t.cumulative));let l=s._triggers[o][a].eventContext,c=new OO(l,e,n,r);return a in s._condEncodings||(s._condEncodings[a]=[]),s._condEncodings[a].push(c),function(t,e,n,r,i){let s=e.responderComponent===bA,o=s?i.source:e.responderComponent,a=i&&i.source&&"stateVar"===i.source.type?r.getVariable(KE.STATE,i.source.key,i.source.stateContext):r.getVariable(KE.EVT_CTX,t),l=n.properties?n.properties:n.channels;if(e.evalFunction){let t=r.getVariable(KE.CONDITION_RESULT,e),n=r.findIncomingDataflowOperator($E.TARGET_EVALUATOR,t);n||(n=r.createOneWayDependency($E.TARGET_EVALUATOR,e.evalFunction)),r.connect(a,n),r.connect(n,t);for(let e of l){let n=Array.isArray(o)?o:[o];for(let i of n){let n=r.getVariable(KE.CHANNEL,e,i),s=n.incomingDataflow;if(s&&s.type===$E.ENCODER&&s.outputVar.channel===e)r.connect(t,s);else if(!s){let s=r.createOneWayDependency($E.ENCODER);r.connect(t,s),r.connect(s,n),s.storeValues(i,e)}}}}else{let t=r.createOneWayDependency($E.TARGET_UPDATER,e.stylingFunction,o,s);for(let e of l){let n;n=o instanceof ZE?r.getVariable(KE.STATE,e,o):Object.values(fA).includes(e)?r.getVariable(KE.CHANNEL,e,o):r.getVariable(KE.PROPERTY,pA(e),o),r.connect(a,t),r.connect(t,n)}}}(l,c,e,s._depGraph,t),s._triggers[o][a]},exports.affix=function(t,e,n,r){let i=aA(t);Jw(t.dataScope)!==Jw(e.dataScope)&&console.warn("Affix: elements and base elements are not created from the same table");let s=RO(t,e),o=i._relations.find(t=>t.id===s);o||(o=new kO(t,e),i._relations.push(o)),o.addChannel(n,r||{}),function(t,e){let n=e.getVariable(KE.AFFIXATION,t),r=e.getOutgoingDataflowOperator($E.AFFIXER,n);e.connect(n,r);for(let n of t.channels){let i=e.getVariable(KE.CHANNEL,n,t.element),s=e.getVariable(KE.CHANNEL,n,t.base);e.connect(s,r),e.connect(r,i)}r.run()}(o,i._depGraph)},exports.align=function(t,e,n){let r=aA(t[0]),i=new CO(t,e,n);!function(t,e){let n=e.createMultiWayDependency($E.ALIGNER),r=e.getVariable(KE.ALIGNMENT,t);e.connect(r,n);for(let r of t.elements){let i=e.getVariable(KE.CHANNEL,t.channel,r);e.connect(i,n)}n.run()}(i,r._depGraph),r._relations.push(i)},exports.attach=function(t,e){if(t.type==Pw.Glyph)for(let e of t.children)e._refBounds||(e._refBounds=e.bounds.clone());t.dataScope=cE(e)},exports.canClassify=EO,exports.canDensify=function(t){if([Pw.Line,Pw.Circle,Pw.Rect,Pw.Area].indexOf(t.type)<0)return!1;if(t.dataScope){let e=JE(t,t.scene);for(let t of e)if(nE(t.dataScope)>1)return!0;return!1}return!0},exports.canDivide=function(t){if([Pw.Line,Pw.Circle,Pw.Rect,Pw.Area,Pw.Ring,Pw.Pie,Pw.Path].indexOf(t.type)<0)return!1;if(t.type===Pw.Path&&(t.closed||!t.firstVertex.dataScope))return!1;if(t.dataScope){let e=JE(t);for(let t of e)if(nE(t.dataScope)>1)return!0;return!1}return!0},exports.canRepeat=iT,exports.classify=function(t,e){let n=aA(t),r=e||{};if(console.log("------ classify by",r.attribute," ----"),!EO(t))throw new Error("The "+t.type+" is not classifiable");return function(t,e,n,r){let i=JE(e);for(let e of i){let i,s={},o=e.children;for(let t of o){let e=iE(t.dataScope,n);e in s||(s[e]=[]),s[e].push(t)}let a=pE(o[0]);for(let o in s){let l=hT(t,{type:Pw.Collection});e.addChild(l),void 0===i&&(i=l.id),l._classId=i,l.dataScope=aE(e.dataScope?e.dataScope:cE(a),n,o);for(let t of s[o])l.addChild(t);r&&(l._layout=r.clone(),l._layout.group=l)}}}(n,t,r.attribute,r.layout),SA(t,t.firstChild.firstChild,n._depGraph),EA(t.firstChild,n._depGraph),TA(t.firstChild,t.firstChild.firstChild,n._depGraph),TA(t,t.firstChild,n._depGraph),n.onChange(KE.CHANNEL,"width",t.firstChild.firstChild),t.firstChild},exports.connect=function(t,e){let n=aA(t[0]),r={};t.forEach(t=>r[iE(t.dataScope,xE)]=t);let i=Jw(e[0].dataScope),s=i.tree?"parent":"source",o=i.tree?"child":"target";for(let e of t)e.links=[];for(let t of e){let e=iE(t.dataScope,s),n=iE(t.dataScope,o),i=r[e],a=r[n];t.source=i,t.target=a,i.links.push(t),a.links.push(t)}OA(t.find(t=>t.links.length>0),n._depGraph),n.onChange(KE.CHANNEL,"x",t[0])},exports.csv=async function(t){return async function(t){let e=await wE("GET",t),n=Da(e.trim(),Za);return new fE(n,t)}(t)},exports.csvString=function(t){return function(t){let e=Da(t.trim(),Za);return new fE(e,"fromString")}(t)},exports.deserialize=function(t){return HM(t)},exports.findElements=rA,exports.getLeafMarks=cA,exports.getPeers=JE,exports.graphJSON=async function(t){return async function(t){let e=await wE("GET",t);return new mE(JSON.parse(e),t)}(t)},exports.isEqual=function(t,e){return function(t,e){return t.fillColor!==e.fillColor?(console.log("fillColor not equal:",t,e),!1):wO(t,e)}(t,e)},exports.isMark=FE,exports.isRefElement=function(t){return t.type===Pw.Axis||t.type===Pw.Legend||t.type===Pw.Gridlines},exports.layout=function(t,e){let n=e||{};switch(t.toLowerCase()){case HE.STACK:return new PM(n);case HE.PACKING:return new IM(n);case HE.FORCE:return new NM(n);case HE.DIRECTED:return new OM(n);case HE.TIDYTREE:return new DM(n);case HE.TREEMAP:return new VM(n);case HE.CIRCULAR:return new zM(n);case HE.CLUSTER:return new MM(n);case HE.SPIRAL:return new BM(n);case HE.GRID:default:return new sT(n)}},exports.repopulate=function(t,e,n){t.dataScope=void 0;let r=aA(t),i=t;for(let t in n){UT(r,i,n[t],e);let s=GA(i.children[0]);for(let t of s)zA(t,r);let o=JE(i);for(let t of o)if(t.layout){for(let e of t.layout.refElements)BA(e,r),wA(e,r._depGraph);t.layout.clearRefElements()}i=i.children[0]}t.dataScope=cE(e),r.onChange(KE.CHANNEL,"width",t.children[0])},exports.scene=function(t){return new kM(t)},exports.serialize=function(t){return sO(t)},exports.sortChildren=function(t,e,n,r){let i=aA(t);if(t instanceof ZA)!function(t,e,n,r){t.dataScope&&Jw(t.dataScope).has(e)?function(t,e,n,r){if(!Jw(t.dataScope).has(e))return void console.warn("Cannot order collection children by an non-existent attribute",e);let i;if(e===_E)i=(t,n)=>parseInt(iE(t.dataScope,e).substring(1))-parseInt(iE(n.dataScope,e).substring(1));else{switch(Jw(t.children[0].dataScope).type(e)){case Vw.Date:break;case Vw.Number:case Vw.Integer:i=(t,n)=>oE(t.dataScope,e)-oE(n.dataScope,e);break;case Vw.String:i=r?(t,n)=>r.indexOf(iE(t.dataScope,e))-r.indexOf(iE(n.dataScope,e)):(t,n)=>iE(t.dataScope,e)<iE(n.dataScope,e)?-1:1}}t.children.sort(i),n&&t.children.reverse()}(t,e,n,r):function(t,e,n){let r;switch(e){case"x":case"y":case"width":case"height":r=(t,n)=>t.bounds[e]-n.bounds[e];break;default:r=(t,n)=>t[e]-n[e]}t._children.sort(r),n&&t.children.reverse()}(t,e,n);t._sortBy={property:e,descending:n,vals:r}}(t,e,n,r),i.onChange(KE.PROPERTY,gA.CHILDREN_ORDER,t);else if(t instanceof dS){let i=JE(t);for(let t of i)MO(t,e,n,r)}},exports.stratify=function(t,e,n){if(!(e instanceof gE||Array.isArray(e)&&e.every(t=>t instanceof gE)))throw"Cannot stratify on a non-tree dataset";if(![Pw.Circle,Pw.Rect,Pw.Ring].includes(t.type))throw"Cannot stratify elements that are not rects, circles, or rings";let r=aA(t),i=n||{},s=i.direction,o=i.size,a=t.parent,l=function(t,e,n,r,i,s){switch(e.type){case Pw.Circle:case Pw.Ring:return function(t,e,n,r,i,s){let o,a=n||lS.OUTWARD,l=i||50;if(a!==lS.INWARD&&a!==lS.OUTWARD)throw"Unknown direction to stratify";let c,u=JE(e,t),h=Array.isArray(s)?s:[s];if(r){let n=hT(t,{type:Pw.Collection});n.dataScope=void 0,null==c&&(c=n.id),n._classId=c;let r=u.map(t=>h[0].getNode(t.datum[xE]));AO(t,u,r,h[0],n,e.classId?e.classId:e.id,400,350,a,l),o=n}else u.forEach((n,r)=>{let i=hT(t,{type:Pw.Collection});i.dataScope=void 0,null==c&&(c=i.id),i._classId=c;let s=n.parent;SO(n,e.id,a,l,h[r],h[r].getRoot(),i,t,!0),i._layout=new LM({direction:a}),i._layout.group=i,s.addChild(i),n===e&&(o=i)});return o}(t,e,n,r,i,s);case Pw.Rect:return function(t,e,n,r,i,s){let o,a,l=n||oS.Top2Bottom,c=i||50;if(!Object.values(oS).includes(l))throw"Unknown direction to stratify";return JE(e).forEach(n=>{let r=hT(t,{type:Pw.Collection});r.dataScope=void 0,null==a&&(a=r.id),r._classId=a;let i=n.parent;TO(n,e.id,l,c,s,s.getRoot(),r,t,!0),r._layout=new LM({direction:l}),r._layout.group=r,i.addChild(r),n===e&&(o=r)}),o}(t,e,n,0,i,s)}}(r,t,s,i.startFromLeaf,o,e);return SA(a,t,r._depGraph),EA(l,r._depGraph),l.children.length>0&&TA(l,l.firstChild,r._depGraph),TA(l.parent,l,r._depGraph),l},exports.table=function(t){return new fE(t,"")},exports.transform=function(t,e){switch(t){case"kde":return new EM(e);case"filter":return new AM(e);default:return new wM(e)}},exports.treeJSON=async function(t){return async function(t){let e=await wE("GET",t);return new gE(JSON.parse(e),t)}(t)},exports.update=function(t,e){if(!t)throw new Error("update: target is required");if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("update: patch must be an object");if(YE(t)){let n=t.group?[t.group]:[],r=[];for(let t of n)r=r.concat(JE(t));0===r.length&&(r=n);for(let t of r)if(t.layout)for(const[n,r]of Object.entries(e))t.layout[n]=r;let i=aA(t);if(i)for(let t of n)t.firstChild&&i.onChange(KE.CHANNEL,"width",t.firstChild);return}let n=JE(t),r=aA(t);for(const[i,s]of Object.entries(e))if("layout"!==i)for(let t of n)MT(t,i,s);else if(r&&"function"==typeof r.setLayout)r.setLayout(t,s);else for(let t of n)t.layout=s;if("width"in e&&n.forEach(t=>{t._refBounds&&t._refBounds.setWidth(e.width)}),"height"in e&&n.forEach(t=>{t._refBounds&&t._refBounds.setHeight(e.height)}),r)for(let n in e)"layout"!==n&&(["vertex","segment"].includes(t.type)&&!["x","y"].includes(n)||(Object.values(fA).includes(n)?r.onChange(KE.CHANNEL,n,t):r.onChange(KE.PROPERTY,n,t)))};