UNPKG

32.5 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Scale={})}(this,function(t){"use strict";function l(t,...e){return e.reduce((e,n)=>t=>e(n(t)),t)}function h(e,n){return n-e?t=>(t-e)/(n-e):t=>.5}function c(t,e,n,r,o){let a=n||0,i=r||t.length;for(var s=o||(t=>t);a<i;){var u=Math.floor((a+i)/2);s(t[u])>e?i=u:a=u+1}return a}const F=Math.sqrt(50),R=Math.sqrt(10),P=Math.sqrt(2);function u(t,e,n){e=(e-t)/Math.max(0,n),t=Math.floor(Math.log(e)/Math.LN10),n=e/10**t;return 0<=t?(n>=F?10:n>=R?5:n>=P?2:1)*10**t:-(10**-t)/(n>=F?10:n>=R?5:n>=P?2:1)}function K(t,e,n){n=Math.abs(e-t)/Math.max(0,n);let r=10**Math.floor(Math.log(n)/Math.LN10);n/=r;return n>=F?r*=10:n>=R?r*=5:n>=P&&(r*=2),e<t?-r:r}const q=(t,e,n=5)=>{t=[t,e];let r=0,o=t.length-1,a=t[r],i=t[o],s;return i<a&&([a,i]=[i,a],[r,o]=[o,r]),0<(s=u(a,i,n))?(a=Math.floor(a/s)*s,i=Math.ceil(i/s)*s,s=u(a,i,n)):s<0&&(a=Math.ceil(a*s)/s,i=Math.floor(i*s)/s,s=u(a,i,n)),0<s?(t[r]=Math.floor(a/s)*s,t[o]=Math.ceil(i/s)*s):s<0&&(t[r]=Math.ceil(a*s)/s,t[o]=Math.floor(i*s)/s),t},n=1e3,r=6e4,o=36e5,a=24*o,i=7*a;var B=30*a,E=365*a;function e(t,n,s,r){const o=(t,e)=>{let n=e;for(;n&&r(t)%e!=0;)s(t,-1),--n;return t},u=(t,e)=>{e&&o(t,e),n(t)};const l=(t,e)=>{t=new Date(+t-1);return u(t,e),s(t,e),u(t),t};return{ceil:l,floor:(t,e)=>{t=new Date(+t);return u(t,e),t},range:(t,e,n,r)=>{for(var o=[],a=Math.floor(n),i=r?l(t,n):l(t);i<e;s(i,a),u(i))o.push(new Date(+i));return o},duration:t}}var s=e(1,t=>t,(t,e=1)=>{t.setTime(+t+e)},t=>t.getTime()),d=e(n,t=>{t.setMilliseconds(0)},(t,e=1)=>{t.setTime(+t+n*e)},t=>t.getSeconds()),g=e(r,t=>{t.setSeconds(0,0)},(t,e=1)=>{t.setTime(+t+r*e)},t=>t.getMinutes()),p=e(o,t=>{t.setMinutes(0,0,0)},(t,e=1)=>{t.setTime(+t+o*e)},t=>t.getHours()),f=e(a,t=>{t.setHours(0,0,0,0)},(t,e=1)=>{t.setTime(+t+a*e)},t=>t.getDate()-1);const W=e(B,t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e=1)=>{var n=t.getMonth();t.setMonth(n+e)},t=>t.getMonth());var $=e(i,t=>{t.setDate(t.getDate()-t.getDay()%7),t.setHours(0,0,0,0)},(t,e=1)=>{t.setDate(t.getDate()+7*e)},t=>{var e=W.floor(t),t=new Date(+t);return Math.floor((+t-+e)/i)}),_=e(E,t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e=1)=>{var n=t.getFullYear();t.setFullYear(n+e)},t=>t.getFullYear());const z={millisecond:s,second:d,minute:g,hour:p,day:f,week:$,month:W,year:_};s=e(1,t=>t,(t,e=1)=>{t.setTime(+t+e)},t=>t.getTime()),d=e(n,t=>{t.setUTCMilliseconds(0)},(t,e=1)=>{t.setTime(+t+n*e)},t=>t.getUTCSeconds()),g=e(r,t=>{t.setUTCSeconds(0,0)},(t,e=1)=>{t.setTime(+t+r*e)},t=>t.getUTCMinutes()),p=e(o,t=>{t.setUTCMinutes(0,0,0)},(t,e=1)=>{t.setTime(+t+o*e)},t=>t.getUTCHours()),f=e(a,t=>{t.setUTCHours(0,0,0,0)},(t,e=1)=>{t.setTime(+t+a*e)},t=>t.getUTCDate()-1);const L=e(B,t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e=1)=>{var n=t.getUTCMonth();t.setUTCMonth(n+e)},t=>t.getUTCMonth());$=e(i,t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7)%7),t.setUTCHours(0,0,0,0)},(t,e=1)=>{t.setTime(+t+i*e)},t=>{var e=L.floor(t),t=new Date(+t);return Math.floor((+t-+e)/i)}),_=e(E,t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e=1)=>{var n=t.getUTCFullYear();t.setUTCFullYear(n+e)},t=>t.getUTCFullYear());const Z={millisecond:s,second:d,minute:g,hour:p,day:f,week:$,month:L,year:_};function J(t,e,n,r,o){var t=+t,e=+e,{tickIntervals:o,year:a,millisecond:i}=function(t){var{year:t,month:e,week:n,day:r,hour:o,minute:a,second:i,millisecond:s}=t?Z:z;return{tickIntervals:[[i,1],[i,5],[i,15],[i,30],[a,1],[a,5],[a,15],[a,30],[o,1],[o,3],[o,6],[o,12],[r,1],[r,2],[n,1],[e,1],[e,3],[t,1]],year:t,millisecond:s}}(o),s=([t,e])=>t.duration*e,n=r?(e-t)/r:n||5,u=r||(e-t)/n,l=o.length,h=c(o,u,0,l,s);let d;return d=h===l?[a,K(t/a.duration,e/a.duration,n)]:h?([l,a]=u/s(o[h-1])<s(o[h])/u?o[h-1]:o[h],[l,r?Math.ceil(r/l.duration):a]):[i,Math.max(K(t,e,n),1)]}const Q=(t,e,n,r,o)=>{var a=e<t,i=a?e:t,t=a?t:e,[e,n]=J(i,t,n,r,o),r=[e.floor(i,n),e.ceil(t,n)];return a?r.reverse():r};var V=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},G=function(t){return null==t},X={}.toString,tt=function(t,e){return X.call(t)==="[object "+e+"]"},et=function(t){return Array.isArray?Array.isArray(t):tt(t,"Array")},nt=function(t){return"object"==typeof t&&null!==t},rt=function(t){if(!nt(t)||!tt(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},m=function(t){return tt(t,"Number")},ot=function(t){return null===t},at=function(t){return void 0===t},it=5;function st(t,e,n,r){for(var o in n=n||0,r=r||it,e){var a;!function(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}(e,o)||(null!==(a=e[o])&&rt(a)?(rt(t[o])||(t[o]={}),n<r?st(t[o],a,n+1,r):t[o]=e[o]):et(a)?(t[o]=[],t[o]=t[o].concat(a)):void 0!==a&&(t[o]=a))}}function v(t){return t}var ut=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)st(t,e[r]);return t},lt=function(t,e){if(!V(t))return-1;var n=Array.prototype.indexOf;if(n)return n.call(t,e);for(var r=-1,o=0;o<t.length;o++)if(t[o]===e){r=o;break}return r};function ht(t){return G(t)?0:(V(t)?t:Object.keys(t)).length}function dt(t,e,n,r){var o,a=arguments.length,i=a<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;0<=s;s--)(o=t[s])&&(i=(a<3?o(i):3<a?o(e,n,i):o(e,n))||i);return 3<a&&i&&Object.defineProperty(e,n,i),i}function M(t){return!at(t)&&!ot(t)&&!Number.isNaN(t)}const ct=e=>t=>-e(-t),gt=(t,e)=>{const n=Math.log(t);t=t===Math.E?Math.log:10===t?Math.log10:2===t?Math.log2:t=>Math.log(t)/n;return e?ct(t):t},pt=(e,t)=>{var n=e===Math.E?Math.exp:t=>e**t;return t?ct(n):n},ft=(t,e,n,r)=>{var o=t<0,a=gt(r,o),r=pt(r,o),o=e<t,i=o?t:e,e=[r(Math.floor(a(o?e:t))),r(Math.ceil(a(i)))];return o?e.reverse():e};function mt(e,i){return t=>{t.prototype.rescale=function(){this.initRange(),this.nice();var[t]=this.chooseTransforms();this.composeOutput(t,this.chooseClamp(t))},t.prototype.initRange=function(){var t=this.options["interpolator"];this.options.range=e(t)},t.prototype.composeOutput=function(t,e){var n,{domain:r,interpolator:o,round:a}=this.getOptions(),r=i(r.map(t)),a=a?(n=o,t=>{t=n(t);return m(t)?Math.round(t):t}):o;this.output=l(a,r,e,t)},t.prototype.invert=void 0}}var y,s={exports:{}},d={exports:{}},vt=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||0<=t.length&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},Mt=Array.prototype.concat,yt=Array.prototype.slice,kt=d.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var o=t[n];vt(o)?e=Mt.call(e,yt.call(o)):e.push(o)}return e},k=(kt.wrap=function(t){return function(){return t(kt(arguments))}},{aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),b=d.exports,bt=Object.hasOwnProperty,wt=Object.create(null);for(y in k)bt.call(k,y)&&(wt[k[y]]=y);var w=s.exports={to:{},get:{}};function D(t,e,n){return Math.min(Math.max(e,t),n)}function O(t){t=Math.round(t).toString(16).toUpperCase();return t.length<2?"0"+t:t}w.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=w.get.hsl(t),n="hsl";break;case"hwb":e=w.get.hwb(t),n="hwb";break;default:e=w.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},w.get.rgb=function(t){if(!t)return null;var e,n,r,o=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var a=2*n;o[n]=parseInt(e.slice(a,2+a),16)}r&&(o[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)o[n]=parseInt(e[n]+e[n],16);r&&(o[3]=parseInt(r+r,16)/255)}else{if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/))for(n=0;n<3;n++)o[n]=parseInt(e[n+1],0);else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:bt.call(k,e[1])?((o=k[e[1]])[3]=1,o):null:null;for(n=0;n<3;n++)o[n]=Math.round(2.55*parseFloat(e[n+1]))}e[4]&&(e[5]?o[3]=.01*parseFloat(e[4]):o[3]=parseFloat(e[4]))}for(n=0;n<3;n++)o[n]=D(o[n],0,255);return o[3]=D(o[3],0,1),o},w.get.hsl=function(t){var e;return(t=t&&t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/))?(e=parseFloat(t[4]),[(parseFloat(t[1])%360+360)%360,D(parseFloat(t[2]),0,100),D(parseFloat(t[3]),0,100),D(isNaN(e)?1:e,0,1)]):null},w.get.hwb=function(t){var e;return(t=t&&t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/))?(e=parseFloat(t[4]),[(parseFloat(t[1])%360+360)%360,D(parseFloat(t[2]),0,100),D(parseFloat(t[3]),0,100),D(isNaN(e)?1:e,0,1)]):null},w.to.hex=function(){var t=b(arguments);return"#"+O(t[0])+O(t[1])+O(t[2])+(t[3]<1?O(Math.round(255*t[3])):"")},w.to.rgb=function(){var t=b(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},w.to.rgb.percent=function(){var t=b(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},w.to.hsl=function(){var t=b(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},w.to.hwb=function(){var t=b(arguments),e="";return 4<=t.length&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},w.to.keyword=function(t){return wt[t.slice(0,3)]};var Dt=s.exports;function Ot(t,e,n){let r=n;return r<0&&(r+=1),1<r&&--r,r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function Tt(t){var e,n,r,t=Dt.get(t);return t?({model:t,value:e}=t,"rgb"===t?e:"hsl"===t?(e=(t=e)[0]/360,n=t[1]/100,r=t[2]/100,t=t[3],0==n?[255*r,255*r,255*r,t]:[255*Ot(n=2*r-(r=r<.5?r*(1+n):r+n-r*n),r,e+1/3),255*Ot(n,r,e),255*Ot(n,r,e-1/3),t]):null):null}const T=(e,n)=>t=>e*(1-t)+n*t,xt=(t,e)=>{const u=Tt(t),l=Tt(e);return null===u||null===l?u?()=>t:()=>e:e=>{var n=new Array(4);for(let t=0;t<4;t+=1){var r=u[t],o=l[t];n[t]=r*(1-e)+o*e}var[t,a,i,s]=n;return`rgba(${Math.round(t)}, ${Math.round(a)}, ${Math.round(i)}, ${s})`}},x=(t,e)=>"number"==typeof t&&"number"==typeof e?T(t,e):"string"==typeof t&&"string"==typeof e?xt(t,e):()=>t,St=(t,e)=>{const n=T(t,e);return t=>Math.round(n(t))};function Ct({map:t,initKey:e},n){e=e(n);return t.has(e)?t.get(e):n}function Yt(t){return"object"==typeof t?t.valueOf():t}class Nt extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=Yt,null!==t)for(var[e,n]of t)this.set(e,n)}get(t){return super.get(Ct({map:this.map,initKey:this.initKey},t))}has(t){return super.has(Ct({map:this.map,initKey:this.initKey},t))}set(t,e){return super.set(([{map:t,initKey:n},r]=[{map:this.map,initKey:this.initKey},t],n=n(r),t.has(n)?t.get(n):(t.set(n,r),r)),e);var n,r}delete(t){return super.delete(([{map:t,initKey:e},n]=[{map:this.map,initKey:this.initKey},t],e=e(n),t.has(e)&&(n=t.get(e),t.delete(e)),n));var e,n}}class S{constructor(t){this.options=ut({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=ut({},this.options,t),this.rescale(t)}rescale(t){}}const C=Symbol("defaultUnknown");function It(e,n,r){for(let t=0;t<n.length;t+=1)e.has(n[t])||e.set(r(n[t]),t)}function At(t){var{value:t,from:e,to:n,mapper:r,notFoundReturn:o}=t;let a=r.get(t);if(void 0===a){if(o!==C)return o;a=e.push(t)-1,r.set(t,a)}return n[a%n.length]}function Ut(t){return t instanceof Date?t=>""+t:"object"==typeof t?t=>JSON.stringify(t):t=>t}class jt extends S{getDefaultOptions(){return{domain:[],range:[],unknown:C}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&It(this.domainIndexMap,this.getDomain(),this.domainKey),At({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&It(this.rangeIndexMap,this.getRange(),this.rangeKey),At({value:this.rangeKey(t),mapper:this.rangeIndexMap,from:this.getRange(),to:this.getDomain(),notFoundReturn:this.options.unknown})}rescale(t){var[e]=this.options.domain,[n]=this.options.range;this.domainKey=Ut(e),this.rangeKey=Ut(n),this.rangeIndexMap?(t&&!t.range||this.rangeIndexMap.clear(),t&&!t.domain&&!t.compare||(this.domainIndexMap.clear(),this.sortedDomain=void 0)):(this.rangeIndexMap=new Map,this.domainIndexMap=new Map)}clone(){return new jt(this.options)}getRange(){return this.options.range}getDomain(){var t,e;return this.sortedDomain||({domain:t,compare:e}=this.options,this.sortedDomain=e?[...t].sort(e):t),this.sortedDomain}}function Ft(t){const{domain:e,range:n,paddingOuter:r,paddingInner:o,flex:a,round:i,align:s}=t;var u=e.length,l=0<(l=(t=u)-(h=a).length)?[...h,...new Array(l).fill(1)]:l<0?h.slice(0,t):h,[t,h]=n,h=h-t,d=h/(2/u*r+1-1/u*o);const c=d*o/u;d-=u*c;const g=function(t){const e=Math.min(...t);return t.map(t=>t/e)}(l),p=d/g.reduce((t,e)=>t+e);var l=new Nt(e.map((t,e)=>{e=g[e]*p;return[t,i?Math.floor(e):e]})),f=new Nt(e.map((t,e)=>{e=g[e]*p+c;return[t,i?Math.floor(e):e]})),d=Array.from(f.values()).reduce((t,e)=>t+e),t=t+(h-(d-d/u*o))*s;let m=i?Math.round(t):t;var v=new Array(u);for(let t=0;t<u;t+=1){v[t]=(M=m,Math.round(1e12*M)/1e12);var M=e[t];m+=f.get(M)}return{valueBandWidth:l,valueStep:f,adjustedRange:v}}class Ht extends jt{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:C,flex:[]}}constructor(t){super(t)}clone(){return new Ht(this.options)}getStep(t){return void 0===this.valueStep?1:"number"==typeof this.valueStep?this.valueStep:void 0===t?Array.from(this.valueStep.values())[0]:this.valueStep.get(t)}getBandWidth(t){return void 0===this.valueBandWidth?1:"number"==typeof this.valueBandWidth?this.valueBandWidth:void 0===t?Array.from(this.valueBandWidth.values())[0]:this.valueBandWidth.get(t)}getRange(){return this.adjustedRange}getPaddingInner(){var{padding:t,paddingInner:e}=this.options;return 0<t?t:e}getPaddingOuter(){var{padding:t,paddingOuter:e}=this.options;return 0<t?t:e}rescale(){super.rescale();var{align:t,domain:e,range:n,round:r,flex:o}=this.options,{adjustedRange:t,valueBandWidth:n,valueStep:r}=function(t){var e=t["domain"];if(0===(e=e.length))return{valueBandWidth:void 0,valueStep:void 0,adjustedRange:[]};if(!(null==(n=t.flex)||!n.length))return Ft(t);var{range:n,paddingOuter:t,paddingInner:r,round:o,align:a}=t;let i,s,u=n[0];return n=n[1]-u,i=n/Math.max(1,2*t+(e-r)),o&&(i=Math.floor(i)),u+=(n-i*(e-r))*a,s=i*(1-r),o&&(u=Math.round(u),s=Math.round(s)),t=new Array(e).fill(0).map((t,e)=>u+e*i),{valueStep:i,valueBandWidth:s,adjustedRange:t}}({align:t,range:n,round:r,flex:o,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:e});this.valueStep=r,this.valueBandWidth=n,this.adjustedRange=t}}const Y=(t,e,n)=>{let r,o,a=t,i=e;if(a===i&&0<n)return[a];let s=u(a,i,n);if(0===s||!Number.isFinite(s))return[];if(0<s){a=Math.ceil(a/s),i=Math.floor(i/s),o=new Array(r=Math.ceil(i-a+1));for(let t=0;t<r;t+=1)o[t]=(a+t)*s}else{s=-s,a=Math.ceil(a*s),i=Math.floor(i*s),o=new Array(r=Math.ceil(i-a+1));for(let t=0;t<r;t+=1)o[t]=(a+t)/s}return o};class Rt extends S{getDefaultOptions(){return{range:[0],domain:[0,1],unknown:void 0,tickCount:5,tickMethod:Y}}map(t){var[e]=this.options.range;return void 0!==e?e:this.options.unknown}invert(t){var[e]=this.options.range;return t===e&&void 0!==e?this.options.domain:[]}getTicks(){var{tickMethod:t,domain:e,tickCount:n}=this.options,[e,r]=e;return m(e)&&m(r)?t(e,r,n):[]}clone(){return new Rt(this.options)}}function H(t){return Math.abs(t)<1e-14?t:parseFloat(t.toFixed(14))}const Pt=[1,5,2,2.5,4,3],Kt=100*Number.EPSILON;const N=(n,r,t=5,o=!0,a=Pt,i=[.25,.2,.5,.05])=>{var s=t<0?0:Math.round(t);if(Number.isNaN(n)||Number.isNaN(r)||"number"!=typeof n||"number"!=typeof r||!s)return[];if(r-n<1e-15||1===s)return[n];var u,l,h,d,c,g,p,f={score:-2,lmin:0,lmax:0,lstep:0};let m=1;for(;m<1/0;){for(let t=0;t<a.length;t+=1){var v=a[t],M=(d=v,c=a,g=m,p=void 0,p=ht(c),1-lt(c,d)/(p-1)-g+1);if(i[0]*M+i[1]+i[2]+i[3]<f.score){m=1/0;break}let e=2;for(;e<1/0;){k=e;var y=(h=s)<=k?2-(k-1)/(h-1):1;if(i[0]*M+i[1]+i[2]*y+i[3]<f.score)break;var k=(r-n)/(e+1)/m/v;let t=Math.ceil(Math.log10(k));for(;t<1/0;){var b=m*v*10**t,w=(O=r,w=b*(e-1),(O-=n)<w?1-((w-O)/2)**2/(.1*O)**2:1);if(i[0]*M+i[1]*w+i[2]*y+i[3]<f.score)break;var D=Math.floor(r/b)*m-(e-1)*m,O=Math.ceil(n/b)*m;if(D<=O){var T=O-D;for(let t=0;t<=T;t+=1){var x=(D+t)*(b/m),S=x+b*(e-1),C=b,Y=function(t,e,n,r,o,a){var i=ht(e),e=lt(e,t);let s=0;return t=(r%a+a)%a,1-e/(i-1)-n+(s=(t<Kt||a-t<Kt)&&r<=0&&0<=o?1:s)}(v,a,m,x,S,C),N=1-.5*((r-S)**2+(n-x)**2)/(.1*(r-n))**2,I=(u=e,I=n,u=(u-1)/(S-(A=x)),l=((l=s)-1)/(Math.max(S,r)-Math.min(I,A)),2-Math.max(u/l,l/u)),A=i[0]*Y+i[1]*N+i[2]*I+ +i[3];f.score<A&&(!o||x<=n&&r<=S)&&(f.lmin=x,f.lmax=S,f.lstep=C,f.score=A)}}t+=1}e+=1}}m+=1}var t=H(f.lmax),e=H(f.lmin),U=H(f.lstep),j=Math.floor((t=(t-e)/U,Math.round(1e12*t)/1e12))+1,F=new Array(j);F[0]=H(e);for(let t=1;t<j;t+=1)F[t]=H(F[t-1]+U);return F};class qt extends S{getDefaultOptions(){return{domain:[0,1],range:[0,1],tickCount:5,unknown:void 0,tickMethod:N}}map(t){return M(t)?t:this.options.unknown}invert(t){return this.map(t)}clone(){return new qt(this.options)}getTicks(){var{domain:t,tickCount:e,tickMethod:n}=this.options,[t,r]=t;return m(t)&&m(r)?n(t,r,e):[]}}const Bt=(t,e,n)=>{var[t,r]=t,[e,o]=e;let a,i;return l(i=t<r?(a=h(t,r),n(e,o)):(a=h(r,t),n(o,e)),a)},Et=(r,t,e)=>{const o=Math.min(r.length,t.length)-1,a=new Array(o),i=new Array(o);var n=r[0]>r[o],s=n?[...r].reverse():r,u=n?[...t].reverse():t;for(let t=0;t<o;t+=1)a[t]=h(s[t],s[t+1]),i[t]=e(u[t],u[t+1]);return t=>{var e=c(r,t,1,o)-1,n=a[e];return l(i[e],n)(t)}},Wt=(t,e,n,r)=>{return(2<Math.min(t.length,e.length)?Et:Bt)(t,e,r?St:n)};class I extends S{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:T,tickCount:5}}map(t){return M(t)?this.output(t):this.options.unknown}invert(t){return M(t)?this.input(t):this.options.unknown}nice(){var t,e,n,r;this.options.nice&&([t,e,n,...r]=this.getTickMethodOptions(),this.options.domain=this.chooseNice()(t,e,n,...r))}getTicks(){var t=this.options["tickMethod"],[e,n,r,...o]=this.getTickMethodOptions();return t(e,n,r,...o)}getTickMethodOptions(){var{domain:t,tickCount:e}=this.options;return[t[0],t[t.length-1],e]}chooseNice(){return q}rescale(){this.nice();var[t,e]=this.chooseTransforms();this.composeOutput(t,this.chooseClamp(t)),this.composeInput(t,e,this.chooseClamp(e))}chooseClamp(t){var{clamp:e,range:n}=this.options,t=this.options.domain.map(t),n=Math.min(t.length,n.length);if(e){e=t[0],t=t[n-1];const r=t<e?t:e,o=t<e?e:t;return t=>Math.min(Math.max(r,t),o)}return v}composeOutput(t,e){var{domain:n,range:r,round:o,interpolate:a}=this.options,n=Wt(n.map(t),r,a,o);this.output=l(n,e,t)}composeInput(t,e,n){var{domain:r,range:o}=this.options,o=Wt(o,r.map(t),T);this.input=l(e,n,o)}}class A extends I{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:x,tickMethod:Y,tickCount:5}}chooseTransforms(){return[v,v]}clone(){return new A(this.options)}}class $t extends Ht{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,padding:0,unknown:C,paddingInner:1,paddingOuter:0}}constructor(t){super(t)}getPaddingInner(){return 1}clone(){return new $t(this.options)}update(t){super.update(t)}getPaddingOuter(){return this.options.padding}}const _t=t=>t<0?-Math.sqrt(-t):Math.sqrt(t);class zt extends I{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,exponent:2,interpolate:x,tickMethod:Y,tickCount:5}}constructor(t){super(t)}chooseTransforms(){var t,e,n,r=this.options["exponent"];return 1===r?[v,v]:(t=.5===r?_t:(e=r,t=>t<0?-((-t)**e):t**e),n=r,[t,t=>t<0?-((-t)**(1/n)):t**(1/n)])}clone(){return new zt(this.options)}}class Lt extends zt{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:x,tickMethod:Y,tickCount:5,exponent:.5}}constructor(t){super(t)}update(t){super.update(t)}clone(){return new Lt(this.options)}}class U extends S{getDefaultOptions(){return{domain:[.5],range:[0,1]}}constructor(t){super(t)}map(t){return M(t)?(t=c(this.thresholds,t,0,this.n),this.options.range[t]):this.options.unknown}invert(t){var e=this.options["range"],e=e.indexOf(t),t=this.thresholds;return[t[e-1],t[e]]}clone(){return new U(this.options)}rescale(){var{domain:t,range:e}=this.options;this.n=Math.min(t.length,e.length-1),this.thresholds=t}}const Zt=(t,e,n,r=10)=>{var o=t<0,a=pt(r,o),i=gt(r,o),s=e<t,u=s?e:t,l=s?t:e;let h=i(u),d=i(l),c=[];if(!(r%1)&&d-h<n){if(h=Math.floor(h),d=Math.ceil(d),o)for(;h<=d;h+=1){var g=a(h);for(let t=r-1;1<=t;--t){var p=g*t;if(l<p)break;u<=p&&c.push(p)}}else for(;h<=d;h+=1){var f=a(h);for(let t=1;t<r;t+=1){var m=f*t;if(l<m)break;u<=m&&c.push(m)}}2*c.length<n&&(c=Y(u,l,n))}else{t=-1===n?d-h:Math.min(d-h,n);c=Y(h,d,t).map(a)}return s?c.reverse():c};class Jt extends I{getDefaultOptions(){return{domain:[1,10],range:[0,1],base:10,interpolate:x,tickMethod:Zt,tickCount:5}}chooseNice(){return ft}getTickMethodOptions(){var{domain:t,tickCount:e,base:n}=this.options;return[t[0],t[t.length-1],e,n]}chooseTransforms(){var{base:t,domain:e}=this.options,e=e[0]<0;return[gt(t,e),pt(t,e)]}clone(){return new Jt(this.options)}}class Qt extends U{getDefaultOptions(){return{domain:[0,1],range:[.5],nice:!1,tickCount:5,tickMethod:N}}constructor(t){super(t)}nice(){var t,e,n=this.options["nice"];n&&([n,t,e]=this.getTickMethodOptions(),this.options.domain=q(n,t,e))}getTicks(){var t=this.options["tickMethod"],[e,n,r]=this.getTickMethodOptions();return t(e,n,r)}getTickMethodOptions(){var{domain:t,tickCount:e}=this.options;return[t[0],t[t.length-1],e]}rescale(){this.nice();var{range:t,domain:e}=this.options,[n,r]=e;this.n=t.length-1,this.thresholds=new Array(this.n);for(let t=0;t<this.n;t+=1)this.thresholds[t]=((t+1)*r-(t-this.n)*n)/(this.n+1)}invert(t){var[t,e]=super.invert(t),[n,r]=this.options.domain;return void 0===t&&void 0===e?[t,e]:[t||n,e||r]}getThresholds(){return this.thresholds}clone(){return new Qt(this.options)}}function Vt(t,e,n=!1){var r=t,o=(n||r.sort((t,e)=>t-e),[]);for(let t=1;t<e;t+=1)o.push(function(t,e){var n,r=t.length;if(r)return r<2?t[r-1]:(r=(r-1)*e,(n=t[e=Math.floor(r)])+(t[e+1]-n)*(r-e))}(r,t/e));return o}class Gt extends U{getDefaultOptions(){return{domain:[],range:[],tickCount:5,unknown:void 0,tickMethod:N}}constructor(t){super(t)}rescale(){var{domain:t,range:e}=this.options;this.n=e.length-1,this.thresholds=Vt(t,this.n+1,!1)}invert(t){var[t,e]=super.invert(t),n=this.options["domain"],r=n[0],n=n[n.length-1];return void 0===t&&void 0===e?[t,e]:[t||r,e||n]}getThresholds(){return this.thresholds}clone(){return new Gt(this.options)}getTicks(){var{tickCount:t,domain:e,tickMethod:n}=this.options,r=e.length-1;return n(e[0],e[r],t)}}var Xt=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,te=/\[([^]*?)\]/gm;function ee(t,e){for(var n=[],r=0,o=t.length;r<o;r++)n.push(t[r].substr(0,e));return n}function ne(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0,o=e;r<o.length;r++){var a,i=o[r];for(a in i)t[a]=i[a]}return t}function j(t,e){for(void 0===e&&(e=2),t=String(t);t.length<e;)t="0"+t;return t}var re,g=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],p=["January","February","March","April","May","June","July","August","September","October","November","December"],f=ee(p,3),oe=ne({},{dayNamesShort:ee(g,3),dayNames:g,monthNamesShort:f,monthNames:p,amPm:["am","pm"],DoFn:function(t){return t+["th","st","nd","rd"][3<t%10?0:(t-t%10!=10?1:0)*t%10]}}),ae={D:function(t){return String(t.getDate())},DD:function(t){return j(t.getDate())},Do:function(t,e){return e.DoFn(t.getDate())},d:function(t){return String(t.getDay())},dd:function(t){return j(t.getDay())},ddd:function(t,e){return e.dayNamesShort[t.getDay()]},dddd:function(t,e){return e.dayNames[t.getDay()]},M:function(t){return String(t.getMonth()+1)},MM:function(t){return j(t.getMonth()+1)},MMM:function(t,e){return e.monthNamesShort[t.getMonth()]},MMMM:function(t,e){return e.monthNames[t.getMonth()]},YY:function(t){return j(String(t.getFullYear()),4).substr(2)},YYYY:function(t){return j(t.getFullYear(),4)},h:function(t){return String(t.getHours()%12||12)},hh:function(t){return j(t.getHours()%12||12)},H:function(t){return String(t.getHours())},HH:function(t){return j(t.getHours())},m:function(t){return String(t.getMinutes())},mm:function(t){return j(t.getMinutes())},s:function(t){return String(t.getSeconds())},ss:function(t){return j(t.getSeconds())},S:function(t){return String(Math.round(t.getMilliseconds()/100))},SS:function(t){return j(Math.round(t.getMilliseconds()/10),2)},SSS:function(t){return j(t.getMilliseconds(),3)},a:function(t,e){return t.getHours()<12?e.amPm[0]:e.amPm[1]},A:function(t,e){return(t.getHours()<12?e.amPm[0]:e.amPm[1]).toUpperCase()},ZZ:function(t){t=t.getTimezoneOffset();return(0<t?"-":"+")+j(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(t){t=t.getTimezoneOffset();return(0<t?"-":"+")+j(Math.floor(Math.abs(t)/60),2)+":"+j(Math.abs(t)%60,2)}},ie={default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"};const se=(t,e,n,r,o)=>{var a=e<t,i=a?e:t,t=a?t:e,[e,n]=J(i,t,n,r,o),r=e.range(i,new Date(+t+1),n,!0);return a?r.reverse():r};function ue(t){var e=t.getTimezoneOffset(),t=new Date(t);return t.setMinutes(t.getMinutes()+e,t.getSeconds(),t.getMilliseconds()),t}class le extends I{getDefaultOptions(){return{domain:[new Date(2e3,0,1),new Date(2e3,0,2)],range:[0,1],nice:!1,tickCount:5,tickInterval:void 0,unknown:void 0,clamp:!1,tickMethod:se,interpolate:T,mask:void 0,utc:!1}}chooseTransforms(){return[t=>+t,t=>new Date(t)]}chooseNice(){return Q}getTickMethodOptions(){var{domain:t,tickCount:e,tickInterval:n,utc:r}=this.options;return[t[0],t[t.length-1],e,n,r]}getFormatter(){const{mask:a,utc:t}=this.options,i=t?Z:z,s=t?ue:v;return t=>{var e=s(t),t=a||function(t,e){var{second:e,minute:n,hour:r,day:o,week:a,month:i,year:s}=e;return e.floor(t)<t?".SSS":n.floor(t)<t?":ss":r.floor(t)<t?"hh:mm":o.floor(t)<t?"hh A":i.floor(t)<t?a.floor(t)<t?"MMM DD":"ddd DD":s.floor(t)<t?"MMMM":"YYYY"}(t,i),n=void 0;if(void 0===t&&(t=ie.default),void 0===n&&(n={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var r=[],o=(t=(t=ie[t]||t).replace(te,function(t,e){return r.push(e),"@@@"}),ne(ne({},oe),n));return(t=t.replace(Xt,function(t){return ae[t](e,o)})).replace(/@@@/g,function(){return r.shift()})}}clone(){return new le(this.options)}}var he;t.Sequential=re=class extends A{getDefaultOptions(){return{domain:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolator:v,tickMethod:Y,tickCount:5}}constructor(t){super(t)}clone(){return new re(this.options)}},t.Sequential=re=dt([mt(function(t){return[t(0),t(1)]},t=>{var[t,e]=t;return l(T(0,1),h(t,e))})],t.Sequential);t.Diverging=he=class extends A{getDefaultOptions(){return{domain:[0,.5,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolator:v,tickMethod:Y,tickCount:5}}constructor(t){super(t)}clone(){return new he(this.options)}},t.Diverging=he=dt([mt(function(t){return[t(0),t(.5),t(1)]},t=>{const[e,n,r]=t,o=l(T(0,.5),h(e,n)),a=l(T(.5,1),h(n,r));return t=>(e>r?t<n?a:o:t<n?o:a)(t)})],t.Diverging);t.Band=Ht,t.Base=S,t.Constant=Rt,t.Continuous=I,t.DURATION_DAY=a,t.DURATION_HOUR=o,t.DURATION_MINUTE=r,t.DURATION_MONTH=B,t.DURATION_SECOND=n,t.DURATION_WEEK=i,t.DURATION_YEAR=E,t.Identity=qt,t.Linear=A,t.Log=Jt,t.Ordinal=jt,t.Point=$t,t.Pow=zt,t.Quantile=Gt,t.Quantize=Qt,t.Sqrt=Lt,t.Threshold=U,t.Time=le,t.createInterpolateColor=xt,t.createInterpolateNumber=T,t.createInterpolateValue=x,t.d3Log=Zt,t.d3Ticks=Y,t.d3Time=se,t.rPretty=(t,e,n=5)=>{if(t===e)return[t];n=n<0?0:Math.round(n);if(0===n)return[];var n=(e-t)/n,r=10**Math.floor(Math.log10(n));let o=r;2*r-n<1.5*(n-o)&&5*r-n<2.75*(n-(o=2*r))&&10*r-n<1.5*(n-(o=5*r))&&(o=10*r);var n=Math.ceil(e/o),r=Math.floor(t/o),n=Math.max(n*o,e),a=Math.min(r*o,t),i=Math.floor((n-a)/o)+1,s=new Array(i);for(let t=0;t<i;t+=1)s[t]=H(a+t*o);return s},t.wilkinsonExtended=N,Object.defineProperty(t,"__esModule",{value:!0})});