UNPKG

chartjs-chart-funnel

Version:
17 lines (16 loc) 46.7 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("chart.js"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["exports","chart.js","chart.js/helpers"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ChartFunnel={},e.Chart,e.Chart.helpers)}(this,function(e,t,r){"use strict";const{min:n,max:o}=Math;var a=(e,t=0,r=1)=>n(o(t,e),r),s=e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=a(e[t],0,255)):3===t&&(e[t]=a(e[t],0,1));return e};const f={};for(let e of["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"])f[`[object ${e}]`]=e.toLowerCase();function l(e){return f[Object.prototype.toString.call(e)]||"object"}var c=(e,t=null)=>e.length>=3?Array.prototype.slice.call(e):"object"==l(e[0])&&t?t.split("").filter(t=>void 0!==e[0][t]).map(t=>e[0][t]):e[0].slice(0),i=e=>{if(e.length<2)return null;const t=e.length-1;return"string"==l(e[t])?e[t].toLowerCase():null};const{PI:u,min:h,max:d}=Math,b=e=>Math.round(100*e)/100,g=e=>Math.round(100*e)/100,m=2*u,p=u/3,w=u/180,y=180/u;function k(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var M={format:{},autodetect:[]};class x{constructor(...e){const t=this;if("object"===l(e[0])&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let r=i(e),n=!1;if(!r){n=!0,M.sorted||(M.autodetect=M.autodetect.sort((e,t)=>t.p-e.p),M.sorted=!0);for(let t of M.autodetect)if(r=t.test(...e),r)break}if(!M.format[r])throw new Error("unknown format: "+e);{const o=M.format[r].apply(null,n?e:e.slice(0,-1));t._rgb=s(o)}3===t._rgb.length&&t._rgb.push(1)}toString(){return"function"==l(this.hex)?this.hex():`[${this._rgb.join(",")}]`}}const v=(...e)=>new x(...e);v.version="3.1.2";const N={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},_=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,A=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,j=e=>{if(e.match(_)){4!==e.length&&7!==e.length||(e=e.substr(1)),3===e.length&&(e=(e=e.split(""))[0]+e[0]+e[1]+e[1]+e[2]+e[2]);const t=parseInt(e,16);return[t>>16,t>>8&255,255&t,1]}if(e.match(A)){5!==e.length&&9!==e.length||(e=e.substr(1)),4===e.length&&(e=(e=e.split(""))[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);const t=parseInt(e,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((255&t)/255*100)/100]}throw new Error(`unknown hex color: ${e}`)},{round:E}=Math,C=(...e)=>{let[t,r,n,o]=c(e,"rgba"),a=i(e)||"auto";void 0===o&&(o=1),"auto"===a&&(a=o<1?"rgba":"rgb"),t=E(t),r=E(r),n=E(n);let s="000000"+(t<<16|r<<8|n).toString(16);s=s.substr(s.length-6);let f="0"+E(255*o).toString(16);switch(f=f.substr(f.length-2),a.toLowerCase()){case"rgba":return`#${s}${f}`;case"argb":return`#${f}${s}`;default:return`#${s}`}};x.prototype.name=function(){const e=C(this._rgb,"rgb");for(let t of Object.keys(N))if(N[t]===e)return t.toLowerCase();return e},M.format.named=e=>{if(e=e.toLowerCase(),N[e])return j(N[e]);throw new Error("unknown color name: "+e)},M.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&"string"===l(e)&&N[e.toLowerCase()])return"named"}}),x.prototype.alpha=function(e,t=!1){return void 0!==e&&"number"===l(e)?t?(this._rgb[3]=e,this):new x([this._rgb[0],this._rgb[1],this._rgb[2],e],"rgb"):this._rgb[3]},x.prototype.clipped=function(){return this._rgb._clipped||!1};const R={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},P=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function $(e){const t=P.get(String(e).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+e);R.labWhitePoint=e,R.Xn=t[0],R.Zn=t[1]}function B(){return R.labWhitePoint}const O=(...e)=>{e=c(e,"lab");const[t,r,n]=e,[o,a,s]=L(t,r,n),[f,l,i]=G(o,a,s);return[f,l,i,e.length>3?e[3]:1]},L=(e,t,r)=>{const{kE:n,kK:o,kKE:a,Xn:s,Yn:f,Zn:l}=R,c=(e+16)/116,i=.002*t+c,u=c-.005*r,h=i*i*i,d=u*u*u;return[(h>n?h:(116*i-16)/o)*s,(e>a?Math.pow((e+16)/116,3):e/o)*f,(d>n?d:(116*u-16)/o)*l]},Y=e=>{const t=Math.sign(e);return((e=Math.abs(e))<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)*t},G=(e,t,r)=>{const{MtxAdaptMa:n,MtxAdaptMaI:o,MtxXYZ2RGB:a,RefWhiteRGB:s,Xn:f,Yn:l,Zn:c}=R,i=f*n.m00+l*n.m10+c*n.m20,u=f*n.m01+l*n.m11+c*n.m21,h=f*n.m02+l*n.m12+c*n.m22,d=s.X*n.m00+s.Y*n.m10+s.Z*n.m20,b=s.X*n.m01+s.Y*n.m11+s.Z*n.m21,g=s.X*n.m02+s.Y*n.m12+s.Z*n.m22,m=(e*n.m00+t*n.m10+r*n.m20)*(d/i),p=(e*n.m01+t*n.m11+r*n.m21)*(b/u),w=(e*n.m02+t*n.m12+r*n.m22)*(g/h),y=m*o.m00+p*o.m10+w*o.m20,k=m*o.m01+p*o.m11+w*o.m21,M=m*o.m02+p*o.m12+w*o.m22;return[255*Y(y*a.m00+k*a.m10+M*a.m20),255*Y(y*a.m01+k*a.m11+M*a.m21),255*Y(y*a.m02+k*a.m12+M*a.m22)]},q=(...e)=>{const[t,r,n,...o]=c(e,"rgb"),[a,s,f]=X(t,r,n),[l,i,u]=function(e,t,r){const{Xn:n,Yn:o,Zn:a,kE:s,kK:f}=R,l=e/n,c=t/o,i=r/a,u=l>s?Math.pow(l,1/3):(f*l+16)/116,h=c>s?Math.pow(c,1/3):(f*c+16)/116,d=i>s?Math.pow(i,1/3):(f*i+16)/116;return[116*h-16,500*(u-h),200*(h-d)]}(a,s,f);return[l,i,u,...o.length>0&&o[0]<1?[o[0]]:[]]};function z(e){const t=Math.sign(e);return((e=Math.abs(e))<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4))*t}const X=(e,t,r)=>{e=z(e/255),t=z(t/255),r=z(r/255);const{MtxRGB2XYZ:n,MtxAdaptMa:o,MtxAdaptMaI:a,Xn:s,Yn:f,Zn:l,As:c,Bs:i,Cs:u}=R;let h=e*n.m00+t*n.m10+r*n.m20,d=e*n.m01+t*n.m11+r*n.m21,b=e*n.m02+t*n.m12+r*n.m22;const g=s*o.m00+f*o.m10+l*o.m20,m=s*o.m01+f*o.m11+l*o.m21,p=s*o.m02+f*o.m12+l*o.m22;let w=h*o.m00+d*o.m10+b*o.m20,y=h*o.m01+d*o.m11+b*o.m21,k=h*o.m02+d*o.m12+b*o.m22;return w*=g/c,y*=m/i,k*=p/u,h=w*a.m00+y*a.m10+k*a.m20,d=w*a.m01+y*a.m11+k*a.m21,b=w*a.m02+y*a.m12+k*a.m22,[h,d,b]};x.prototype.lab=function(){return q(this._rgb)};Object.assign(v,{lab:(...e)=>new x(...e,"lab"),getLabWhitePoint:B,setLabWhitePoint:$}),M.format.lab=O,M.autodetect.push({p:2,test:(...e)=>{if("array"===l(e=c(e,"lab"))&&3===e.length)return"lab"}}),x.prototype.darken=function(e=1){const t=this.lab();return t[0]-=R.Kn*e,new x(t,"lab").alpha(this.alpha(),!0)},x.prototype.brighten=function(e=1){return this.darken(-e)},x.prototype.darker=x.prototype.darken,x.prototype.brighter=x.prototype.brighten,x.prototype.get=function(e){const[t,r]=e.split("."),n=this[t]();if(r){const e=t.indexOf(r)-("ok"===t.substr(0,2)?2:0);if(e>-1)return n[e];throw new Error(`unknown channel ${r} in mode ${t}`)}return n};const{pow:S}=Math;x.prototype.luminance=function(e,t="rgb"){if(void 0!==e&&"number"===l(e)){if(0===e)return new x([0,0,0,this._rgb[3]],"rgb");if(1===e)return new x([255,255,255,this._rgb[3]],"rgb");let r=this.luminance(),n=20;const o=(r,a)=>{const s=r.interpolate(a,.5,t),f=s.luminance();return Math.abs(e-f)<1e-7||!n--?s:f>e?o(r,s):o(s,a)},a=(r>e?o(new x([0,0,0]),this):o(this,new x([255,255,255]))).rgb();return new x([...a,this._rgb[3]])}return Z(...this._rgb.slice(0,3))};const Z=(e,t,r)=>.2126*(e=I(e))+.7152*(t=I(t))+.0722*(r=I(r)),I=e=>(e/=255)<=.03928?e/12.92:S((e+.055)/1.055,2.4);var F={},W=(e,t,r=.5,...n)=>{let o=n[0]||"lrgb";if(F[o]||n.length||(o=Object.keys(F)[0]),!F[o])throw new Error(`interpolation mode ${o} is not defined`);return"object"!==l(e)&&(e=new x(e)),"object"!==l(t)&&(t=new x(t)),F[o](e,t,r).alpha(e.alpha()+r*(t.alpha()-e.alpha()))};x.prototype.mix=x.prototype.interpolate=function(e,t=.5,...r){return W(this,e,t,...r)},x.prototype.premultiply=function(e=!1){const t=this._rgb,r=t[3];return e?(this._rgb=[t[0]*r,t[1]*r,t[2]*r,r],this):new x([t[0]*r,t[1]*r,t[2]*r,r],"rgb")};const{sin:K,cos:T}=Math,U=(...e)=>{let[t,r,n]=c(e,"lch");return isNaN(n)&&(n=0),n*=w,[t,T(n)*r,K(n)*r]},V=(...e)=>{e=c(e,"lch");const[t,r,n]=e,[o,a,s]=U(t,r,n),[f,l,i]=O(o,a,s);return[f,l,i,e.length>3?e[3]:1]},{sqrt:D,atan2:H,round:J}=Math,Q=(...e)=>{const[t,r,n]=c(e,"lab"),o=D(r*r+n*n);let a=(H(n,r)*y+360)%360;return 0===J(1e4*o)&&(a=Number.NaN),[t,o,a]},ee=(...e)=>{const[t,r,n,...o]=c(e,"rgb"),[a,s,f]=q(t,r,n),[l,i,u]=Q(a,s,f);return[l,i,u,...o.length>0&&o[0]<1?[o[0]]:[]]};x.prototype.lch=function(){return ee(this._rgb)},x.prototype.hcl=function(){return k(ee(this._rgb))};Object.assign(v,{lch:(...e)=>new x(...e,"lch"),hcl:(...e)=>new x(...e,"hcl")}),M.format.lch=V,M.format.hcl=(...e)=>{const t=k(c(e,"hcl"));return V(...t)},["lch","hcl"].forEach(e=>M.autodetect.push({p:2,test:(...t)=>{if("array"===l(t=c(t,e))&&3===t.length)return e}})),x.prototype.saturate=function(e=1){const t=this.lch();return t[1]+=R.Kn*e,t[1]<0&&(t[1]=0),new x(t,"lch").alpha(this.alpha(),!0)},x.prototype.desaturate=function(e=1){return this.saturate(-e)},x.prototype.set=function(e,t,r=!1){const[n,o]=e.split("."),a=this[n]();if(o){const e=n.indexOf(o)-("ok"===n.substr(0,2)?2:0);if(e>-1){if("string"==l(t))switch(t.charAt(0)){case"+":case"-":a[e]+=+t;break;case"*":a[e]*=+t.substr(1);break;case"/":a[e]/=+t.substr(1);break;default:a[e]=+t}else{if("number"!==l(t))throw new Error("unsupported value for Color.set");a[e]=t}const o=new x(a,n);return r?(this._rgb=o._rgb,this):o}throw new Error(`unknown channel ${o} in mode ${n}`)}return a},x.prototype.tint=function(e=.5,...t){return W(this,"white",e,...t)},x.prototype.shade=function(e=.5,...t){return W(this,"black",e,...t)};F.rgb=(e,t,r)=>{const n=e._rgb,o=t._rgb;return new x(n[0]+r*(o[0]-n[0]),n[1]+r*(o[1]-n[1]),n[2]+r*(o[2]-n[2]),"rgb")};const{sqrt:te,pow:re}=Math;F.lrgb=(e,t,r)=>{const[n,o,a]=e._rgb,[s,f,l]=t._rgb;return new x(te(re(n,2)*(1-r)+re(s,2)*r),te(re(o,2)*(1-r)+re(f,2)*r),te(re(a,2)*(1-r)+re(l,2)*r),"rgb")};F.lab=(e,t,r)=>{const n=e.lab(),o=t.lab();return new x(n[0]+r*(o[0]-n[0]),n[1]+r*(o[1]-n[1]),n[2]+r*(o[2]-n[2]),"lab")};var ne=(e,t,r,n)=>{let o,a,s,f,l,c,i,u,h,d,b,g;return"hsl"===n?(o=e.hsl(),a=t.hsl()):"hsv"===n?(o=e.hsv(),a=t.hsv()):"hcg"===n?(o=e.hcg(),a=t.hcg()):"hsi"===n?(o=e.hsi(),a=t.hsi()):"lch"===n||"hcl"===n?(n="hcl",o=e.hcl(),a=t.hcl()):"oklch"===n&&(o=e.oklch().reverse(),a=t.oklch().reverse()),"h"!==n.substr(0,1)&&"oklch"!==n||([s,l,i]=o,[f,c,u]=a),isNaN(s)||isNaN(f)?isNaN(s)?isNaN(f)?d=Number.NaN:(d=f,1!=i&&0!=i||"hsv"==n||(h=c)):(d=s,1!=u&&0!=u||"hsv"==n||(h=l)):(g=f>s&&f-s>180?f-(s+360):f<s&&s-f>180?f+360-s:f-s,d=s+r*g),void 0===h&&(h=l+r*(c-l)),b=i+r*(u-i),new x("oklch"===n?[b,h,d]:[d,h,b],n)};const oe=(e,t,r)=>ne(e,t,r,"lch");F.lch=oe,F.hcl=oe;x.prototype.num=function(){return((...e)=>{const[t,r,n]=c(e,"rgb");return(t<<16)+(r<<8)+n})(this._rgb)};Object.assign(v,{num:(...e)=>new x(...e,"num")}),M.format.num=e=>{if("number"==l(e)&&e>=0&&e<=16777215){return[e>>16,e>>8&255,255&e,1]}throw new Error("unknown num color: "+e)},M.autodetect.push({p:5,test:(...e)=>{if(1===e.length&&"number"===l(e[0])&&e[0]>=0&&e[0]<=16777215)return"num"}});F.num=(e,t,r)=>{const n=e.num(),o=t.num();return new x(n+r*(o-n),"num")};const{floor:ae}=Math;x.prototype.hcg=function(){return((...e)=>{const[t,r,n]=c(e,"rgb"),o=h(t,r,n),a=d(t,r,n),s=a-o,f=100*s/255,l=o/(255-s)*100;let i;return 0===s?i=Number.NaN:(t===a&&(i=(r-n)/s),r===a&&(i=2+(n-t)/s),n===a&&(i=4+(t-r)/s),i*=60,i<0&&(i+=360)),[i,f,l]})(this._rgb)};v.hcg=(...e)=>new x(...e,"hcg"),M.format.hcg=(...e)=>{e=c(e,"hcg");let t,r,n,[o,a,s]=e;s*=255;const f=255*a;if(0===a)t=r=n=s;else{360===o&&(o=0),o>360&&(o-=360),o<0&&(o+=360),o/=60;const e=ae(o),l=o-e,c=s*(1-a),i=c+f*(1-l),u=c+f*l,h=c+f;switch(e){case 0:[t,r,n]=[h,u,c];break;case 1:[t,r,n]=[i,h,c];break;case 2:[t,r,n]=[c,h,u];break;case 3:[t,r,n]=[c,i,h];break;case 4:[t,r,n]=[u,c,h];break;case 5:[t,r,n]=[h,c,i]}}return[t,r,n,e.length>3?e[3]:1]},M.autodetect.push({p:1,test:(...e)=>{if("array"===l(e=c(e,"hcg"))&&3===e.length)return"hcg"}});F.hcg=(e,t,r)=>ne(e,t,r,"hcg");const{cos:se}=Math,{min:fe,sqrt:le,acos:ce}=Math;x.prototype.hsi=function(){return((...e)=>{let t,[r,n,o]=c(e,"rgb");r/=255,n/=255,o/=255;const a=fe(r,n,o),s=(r+n+o)/3,f=s>0?1-a/s:0;return 0===f?t=NaN:(t=(r-n+(r-o))/2,t/=le((r-n)*(r-n)+(r-o)*(n-o)),t=ce(t),o>n&&(t=m-t),t/=m),[360*t,f,s]})(this._rgb)};v.hsi=(...e)=>new x(...e,"hsi"),M.format.hsi=(...e)=>{e=c(e,"hsi");let t,r,n,[o,s,f]=e;return isNaN(o)&&(o=0),isNaN(s)&&(s=0),o>360&&(o-=360),o<0&&(o+=360),o/=360,o<1/3?(n=(1-s)/3,t=(1+s*se(m*o)/se(p-m*o))/3,r=1-(n+t)):o<2/3?(o-=1/3,t=(1-s)/3,r=(1+s*se(m*o)/se(p-m*o))/3,n=1-(t+r)):(o-=2/3,r=(1-s)/3,n=(1+s*se(m*o)/se(p-m*o))/3,t=1-(r+n)),t=a(f*t*3),r=a(f*r*3),n=a(f*n*3),[255*t,255*r,255*n,e.length>3?e[3]:1]},M.autodetect.push({p:2,test:(...e)=>{if("array"===l(e=c(e,"hsi"))&&3===e.length)return"hsi"}});F.hsi=(e,t,r)=>ne(e,t,r,"hsi");const ie=(...e)=>{e=c(e,"hsl");const[t,r,n]=e;let o,a,s;if(0===r)o=a=s=255*n;else{const e=[0,0,0],f=[0,0,0],l=n<.5?n*(1+r):n+r-n*r,c=2*n-l,i=t/360;e[0]=i+1/3,e[1]=i,e[2]=i-1/3;for(let t=0;t<3;t++)e[t]<0&&(e[t]+=1),e[t]>1&&(e[t]-=1),6*e[t]<1?f[t]=c+6*(l-c)*e[t]:2*e[t]<1?f[t]=l:3*e[t]<2?f[t]=c+(l-c)*(2/3-e[t])*6:f[t]=c;[o,a,s]=[255*f[0],255*f[1],255*f[2]]}return e.length>3?[o,a,s,e[3]]:[o,a,s,1]},ue=(...e)=>{e=c(e,"rgba");let[t,r,n]=e;t/=255,r/=255,n/=255;const o=h(t,r,n),a=d(t,r,n),s=(a+o)/2;let f,l;return a===o?(f=0,l=Number.NaN):f=s<.5?(a-o)/(a+o):(a-o)/(2-a-o),t==a?l=(r-n)/(a-o):r==a?l=2+(n-t)/(a-o):n==a&&(l=4+(t-r)/(a-o)),l*=60,l<0&&(l+=360),e.length>3&&void 0!==e[3]?[l,f,s,e[3]]:[l,f,s]};x.prototype.hsl=function(){return ue(this._rgb)};v.hsl=(...e)=>new x(...e,"hsl"),M.format.hsl=ie,M.autodetect.push({p:2,test:(...e)=>{if("array"===l(e=c(e,"hsl"))&&3===e.length)return"hsl"}});F.hsl=(e,t,r)=>ne(e,t,r,"hsl");const{floor:he}=Math,{min:de,max:be}=Math;x.prototype.hsv=function(){return((...e)=>{e=c(e,"rgb");let[t,r,n]=e;const o=de(t,r,n),a=be(t,r,n),s=a-o;let f,l,i;return i=a/255,0===a?(f=Number.NaN,l=0):(l=s/a,t===a&&(f=(r-n)/s),r===a&&(f=2+(n-t)/s),n===a&&(f=4+(t-r)/s),f*=60,f<0&&(f+=360)),[f,l,i]})(this._rgb)};v.hsv=(...e)=>new x(...e,"hsv"),M.format.hsv=(...e)=>{e=c(e,"hsv");let t,r,n,[o,a,s]=e;if(s*=255,0===a)t=r=n=s;else{360===o&&(o=0),o>360&&(o-=360),o<0&&(o+=360),o/=60;const e=he(o),f=o-e,l=s*(1-a),c=s*(1-a*f),i=s*(1-a*(1-f));switch(e){case 0:[t,r,n]=[s,i,l];break;case 1:[t,r,n]=[c,s,l];break;case 2:[t,r,n]=[l,s,i];break;case 3:[t,r,n]=[l,c,s];break;case 4:[t,r,n]=[i,l,s];break;case 5:[t,r,n]=[s,l,c]}}return[t,r,n,e.length>3?e[3]:1]},M.autodetect.push({p:2,test:(...e)=>{if("array"===l(e=c(e,"hsv"))&&3===e.length)return"hsv"}});function ge(e,t){let r=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let n=t[0].length,o=t[0].map((e,r)=>t.map(e=>e[r])),a=e.map(e=>o.map(t=>Array.isArray(e)?e.reduce((e,r,n)=>e+r*(t[n]||0),0):t.reduce((t,r)=>t+r*e,0)));return 1===r&&(a=a[0]),1===n?a.map(e=>e[0]):a}F.hsv=(e,t,r)=>ne(e,t,r,"hsv");const me=(...e)=>{e=c(e,"lab");const[t,r,n,...o]=e,[a,s,f]=(l=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],i=ge([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[t,r,n]),ge(l,i.map(e=>e**3)));var l,i;const[u,h,d]=G(a,s,f);return[u,h,d,...o.length>0&&o[0]<1?[o[0]]:[]]};const pe=(...e)=>{const[t,r,n,...o]=c(e,"rgb");return[...function(e){const t=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],r=ge([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],e);return ge(t,r.map(e=>Math.cbrt(e)))}(X(t,r,n)),...o.length>0&&o[0]<1?[o[0]]:[]]};x.prototype.oklab=function(){return pe(this._rgb)};Object.assign(v,{oklab:(...e)=>new x(...e,"oklab")}),M.format.oklab=me,M.autodetect.push({p:2,test:(...e)=>{if("array"===l(e=c(e,"oklab"))&&3===e.length)return"oklab"}});F.oklab=(e,t,r)=>{const n=e.oklab(),o=t.oklab();return new x(n[0]+r*(o[0]-n[0]),n[1]+r*(o[1]-n[1]),n[2]+r*(o[2]-n[2]),"oklab")};F.oklch=(e,t,r)=>ne(e,t,r,"oklch");const{pow:we,sqrt:ye,PI:ke,cos:Me,sin:xe,atan2:ve}=Math;const Ne=(e,t)=>{const r=e.length,n=[0,0,0,0];for(let o=0;o<e.length;o++){const a=e[o],s=t[o]/r,f=a._rgb;n[0]+=we(f[0],2)*s,n[1]+=we(f[1],2)*s,n[2]+=we(f[2],2)*s,n[3]+=f[3]*s}return n[0]=ye(n[0]),n[1]=ye(n[1]),n[2]=ye(n[2]),n[3]>.9999999&&(n[3]=1),new x(s(n))},{pow:_e}=Math;function Ae(e){let t="rgb",r=v("#ccc"),n=0,o=[0,1],s=[],f=[0,0],c=!1,i=[],u=!1,h=0,d=1,b=!1,g={},m=!0,p=1;const w=function(e){if((e=e||["#fff","#000"])&&"string"===l(e)&&v.brewer&&v.brewer[e.toLowerCase()]&&(e=v.brewer[e.toLowerCase()]),"array"===l(e)){1===e.length&&(e=[e[0],e[0]]),e=e.slice(0);for(let t=0;t<e.length;t++)e[t]=v(e[t]);s.length=0;for(let t=0;t<e.length;t++)s.push(t/(e.length-1))}return x(),i=e};let y=e=>e,k=e=>e;const M=function(e,n){let o,u;if(null==n&&(n=!1),isNaN(e)||null===e)return r;if(n)u=e;else if(c&&c.length>2){u=function(e){if(null!=c){const t=c.length-1;let r=0;for(;r<t&&e>=c[r];)r++;return r-1}return 0}(e)/(c.length-2)}else u=d!==h?(e-h)/(d-h):1;u=k(u),n||(u=y(u)),1!==p&&(u=_e(u,p)),u=f[0]+u*(1-f[0]-f[1]),u=a(u,0,1);const b=Math.floor(1e4*u);if(m&&g[b])o=g[b];else{if("array"===l(i))for(let e=0;e<s.length;e++){const r=s[e];if(u<=r){o=i[e];break}if(u>=r&&e===s.length-1){o=i[e];break}if(u>r&&u<s[e+1]){u=(u-r)/(s[e+1]-r),o=v.interpolate(i[e],i[e+1],u,t);break}}else"function"===l(i)&&(o=i(u));m&&(g[b]=o)}return o};var x=()=>g={};w(e);const N=function(e){const t=v(M(e));return u&&t[u]?t[u]():t};return N.classes=function(e){if(null!=e){if("array"===l(e))c=e,o=[e[0],e[e.length-1]];else{const t=v.analyze(o);c=0===e?[t.min,t.max]:v.limits(t,"e",e)}return N}return c},N.domain=function(e){if(!arguments.length)return o;h=e[0],d=e[e.length-1],s=[];const t=i.length;if(e.length===t&&h!==d)for(let t of Array.from(e))s.push((t-h)/(d-h));else{for(let e=0;e<t;e++)s.push(e/(t-1));if(e.length>2){const t=e.map((t,r)=>r/(e.length-1)),r=e.map(e=>(e-h)/(d-h));r.every((e,r)=>t[r]===e)||(k=e=>{if(e<=0||e>=1)return e;let n=0;for(;e>=r[n+1];)n++;const o=(e-r[n])/(r[n+1]-r[n]);return t[n]+o*(t[n+1]-t[n])})}}return o=[h,d],N},N.mode=function(e){return arguments.length?(t=e,x(),N):t},N.range=function(e,t){return w(e),N},N.out=function(e){return u=e,N},N.spread=function(e){return arguments.length?(n=e,N):n},N.correctLightness=function(e){return null==e&&(e=!0),b=e,x(),y=b?function(e){const t=M(0,!0).lab()[0],r=M(1,!0).lab()[0],n=t>r;let o=M(e,!0).lab()[0];const a=t+(r-t)*e;let s=o-a,f=0,l=1,c=20;for(;Math.abs(s)>.01&&c-- >0;)(function(){n&&(s*=-1),s<0?(f=e,e+=.5*(l-e)):(l=e,e+=.5*(f-e)),o=M(e,!0).lab()[0],s=o-a})();return e}:e=>e,N},N.padding=function(e){return null!=e?("number"===l(e)&&(e=[e,e]),f=e,N):f},N.colors=function(t,r){arguments.length<2&&(r="hex");let n=[];if(0===arguments.length)n=i.slice(0);else if(1===t)n=[N(.5)];else if(t>1){const e=o[0],r=o[1]-e;n=function(e,t){let r=[],n=e<t,o=t;for(let t=e;n?t<o:t>o;n?t++:t--)r.push(t);return r}(0,t).map(n=>N(e+n/(t-1)*r))}else{e=[];let t=[];if(c&&c.length>2)for(let e=1,r=c.length,n=1<=r;n?e<r:e>r;n?e++:e--)t.push(.5*(c[e-1]+c[e]));else t=o;n=t.map(e=>N(e))}return v[r]&&(n=n.map(e=>e[r]())),n},N.cache=function(e){return null!=e?(m=e,N):m},N.gamma=function(e){return null!=e?(p=e,N):p},N.nodata=function(e){return null!=e?(r=v(e),N):r},N}const{round:je}=Math;x.prototype.rgb=function(e=!0){return!1===e?this._rgb.slice(0,3):this._rgb.slice(0,3).map(je)},x.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,r)=>r<3?!1===e?t:je(t):t)};Object.assign(v,{rgb:(...e)=>new x(...e,"rgb")}),M.format.rgb=(...e)=>{const t=c(e,"rgba");return void 0===t[3]&&(t[3]=1),t},M.autodetect.push({p:3,test:(...e)=>{if("array"===l(e=c(e,"rgba"))&&(3===e.length||4===e.length&&"number"==l(e[3])&&e[3]>=0&&e[3]<=1))return"rgb"}});const Ee=(e,t,r)=>{if(!Ee[r])throw new Error("unknown blend mode "+r);return Ee[r](e,t)},Ce=e=>(t,r)=>{const n=v(r).rgb(),o=v(t).rgb();return v.rgb(e(n,o))},Re=e=>(t,r)=>{const n=[];return n[0]=e(t[0],r[0]),n[1]=e(t[1],r[1]),n[2]=e(t[2],r[2]),n};Ee.normal=Ce(Re(e=>e)),Ee.multiply=Ce(Re((e,t)=>e*t/255)),Ee.screen=Ce(Re((e,t)=>255*(1-(1-e/255)*(1-t/255)))),Ee.overlay=Ce(Re((e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)))),Ee.darken=Ce(Re((e,t)=>e>t?t:e)),Ee.lighten=Ce(Re((e,t)=>e>t?e:t)),Ee.dodge=Ce(Re((e,t)=>255===e||(e=t/255*255/(1-e/255))>255?255:e)),Ee.burn=Ce(Re((e,t)=>255*(1-(1-t/255)/(e/255))));const{pow:Pe,sin:$e,cos:Be}=Math;const{floor:Oe,random:Le}=Math;const{log:Ye,pow:Ge,floor:qe,abs:ze}=Math;function Xe(e,t=null){const r={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===l(e)&&(e=Object.values(e)),e.forEach(e=>{t&&"object"===l(e)&&(e=e[t]),null==e||isNaN(e)||(r.values.push(e),r.sum+=e,e<r.min&&(r.min=e),e>r.max&&(r.max=e),r.count+=1)}),r.domain=[r.min,r.max],r.limits=(e,t)=>Se(r,e,t),r}function Se(e,t="equal",r=7){"array"==l(e)&&(e=Xe(e));const{min:n,max:o}=e,a=e.values.sort((e,t)=>e-t);if(1===r)return[n,o];const s=[];if("c"===t.substr(0,1)&&(s.push(n),s.push(o)),"e"===t.substr(0,1)){s.push(n);for(let e=1;e<r;e++)s.push(n+e/r*(o-n));s.push(o)}else if("l"===t.substr(0,1)){if(n<=0)throw new Error("Logarithmic scales are only possible for values > 0");const e=Math.LOG10E*Ye(n),t=Math.LOG10E*Ye(o);s.push(n);for(let n=1;n<r;n++)s.push(Ge(10,e+n/r*(t-e)));s.push(o)}else if("q"===t.substr(0,1)){s.push(n);for(let e=1;e<r;e++){const t=(a.length-1)*e/r,n=qe(t);if(n===t)s.push(a[n]);else{const e=t-n;s.push(a[n]*(1-e)+a[n+1]*e)}}s.push(o)}else if("k"===t.substr(0,1)){let e;const t=a.length,f=new Array(t),l=new Array(r);let c=!0,i=0,u=null;u=[],u.push(n);for(let e=1;e<r;e++)u.push(n+e/r*(o-n));for(u.push(o);c;){for(let e=0;e<r;e++)l[e]=0;for(let e=0;e<t;e++){const t=a[e];let n,o=Number.MAX_VALUE;for(let a=0;a<r;a++){const r=ze(u[a]-t);r<o&&(o=r,n=a),l[n]++,f[e]=n}}const n=new Array(r);for(let e=0;e<r;e++)n[e]=null;for(let r=0;r<t;r++)e=f[r],null===n[e]?n[e]=a[r]:n[e]+=a[r];for(let e=0;e<r;e++)n[e]*=1/l[e];c=!1;for(let e=0;e<r;e++)if(n[e]!==u[e]){c=!0;break}u=n,i++,i>200&&(c=!1)}const h={};for(let e=0;e<r;e++)h[e]=[];for(let r=0;r<t;r++)e=f[r],h[e].push(a[r]);let d=[];for(let e=0;e<r;e++)d.push(h[e][0]),d.push(h[e][h[e].length-1]);d=d.sort((e,t)=>e-t),s.push(d[0]);for(let e=1;e<d.length;e+=2){const t=d[e];isNaN(t)||-1!==s.indexOf(t)||s.push(t)}}return s} /** * @license * * The APCA contrast prediction algorithm is based of the formulas published * in the APCA-1.0.98G specification by Myndex. The specification is available at: * https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg * * Note that the APCA implementation is still beta, so please update to * future versions of chroma.js when they become available. * * You can read more about the APCA Readability Criterion at * https://readtech.org/ARC/ */ const Ze=.022;function Ie(e,t,r){return.2126729*Math.pow(e/255,2.4)+.7151522*Math.pow(t/255,2.4)+.072175*Math.pow(r/255,2.4)}const{sqrt:Fe,pow:We,min:Ke,max:Te,atan2:Ue,abs:Ve,cos:De,sin:He,exp:Je,PI:Qe}=Math;var et={cool:()=>Ae([v.hsl(180,1,.9),v.hsl(250,.7,.4)]),hot:()=>Ae(["#000","#f00","#ff0","#fff"]).mode("rgb")};const tt={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},rt=Object.keys(tt),nt=new Map(rt.map(e=>[e.toLowerCase(),e])),ot="function"==typeof Proxy?new Proxy(tt,{get(e,t){const r=t.toLowerCase();if(nt.has(r))return e[nt.get(r)]},getOwnPropertyNames:()=>Object.getOwnPropertyNames(rt)}):tt,{max:at}=Math;x.prototype.cmyk=function(){return((...e)=>{let[t,r,n]=c(e,"rgb");t/=255,r/=255,n/=255;const o=1-at(t,at(r,n)),a=o<1?1/(1-o):0;return[(1-t-o)*a,(1-r-o)*a,(1-n-o)*a,o]})(this._rgb)};Object.assign(v,{cmyk:(...e)=>new x(...e,"cmyk")}),M.format.cmyk=(...e)=>{e=c(e,"cmyk");const[t,r,n,o]=e,a=e.length>4?e[4]:1;return 1===o?[0,0,0,a]:[t>=1?0:255*(1-t)*(1-o),r>=1?0:255*(1-r)*(1-o),n>=1?0:255*(1-n)*(1-o),a]},M.autodetect.push({p:2,test:(...e)=>{if("array"===l(e=c(e,"cmyk"))&&4===e.length)return"cmyk"}});const st=(...e)=>{const[t,r,n,...o]=c(e,"rgb"),[a,s,f]=pe(t,r,n),[l,i,u]=Q(a,s,f);return[l,i,u,...o.length>0&&o[0]<1?[o[0]]:[]]},{round:ft}=Math,lt=(...e)=>{const t=c(e,"rgba");let r=i(e)||"rgb";if("hsl"===r.substr(0,3))return((...e)=>{const t=c(e,"hsla");let r=i(e)||"lsa";return t[0]=b(t[0]||0)+"deg",t[1]=b(100*t[1])+"%",t[2]=b(100*t[2])+"%","hsla"===r||t.length>3&&t[3]<1?(t[3]="/ "+(t.length>3?t[3]:1),r="hsla"):t.length=3,`${r.substr(0,3)}(${t.join(" ")})`})(ue(t),r);if("lab"===r.substr(0,3)){const e=B();$("d50");const n=((...e)=>{const t=c(e,"lab");let r=i(e)||"lab";return t[0]=b(t[0])+"%",t[1]=b(t[1]),t[2]=b(t[2]),"laba"===r||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(" ")})`})(q(t),r);return $(e),n}if("lch"===r.substr(0,3)){const e=B();$("d50");const n=((...e)=>{const t=c(e,"lch");let r=i(e)||"lab";return t[0]=b(t[0])+"%",t[1]=b(t[1]),t[2]=isNaN(t[2])?"none":b(t[2])+"deg","lcha"===r||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(" ")})`})(ee(t),r);return $(e),n}return"oklab"===r.substr(0,5)?((...e)=>{const t=c(e,"lab");return t[0]=b(100*t[0])+"%",t[1]=g(t[1]),t[2]=g(t[2]),t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(" ")})`})(pe(t)):"oklch"===r.substr(0,5)?((...e)=>{const t=c(e,"lch");return t[0]=b(100*t[0])+"%",t[1]=g(t[1]),t[2]=isNaN(t[2])?"none":b(t[2])+"deg",t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(" ")})`})(st(t)):(t[0]=ft(t[0]),t[1]=ft(t[1]),t[2]=ft(t[2]),("rgba"===r||t.length>3&&t[3]<1)&&(t[3]="/ "+(t.length>3?t[3]:1),r="rgba"),`${r.substr(0,3)}(${t.slice(0,"rgb"===r?3:4).join(" ")})`)},ct=(...e)=>{e=c(e,"lch");const[t,r,n,...o]=e,[a,s,f]=U(t,r,n),[l,i,u]=me(a,s,f);return[l,i,u,...o.length>0&&o[0]<1?[o[0]]:[]]},it=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,ut=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,ht=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,dt=/\s*/.source,bt=/\s+/.source,gt=/\s*,\s*/.source,mt=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,pt=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,wt=new RegExp("^rgba?\\("+dt+[it,it,it].join(bt)+pt+"\\)$"),yt=new RegExp("^rgb\\("+dt+[it,it,it].join(gt)+dt+"\\)$"),kt=new RegExp("^rgba\\("+dt+[it,it,it,ut].join(gt)+dt+"\\)$"),Mt=new RegExp("^hsla?\\("+dt+[mt,ht,ht].join(bt)+pt+"\\)$"),xt=new RegExp("^hsl?\\("+dt+[mt,ht,ht].join(gt)+dt+"\\)$"),vt=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Nt=new RegExp("^lab\\("+dt+[ut,ut,ut].join(bt)+pt+"\\)$"),_t=new RegExp("^lch\\("+dt+[ut,ut,mt].join(bt)+pt+"\\)$"),At=new RegExp("^oklab\\("+dt+[ut,ut,ut].join(bt)+pt+"\\)$"),jt=new RegExp("^oklch\\("+dt+[ut,ut,mt].join(bt)+pt+"\\)$"),{round:Et}=Math,Ct=e=>e.map((e,t)=>t<=2?a(Et(e),0,255):e),Rt=(e,t=0,r=100,n=!1)=>("string"==typeof e&&e.endsWith("%")&&(e=parseFloat(e.substring(0,e.length-1))/100,e=n?t+.5*(e+1)*(r-t):t+e*(r-t)),+e),Pt=(e,t)=>"none"===e?t:e,$t=e=>{if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];let t;if(M.format.named)try{return M.format.named(e)}catch(e){}if((t=e.match(wt))||(t=e.match(yt))){let e=t.slice(1,4);for(let t=0;t<3;t++)e[t]=+Rt(Pt(e[t],0),0,255);e=Ct(e);const r=void 0!==t[4]?+Rt(t[4],0,1):1;return e[3]=r,e}if(t=e.match(kt)){const e=t.slice(1,5);for(let t=0;t<4;t++)e[t]=+Rt(e[t],0,255);return e}if((t=e.match(Mt))||(t=e.match(xt))){const e=t.slice(1,4);e[0]=+Pt(e[0].replace("deg",""),0),e[1]=.01*+Rt(Pt(e[1],0),0,100),e[2]=.01*+Rt(Pt(e[2],0),0,100);const r=Ct(ie(e)),n=void 0!==t[4]?+Rt(t[4],0,1):1;return r[3]=n,r}if(t=e.match(vt)){const e=t.slice(1,4);e[1]*=.01,e[2]*=.01;const r=ie(e);for(let e=0;e<3;e++)r[e]=Et(r[e]);return r[3]=+t[4],r}if(t=e.match(Nt)){const e=t.slice(1,4);e[0]=Rt(Pt(e[0],0),0,100),e[1]=Rt(Pt(e[1],0),-125,125,!0),e[2]=Rt(Pt(e[2],0),-125,125,!0);const r=B();$("d50");const n=Ct(O(e));$(r);const o=void 0!==t[4]?+Rt(t[4],0,1):1;return n[3]=o,n}if(t=e.match(_t)){const e=t.slice(1,4);e[0]=Rt(e[0],0,100),e[1]=Rt(Pt(e[1],0),0,150,!1),e[2]=+Pt(e[2].replace("deg",""),0);const r=B();$("d50");const n=Ct(V(e));$(r);const o=void 0!==t[4]?+Rt(t[4],0,1):1;return n[3]=o,n}if(t=e.match(At)){const e=t.slice(1,4);e[0]=Rt(Pt(e[0],0),0,1),e[1]=Rt(Pt(e[1],0),-.4,.4,!0),e[2]=Rt(Pt(e[2],0),-.4,.4,!0);const r=Ct(me(e)),n=void 0!==t[4]?+Rt(t[4],0,1):1;return r[3]=n,r}if(t=e.match(jt)){const e=t.slice(1,4);e[0]=Rt(Pt(e[0],0),0,1),e[1]=Rt(Pt(e[1],0),0,.4,!1),e[2]=+Pt(e[2].replace("deg",""),0);const r=Ct(ct(e)),n=void 0!==t[4]?+Rt(t[4],0,1):1;return r[3]=n,r}};$t.test=e=>wt.test(e)||Mt.test(e)||Nt.test(e)||_t.test(e)||At.test(e)||jt.test(e)||yt.test(e)||kt.test(e)||xt.test(e)||vt.test(e)||"transparent"===e,x.prototype.css=function(e){return lt(this._rgb,e)};v.css=(...e)=>new x(...e,"css"),M.format.css=$t,M.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&"string"===l(e)&&$t.test(e))return"css"}}),M.format.gl=(...e)=>{const t=c(e,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t};v.gl=(...e)=>new x(...e,"gl"),x.prototype.gl=function(){const e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]},x.prototype.hex=function(e){return C(this._rgb,e)};v.hex=(...e)=>new x(...e,"hex"),M.format.hex=j,M.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&"string"===l(e)&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return"hex"}});const{log:Bt}=Math,Ot=e=>{const t=e/100;let r,n,o;return t<66?(r=255,n=t<6?0:-155.25485562709179-.44596950469579133*(n=t-2)+104.49216199393888*Bt(n),o=t<20?0:.8274096064007395*(o=t-10)-254.76935184120902+115.67994401066147*Bt(o)):(r=351.97690566805693+.114206453784165*(r=t-55)-40.25366309332127*Bt(r),n=325.4494125711974+.07943456536662342*(n=t-50)-28.0852963507957*Bt(n),o=255),[r,n,o,1]},{round:Lt}=Math;x.prototype.temp=x.prototype.kelvin=x.prototype.temperature=function(){return((...e)=>{const t=c(e,"rgb"),r=t[0],n=t[2];let o,a=1e3,s=4e4;for(;s-a>.4;){o=.5*(s+a);const e=Ot(o);e[2]/e[0]>=n/r?s=o:a=o}return Lt(o)})(this._rgb)};const Yt=(...e)=>new x(...e,"temp");Object.assign(v,{temp:Yt,kelvin:Yt,temperature:Yt}),M.format.temp=M.format.kelvin=M.format.temperature=Ot,x.prototype.oklch=function(){return st(this._rgb)};function Gt(e,t="#000000",r="#ffffff"){return v(e).luminance()>.5?t:r}function qt(e,t){return v.scale("Blues")(e/(t-1)).hex()}function zt(e,t,r,n=1e-5){return e>=Math.min(t,r)-n&&e<=Math.max(t,r)+n}function Xt(e){return{left:e.top,right:e.bottom,top:e.left,bottom:e.right,horizontal:!e.horizontal}}Object.assign(v,{oklch:(...e)=>new x(...e,"oklch")}),M.format.oklch=ct,M.autodetect.push({p:2,test:(...e)=>{if("array"===l(e=c(e,"oklch"))&&3===e.length)return"oklch"}}),Object.assign(v,{analyze:Xe,average:(e,t="lrgb",r=null)=>{const n=e.length;r||(r=Array.from(new Array(n)).map(()=>1));const o=n/r.reduce(function(e,t){return e+t});if(r.forEach((e,t)=>{r[t]*=o}),e=e.map(e=>new x(e)),"lrgb"===t)return Ne(e,r);const a=e.shift(),s=a.get(t),f=[];let l=0,c=0;for(let e=0;e<s.length;e++)if(s[e]=(s[e]||0)*r[0],f.push(isNaN(s[e])?0:r[0]),"h"===t.charAt(e)&&!isNaN(s[e])){const t=s[e]/180*ke;l+=Me(t)*r[0],c+=xe(t)*r[0]}let i=a.alpha()*r[0];e.forEach((e,n)=>{const o=e.get(t);i+=e.alpha()*r[n+1];for(let e=0;e<s.length;e++)if(!isNaN(o[e]))if(f[e]+=r[n+1],"h"===t.charAt(e)){const t=o[e]/180*ke;l+=Me(t)*r[n+1],c+=xe(t)*r[n+1]}else s[e]+=o[e]*r[n+1]});for(let e=0;e<s.length;e++)if("h"===t.charAt(e)){let t=ve(c/f[e],l/f[e])/ke*180;for(;t<0;)t+=360;for(;t>=360;)t-=360;s[e]=t}else s[e]=s[e]/f[e];return i/=n,new x(s,t).alpha(i>.99999?1:i,!0)},bezier:e=>{const t=function(e){let t,r,n,o;if(2===(e=e.map(e=>new x(e))).length)[r,n]=e.map(e=>e.lab()),t=function(e){const t=[0,1,2].map(t=>r[t]+e*(n[t]-r[t]));return new x(t,"lab")};else if(3===e.length)[r,n,o]=e.map(e=>e.lab()),t=function(e){const t=[0,1,2].map(t=>(1-e)*(1-e)*r[t]+2*(1-e)*e*n[t]+e*e*o[t]);return new x(t,"lab")};else if(4===e.length){let a;[r,n,o,a]=e.map(e=>e.lab()),t=function(e){const t=[0,1,2].map(t=>(1-e)*(1-e)*(1-e)*r[t]+3*(1-e)*(1-e)*e*n[t]+3*(1-e)*e*e*o[t]+e*e*e*a[t]);return new x(t,"lab")}}else{if(!(e.length>=5))throw new RangeError("No point in running bezier with only one color.");{let r,n,o;r=e.map(e=>e.lab()),o=e.length-1,n=function(e){let t=[1,1];for(let r=1;r<e;r++){let e=[1];for(let r=1;r<=t.length;r++)e[r]=(t[r]||0)+t[r-1];t=e}return t}(o),t=function(e){const t=1-e,a=[0,1,2].map(a=>r.reduce((r,s,f)=>r+n[f]*t**(o-f)*e**f*s[a],0));return new x(a,"lab")}}}return t}(e);return t.scale=()=>Ae(t),t},blend:Ee,brewer:ot,Color:x,colors:N,contrast:(e,t)=>{e=new x(e),t=new x(t);const r=e.luminance(),n=t.luminance();return r>n?(r+.05)/(n+.05):(n+.05)/(r+.05)},contrastAPCA:(e,t)=>{e=new x(e),t=new x(t),e.alpha()<1&&(e=W(t,e,e.alpha(),"rgb"));const r=Ie(...e.rgb()),n=Ie(...t.rgb()),o=r>=Ze?r:r+Math.pow(Ze-r,1.414),a=n>=Ze?n:n+Math.pow(Ze-n,1.414),s=Math.pow(a,.56)-Math.pow(o,.57),f=Math.pow(a,.65)-Math.pow(o,.62),l=Math.abs(a-o)<5e-4?0:o<a?1.14*s:1.14*f;return 100*(Math.abs(l)<.1?0:l>0?l-.027:l+.027)},cubehelix:function(e=300,t=-1.5,r=1,n=1,o=[0,1]){let a,f=0;"array"===l(o)?a=o[1]-o[0]:(a=0,o=[o,o]);const c=function(l){const c=m*((e+120)/360+t*l),i=Pe(o[0]+a*l,n),u=(0!==f?r[0]+l*f:r)*i*(1-i)/2,h=Be(c),d=$e(c);return v(s([255*(i+u*(-.14861*h+1.78277*d)),255*(i+u*(-.29227*h-.90649*d)),255*(i+u*(1.97294*h)),1]))};return c.start=function(t){return null==t?e:(e=t,c)},c.rotations=function(e){return null==e?t:(t=e,c)},c.gamma=function(e){return null==e?n:(n=e,c)},c.hue=function(e){return null==e?r:("array"===l(r=e)?(f=r[1]-r[0],0===f&&(r=r[1])):f=0,c)},c.lightness=function(e){return null==e?o:("array"===l(e)?(o=e,a=e[1]-e[0]):(o=[e,e],a=0),c)},c.scale=()=>v.scale(c),c.hue(r),c},deltaE:function(e,t,r=1,n=1,o=1){var a=function(e){return 360*e/(2*Qe)},s=function(e){return 2*Qe*e/360};e=new x(e),t=new x(t);const[f,l,c]=Array.from(e.lab()),[i,u,h]=Array.from(t.lab()),d=(f+i)/2,b=(Fe(We(l,2)+We(c,2))+Fe(We(u,2)+We(h,2)))/2,g=.5*(1-Fe(We(b,7)/(We(b,7)+We(25,7)))),m=l*(1+g),p=u*(1+g),w=Fe(We(m,2)+We(c,2)),y=Fe(We(p,2)+We(h,2)),k=(w+y)/2,M=a(Ue(c,m)),v=a(Ue(h,p)),N=M>=0?M:M+360,_=v>=0?v:v+360,A=Ve(N-_)>180?(N+_+360)/2:(N+_)/2,j=1-.17*De(s(A-30))+.24*De(s(2*A))+.32*De(s(3*A+6))-.2*De(s(4*A-63));let E=_-N;E=Ve(E)<=180?E:_<=N?E+360:E-360,E=2*Fe(w*y)*He(s(E)/2);const C=i-f,R=y-w,P=1+.015*We(d-50,2)/Fe(20+We(d-50,2)),$=1+.045*k,B=1+.015*k*j,O=30*Je(-We((A-275)/25,2)),L=-(2*Fe(We(k,7)/(We(k,7)+We(25,7))))*He(2*s(O)),Y=Fe(We(C/(r*P),2)+We(R/(n*$),2)+We(E/(o*B),2)+L*(R/(n*$))*(E/(o*B)));return Te(0,Ke(100,Y))},distance:function(e,t,r="lab"){e=new x(e),t=new x(t);const n=e.get(r),o=t.get(r);let a=0;for(let e in n){const t=(n[e]||0)-(o[e]||0);a+=t*t}return Math.sqrt(a)},input:M,interpolate:W,limits:Se,mix:W,random:()=>{let e="#";for(let t=0;t<6;t++)e+="0123456789abcdef".charAt(Oe(16*Le()));return new x(e,"hex")},scale:Ae,scales:et,valid:(...e)=>{try{return new x(...e),!0}catch(e){return!1}}});class St extends t.BarElement{constructor(){super(...arguments),this.align="center",this.next=void 0,this.previous=void 0}getBounds(e=!1){const{x:t,y:r,base:n,width:o,height:a,horizontal:s}=this.getProps(["x","y","base","width","height","horizontal"],e);if(s){const e=Math.abs(t-n),o=a/2;return{left:n-("left"!==this.align?e:0),top:r-o,right:n+("right"!==this.align?e:0),bottom:r+o,horizontal:s}}{const e=Math.abs(r-n),a=o/2,f=t+a;return{left:t-a,top:n-("right"!==this.align?e:0),right:f,bottom:n+("left"!==this.align?e:0),horizontal:s}}}inRange(e,t,r){const n=this.getBounds(r),o=null==e||zt(e,n.left,n.right),a=null==t||zt(t,n.top,n.bottom);return o&&a}inXRange(e,t){return this.inRange(e,null,t)}inYRange(e,t){return this.inRange(null,e,t)}getCenterPoint(e){const{x:t,y:r,base:n,horizontal:o}=this.getProps(["x","y","base","horizontal"],e);return{center:{x:o?n:t,y:o?r:n},left:{x:o?(n+t)/2:t,y:o?r:(n+r)/2},right:{x:o?n-(t-n)/2:t,y:o?r:n-(r+n)/2}}[this.align]}tooltipPosition(e){return this.getCenterPoint(e)}getRange(e){const{width:t,height:r}=this.getProps(["width","height"]);return"x"===e?t:r}computeWayPoints(e=!1){let t=this.options.shrinkAnchor,r=Math.max(Math.min(this.options.shrinkFraction,1),0);0===r&&(t="none",r=1);let n=this.getBounds(e);const o=n.horizontal;let a=!this.next||"top"!==t&&"middle"!==t?n:this.next.getBounds(e),s=!this.previous||"bottom"!==t&&"middle"!==t?n:this.previous.getBounds(e);o||(n=Xt(n),a=Xt(a),s=Xt(s));const f=Math.floor((n.bottom-n.top)*(1-r)),l=Math.floor((n.bottom-n.top-f)/2),c=[],i=[];if("none"===t||"top"===t)c.push([n.left,n.top],[n.right,n.top]);else{let e=1;if("middle"===t){e=l/(Math.floor((s.bottom-s.top)*r*.5)+l)}c.push([n.left+(s.left-n.left)*e,n.top],[n.right+(s.right-n.right)*e,n.top])}if("middle"===t?(c.push([n.right,n.top+l]),c.push([n.right,n.bottom-l]),i.push([n.left,n.top+l]),i.push([n.left,n.bottom-l])):"top"===t&&r<1?(c.push([n.right,n.top+f]),i.push([n.left,n.top+f])):"bottom"===t&&r<1&&(c.push([n.right,n.bottom-f]),i.push([n.left,n.bottom-f])),"none"===t||"bottom"===t)c.push([n.right,n.bottom],[n.left,n.bottom]);else{let e=1;if("middle"===t){e=l/(Math.floor((a.bottom-a.top)*r*.5)+l)}c.push([n.right+(a.right-n.right)*e,n.bottom],[n.left+(a.left-n.left)*e,n.bottom])}return c.push(...i.reverse()),o?c:c.map(([e,t])=>[t,e])}draw(e){const{options:t}=this;e.save(),e.beginPath();const r=this.computeWayPoints();e.moveTo(r[0][0],r[0][1]);for(const t of r.slice(1))e.lineTo(t[0],t[1]);t.backgroundColor&&(e.fillStyle=t.backgroundColor,e.fill()),t.borderColor&&(e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,e.stroke()),e.restore()}}St.id="trapezoid",St.defaults={...t.BarElement.defaults,shrinkAnchor:"top",shrinkFraction:1},St.defaultRoutes=t.BarElement.defaultRoutes;class Zt extends t.BarController{getMinMax(e,t){const{max:r}=super.getMinMax(e,t);return{center:{min:-r,max:r},left:{min:0,max:r},right:{min:-r,max:0}}[this.options.align]}update(e){super.update(e);const t=this._cachedMeta.data||[];for(let e=0;e<t.length;e++)t[e].align=this.options.align,t[e].next=t[e+1],t[e].previous=t[e-1]}}Zt.id="funnel",Zt.defaults=r.merge({},[t.BarController.defaults,{dataElementType:St.id,barPercentage:1,align:"center",categoryPercentage:.98}]),Zt.overrides=r.merge({},[t.BarController.overrides,{plugins:{legend:{display:!1},colors:{enabled:!1},datalabels:{anchor:"start",textAlign:"center",font:{size:20},color:e=>Gt(e.chart.getDatasetMeta(e.datasetIndex).data[e.dataIndex].options.backgroundColor,t.Chart.defaults.color,"#ffffff"),formatter:(e,t)=>{var r,n;return`${null!==(n=null===(r=t.chart.data.labels)||void 0===r?void 0:r[t.dataIndex])&&void 0!==n?n:""}\n${(100*e).toLocaleString()}%`}}},scales:{_index_:{display:!1,padding:10,grid:{display:!1}},_value_:{display:!1,beginAtZero:!1,grace:0,grid:{display:!1}}},elements:{trapezoid:{backgroundColor(e){const t=e.chart.data.datasets[e.datasetIndex].data.length;return qt(e.dataIndex,t)}}}}]);class It extends t.Chart{constructor(e,r){super(e,function(e,r,n,o=[],a=[]){t.registry.addControllers(n),Array.isArray(o)?t.registry.addElements(...o):t.registry.addElements(o),Array.isArray(a)?t.registry.addScales(...a):t.registry.addScales(a);const s=r;return s.type=e,s}("funnel",r,Zt,St,[t.CategoryScale,t.LinearScale]))}}It.id=Zt.id,t.registry.addControllers(Zt),t.registry.addElements(St),e.FunnelChart=It,e.FunnelController=Zt,e.TrapezoidElement=St,e.blues=qt,e.pickForegroundColorToBackgroundColor=Gt}); //# sourceMappingURL=index.umd.min.js.map