UNPKG

visiojs

Version:

Microsoft Visio javascript alternative for creating diagrams and schematics

1 lines 300 kB
"use strict";function hn(n,t){return n==null||t==null?NaN:n<t?-1:n>t?1:n>=t?0:NaN}function Vl(n,t){return n==null||t==null?NaN:t<n?-1:t>n?1:t>=n?0:NaN}function Oo(n){let t,e,r;n.length!==2?(t=hn,e=(u,c)=>hn(n(u),c),r=(u,c)=>n(u)-c):(t=n===hn||n===Vl?n:$g,e=n,r=n);function i(u,c,f=0,s=u.length){if(f<s){if(t(c,c)!==0)return s;do{const h=f+s>>>1;e(u[h],c)<0?f=h+1:s=h}while(f<s)}return f}function o(u,c,f=0,s=u.length){if(f<s){if(t(c,c)!==0)return s;do{const h=f+s>>>1;e(u[h],c)<=0?f=h+1:s=h}while(f<s)}return f}function a(u,c,f=0,s=u.length){const h=i(u,c,f,s-1);return h>f&&r(u[h-1],c)>-r(u[h],c)?h-1:h}return{left:i,center:a,right:o}}function $g(){return 0}function ji(n){return n===null?NaN:+n}function*Tg(n,t){if(t===void 0)for(let e of n)e!=null&&(e=+e)>=e&&(yield e);else{let e=-1;for(let r of n)(r=t(r,++e,n))!=null&&(r=+r)>=r&&(yield r)}}const Gl=Oo(hn),Ft=Gl.right,Ag=Gl.left,Sg=Oo(ji).center;function Eg(n,t){if(!((t=+t)>=0))throw new RangeError("invalid r");let e=n.length;if(!((e=Math.floor(e))>=0))throw new RangeError("invalid length");if(!e||!t)return n;const r=lf(t),i=n.slice();return r(n,i,0,e,1),r(i,n,0,e,1),r(n,i,0,e,1),n}const Zl=Ql(lf),kg=Ql(Ng);function Ql(n){return function(t,e,r=e){if(!((e=+e)>=0))throw new RangeError("invalid rx");if(!((r=+r)>=0))throw new RangeError("invalid ry");let{data:i,width:o,height:a}=t;if(!((o=Math.floor(o))>=0))throw new RangeError("invalid width");if(!((a=Math.floor(a!==void 0?a:i.length/o))>=0))throw new RangeError("invalid height");if(!o||!a||!e&&!r)return t;const u=e&&n(e),c=r&&n(r),f=i.slice();return u&&c?(we(u,f,i,o,a),we(u,i,f,o,a),we(u,f,i,o,a),xe(c,i,f,o,a),xe(c,f,i,o,a),xe(c,i,f,o,a)):u?(we(u,i,f,o,a),we(u,f,i,o,a),we(u,i,f,o,a)):c&&(xe(c,i,f,o,a),xe(c,f,i,o,a),xe(c,i,f,o,a)),t}}function we(n,t,e,r,i){for(let o=0,a=r*i;o<a;)n(t,e,o,o+=r,1)}function xe(n,t,e,r,i){for(let o=0,a=r*i;o<r;++o)n(t,e,o,o+a,r)}function Ng(n){const t=lf(n);return(e,r,i,o,a)=>{i<<=2,o<<=2,a<<=2,t(e,r,i+0,o+0,a),t(e,r,i+1,o+1,a),t(e,r,i+2,o+2,a),t(e,r,i+3,o+3,a)}}function lf(n){const t=Math.floor(n);if(t===n)return Rg(n);const e=n-t,r=2*n+1;return(i,o,a,u,c)=>{if(!((u-=c)>=a))return;let f=t*o[a];const s=c*t,h=s+c;for(let l=a,d=a+s;l<d;l+=c)f+=o[Math.min(u,l)];for(let l=a,d=u;l<=d;l+=c)f+=o[Math.min(u,l+s)],i[l]=(f+e*(o[Math.max(a,l-h)]+o[Math.min(u,l+h)]))/r,f-=o[Math.max(a,l-s)]}}function Rg(n){const t=2*n+1;return(e,r,i,o,a)=>{if(!((o-=a)>=i))return;let u=n*r[i];const c=a*n;for(let f=i,s=i+c;f<s;f+=a)u+=r[Math.min(o,f)];for(let f=i,s=o;f<=s;f+=a)u+=r[Math.min(o,f+c)],e[f]=u/t,u-=r[Math.max(i,f-c)]}}function Yo(n,t){let e=0;if(t===void 0)for(let r of n)r!=null&&(r=+r)>=r&&++e;else{let r=-1;for(let i of n)(i=t(i,++r,n))!=null&&(i=+i)>=i&&++e}return e}function Ig(n){return n.length|0}function Cg(n){return!(n>0)}function Pg(n){return typeof n!="object"||"length"in n?n:Array.from(n)}function Dg(n){return t=>n(...t)}function zg(...n){const t=typeof n[n.length-1]=="function"&&Dg(n.pop());n=n.map(Pg);const e=n.map(Ig),r=n.length-1,i=new Array(r+1).fill(0),o=[];if(r<0||e.some(Cg))return o;for(;;){o.push(i.map((u,c)=>n[c][u]));let a=r;for(;++i[a]===e[a];){if(a===0)return t?o.map(t):o;i[a--]=0}}}function Og(n,t){var e=0,r=0;return Float64Array.from(n,t===void 0?i=>e+=+i||0:i=>e+=+t(i,r++,n)||0)}function Kl(n,t){let e=0,r,i=0,o=0;if(t===void 0)for(let a of n)a!=null&&(a=+a)>=a&&(r=a-i,i+=r/++e,o+=r*(a-i));else{let a=-1;for(let u of n)(u=t(u,++a,n))!=null&&(u=+u)>=u&&(r=u-i,i+=r/++e,o+=r*(u-i))}if(e>1)return o/(e-1)}function Jl(n,t){const e=Kl(n,t);return e&&Math.sqrt(e)}function Er(n,t){let e,r;if(t===void 0)for(const i of n)i!=null&&(e===void 0?i>=i&&(e=r=i):(e>i&&(e=i),r<i&&(r=i)));else{let i=-1;for(let o of n)(o=t(o,++i,n))!=null&&(e===void 0?o>=o&&(e=r=o):(e>o&&(e=o),r<o&&(r=o)))}return[e,r]}class bn{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const e=this._partials;let r=0;for(let i=0;i<this._n&&i<32;i++){const o=e[i],a=t+o,u=Math.abs(t)<Math.abs(o)?t-(a-o):o-(a-t);u&&(e[r++]=u),t=a}return e[r]=t,this._n=r+1,this}valueOf(){const t=this._partials;let e=this._n,r,i,o,a=0;if(e>0){for(a=t[--e];e>0&&(r=a,i=t[--e],a=r+i,o=i-(a-r),!o););e>0&&(o<0&&t[e-1]<0||o>0&&t[e-1]>0)&&(i=o*2,r=a+i,i==r-a&&(a=r))}return a}}function Yg(n,t){const e=new bn;if(t===void 0)for(let r of n)(r=+r)&&e.add(r);else{let r=-1;for(let i of n)(i=+t(i,++r,n))&&e.add(i)}return+e}function Fg(n,t){const e=new bn;let r=-1;return Float64Array.from(n,t===void 0?i=>e.add(+i||0):i=>e.add(+t(i,++r,n)||0))}class Pr extends Map{constructor(t,e=eh){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(hu(this,t))}has(t){return super.has(hu(this,t))}set(t,e){return super.set(nh(this,t),e)}delete(t){return super.delete(th(this,t))}}class ie extends Set{constructor(t,e=eh){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),t!=null)for(const r of t)this.add(r)}has(t){return super.has(hu(this,t))}add(t){return super.add(nh(this,t))}delete(t){return super.delete(th(this,t))}}function hu({_intern:n,_key:t},e){const r=t(e);return n.has(r)?n.get(r):e}function nh({_intern:n,_key:t},e){const r=t(e);return n.has(r)?n.get(r):(n.set(r,e),e)}function th({_intern:n,_key:t},e){const r=t(e);return n.has(r)&&(e=n.get(r),n.delete(r)),e}function eh(n){return n!==null&&typeof n=="object"?n.valueOf():n}function qe(n){return n}function rh(n,...t){return er(n,qe,qe,t)}function ih(n,...t){return er(n,Array.from,qe,t)}function oh(n,t){for(let e=1,r=t.length;e<r;++e)n=n.flatMap(i=>i.pop().map(([o,a])=>[...i,o,a]));return n}function qg(n,...t){return oh(ih(n,...t),t)}function Lg(n,t,...e){return oh(uh(n,t,...e),e)}function ah(n,t,...e){return er(n,qe,t,e)}function uh(n,t,...e){return er(n,Array.from,t,e)}function Bg(n,...t){return er(n,qe,fh,t)}function Ug(n,...t){return er(n,Array.from,fh,t)}function fh(n){if(n.length!==1)throw new Error("duplicate key");return n[0]}function er(n,t,e,r){return(function i(o,a){if(a>=r.length)return e(o);const u=new Pr,c=r[a++];let f=-1;for(const s of o){const h=c(s,++f,o),l=u.get(h);l?l.push(s):u.set(h,[s])}for(const[s,h]of u)u.set(s,i(h,a));return t(u)})(n,0)}function ch(n,t){return Array.from(t,e=>n[e])}function du(n,...t){if(typeof n[Symbol.iterator]!="function")throw new TypeError("values is not iterable");n=Array.from(n);let[e]=t;if(e&&e.length!==2||t.length>1){const r=Uint32Array.from(n,(i,o)=>o);return t.length>1?(t=t.map(i=>n.map(i)),r.sort((i,o)=>{for(const a of t){const u=Le(a[i],a[o]);if(u)return u}})):(e=n.map(e),r.sort((i,o)=>Le(e[i],e[o]))),ch(n,r)}return n.sort(hf(e))}function hf(n=hn){if(n===hn)return Le;if(typeof n!="function")throw new TypeError("compare is not a function");return(t,e)=>{const r=n(t,e);return r||r===0?r:(n(e,e)===0)-(n(t,t)===0)}}function Le(n,t){return(n==null||!(n>=n))-(t==null||!(t>=t))||(n<t?-1:n>t?1:0)}function Xg(n,t,e){return(t.length!==2?du(ah(n,t,e),(([r,i],[o,a])=>hn(i,a)||hn(r,o))):du(rh(n,e),(([r,i],[o,a])=>t(i,a)||hn(r,o)))).map(([r])=>r)}var Hg=Array.prototype,jg=Hg.slice;function Aa(n){return()=>n}const Wg=Math.sqrt(50),Vg=Math.sqrt(10),Gg=Math.sqrt(2);function Wi(n,t,e){const r=(t-n)/Math.max(0,e),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),a=o>=Wg?10:o>=Vg?5:o>=Gg?2:1;let u,c,f;return i<0?(f=Math.pow(10,-i)/a,u=Math.round(n*f),c=Math.round(t*f),u/f<n&&++u,c/f>t&&--c,f=-f):(f=Math.pow(10,i)*a,u=Math.round(n/f),c=Math.round(t/f),u*f<n&&++u,c*f>t&&--c),c<u&&.5<=e&&e<2?Wi(n,t,e*2):[u,c,f]}function oe(n,t,e){if(t=+t,n=+n,e=+e,!(e>0))return[];if(n===t)return[n];const r=t<n,[i,o,a]=r?Wi(t,n,e):Wi(n,t,e);if(!(o>=i))return[];const u=o-i+1,c=new Array(u);if(r)if(a<0)for(let f=0;f<u;++f)c[f]=(o-f)/-a;else for(let f=0;f<u;++f)c[f]=(o-f)*a;else if(a<0)for(let f=0;f<u;++f)c[f]=(i+f)/-a;else for(let f=0;f<u;++f)c[f]=(i+f)*a;return c}function ae(n,t,e){return t=+t,n=+n,e=+e,Wi(n,t,e)[2]}function Vi(n,t,e){t=+t,n=+n,e=+e;const r=t<n,i=r?ae(t,n,e):ae(n,t,e);return(r?-1:1)*(i<0?1/-i:i)}function df(n,t,e){let r;for(;;){const i=ae(n,t,e);if(i===r||i===0||!isFinite(i))return[n,t];i>0?(n=Math.floor(n/i)*i,t=Math.ceil(t/i)*i):i<0&&(n=Math.ceil(n*i)/i,t=Math.floor(t*i)/i),r=i}}function gf(n){return Math.max(1,Math.ceil(Math.log(Yo(n))/Math.LN2)+1)}function Nc(){var n=qe,t=Er,e=gf;function r(i){Array.isArray(i)||(i=Array.from(i));var o,a=i.length,u,c,f=new Array(a);for(o=0;o<a;++o)f[o]=n(i[o],o,i);var s=t(f),h=s[0],l=s[1],d=e(f,h,l);if(!Array.isArray(d)){const v=l,_=+d;if(t===Er&&([h,l]=df(h,l,_)),d=oe(h,l,_),d[0]<=h&&(c=ae(h,l,_)),d[d.length-1]>=l)if(v>=l&&t===Er){const w=ae(h,l,_);isFinite(w)&&(w>0?l=(Math.floor(l/w)+1)*w:w<0&&(l=(Math.ceil(l*-w)+1)/-w))}else d.pop()}for(var p=d.length,m=0,g=p;d[m]<=h;)++m;for(;d[g-1]>l;)--g;(m||g<p)&&(d=d.slice(m,g),p=g-m);var y=new Array(p+1),b;for(o=0;o<=p;++o)b=y[o]=[],b.x0=o>0?d[o-1]:h,b.x1=o<p?d[o]:l;if(isFinite(c)){if(c>0)for(o=0;o<a;++o)(u=f[o])!=null&&h<=u&&u<=l&&y[Math.min(p,Math.floor((u-h)/c))].push(i[o]);else if(c<0){for(o=0;o<a;++o)if((u=f[o])!=null&&h<=u&&u<=l){const v=Math.floor((h-u)*c);y[Math.min(p,v+(d[v]<=u))].push(i[o])}}}else for(o=0;o<a;++o)(u=f[o])!=null&&h<=u&&u<=l&&y[Ft(d,u,0,p)].push(i[o]);return y}return r.value=function(i){return arguments.length?(n=typeof i=="function"?i:Aa(i),r):n},r.domain=function(i){return arguments.length?(t=typeof i=="function"?i:Aa([i[0],i[1]]),r):t},r.thresholds=function(i){return arguments.length?(e=typeof i=="function"?i:Aa(Array.isArray(i)?jg.call(i):i),r):e},r}function Dr(n,t){let e;if(t===void 0)for(const r of n)r!=null&&(e<r||e===void 0&&r>=r)&&(e=r);else{let r=-1;for(let i of n)(i=t(i,++r,n))!=null&&(e<i||e===void 0&&i>=i)&&(e=i)}return e}function pf(n,t){let e,r=-1,i=-1;if(t===void 0)for(const o of n)++i,o!=null&&(e<o||e===void 0&&o>=o)&&(e=o,r=i);else for(let o of n)(o=t(o,++i,n))!=null&&(e<o||e===void 0&&o>=o)&&(e=o,r=i);return r}function Gi(n,t){let e;if(t===void 0)for(const r of n)r!=null&&(e>r||e===void 0&&r>=r)&&(e=r);else{let r=-1;for(let i of n)(i=t(i,++r,n))!=null&&(e>i||e===void 0&&i>=i)&&(e=i)}return e}function mf(n,t){let e,r=-1,i=-1;if(t===void 0)for(const o of n)++i,o!=null&&(e>o||e===void 0&&o>=o)&&(e=o,r=i);else for(let o of n)(o=t(o,++i,n))!=null&&(e>o||e===void 0&&o>=o)&&(e=o,r=i);return r}function Fo(n,t,e=0,r=1/0,i){if(t=Math.floor(t),e=Math.floor(Math.max(0,e)),r=Math.floor(Math.min(n.length-1,r)),!(e<=t&&t<=r))return n;for(i=i===void 0?Le:hf(i);r>e;){if(r-e>600){const c=r-e+1,f=t-e+1,s=Math.log(c),h=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*h*(c-h)/c)*(f-c/2<0?-1:1),d=Math.max(e,Math.floor(t-f*h/c+l)),p=Math.min(r,Math.floor(t+(c-f)*h/c+l));Fo(n,t,d,p,i)}const o=n[t];let a=e,u=r;for(ur(n,e,t),i(n[r],o)>0&&ur(n,e,r);a<u;){for(ur(n,a,u),++a,--u;i(n[a],o)<0;)++a;for(;i(n[u],o)>0;)--u}i(n[e],o)===0?ur(n,e,u):(++u,ur(n,u,r)),u<=t&&(e=u+1),t<=u&&(r=u-1)}return n}function ur(n,t,e){const r=n[t];n[t]=n[e],n[e]=r}function sh(n,t=hn){let e,r=!1;if(t.length===1){let i;for(const o of n){const a=t(o);(r?hn(a,i)>0:hn(a,a)===0)&&(e=o,i=a,r=!0)}}else for(const i of n)(r?t(i,e)>0:t(i,i)===0)&&(e=i,r=!0);return e}function zr(n,t,e){if(n=Float64Array.from(Tg(n,e)),!(!(r=n.length)||isNaN(t=+t))){if(t<=0||r<2)return Gi(n);if(t>=1)return Dr(n);var r,i=(r-1)*t,o=Math.floor(i),a=Dr(Fo(n,o).subarray(0,o+1)),u=Gi(n.subarray(o+1));return a+(u-a)*(i-o)}}function lh(n,t,e=ji){if(!(!(r=n.length)||isNaN(t=+t))){if(t<=0||r<2)return+e(n[0],0,n);if(t>=1)return+e(n[r-1],r-1,n);var r,i=(r-1)*t,o=Math.floor(i),a=+e(n[o],o,n),u=+e(n[o+1],o+1,n);return a+(u-a)*(i-o)}}function hh(n,t,e=ji){if(!isNaN(t=+t)){if(r=Float64Array.from(n,(u,c)=>ji(e(n[c],c,n))),t<=0)return mf(r);if(t>=1)return pf(r);var r,i=Uint32Array.from(n,(u,c)=>c),o=r.length-1,a=Math.floor(o*t);return Fo(i,a,0,o,(u,c)=>Le(r[u],r[c])),a=sh(i.subarray(0,a+1),u=>r[u]),a>=0?a:-1}}function Zg(n,t,e){const r=Yo(n),i=zr(n,.75)-zr(n,.25);return r&&i?Math.ceil((e-t)/(2*i*Math.pow(r,-1/3))):1}function Qg(n,t,e){const r=Yo(n),i=Jl(n);return r&&i?Math.ceil((e-t)*Math.cbrt(r)/(3.49*i)):1}function Kg(n,t){let e=0,r=0;if(t===void 0)for(let i of n)i!=null&&(i=+i)>=i&&(++e,r+=i);else{let i=-1;for(let o of n)(o=t(o,++i,n))!=null&&(o=+o)>=o&&(++e,r+=o)}if(e)return r/e}function Jg(n,t){return zr(n,.5,t)}function np(n,t){return hh(n,.5,t)}function*tp(n){for(const t of n)yield*t}function yf(n){return Array.from(tp(n))}function ep(n,t){const e=new Pr;if(t===void 0)for(let o of n)o!=null&&o>=o&&e.set(o,(e.get(o)||0)+1);else{let o=-1;for(let a of n)(a=t(a,++o,n))!=null&&a>=a&&e.set(a,(e.get(a)||0)+1)}let r,i=0;for(const[o,a]of e)a>i&&(i=a,r=o);return r}function rp(n,t=ip){const e=[];let r,i=!1;for(const o of n)i&&e.push(t(r,o)),r=o,i=!0;return e}function ip(n,t){return[n,t]}function zt(n,t,e){n=+n,t=+t,e=(i=arguments.length)<2?(t=n,n=0,1):i<3?1:+e;for(var r=-1,i=Math.max(0,Math.ceil((t-n)/e))|0,o=new Array(i);++r<i;)o[r]=n+r*e;return o}function op(n,t=hn){if(typeof n[Symbol.iterator]!="function")throw new TypeError("values is not iterable");let e=Array.from(n);const r=new Float64Array(e.length);t.length!==2&&(e=e.map(t),t=hn);const i=(u,c)=>t(e[u],e[c]);let o,a;return n=Uint32Array.from(e,(u,c)=>c),n.sort(t===hn?(u,c)=>Le(e[u],e[c]):hf(i)),n.forEach((u,c)=>{const f=i(u,o===void 0?u:o);f>=0?((o===void 0||f>0)&&(o=u,a=c),r[u]=a):r[u]=NaN}),r}function ap(n,t=hn){let e,r=!1;if(t.length===1){let i;for(const o of n){const a=t(o);(r?hn(a,i)<0:hn(a,a)===0)&&(e=o,i=a,r=!0)}}else for(const i of n)(r?t(i,e)<0:t(i,i)===0)&&(e=i,r=!0);return e}function dh(n,t=hn){if(t.length===1)return mf(n,t);let e,r=-1,i=-1;for(const o of n)++i,(r<0?t(o,o)===0:t(o,e)<0)&&(e=o,r=i);return r}function up(n,t=hn){if(t.length===1)return pf(n,t);let e,r=-1,i=-1;for(const o of n)++i,(r<0?t(o,o)===0:t(o,e)>0)&&(e=o,r=i);return r}function fp(n,t){const e=dh(n,t);return e<0?void 0:e}const cp=gh(Math.random);function gh(n){return function(e,r=0,i=e.length){let o=i-(r=+r);for(;o;){const a=n()*o--|0,u=e[o+r];e[o+r]=e[a+r],e[a+r]=u}return e}}function sp(n,t){let e=0;if(t===void 0)for(let r of n)(r=+r)&&(e+=r);else{let r=-1;for(let i of n)(i=+t(i,++r,n))&&(e+=i)}return e}function ph(n){if(!(o=n.length))return[];for(var t=-1,e=Gi(n,lp),r=new Array(e);++t<e;)for(var i=-1,o,a=r[t]=new Array(o);++i<o;)a[i]=n[i][t];return r}function lp(n){return n.length}function hp(){return ph(arguments)}function dp(n,t){if(typeof t!="function")throw new TypeError("test is not a function");let e=-1;for(const r of n)if(!t(r,++e,n))return!1;return!0}function gp(n,t){if(typeof t!="function")throw new TypeError("test is not a function");let e=-1;for(const r of n)if(t(r,++e,n))return!0;return!1}function pp(n,t){if(typeof t!="function")throw new TypeError("test is not a function");const e=[];let r=-1;for(const i of n)t(i,++r,n)&&e.push(i);return e}function mp(n,t){if(typeof n[Symbol.iterator]!="function")throw new TypeError("values is not iterable");if(typeof t!="function")throw new TypeError("mapper is not a function");return Array.from(n,(e,r)=>t(e,r,n))}function yp(n,t,e){if(typeof t!="function")throw new TypeError("reducer is not a function");const r=n[Symbol.iterator]();let i,o,a=-1;if(arguments.length<3){if({done:i,value:e}=r.next(),i)return;++a}for(;{done:i,value:o}=r.next(),!i;)e=t(e,o,++a,n);return e}function _p(n){if(typeof n[Symbol.iterator]!="function")throw new TypeError("values is not iterable");return Array.from(n).reverse()}function vp(n,...t){n=new ie(n);for(const e of t)for(const r of e)n.delete(r);return n}function bp(n,t){const e=t[Symbol.iterator](),r=new ie;for(const i of n){if(r.has(i))return!1;let o,a;for(;({value:o,done:a}=e.next())&&!a;){if(Object.is(i,o))return!1;r.add(o)}}return!0}function wp(n,...t){n=new ie(n),t=t.map(xp);n:for(const e of n)for(const r of t)if(!r.has(e)){n.delete(e);continue n}return n}function xp(n){return n instanceof ie?n:new ie(n)}function mh(n,t){const e=n[Symbol.iterator](),r=new Set;for(const i of t){const o=Rc(i);if(r.has(o))continue;let a,u;for(;{value:a,done:u}=e.next();){if(u)return!1;const c=Rc(a);if(r.add(c),Object.is(o,c))break}}return!0}function Rc(n){return n!==null&&typeof n=="object"?n.valueOf():n}function Mp(n,t){return mh(t,n)}function $p(...n){const t=new ie;for(const e of n)for(const r of e)t.add(r);return t}function Tp(n){return n}var Pi=1,Di=2,gu=3,mr=4,Ic=1e-6;function Ap(n){return"translate("+n+",0)"}function Sp(n){return"translate(0,"+n+")"}function Ep(n){return t=>+n(t)}function kp(n,t){return t=Math.max(0,n.bandwidth()-t*2)/2,n.round()&&(t=Math.round(t)),e=>+n(e)+t}function Np(){return!this.__axis}function qo(n,t){var e=[],r=null,i=null,o=6,a=6,u=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,f=n===Pi||n===mr?-1:1,s=n===mr||n===Di?"x":"y",h=n===Pi||n===gu?Ap:Sp;function l(d){var p=r??(t.ticks?t.ticks.apply(t,e):t.domain()),m=i??(t.tickFormat?t.tickFormat.apply(t,e):Tp),g=Math.max(o,0)+u,y=t.range(),b=+y[0]+c,v=+y[y.length-1]+c,_=(t.bandwidth?kp:Ep)(t.copy(),c),w=d.selection?d.selection():d,M=w.selectAll(".domain").data([null]),k=w.selectAll(".tick").data(p,t).order(),N=k.exit(),T=k.enter().append("g").attr("class","tick"),A=k.select("line"),$=k.select("text");M=M.merge(M.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),k=k.merge(T),A=A.merge(T.append("line").attr("stroke","currentColor").attr(s+"2",f*o)),$=$.merge(T.append("text").attr("fill","currentColor").attr(s,f*g).attr("dy",n===Pi?"0em":n===gu?"0.71em":"0.32em")),d!==w&&(M=M.transition(d),k=k.transition(d),A=A.transition(d),$=$.transition(d),N=N.transition(d).attr("opacity",Ic).attr("transform",function(C){return isFinite(C=_(C))?h(C+c):this.getAttribute("transform")}),T.attr("opacity",Ic).attr("transform",function(C){var R=this.parentNode.__axis;return h((R&&isFinite(R=R(C))?R:_(C))+c)})),N.remove(),M.attr("d",n===mr||n===Di?a?"M"+f*a+","+b+"H"+c+"V"+v+"H"+f*a:"M"+c+","+b+"V"+v:a?"M"+b+","+f*a+"V"+c+"H"+v+"V"+f*a:"M"+b+","+c+"H"+v),k.attr("opacity",1).attr("transform",function(C){return h(_(C)+c)}),A.attr(s+"2",f*o),$.attr(s,f*g).text(m),w.filter(Np).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",n===Di?"start":n===mr?"end":"middle"),w.each(function(){this.__axis=_})}return l.scale=function(d){return arguments.length?(t=d,l):t},l.ticks=function(){return e=Array.from(arguments),l},l.tickArguments=function(d){return arguments.length?(e=d==null?[]:Array.from(d),l):e.slice()},l.tickValues=function(d){return arguments.length?(r=d==null?null:Array.from(d),l):r&&r.slice()},l.tickFormat=function(d){return arguments.length?(i=d,l):i},l.tickSize=function(d){return arguments.length?(o=a=+d,l):o},l.tickSizeInner=function(d){return arguments.length?(o=+d,l):o},l.tickSizeOuter=function(d){return arguments.length?(a=+d,l):a},l.tickPadding=function(d){return arguments.length?(u=+d,l):u},l.offset=function(d){return arguments.length?(c=+d,l):c},l}function Rp(n){return qo(Pi,n)}function Ip(n){return qo(Di,n)}function Cp(n){return qo(gu,n)}function Pp(n){return qo(mr,n)}var Dp={value:()=>{}};function pe(){for(var n=0,t=arguments.length,e={},r;n<t;++n){if(!(r=arguments[n]+"")||r in e||/[\s.]/.test(r))throw new Error("illegal type: "+r);e[r]=[]}return new zi(e)}function zi(n){this._=n}function zp(n,t){return n.trim().split(/^|\s+/).map(function(e){var r="",i=e.indexOf(".");if(i>=0&&(r=e.slice(i+1),e=e.slice(0,i)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:r}})}zi.prototype=pe.prototype={constructor:zi,on:function(n,t){var e=this._,r=zp(n+"",e),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(n=r[o]).type)&&(i=Op(e[i],n.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(i=(n=r[o]).type)e[i]=Cc(e[i],n.name,t);else if(t==null)for(i in e)e[i]=Cc(e[i],n.name,null);return this},copy:function(){var n={},t=this._;for(var e in t)n[e]=t[e].slice();return new zi(n)},call:function(n,t){if((i=arguments.length-2)>0)for(var e=new Array(i),r=0,i,o;r<i;++r)e[r]=arguments[r+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(o=this._[n],r=0,i=o.length;r<i;++r)o[r].value.apply(t,e)},apply:function(n,t,e){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var r=this._[n],i=0,o=r.length;i<o;++i)r[i].value.apply(t,e)}};function Op(n,t){for(var e=0,r=n.length,i;e<r;++e)if((i=n[e]).name===t)return i.value}function Cc(n,t,e){for(var r=0,i=n.length;r<i;++r)if(n[r].name===t){n[r]=Dp,n=n.slice(0,r).concat(n.slice(r+1));break}return e!=null&&n.push({name:t,value:e}),n}var pu="http://www.w3.org/1999/xhtml";const mu={svg:"http://www.w3.org/2000/svg",xhtml:pu,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Kr(n){var t=n+="",e=t.indexOf(":");return e>=0&&(t=n.slice(0,e))!=="xmlns"&&(n=n.slice(e+1)),mu.hasOwnProperty(t)?{space:mu[t],local:n}:n}function Yp(n){return function(){var t=this.ownerDocument,e=this.namespaceURI;return e===pu&&t.documentElement.namespaceURI===pu?t.createElement(n):t.createElementNS(e,n)}}function Fp(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function Lo(n){var t=Kr(n);return(t.local?Fp:Yp)(t)}function qp(){}function Bo(n){return n==null?qp:function(){return this.querySelector(n)}}function Lp(n){typeof n!="function"&&(n=Bo(n));for(var t=this._groups,e=t.length,r=new Array(e),i=0;i<e;++i)for(var o=t[i],a=o.length,u=r[i]=new Array(a),c,f,s=0;s<a;++s)(c=o[s])&&(f=n.call(c,c.__data__,s,o))&&("__data__"in c&&(f.__data__=c.__data__),u[s]=f);return new qn(r,this._parents)}function yh(n){return n==null?[]:Array.isArray(n)?n:Array.from(n)}function Bp(){return[]}function _f(n){return n==null?Bp:function(){return this.querySelectorAll(n)}}function Up(n){return function(){return yh(n.apply(this,arguments))}}function Xp(n){typeof n=="function"?n=Up(n):n=_f(n);for(var t=this._groups,e=t.length,r=[],i=[],o=0;o<e;++o)for(var a=t[o],u=a.length,c,f=0;f<u;++f)(c=a[f])&&(r.push(n.call(c,c.__data__,f,a)),i.push(c));return new qn(r,i)}function vf(n){return function(){return this.matches(n)}}function _h(n){return function(t){return t.matches(n)}}var Hp=Array.prototype.find;function jp(n){return function(){return Hp.call(this.children,n)}}function Wp(){return this.firstElementChild}function Vp(n){return this.select(n==null?Wp:jp(typeof n=="function"?n:_h(n)))}var Gp=Array.prototype.filter;function Zp(){return Array.from(this.children)}function Qp(n){return function(){return Gp.call(this.children,n)}}function Kp(n){return this.selectAll(n==null?Zp:Qp(typeof n=="function"?n:_h(n)))}function Jp(n){typeof n!="function"&&(n=vf(n));for(var t=this._groups,e=t.length,r=new Array(e),i=0;i<e;++i)for(var o=t[i],a=o.length,u=r[i]=[],c,f=0;f<a;++f)(c=o[f])&&n.call(c,c.__data__,f,o)&&u.push(c);return new qn(r,this._parents)}function vh(n){return new Array(n.length)}function n2(){return new qn(this._enter||this._groups.map(vh),this._parents)}function Zi(n,t){this.ownerDocument=n.ownerDocument,this.namespaceURI=n.namespaceURI,this._next=null,this._parent=n,this.__data__=t}Zi.prototype={constructor:Zi,appendChild:function(n){return this._parent.insertBefore(n,this._next)},insertBefore:function(n,t){return this._parent.insertBefore(n,t)},querySelector:function(n){return this._parent.querySelector(n)},querySelectorAll:function(n){return this._parent.querySelectorAll(n)}};function t2(n){return function(){return n}}function e2(n,t,e,r,i,o){for(var a=0,u,c=t.length,f=o.length;a<f;++a)(u=t[a])?(u.__data__=o[a],r[a]=u):e[a]=new Zi(n,o[a]);for(;a<c;++a)(u=t[a])&&(i[a]=u)}function r2(n,t,e,r,i,o,a){var u,c,f=new Map,s=t.length,h=o.length,l=new Array(s),d;for(u=0;u<s;++u)(c=t[u])&&(l[u]=d=a.call(c,c.__data__,u,t)+"",f.has(d)?i[u]=c:f.set(d,c));for(u=0;u<h;++u)d=a.call(n,o[u],u,o)+"",(c=f.get(d))?(r[u]=c,c.__data__=o[u],f.delete(d)):e[u]=new Zi(n,o[u]);for(u=0;u<s;++u)(c=t[u])&&f.get(l[u])===c&&(i[u]=c)}function i2(n){return n.__data__}function o2(n,t){if(!arguments.length)return Array.from(this,i2);var e=t?r2:e2,r=this._parents,i=this._groups;typeof n!="function"&&(n=t2(n));for(var o=i.length,a=new Array(o),u=new Array(o),c=new Array(o),f=0;f<o;++f){var s=r[f],h=i[f],l=h.length,d=a2(n.call(s,s&&s.__data__,f,r)),p=d.length,m=u[f]=new Array(p),g=a[f]=new Array(p),y=c[f]=new Array(l);e(s,h,m,g,y,d,t);for(var b=0,v=0,_,w;b<p;++b)if(_=m[b]){for(b>=v&&(v=b+1);!(w=g[v])&&++v<p;);_._next=w||null}}return a=new qn(a,r),a._enter=u,a._exit=c,a}function a2(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function u2(){return new qn(this._exit||this._groups.map(vh),this._parents)}function f2(n,t,e){var r=this.enter(),i=this,o=this.exit();return typeof n=="function"?(r=n(r),r&&(r=r.selection())):r=r.append(n+""),t!=null&&(i=t(i),i&&(i=i.selection())),e==null?o.remove():e(o),r&&i?r.merge(i).order():i}function c2(n){for(var t=n.selection?n.selection():n,e=this._groups,r=t._groups,i=e.length,o=r.length,a=Math.min(i,o),u=new Array(i),c=0;c<a;++c)for(var f=e[c],s=r[c],h=f.length,l=u[c]=new Array(h),d,p=0;p<h;++p)(d=f[p]||s[p])&&(l[p]=d);for(;c<i;++c)u[c]=e[c];return new qn(u,this._parents)}function s2(){for(var n=this._groups,t=-1,e=n.length;++t<e;)for(var r=n[t],i=r.length-1,o=r[i],a;--i>=0;)(a=r[i])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function l2(n){n||(n=h2);function t(h,l){return h&&l?n(h.__data__,l.__data__):!h-!l}for(var e=this._groups,r=e.length,i=new Array(r),o=0;o<r;++o){for(var a=e[o],u=a.length,c=i[o]=new Array(u),f,s=0;s<u;++s)(f=a[s])&&(c[s]=f);c.sort(t)}return new qn(i,this._parents).order()}function h2(n,t){return n<t?-1:n>t?1:n>=t?0:NaN}function d2(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function g2(){return Array.from(this)}function p2(){for(var n=this._groups,t=0,e=n.length;t<e;++t)for(var r=n[t],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null}function m2(){let n=0;for(const t of this)++n;return n}function y2(){return!this.node()}function _2(n){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var i=t[e],o=0,a=i.length,u;o<a;++o)(u=i[o])&&n.call(u,u.__data__,o,i);return this}function v2(n){return function(){this.removeAttribute(n)}}function b2(n){return function(){this.removeAttributeNS(n.space,n.local)}}function w2(n,t){return function(){this.setAttribute(n,t)}}function x2(n,t){return function(){this.setAttributeNS(n.space,n.local,t)}}function M2(n,t){return function(){var e=t.apply(this,arguments);e==null?this.removeAttribute(n):this.setAttribute(n,e)}}function $2(n,t){return function(){var e=t.apply(this,arguments);e==null?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,e)}}function T2(n,t){var e=Kr(n);if(arguments.length<2){var r=this.node();return e.local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}return this.each((t==null?e.local?b2:v2:typeof t=="function"?e.local?$2:M2:e.local?x2:w2)(e,t))}function bf(n){return n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView}function A2(n){return function(){this.style.removeProperty(n)}}function S2(n,t,e){return function(){this.style.setProperty(n,t,e)}}function E2(n,t,e){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(n):this.style.setProperty(n,r,e)}}function k2(n,t,e){return arguments.length>1?this.each((t==null?A2:typeof t=="function"?E2:S2)(n,t,e??"")):ue(this.node(),n)}function ue(n,t){return n.style.getPropertyValue(t)||bf(n).getComputedStyle(n,null).getPropertyValue(t)}function N2(n){return function(){delete this[n]}}function R2(n,t){return function(){this[n]=t}}function I2(n,t){return function(){var e=t.apply(this,arguments);e==null?delete this[n]:this[n]=e}}function C2(n,t){return arguments.length>1?this.each((t==null?N2:typeof t=="function"?I2:R2)(n,t)):this.node()[n]}function bh(n){return n.trim().split(/^|\s+/)}function wf(n){return n.classList||new wh(n)}function wh(n){this._node=n,this._names=bh(n.getAttribute("class")||"")}wh.prototype={add:function(n){var t=this._names.indexOf(n);t<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var t=this._names.indexOf(n);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function xh(n,t){for(var e=wf(n),r=-1,i=t.length;++r<i;)e.add(t[r])}function Mh(n,t){for(var e=wf(n),r=-1,i=t.length;++r<i;)e.remove(t[r])}function P2(n){return function(){xh(this,n)}}function D2(n){return function(){Mh(this,n)}}function z2(n,t){return function(){(t.apply(this,arguments)?xh:Mh)(this,n)}}function O2(n,t){var e=bh(n+"");if(arguments.length<2){for(var r=wf(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each((typeof t=="function"?z2:t?P2:D2)(e,t))}function Y2(){this.textContent=""}function F2(n){return function(){this.textContent=n}}function q2(n){return function(){var t=n.apply(this,arguments);this.textContent=t??""}}function L2(n){return arguments.length?this.each(n==null?Y2:(typeof n=="function"?q2:F2)(n)):this.node().textContent}function B2(){this.innerHTML=""}function U2(n){return function(){this.innerHTML=n}}function X2(n){return function(){var t=n.apply(this,arguments);this.innerHTML=t??""}}function H2(n){return arguments.length?this.each(n==null?B2:(typeof n=="function"?X2:U2)(n)):this.node().innerHTML}function j2(){this.nextSibling&&this.parentNode.appendChild(this)}function W2(){return this.each(j2)}function V2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function G2(){return this.each(V2)}function Z2(n){var t=typeof n=="function"?n:Lo(n);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Q2(){return null}function K2(n,t){var e=typeof n=="function"?n:Lo(n),r=t==null?Q2:typeof t=="function"?t:Bo(t);return this.select(function(){return this.insertBefore(e.apply(this,arguments),r.apply(this,arguments)||null)})}function J2(){var n=this.parentNode;n&&n.removeChild(this)}function nm(){return this.each(J2)}function tm(){var n=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(n,this.nextSibling):n}function em(){var n=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(n,this.nextSibling):n}function rm(n){return this.select(n?em:tm)}function im(n){return arguments.length?this.property("__data__",n):this.node().__data__}function om(n){return function(t){n.call(this,t,this.__data__)}}function am(n){return n.trim().split(/^|\s+/).map(function(t){var e="",r=t.indexOf(".");return r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),{type:t,name:e}})}function um(n){return function(){var t=this.__on;if(t){for(var e=0,r=-1,i=t.length,o;e<i;++e)o=t[e],(!n.type||o.type===n.type)&&o.name===n.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function fm(n,t,e){return function(){var r=this.__on,i,o=om(t);if(r){for(var a=0,u=r.length;a<u;++a)if((i=r[a]).type===n.type&&i.name===n.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=e),i.value=t;return}}this.addEventListener(n.type,o,e),i={type:n.type,name:n.name,value:t,listener:o,options:e},r?r.push(i):this.__on=[i]}}function cm(n,t,e){var r=am(n+""),i,o=r.length,a;if(arguments.length<2){var u=this.node().__on;if(u){for(var c=0,f=u.length,s;c<f;++c)for(i=0,s=u[c];i<o;++i)if((a=r[i]).type===s.type&&a.name===s.name)return s.value}return}for(u=t?fm:um,i=0;i<o;++i)this.each(u(r[i],t,e));return this}function $h(n,t,e){var r=bf(n),i=r.CustomEvent;typeof i=="function"?i=new i(t,e):(i=r.document.createEvent("Event"),e?(i.initEvent(t,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(t,!1,!1)),n.dispatchEvent(i)}function sm(n,t){return function(){return $h(this,n,t)}}function lm(n,t){return function(){return $h(this,n,t.apply(this,arguments))}}function hm(n,t){return this.each((typeof t=="function"?lm:sm)(n,t))}function*dm(){for(var n=this._groups,t=0,e=n.length;t<e;++t)for(var r=n[t],i=0,o=r.length,a;i<o;++i)(a=r[i])&&(yield a)}var xf=[null];function qn(n,t){this._groups=n,this._parents=t}function me(){return new qn([[document.documentElement]],xf)}function gm(){return this}qn.prototype=me.prototype={constructor:qn,select:Lp,selectAll:Xp,selectChild:Vp,selectChildren:Kp,filter:Jp,data:o2,enter:n2,exit:u2,join:f2,merge:c2,selection:gm,order:s2,sort:l2,call:d2,nodes:g2,node:p2,size:m2,empty:y2,each:_2,attr:T2,style:k2,property:C2,classed:O2,text:L2,html:H2,raise:W2,lower:G2,append:Z2,insert:K2,remove:nm,clone:rm,datum:im,on:cm,dispatch:hm,[Symbol.iterator]:dm};function X(n){return typeof n=="string"?new qn([[document.querySelector(n)]],[document.documentElement]):new qn([[n]],xf)}function pm(n){return X(Lo(n).call(document.documentElement))}var mm=0;function Th(){return new yu}function yu(){this._="@"+(++mm).toString(36)}yu.prototype=Th.prototype={constructor:yu,get:function(n){for(var t=this._;!(t in n);)if(!(n=n.parentNode))return;return n[t]},set:function(n,t){return n[this._]=t},remove:function(n){return this._ in n&&delete n[this._]},toString:function(){return this._}};function Ah(n){let t;for(;t=n.sourceEvent;)n=t;return n}function wn(n,t){if(n=Ah(n),t===void 0&&(t=n.currentTarget),t){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();return r.x=n.clientX,r.y=n.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[n.clientX-i.left-t.clientLeft,n.clientY-i.top-t.clientTop]}}return[n.pageX,n.pageY]}function ym(n,t){return n.target&&(n=Ah(n),t===void 0&&(t=n.currentTarget),n=n.touches||[n]),Array.from(n,e=>wn(e,t))}function _m(n){return typeof n=="string"?new qn([document.querySelectorAll(n)],[document.documentElement]):new qn([yh(n)],xf)}const vm={passive:!1},Or={capture:!0,passive:!1};function Sa(n){n.stopImmediatePropagation()}function De(n){n.preventDefault(),n.stopImmediatePropagation()}function Uo(n){var t=n.document.documentElement,e=X(n).on("dragstart.drag",De,Or);"onselectstart"in t?e.on("selectstart.drag",De,Or):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Xo(n,t){var e=n.document.documentElement,r=X(n).on("dragstart.drag",null);t&&(r.on("click.drag",De,Or),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in e?r.on("selectstart.drag",null):(e.style.MozUserSelect=e.__noselect,delete e.__noselect)}const hi=n=>()=>n;function _u(n,{sourceEvent:t,subject:e,target:r,identifier:i,active:o,x:a,y:u,dx:c,dy:f,dispatch:s}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:s}})}_u.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function bm(n){return!n.ctrlKey&&!n.button}function wm(){return this.parentNode}function xm(n,t){return t??{x:n.x,y:n.y}}function Mm(){return navigator.maxTouchPoints||"ontouchstart"in this}function Sh(){var n=bm,t=wm,e=xm,r=Mm,i={},o=pe("start","drag","end"),a=0,u,c,f,s,h=0;function l(_){_.on("mousedown.drag",d).filter(r).on("touchstart.drag",g).on("touchmove.drag",y,vm).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(_,w){if(!(s||!n.call(this,_,w))){var M=v(this,t.call(this,_,w),_,w,"mouse");M&&(X(_.view).on("mousemove.drag",p,Or).on("mouseup.drag",m,Or),Uo(_.view),Sa(_),f=!1,u=_.clientX,c=_.clientY,M("start",_))}}function p(_){if(De(_),!f){var w=_.clientX-u,M=_.clientY-c;f=w*w+M*M>h}i.mouse("drag",_)}function m(_){X(_.view).on("mousemove.drag mouseup.drag",null),Xo(_.view,f),De(_),i.mouse("end",_)}function g(_,w){if(n.call(this,_,w)){var M=_.changedTouches,k=t.call(this,_,w),N=M.length,T,A;for(T=0;T<N;++T)(A=v(this,k,_,w,M[T].identifier,M[T]))&&(Sa(_),A("start",_,M[T]))}}function y(_){var w=_.changedTouches,M=w.length,k,N;for(k=0;k<M;++k)(N=i[w[k].identifier])&&(De(_),N("drag",_,w[k]))}function b(_){var w=_.changedTouches,M=w.length,k,N;for(s&&clearTimeout(s),s=setTimeout(function(){s=null},500),k=0;k<M;++k)(N=i[w[k].identifier])&&(Sa(_),N("end",_,w[k]))}function v(_,w,M,k,N,T){var A=o.copy(),$=wn(T||M,w),C,R,x;if((x=e.call(_,new _u("beforestart",{sourceEvent:M,target:l,identifier:N,active:a,x:$[0],y:$[1],dx:0,dy:0,dispatch:A}),k))!=null)return C=x.x-$[0]||0,R=x.y-$[1]||0,function E(S,I,D){var P=$,O;switch(S){case"start":i[N]=E,O=a++;break;case"end":delete i[N],--a;case"drag":$=wn(D||I,w),O=a;break}A.call(S,_,new _u(S,{sourceEvent:I,subject:x,target:l,identifier:N,active:O,x:$[0]+C,y:$[1]+R,dx:$[0]-P[0],dy:$[1]-P[1],dispatch:A}),k)}}return l.filter=function(_){return arguments.length?(n=typeof _=="function"?_:hi(!!_),l):n},l.container=function(_){return arguments.length?(t=typeof _=="function"?_:hi(_),l):t},l.subject=function(_){return arguments.length?(e=typeof _=="function"?_:hi(_),l):e},l.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:hi(!!_),l):r},l.on=function(){var _=o.on.apply(o,arguments);return _===o?l:_},l.clickDistance=function(_){return arguments.length?(h=(_=+_)*_,l):Math.sqrt(h)},l}function rr(n,t,e){n.prototype=t.prototype=e,e.constructor=n}function Jr(n,t){var e=Object.create(n.prototype);for(var r in t)e[r]=t[r];return e}function Xt(){}var fe=.7,Be=1/fe,ze="\\s*([+-]?\\d+)\\s*",Yr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",$m=/^#([0-9a-f]{3,8})$/,Tm=new RegExp(`^rgb\\(${ze},${ze},${ze}\\)$`),Am=new RegExp(`^rgb\\(${dt},${dt},${dt}\\)$`),Sm=new RegExp(`^rgba\\(${ze},${ze},${ze},${Yr}\\)$`),Em=new RegExp(`^rgba\\(${dt},${dt},${dt},${Yr}\\)$`),km=new RegExp(`^hsl\\(${Yr},${dt},${dt}\\)$`),Nm=new RegExp(`^hsla\\(${Yr},${dt},${dt},${Yr}\\)$`),Pc={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};rr(Xt,qt,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:Dc,formatHex:Dc,formatHex8:Rm,formatHsl:Im,formatRgb:zc,toString:zc});function Dc(){return this.rgb().formatHex()}function Rm(){return this.rgb().formatHex8()}function Im(){return Eh(this).formatHsl()}function zc(){return this.rgb().formatRgb()}function qt(n){var t,e;return n=(n+"").trim().toLowerCase(),(t=$m.exec(n))?(e=t[1].length,t=parseInt(t[1],16),e===6?Oc(t):e===3?new xn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):e===8?di(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):e===4?di(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Tm.exec(n))?new xn(t[1],t[2],t[3],1):(t=Am.exec(n))?new xn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Sm.exec(n))?di(t[1],t[2],t[3],t[4]):(t=Em.exec(n))?di(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=km.exec(n))?qc(t[1],t[2]/100,t[3]/100,1):(t=Nm.exec(n))?qc(t[1],t[2]/100,t[3]/100,t[4]):Pc.hasOwnProperty(n)?Oc(Pc[n]):n==="transparent"?new xn(NaN,NaN,NaN,0):null}function Oc(n){return new xn(n>>16&255,n>>8&255,n&255,1)}function di(n,t,e,r){return r<=0&&(n=t=e=NaN),new xn(n,t,e,r)}function Mf(n){return n instanceof Xt||(n=qt(n)),n?(n=n.rgb(),new xn(n.r,n.g,n.b,n.opacity)):new xn}function Ue(n,t,e,r){return arguments.length===1?Mf(n):new xn(n,t,e,r??1)}function xn(n,t,e,r){this.r=+n,this.g=+t,this.b=+e,this.opacity=+r}rr(xn,Ue,Jr(Xt,{brighter(n){return n=n==null?Be:Math.pow(Be,n),new xn(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?fe:Math.pow(fe,n),new xn(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new xn(te(this.r),te(this.g),te(this.b),Qi(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:Yc,formatHex:Yc,formatHex8:Cm,formatRgb:Fc,toString:Fc}));function Yc(){return`#${Jt(this.r)}${Jt(this.g)}${Jt(this.b)}`}function Cm(){return`#${Jt(this.r)}${Jt(this.g)}${Jt(this.b)}${Jt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Fc(){const n=Qi(this.opacity);return`${n===1?"rgb(":"rgba("}${te(this.r)}, ${te(this.g)}, ${te(this.b)}${n===1?")":`, ${n})`}`}function Qi(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function te(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function Jt(n){return n=te(n),(n<16?"0":"")+n.toString(16)}function qc(n,t,e,r){return r<=0?n=t=e=NaN:e<=0||e>=1?n=t=NaN:t<=0&&(n=NaN),new rt(n,t,e,r)}function Eh(n){if(n instanceof rt)return new rt(n.h,n.s,n.l,n.opacity);if(n instanceof Xt||(n=qt(n)),!n)return new rt;if(n instanceof rt)return n;n=n.rgb();var t=n.r/255,e=n.g/255,r=n.b/255,i=Math.min(t,e,r),o=Math.max(t,e,r),a=NaN,u=o-i,c=(o+i)/2;return u?(t===o?a=(e-r)/u+(e<r)*6:e===o?a=(r-t)/u+2:a=(t-e)/u+4,u/=c<.5?o+i:2-o-i,a*=60):u=c>0&&c<1?0:a,new rt(a,u,c,n.opacity)}function Ki(n,t,e,r){return arguments.length===1?Eh(n):new rt(n,t,e,r??1)}function rt(n,t,e,r){this.h=+n,this.s=+t,this.l=+e,this.opacity=+r}rr(rt,Ki,Jr(Xt,{brighter(n){return n=n==null?Be:Math.pow(Be,n),new rt(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?fe:Math.pow(fe,n),new rt(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,t=isNaN(n)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*t,i=2*e-r;return new xn(Ea(n>=240?n-240:n+120,i,r),Ea(n,i,r),Ea(n<120?n+240:n-120,i,r),this.opacity)},clamp(){return new rt(Lc(this.h),gi(this.s),gi(this.l),Qi(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 n=Qi(this.opacity);return`${n===1?"hsl(":"hsla("}${Lc(this.h)}, ${gi(this.s)*100}%, ${gi(this.l)*100}%${n===1?")":`, ${n})`}`}}));function Lc(n){return n=(n||0)%360,n<0?n+360:n}function gi(n){return Math.max(0,Math.min(1,n||0))}function Ea(n,t,e){return(n<60?t+(e-t)*n/60:n<180?e:n<240?t+(e-t)*(240-n)/60:t)*255}const kh=Math.PI/180,Nh=180/Math.PI,Ji=18,Rh=.96422,Ih=1,Ch=.82521,Ph=4/29,Oe=6/29,Dh=3*Oe*Oe,Pm=Oe*Oe*Oe;function zh(n){if(n instanceof at)return new at(n.l,n.a,n.b,n.opacity);if(n instanceof lt)return Yh(n);n instanceof xn||(n=Mf(n));var t=Ia(n.r),e=Ia(n.g),r=Ia(n.b),i=ka((.2225045*t+.7168786*e+.0606169*r)/Ih),o,a;return t===e&&e===r?o=a=i:(o=ka((.4360747*t+.3850649*e+.1430804*r)/Rh),a=ka((.0139322*t+.0971045*e+.7141733*r)/Ch)),new at(116*i-16,500*(o-i),200*(i-a),n.opacity)}function Dm(n,t){return new at(n,0,0,t??1)}function no(n,t,e,r){return arguments.length===1?zh(n):new at(n,t,e,r??1)}function at(n,t,e,r){this.l=+n,this.a=+t,this.b=+e,this.opacity=+r}rr(at,no,Jr(Xt,{brighter(n){return new at(this.l+Ji*(n??1),this.a,this.b,this.opacity)},darker(n){return new at(this.l-Ji*(n??1),this.a,this.b,this.opacity)},rgb(){var n=(this.l+16)/116,t=isNaN(this.a)?n:n+this.a/500,e=isNaN(this.b)?n:n-this.b/200;return t=Rh*Na(t),n=Ih*Na(n),e=Ch*Na(e),new xn(Ra(3.1338561*t-1.6168667*n-.4906146*e),Ra(-.9787684*t+1.9161415*n+.033454*e),Ra(.0719453*t-.2289914*n+1.4052427*e),this.opacity)}}));function ka(n){return n>Pm?Math.pow(n,1/3):n/Dh+Ph}function Na(n){return n>Oe?n*n*n:Dh*(n-Ph)}function Ra(n){return 255*(n<=.0031308?12.92*n:1.055*Math.pow(n,1/2.4)-.055)}function Ia(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Oh(n){if(n instanceof lt)return new lt(n.h,n.c,n.l,n.opacity);if(n instanceof at||(n=zh(n)),n.a===0&&n.b===0)return new lt(NaN,0<n.l&&n.l<100?0:NaN,n.l,n.opacity);var t=Math.atan2(n.b,n.a)*Nh;return new lt(t<0?t+360:t,Math.sqrt(n.a*n.a+n.b*n.b),n.l,n.opacity)}function zm(n,t,e,r){return arguments.length===1?Oh(n):new lt(e,t,n,r??1)}function to(n,t,e,r){return arguments.length===1?Oh(n):new lt(n,t,e,r??1)}function lt(n,t,e,r){this.h=+n,this.c=+t,this.l=+e,this.opacity=+r}function Yh(n){if(isNaN(n.h))return new at(n.l,0,0,n.opacity);var t=n.h*kh;return new at(n.l,Math.cos(t)*n.c,Math.sin(t)*n.c,n.opacity)}rr(lt,to,Jr(Xt,{brighter(n){return new lt(this.h,this.c,this.l+Ji*(n??1),this.opacity)},darker(n){return new lt(this.h,this.c,this.l-Ji*(n??1),this.opacity)},rgb(){return Yh(this).rgb()}}));var Fh=-.14861,$f=1.78277,Tf=-.29227,Ho=-.90649,Fr=1.97294,Bc=Fr*Ho,Uc=Fr*$f,Xc=$f*Tf-Ho*Fh;function Om(n){if(n instanceof ee)return new ee(n.h,n.s,n.l,n.opacity);n instanceof xn||(n=Mf(n));var t=n.r/255,e=n.g/255,r=n.b/255,i=(Xc*r+Bc*t-Uc*e)/(Xc+Bc-Uc),o=r-i,a=(Fr*(e-i)-Tf*o)/Ho,u=Math.sqrt(a*a+o*o)/(Fr*i*(1-i)),c=u?Math.atan2(a,o)*Nh-120:NaN;return new ee(c<0?c+360:c,u,i,n.opacity)}function ut(n,t,e,r){return arguments.length===1?Om(n):new ee(n,t,e,r??1)}function ee(n,t,e,r){this.h=+n,this.s=+t,this.l=+e,this.opacity=+r}rr(ee,ut,Jr(Xt,{brighter(n){return n=n==null?Be:Math.pow(Be,n),new ee(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?fe:Math.pow(fe,n),new ee(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=isNaN(this.h)?0:(this.h+120)*kh,t=+this.l,e=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(n),i=Math.sin(n);return new xn(255*(t+e*(Fh*r+$f*i)),255*(t+e*(Tf*r+Ho*i)),255*(t+e*(Fr*r)),this.opacity)}}));function qh(n,t,e,r,i){var o=n*n,a=o*n;return((1-3*n+3*o-a)*t+(4-6*o+3*a)*e+(1+3*n+3*o-3*a)*r+a*i)/6}function Lh(n){var t=n.length-1;return function(e){var r=e<=0?e=0:e>=1?(e=1,t-1):Math.floor(e*t),i=n[r],o=n[r+1],a=r>0?n[r-1]:2*i-o,u=r<t-1?n[r+2]:2*o-i;return qh((e-r/t)*t,a,i,o,u)}}function Bh(n){var t=n.length;return function(e){var r=Math.floor(((e%=1)<0?++e:e)*t),i=n[(r+t-1)%t],o=n[r%t],a=n[(r+1)%t],u=n[(r+2)%t];return qh((e-r/t)*t,i,o,a,u)}}const jo=n=>()=>n;function Uh(n,t){return function(e){return n+e*t}}function Ym(n,t,e){return n=Math.pow(n,e),t=Math.pow(t,e)-n,e=1/e,function(r){return Math.pow(n+r*t,e)}}function Wo(n,t){var e=t-n;return e?Uh(n,e>180||e<-180?e-360*Math.round(e/360):e):jo(isNaN(n)?t:n)}function Fm(n){return(n=+n)==1?Mn:function(t,e){return e-t?Ym(t,e,n):jo(isNaN(t)?e:t)}}function Mn(n,t){var e=t-n;return e?Uh(n,e):jo(isNaN(n)?t:n)}const qr=(function n(t){var e=Fm(t);function r(i,o){var a=e((i=Ue(i)).r,(o=Ue(o)).r),u=e(i.g,o.g),c=e(i.b,o.b),f=Mn(i.opacity,o.opacity);return function(s){return i.r=a(s),i.g=u(s),i.b=c(s),i.opacity=f(s),i+""}}return r.gamma=n,r})(1);function Xh(n){return function(t){var e=t.length,r=new Array(e),i=new Array(e),o=new Array(e),a,u;for(a=0;a<e;++a)u=Ue(t[a]),r[a]=u.r||0,i[a]=u.g||0,o[a]=u.b||0;return r=n(r),i=n(i),o=n(o),u.opacity=1,function(c){return u.r=r(c),u.g=i(c),u.b=o(c),u+""}}}var Hh=Xh(Lh),qm=Xh(Bh);function Af(n,t){t||(t=[]);var e=n?Math.min(t.length,n.length):0,r=t.slice(),i;return function(o){for(i=0;i<e;++i)r[i]=n[i]*(1-o)+t[i]*o;return r}}function jh(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Lm(n,t){return(jh(t)?Af:Wh)(n,t)}function Wh(n,t){var e=t?t.length:0,r=n?Math.min(e,n.length):0,i=new Array(r),o=new Array(e),a;for(a=0;a<r;++a)i[a]=Ht(n[a],t[a]);for(;a<e;++a)o[a]=t[a];return function(u){for(a=0;a<r;++a)o[a]=i[a](u);return o}}function Vh(n,t){var e=new Date;return n=+n,t=+t,function(r){return e.setTime(n*(1-r)+t*r),e}}function Kn(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function Gh(n,t){var e={},r={},i;(n===null||typeof n!="object")&&(n={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in n?e[i]=Ht(n[i],t[i]):r[i]=t[i];return function(o){for(i in e)r[