diff --git a/dist/chroma-light.cjs b/dist/chroma-light.cjs index bb58b840..595258b4 100644 --- a/dist/chroma-light.cjs +++ b/dist/chroma-light.cjs @@ -61,10 +61,13 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory()); })(this, (function () { 'use strict'; + var min$1 = Math.min; + var max$1 = Math.max; + function limit (x, low, high) { if ( high === void 0 ) high = 1; - return min(max(low, x), high); + return min$1(max$1(low, x), high); } function clip_rgb (rgb) { diff --git a/dist/chroma-light.min.cjs b/dist/chroma-light.min.cjs index 1e876062..ddc330ad 100644 --- a/dist/chroma-light.min.cjs +++ b/dist/chroma-light.min.cjs @@ -55,4 +55,4 @@ * @preserve */ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).chroma=r()}(this,(function(){"use strict";function t(t,r,n){return void 0===n&&(n=1),l(c(r,t),n)}for(var r={},n=0,e=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];n=3?Array.prototype.slice.call(t):"object"==o(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0].slice(0)}function s(t){if(t.length<2)return null;var r=t.length-1;return"string"==o(t[r])?t[r].toLowerCase():null}var u=Math.PI,l=Math.min,c=Math.max,h=function(t){return Math.round(100*t)/100},f=function(t){return Math.round(100*t)/100},d=u/180,g=180/u,m={format:{},autodetect:[]},p=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=this;if("object"===o(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=s(r),i=!1;if(!a){i=!0,m.sorted||(m.autodetect=m.autodetect.sort((function(t,r){return r.p-t.p})),m.sorted=!0);for(var u=0,l=m.autodetect;u255)&&(r._clipped=!0),r[n]=t(r[n],0,255)):3===n&&(r[n]=t(r[n],0,1));return r}(h),3===e._rgb.length&&e._rgb.push(1)};p.prototype.toString=function(){return"function"==o(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var v=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t)))};v.version="3.0.0";var b=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=i(t,"rgba"))[0],o=t[1],s=t[2],u=l(a/=255,o/=255,s/=255),h=c(a,o,s),f=(h+u)/2;return h===u?(n=0,e=Number.NaN):n=f<.5?(h-u)/(h+u):(h-u)/(2-h-u),a==h?e=(o-s)/(h-u):o==h?e=2+(s-a)/(h-u):s==h&&(e=4+(a-o)/(h-u)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,f,t[3]]:[e,n,f]},y={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,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}},w=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 M(t){var r=w.get(String(t).toLowerCase());if(!r)throw new Error("unknown Lab illuminant "+t);y.labWhitePoint=t,y.Xn=r[0],y.Zn=r[1]}function k(){return y.labWhitePoint}var x=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],a=n[1],o=n[2],s=n.slice(3),u=A(e,a,o),l=function(t,r,n){var e=y.Xn,a=y.Yn,o=y.Zn,i=y.kE,s=y.kK,u=t/e,l=r/a,c=n/o,h=u>i?Math.pow(u,1/3):(s*u+16)/116,f=l>i?Math.pow(l,1/3):(s*l+16)/116,d=c>i?Math.pow(c,1/3):(s*c+16)/116;return[116*f-16,500*(h-f),200*(f-d)]}(u[0],u[1],u[2]);return[l[0],l[1],l[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])};function _(t){var r=Math.sign(t);return((t=Math.abs(t))<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4))*r}var A=function(t,r,n){t=_(t/255),r=_(r/255),n=_(n/255);var e=y.MtxRGB2XYZ,a=y.MtxAdaptMa,o=y.MtxAdaptMaI,i=y.Xn,s=y.Yn,u=y.Zn,l=y.As,c=y.Bs,h=y.Cs,f=t*e.m00+r*e.m10+n*e.m20,d=t*e.m01+r*e.m11+n*e.m21,g=t*e.m02+r*e.m12+n*e.m22,m=i*a.m00+s*a.m10+u*a.m20,p=i*a.m01+s*a.m11+u*a.m21,v=i*a.m02+s*a.m12+u*a.m22,b=f*a.m00+d*a.m10+g*a.m20,w=f*a.m01+d*a.m11+g*a.m21,M=f*a.m02+d*a.m12+g*a.m22;return w*=p/c,M*=v/h,[f=(b*=m/l)*o.m00+w*o.m10+M*o.m20,d=b*o.m01+w*o.m11+M*o.m21,g=b*o.m02+w*o.m12+M*o.m22]},j=Math.sqrt,$=Math.atan2,F=Math.round,X=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab"),e=n[0],a=n[1],o=n[2],s=j(a*a+o*o),u=($(o,a)*g+360)%360;return 0===F(1e4*s)&&(u=Number.NaN),[e,s,u]};function Z(t,r){var n=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(r[0])||(r=r.map((function(t){return[t]})));var e=r[0].length,a=r[0].map((function(t,n){return r.map((function(t){return t[n]}))})),o=t.map((function(t){return a.map((function(r){return Array.isArray(t)?t.reduce((function(t,n,e){return t+n*(r[e]||0)}),0):r.reduce((function(r,n){return r+n*t}),0)}))}));return 1===n&&(o=o[0]),1===e?o.map((function(t){return t[0]})):o}var E=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=i(t,"rgb"),o=a[0],s=a[1],u=a[2],l=a.slice(3),c=A(o,s,u);return(n=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],e=Z([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],c),Z(n,e.map((function(t){return Math.cbrt(t)})))).concat(l.length>0&&l[0]<1?[l[0]]:[])};var Y=Math.round,N=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=s(t)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"hsla"),e=s(t)||"lsa";return n[0]=h(n[0]||0)+"deg",n[1]=h(100*n[1])+"%",n[2]=h(100*n[2])+"%","hsla"===e||n.length>3&&n[3]<1?(n[3]="/ "+(n.length>3?n[3]:1),e="hsla"):n.length=3,e.substr(0,3)+"("+n.join(" ")+")"}(b(n),e);if("lab"===e.substr(0,3)){var a=k();M("d50");var o=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab"),e=s(t)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(x(n),e);return M(a),o}if("lch"===e.substr(0,3)){var u=k();M("d50");var l=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lch"),e=s(t)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],a=n[1],o=n[2],s=n.slice(3),u=x(e,a,o),l=u[0],c=u[1],h=u[2],f=X(l,c,h);return[f[0],f[1],f[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])}(n),e);return M(u),l}return"oklab"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab");return n[0]=h(100*n[0])+"%",n[1]=f(n[1]),n[2]=f(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}(E(n)):"oklch"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab");return n[0]=h(100*n[0])+"%",n[1]=f(n[1]),n[2]=h(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],a=n[1],o=n[2],s=n.slice(3),u=E(e,a,o),l=u[0],c=u[1],h=u[2],f=X(l,c,h);return[f[0],f[1],f[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])}(n)):(n[0]=Y(n[0]),n[1]=Y(n[1]),n[2]=Y(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},B=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,a,o,s=(r=i(r,"hsl"))[0],u=r[1],l=r[2];if(0===u)e=a=o=255*l;else{var c=[0,0,0],h=[0,0,0],f=l<.5?l*(1+u):l+u-l*u,d=2*l-f,g=s/360;c[0]=g+1/3,c[1]=g,c[2]=g-1/3;for(var m=0;m<3;m++)c[m]<0&&(c[m]+=1),c[m]>1&&(c[m]-=1),6*c[m]<1?h[m]=d+6*(f-d)*c[m]:2*c[m]<1?h[m]=f:3*c[m]<2?h[m]=d+(f-d)*(2/3-c[m])*6:h[m]=d;e=(t=[255*h[0],255*h[1],255*h[2]])[0],a=t[1],o=t[2]}return r.length>3?[e,a,o,r[3]]:[e,a,o,1]},C=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lab"))[0],e=t[1],a=t[2],o=O(n,e,a),s=o[0],u=o[1],l=o[2],c=L(s,u,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]},O=function(t,r,n){var e=y.kE,a=y.kK,o=y.kKE,i=y.Xn,s=y.Yn,u=y.Zn,l=(t+16)/116,c=.002*r+l,h=l-.005*n,f=c*c*c,d=h*h*h;return[(f>e?f:(116*c-16)/a)*i,(t>o?Math.pow((t+16)/116,3):t/a)*s,(d>e?d:(116*h-16)/a)*u]},R=function(t){var r=Math.sign(t);return((t=Math.abs(t))<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)*r},L=function(t,r,n){var e=y.MtxAdaptMa,a=y.MtxAdaptMaI,o=y.MtxXYZ2RGB,i=y.RefWhiteRGB,s=y.Xn,u=y.Yn,l=y.Zn,c=s*e.m00+u*e.m10+l*e.m20,h=s*e.m01+u*e.m11+l*e.m21,f=s*e.m02+u*e.m12+l*e.m22,d=i.X*e.m00+i.Y*e.m10+i.Z*e.m20,g=i.X*e.m01+i.Y*e.m11+i.Z*e.m21,m=i.X*e.m02+i.Y*e.m12+i.Z*e.m22,p=(t*e.m00+r*e.m10+n*e.m20)*(d/c),v=(t*e.m01+r*e.m11+n*e.m21)*(g/h),b=(t*e.m02+r*e.m12+n*e.m22)*(m/f),w=p*a.m00+v*a.m10+b*a.m20,M=p*a.m01+v*a.m11+b*a.m21,k=p*a.m02+v*a.m12+b*a.m22;return[255*R(w*o.m00+M*o.m10+k*o.m20),255*R(w*o.m01+M*o.m11+k*o.m21),255*R(w*o.m02+M*o.m12+k*o.m22)]},W=Math.sin,K=Math.cos,G=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lch"),e=n[0],a=n[1],o=n[2];return isNaN(o)&&(o=0),[e,K(o*=d)*a,W(o)*a]},I=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=i(t,"lab"))[0],o=t[1],s=t[2],u=t.slice(3),l=(n=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],e=Z([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,o,s]),Z(n,e.map((function(t){return Math.pow(t,3)})))),c=l[0],h=l[1],f=l[2],d=L(c,h,f);return[d[0],d[1],d[2]].concat(u.length>0&&u[0]<1?[u[0]]:[])};var P=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,S=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,q=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,T=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,D=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,U=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,z=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,H=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,J=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,Q=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,V=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,tt=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,rt=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,nt=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,et=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,at=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,ot=Math.round,it=function(r){return r.map((function(r,n){return n<=2?t(ot(r),0,255):r}))},st=function(t,r,n,e){return void 0===r&&(r=0),void 0===n&&(n=100),void 0===e&&(e=!1),"string"==typeof t&&t.endsWith("%")&&(t=parseFloat(t.substring(0,t.length-1))/100,t=e?r+.5*(t+1)*(n-r):r+t*(n-r)),+t},ut=function(t,r){return"none"===t?r:t},lt=function(t){var r;if(t=t.toLowerCase().trim(),m.format.named)try{return m.format.named(t)}catch(t){}if((r=t.match(P))||(r=t.match(S))){for(var n=r.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if((r=t.match(q))||(r=t.match(T))){for(var a=r.slice(1,5),o=0;o<4;o++)a[o]=+a[o];return a}if((r=t.match(D))||(r=t.match(U))){for(var s=r.slice(1,4),u=0;u<3;u++)s[u]=ot(2.55*s[u]);return s[3]=1,s}if((r=t.match(z))||(r=t.match(H))){for(var l=r.slice(1,5),c=0;c<3;c++)l[c]=ot(2.55*l[c]);return l[3]=+l[3],l}if((r=t.match(J))||(r=t.match(Q))){var h=r.slice(1,4);h[1]*=.01,h[2]*=.01;for(var f=B(h),d=0;d<3;d++)f[d]=ot(f[d]);return f[3]=1,f}if((r=t.match(V))||(r=t.match(tt))){var g=r.slice(1,4);g[1]*=.01,g[2]*=.01;for(var p=B(g),v=0;v<3;v++)p[v]=ot(p[v]);return p[3]=+r[4],p}if(r=t.match(rt)){var b=r.slice(1,4);b[0]=st(b[0],0,100),b[1]=st(b[1],-125,125,!0),b[2]=st(b[2],-125,125,!0);var y=k();M("d50");var w=it(C(b));return M(y),w[3]=void 0!==r[4]?+r[4]:1,w}if(r=t.match(nt)){var x=r.slice(1,4);x[0]=st(x[0],0,100),x[1]=st(ut(x[1],0),0,150,!1),x[2]=+ut(x[2].replace("deg",""),0);var _=k();M("d50");var A=it(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lch"))[0],e=t[1],a=t[2],o=G(n,e,a),s=o[0],u=o[1],l=o[2],c=C(s,u,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]}(x));return M(_),A[3]=void 0!==r[4]?+r[4]:1,A}if(r=t.match(et)){var j=r.slice(1,4);j[0]=st(j[0],0,1),j[1]=st(j[1],-.4,.4,!0),j[2]=st(j[2],-.4,.4,!0);var $=it(I(j));return $[3]=void 0!==r[4]?+r[4]:1,$}if(r=t.match(at)){var F=r.slice(1,4);F[0]=st(F[0],0,1),F[1]=st(ut(F[1],0),0,.4,!1),F[2]=+ut(F[2].replace("deg",""),0);var X=it(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lch"))[0],e=t[1],a=t[2],o=t.slice(3),s=G(n,e,a),u=s[0],l=s[1],c=s[2],h=I(u,l,c);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])}(F));return X[3]=void 0!==r[4]?+r[4]:1,X}};lt.test=function(t){return P.test(t)||q.test(t)||D.test(t)||z.test(t)||J.test(t)||V.test(t)||rt.test(t)||nt.test(t)||et.test(t)||at.test(t)||S.test(t)||T.test(t)||U.test(t)||H.test(t)||Q.test(t)||tt.test(t)},p.prototype.css=function(t){return N(this._rgb,t)};var ct=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["css"])))};v.css=ct,m.format.css=lt,m.autodetect.push({p:5,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===o(t)&<.test(t))return"css"}});var ht=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,ft=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,dt=Math.round;p.prototype.hex=function(t){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=n[0],a=n[1],o=n[2],u=n[3],l=s(t)||"auto";void 0===u&&(u=1),"auto"===l&&(l=u<1?"rgba":"rgb");var c="000000"+((e=dt(e))<<16|(a=dt(a))<<8|(o=dt(o))).toString(16);c=c.substr(c.length-6);var h="0"+dt(255*u).toString(16);switch(h=h.substr(h.length-2),l.toLowerCase()){case"rgba":return"#"+c+h;case"argb":return"#"+h+c;default:return"#"+c}}(this._rgb,t)};var gt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["hex"])))};v.hex=gt,m.format.hex=function(t){if(t.match(ht)){4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var r=parseInt(t,16);return[r>>16,r>>8&255,255&r,1]}if(t.match(ft)){5!==t.length&&9!==t.length||(t=t.substr(1)),4===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);var n=parseInt(t,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+t)},m.autodetect.push({p:4,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===o(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}}),p.prototype.hsl=function(){return b(this._rgb)};var mt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["hsl"])))};v.hsl=mt,m.format.hsl=B,m.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"hsl"))&&3===t.length)return"hsl"}}),p.prototype.lab=function(){return x(this._rgb)};var pt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["lab"])))};Object.assign(v,{lab:pt,getLabWhitePoint:k,setLabWhitePoint:M}),m.format.lab=C,m.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"lab"))&&3===t.length)return"lab"}}),p.prototype.oklab=function(){return E(this._rgb)};var vt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["oklab"])))};Object.assign(v,{oklab:vt}),m.format.oklab=I,m.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"oklab"))&&3===t.length)return"oklab"}});var bt=Math.round;p.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(bt)},p.prototype.rgba=function(t){return void 0===t&&(t=!0),this._rgb.slice(0,4).map((function(r,n){return n<3?!1===t?r:bt(r):r}))};var yt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["rgb"])))};Object.assign(v,{rgb:yt}),m.format.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba");return void 0===n[3]&&(n[3]=1),n},m.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"rgba"))&&(3===t.length||4===t.length&&"number"==o(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}}),p.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===o(t)?r?(this._rgb[3]=t,this):new p([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},p.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=y.Kn*t,new p(r,"lab").alpha(this.alpha(),!0)},p.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},p.prototype.darker=p.prototype.darken,p.prototype.brighter=p.prototype.brighten,p.prototype.get=function(t){var r=t.split("."),n=r[0],e=r[1],a=this[n]();if(e){var o=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(o>-1)return a[o];throw new Error("unknown channel "+e+" in mode "+n)}return a};var wt={};function Mt(t,r,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var i=e[0]||"lrgb";if(wt[i]||e.length||(i=Object.keys(wt)[0]),!wt[i])throw new Error("interpolation mode "+i+" is not defined");return"object"!==o(t)&&(t=new p(t)),"object"!==o(r)&&(r=new p(r)),wt[i](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}p.prototype.mix=p.prototype.interpolate=function(t,r){void 0===r&&(r=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return Mt.apply(void 0,[this,t,r].concat(n))},p.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),a=e[0],i=e[1],s=this[a]();if(i){var u=a.indexOf(i)-("ok"===a.substr(0,2)?2:0);if(u>-1){if("string"==o(r))switch(r.charAt(0)){case"+":case"-":s[u]+=+r;break;case"*":s[u]*=+r.substr(1);break;case"/":s[u]/=+r.substr(1);break;default:s[u]=+r}else{if("number"!==o(r))throw new Error("unsupported value for Color.set");s[u]=r}var l=new p(s,a);return n?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+i+" in mode "+a)}return s},p.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Mt.apply(void 0,[this,"white",t].concat(r))},p.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Mt.apply(void 0,[this,"black",t].concat(r))};var kt=Math.sqrt,xt=Math.pow;wt.lrgb=function(t,r,n){var e=t._rgb,a=e[0],o=e[1],i=e[2],s=r._rgb,u=s[0],l=s[1],c=s[2];return new p(kt(xt(a,2)*(1-n)+xt(u,2)*n),kt(xt(o,2)*(1-n)+xt(l,2)*n),kt(xt(i,2)*(1-n)+xt(c,2)*n),"rgb")};return wt.oklab=function(t,r,n){var e=t.oklab(),a=r.oklab();return new p(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")},Object.assign(v,{Color:p,valid:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{return new(Function.prototype.bind.apply(p,[null].concat(t))),!0}catch(t){return!1}},css:ct,hex:gt,hsl:mt,lab:pt,oklab:vt,rgb:yt,mix:Mt,interpolate:Mt}),v})); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).chroma=r()}(this,(function(){"use strict";var t=Math.min,r=Math.max;function n(n,e,a){return void 0===a&&(a=1),t(r(e,n),a)}for(var e={},a=0,o=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];a=3?Array.prototype.slice.call(t):"object"==s(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0].slice(0)}function l(t){if(t.length<2)return null;var r=t.length-1;return"string"==s(t[r])?t[r].toLowerCase():null}var c=Math.PI,h=Math.min,f=Math.max,d=function(t){return Math.round(100*t)/100},g=function(t){return Math.round(100*t)/100},m=c/180,p=180/c,v={format:{},autodetect:[]},b=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var e=this;if("object"===s(t[0])&&t[0].constructor&&t[0].constructor===this.constructor)return t[0];var a=l(t),o=!1;if(!a){o=!0,v.sorted||(v.autodetect=v.autodetect.sort((function(t,r){return r.p-t.p})),v.sorted=!0);for(var i=0,u=v.autodetect;i255)&&(t._clipped=!0),t[r]=n(t[r],0,255)):3===r&&(t[r]=n(t[r],0,1));return t}(h),3===e._rgb.length&&e._rgb.push(1)};b.prototype.toString=function(){return"function"==s(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var y=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t)))};y.version="3.0.0";var w=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=u(t,"rgba"))[0],o=t[1],i=t[2],s=h(a/=255,o/=255,i/=255),l=f(a,o,i),c=(l+s)/2;return l===s?(n=0,e=Number.NaN):n=c<.5?(l-s)/(l+s):(l-s)/(2-l-s),a==l?e=(o-i)/(l-s):o==l?e=2+(i-a)/(l-s):i==l&&(e=4+(a-o)/(l-s)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,c,t[3]]:[e,n,c]},M={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,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}},k=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 x(t){var r=k.get(String(t).toLowerCase());if(!r)throw new Error("unknown Lab illuminant "+t);M.labWhitePoint=t,M.Xn=r[0],M.Zn=r[1]}function _(){return M.labWhitePoint}var A=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgb"),e=n[0],a=n[1],o=n[2],i=n.slice(3),s=$(e,a,o),l=function(t,r,n){var e=M.Xn,a=M.Yn,o=M.Zn,i=M.kE,s=M.kK,u=t/e,l=r/a,c=n/o,h=u>i?Math.pow(u,1/3):(s*u+16)/116,f=l>i?Math.pow(l,1/3):(s*l+16)/116,d=c>i?Math.pow(c,1/3):(s*c+16)/116;return[116*f-16,500*(h-f),200*(f-d)]}(s[0],s[1],s[2]);return[l[0],l[1],l[2]].concat(i.length>0&&i[0]<1?[i[0]]:[])};function j(t){var r=Math.sign(t);return((t=Math.abs(t))<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4))*r}var $=function(t,r,n){t=j(t/255),r=j(r/255),n=j(n/255);var e=M.MtxRGB2XYZ,a=M.MtxAdaptMa,o=M.MtxAdaptMaI,i=M.Xn,s=M.Yn,u=M.Zn,l=M.As,c=M.Bs,h=M.Cs,f=t*e.m00+r*e.m10+n*e.m20,d=t*e.m01+r*e.m11+n*e.m21,g=t*e.m02+r*e.m12+n*e.m22,m=i*a.m00+s*a.m10+u*a.m20,p=i*a.m01+s*a.m11+u*a.m21,v=i*a.m02+s*a.m12+u*a.m22,b=f*a.m00+d*a.m10+g*a.m20,y=f*a.m01+d*a.m11+g*a.m21,w=f*a.m02+d*a.m12+g*a.m22;return y*=p/c,w*=v/h,[f=(b*=m/l)*o.m00+y*o.m10+w*o.m20,d=b*o.m01+y*o.m11+w*o.m21,g=b*o.m02+y*o.m12+w*o.m22]},F=Math.sqrt,X=Math.atan2,Z=Math.round,E=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lab"),e=n[0],a=n[1],o=n[2],i=F(a*a+o*o),s=(X(o,a)*p+360)%360;return 0===Z(1e4*i)&&(s=Number.NaN),[e,i,s]};function Y(t,r){var n=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(r[0])||(r=r.map((function(t){return[t]})));var e=r[0].length,a=r[0].map((function(t,n){return r.map((function(t){return t[n]}))})),o=t.map((function(t){return a.map((function(r){return Array.isArray(t)?t.reduce((function(t,n,e){return t+n*(r[e]||0)}),0):r.reduce((function(r,n){return r+n*t}),0)}))}));return 1===n&&(o=o[0]),1===e?o.map((function(t){return t[0]})):o}var N=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=u(t,"rgb"),o=a[0],i=a[1],s=a[2],l=a.slice(3),c=$(o,i,s);return(n=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],e=Y([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],c),Y(n,e.map((function(t){return Math.cbrt(t)})))).concat(l.length>0&&l[0]<1?[l[0]]:[])};var B=Math.round,C=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgba"),e=l(t)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"hsla"),e=l(t)||"lsa";return n[0]=d(n[0]||0)+"deg",n[1]=d(100*n[1])+"%",n[2]=d(100*n[2])+"%","hsla"===e||n.length>3&&n[3]<1?(n[3]="/ "+(n.length>3?n[3]:1),e="hsla"):n.length=3,e.substr(0,3)+"("+n.join(" ")+")"}(w(n),e);if("lab"===e.substr(0,3)){var a=_();x("d50");var o=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lab"),e=l(t)||"lab";return n[0]=d(n[0])+"%",n[1]=d(n[1]),n[2]=d(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(A(n),e);return x(a),o}if("lch"===e.substr(0,3)){var i=_();x("d50");var s=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lch"),e=l(t)||"lab";return n[0]=d(n[0])+"%",n[1]=d(n[1]),n[2]=d(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgb"),e=n[0],a=n[1],o=n[2],i=n.slice(3),s=A(e,a,o),l=s[0],c=s[1],h=s[2],f=E(l,c,h);return[f[0],f[1],f[2]].concat(i.length>0&&i[0]<1?[i[0]]:[])}(n),e);return x(i),s}return"oklab"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lab");return n[0]=d(100*n[0])+"%",n[1]=g(n[1]),n[2]=g(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}(N(n)):"oklch"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lab");return n[0]=d(100*n[0])+"%",n[1]=g(n[1]),n[2]=d(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgb"),e=n[0],a=n[1],o=n[2],i=n.slice(3),s=N(e,a,o),l=s[0],c=s[1],h=s[2],f=E(l,c,h);return[f[0],f[1],f[2]].concat(i.length>0&&i[0]<1?[i[0]]:[])}(n)):(n[0]=B(n[0]),n[1]=B(n[1]),n[2]=B(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},O=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,a,o,i=(r=u(r,"hsl"))[0],s=r[1],l=r[2];if(0===s)e=a=o=255*l;else{var c=[0,0,0],h=[0,0,0],f=l<.5?l*(1+s):l+s-l*s,d=2*l-f,g=i/360;c[0]=g+1/3,c[1]=g,c[2]=g-1/3;for(var m=0;m<3;m++)c[m]<0&&(c[m]+=1),c[m]>1&&(c[m]-=1),6*c[m]<1?h[m]=d+6*(f-d)*c[m]:2*c[m]<1?h[m]=f:3*c[m]<2?h[m]=d+(f-d)*(2/3-c[m])*6:h[m]=d;e=(t=[255*h[0],255*h[1],255*h[2]])[0],a=t[1],o=t[2]}return r.length>3?[e,a,o,r[3]]:[e,a,o,1]},R=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=u(t,"lab"))[0],e=t[1],a=t[2],o=L(n,e,a),i=o[0],s=o[1],l=o[2],c=K(i,s,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]},L=function(t,r,n){var e=M.kE,a=M.kK,o=M.kKE,i=M.Xn,s=M.Yn,u=M.Zn,l=(t+16)/116,c=.002*r+l,h=l-.005*n,f=c*c*c,d=h*h*h;return[(f>e?f:(116*c-16)/a)*i,(t>o?Math.pow((t+16)/116,3):t/a)*s,(d>e?d:(116*h-16)/a)*u]},W=function(t){var r=Math.sign(t);return((t=Math.abs(t))<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)*r},K=function(t,r,n){var e=M.MtxAdaptMa,a=M.MtxAdaptMaI,o=M.MtxXYZ2RGB,i=M.RefWhiteRGB,s=M.Xn,u=M.Yn,l=M.Zn,c=s*e.m00+u*e.m10+l*e.m20,h=s*e.m01+u*e.m11+l*e.m21,f=s*e.m02+u*e.m12+l*e.m22,d=i.X*e.m00+i.Y*e.m10+i.Z*e.m20,g=i.X*e.m01+i.Y*e.m11+i.Z*e.m21,m=i.X*e.m02+i.Y*e.m12+i.Z*e.m22,p=(t*e.m00+r*e.m10+n*e.m20)*(d/c),v=(t*e.m01+r*e.m11+n*e.m21)*(g/h),b=(t*e.m02+r*e.m12+n*e.m22)*(m/f),y=p*a.m00+v*a.m10+b*a.m20,w=p*a.m01+v*a.m11+b*a.m21,k=p*a.m02+v*a.m12+b*a.m22;return[255*W(y*o.m00+w*o.m10+k*o.m20),255*W(y*o.m01+w*o.m11+k*o.m21),255*W(y*o.m02+w*o.m12+k*o.m22)]},G=Math.sin,I=Math.cos,P=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lch"),e=n[0],a=n[1],o=n[2];return isNaN(o)&&(o=0),[e,I(o*=m)*a,G(o)*a]},S=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=u(t,"lab"))[0],o=t[1],i=t[2],s=t.slice(3),l=(n=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],e=Y([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,o,i]),Y(n,e.map((function(t){return Math.pow(t,3)})))),c=l[0],h=l[1],f=l[2],d=K(c,h,f);return[d[0],d[1],d[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])};var q=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,T=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,D=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,U=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,z=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,H=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,J=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,Q=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,V=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,tt=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,rt=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,nt=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,et=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,at=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,ot=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,it=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,st=Math.round,ut=function(t){return t.map((function(t,r){return r<=2?n(st(t),0,255):t}))},lt=function(t,r,n,e){return void 0===r&&(r=0),void 0===n&&(n=100),void 0===e&&(e=!1),"string"==typeof t&&t.endsWith("%")&&(t=parseFloat(t.substring(0,t.length-1))/100,t=e?r+.5*(t+1)*(n-r):r+t*(n-r)),+t},ct=function(t,r){return"none"===t?r:t},ht=function(t){var r;if(t=t.toLowerCase().trim(),v.format.named)try{return v.format.named(t)}catch(t){}if((r=t.match(q))||(r=t.match(T))){for(var n=r.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if((r=t.match(D))||(r=t.match(U))){for(var a=r.slice(1,5),o=0;o<4;o++)a[o]=+a[o];return a}if((r=t.match(z))||(r=t.match(H))){for(var i=r.slice(1,4),s=0;s<3;s++)i[s]=st(2.55*i[s]);return i[3]=1,i}if((r=t.match(J))||(r=t.match(Q))){for(var l=r.slice(1,5),c=0;c<3;c++)l[c]=st(2.55*l[c]);return l[3]=+l[3],l}if((r=t.match(V))||(r=t.match(tt))){var h=r.slice(1,4);h[1]*=.01,h[2]*=.01;for(var f=O(h),d=0;d<3;d++)f[d]=st(f[d]);return f[3]=1,f}if((r=t.match(rt))||(r=t.match(nt))){var g=r.slice(1,4);g[1]*=.01,g[2]*=.01;for(var m=O(g),p=0;p<3;p++)m[p]=st(m[p]);return m[3]=+r[4],m}if(r=t.match(et)){var b=r.slice(1,4);b[0]=lt(b[0],0,100),b[1]=lt(b[1],-125,125,!0),b[2]=lt(b[2],-125,125,!0);var y=_();x("d50");var w=ut(R(b));return x(y),w[3]=void 0!==r[4]?+r[4]:1,w}if(r=t.match(at)){var M=r.slice(1,4);M[0]=lt(M[0],0,100),M[1]=lt(ct(M[1],0),0,150,!1),M[2]=+ct(M[2].replace("deg",""),0);var k=_();x("d50");var A=ut(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=u(t,"lch"))[0],e=t[1],a=t[2],o=P(n,e,a),i=o[0],s=o[1],l=o[2],c=R(i,s,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]}(M));return x(k),A[3]=void 0!==r[4]?+r[4]:1,A}if(r=t.match(ot)){var j=r.slice(1,4);j[0]=lt(j[0],0,1),j[1]=lt(j[1],-.4,.4,!0),j[2]=lt(j[2],-.4,.4,!0);var $=ut(S(j));return $[3]=void 0!==r[4]?+r[4]:1,$}if(r=t.match(it)){var F=r.slice(1,4);F[0]=lt(F[0],0,1),F[1]=lt(ct(F[1],0),0,.4,!1),F[2]=+ct(F[2].replace("deg",""),0);var X=ut(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=u(t,"lch"))[0],e=t[1],a=t[2],o=t.slice(3),i=P(n,e,a),s=i[0],l=i[1],c=i[2],h=S(s,l,c);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])}(F));return X[3]=void 0!==r[4]?+r[4]:1,X}};ht.test=function(t){return q.test(t)||D.test(t)||z.test(t)||J.test(t)||V.test(t)||rt.test(t)||et.test(t)||at.test(t)||ot.test(t)||it.test(t)||T.test(t)||U.test(t)||H.test(t)||Q.test(t)||tt.test(t)||nt.test(t)},b.prototype.css=function(t){return C(this._rgb,t)};var ft=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["css"])))};y.css=ft,v.format.css=ht,v.autodetect.push({p:5,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===s(t)&&ht.test(t))return"css"}});var dt=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,gt=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,mt=Math.round;b.prototype.hex=function(t){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgba"),e=n[0],a=n[1],o=n[2],i=n[3],s=l(t)||"auto";void 0===i&&(i=1),"auto"===s&&(s=i<1?"rgba":"rgb");var c="000000"+((e=mt(e))<<16|(a=mt(a))<<8|(o=mt(o))).toString(16);c=c.substr(c.length-6);var h="0"+mt(255*i).toString(16);switch(h=h.substr(h.length-2),s.toLowerCase()){case"rgba":return"#"+c+h;case"argb":return"#"+h+c;default:return"#"+c}}(this._rgb,t)};var pt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["hex"])))};y.hex=pt,v.format.hex=function(t){if(t.match(dt)){4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var r=parseInt(t,16);return[r>>16,r>>8&255,255&r,1]}if(t.match(gt)){5!==t.length&&9!==t.length||(t=t.substr(1)),4===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);var n=parseInt(t,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+t)},v.autodetect.push({p:4,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===s(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}}),b.prototype.hsl=function(){return w(this._rgb)};var vt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["hsl"])))};y.hsl=vt,v.format.hsl=O,v.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===s(t=u(t,"hsl"))&&3===t.length)return"hsl"}}),b.prototype.lab=function(){return A(this._rgb)};var bt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["lab"])))};Object.assign(y,{lab:bt,getLabWhitePoint:_,setLabWhitePoint:x}),v.format.lab=R,v.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===s(t=u(t,"lab"))&&3===t.length)return"lab"}}),b.prototype.oklab=function(){return N(this._rgb)};var yt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["oklab"])))};Object.assign(y,{oklab:yt}),v.format.oklab=S,v.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===s(t=u(t,"oklab"))&&3===t.length)return"oklab"}});var wt=Math.round;b.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(wt)},b.prototype.rgba=function(t){return void 0===t&&(t=!0),this._rgb.slice(0,4).map((function(r,n){return n<3?!1===t?r:wt(r):r}))};var Mt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["rgb"])))};Object.assign(y,{rgb:Mt}),v.format.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgba");return void 0===n[3]&&(n[3]=1),n},v.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===s(t=u(t,"rgba"))&&(3===t.length||4===t.length&&"number"==s(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}}),b.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===s(t)?r?(this._rgb[3]=t,this):new b([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},b.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=M.Kn*t,new b(r,"lab").alpha(this.alpha(),!0)},b.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},b.prototype.darker=b.prototype.darken,b.prototype.brighter=b.prototype.brighten,b.prototype.get=function(t){var r=t.split("."),n=r[0],e=r[1],a=this[n]();if(e){var o=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(o>-1)return a[o];throw new Error("unknown channel "+e+" in mode "+n)}return a};var kt={};function xt(t,r,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var o=e[0]||"lrgb";if(kt[o]||e.length||(o=Object.keys(kt)[0]),!kt[o])throw new Error("interpolation mode "+o+" is not defined");return"object"!==s(t)&&(t=new b(t)),"object"!==s(r)&&(r=new b(r)),kt[o](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}b.prototype.mix=b.prototype.interpolate=function(t,r){void 0===r&&(r=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return xt.apply(void 0,[this,t,r].concat(n))},b.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),a=e[0],o=e[1],i=this[a]();if(o){var u=a.indexOf(o)-("ok"===a.substr(0,2)?2:0);if(u>-1){if("string"==s(r))switch(r.charAt(0)){case"+":case"-":i[u]+=+r;break;case"*":i[u]*=+r.substr(1);break;case"/":i[u]/=+r.substr(1);break;default:i[u]=+r}else{if("number"!==s(r))throw new Error("unsupported value for Color.set");i[u]=r}var l=new b(i,a);return n?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+o+" in mode "+a)}return i},b.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return xt.apply(void 0,[this,"white",t].concat(r))},b.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return xt.apply(void 0,[this,"black",t].concat(r))};var _t=Math.sqrt,At=Math.pow;kt.lrgb=function(t,r,n){var e=t._rgb,a=e[0],o=e[1],i=e[2],s=r._rgb,u=s[0],l=s[1],c=s[2];return new b(_t(At(a,2)*(1-n)+At(u,2)*n),_t(At(o,2)*(1-n)+At(l,2)*n),_t(At(i,2)*(1-n)+At(c,2)*n),"rgb")};return kt.oklab=function(t,r,n){var e=t.oklab(),a=r.oklab();return new b(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")},Object.assign(y,{Color:b,valid:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{return new(Function.prototype.bind.apply(b,[null].concat(t))),!0}catch(t){return!1}},css:ft,hex:pt,hsl:vt,lab:bt,oklab:yt,rgb:Mt,mix:xt,interpolate:xt}),y})); diff --git a/dist/chroma.cjs b/dist/chroma.cjs index 0769b043..5e914159 100644 --- a/dist/chroma.cjs +++ b/dist/chroma.cjs @@ -61,11 +61,14 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory()); })(this, (function () { 'use strict'; + var min$4 = Math.min; + var max$4 = Math.max; + function limit (x, low, high) { if ( low === void 0 ) low = 0; if ( high === void 0 ) high = 1; - return min$3(max$3(low, x), high); + return min$4(max$4(low, x), high); } function clip_rgb (rgb) { @@ -84,7 +87,7 @@ // ported from jQuery's $.type var classToType = {}; - for (var i$1 = 0, list$1 = [ + for (var i = 0, list = [ 'Boolean', 'Number', 'String', @@ -94,8 +97,8 @@ 'RegExp', 'Undefined', 'Null' - ]; i$1 < list$1.length; i$1 += 1) { - var name = list$1[i$1]; + ]; i < list.length; i += 1) { + var name = list[i]; classToType[("[object " + name + "]")] = name.toLowerCase(); } @@ -3858,12 +3861,21 @@ Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2'] }; - // add lowercase aliases for case-insensitive matches - for (var i = 0, list = Object.keys(colorbrewer); i < list.length; i += 1) { - var key = list[i]; + var colorbrewerTypes = Object.keys(colorbrewer); + var typeMap = new Map(colorbrewerTypes.map(function (key) { return [key.toLowerCase(), key]; })); - colorbrewer[key.toLowerCase()] = colorbrewer[key]; - } + // use Proxy to allow case-insensitive access to palettes + var colorbrewerProxy = typeof Proxy === 'function' ? new Proxy(colorbrewer, { + get: function get(target, prop) { + var lower = prop.toLowerCase(); + if (typeMap.has(lower)) { + return target[typeMap.get(lower)]; + } + }, + getOwnPropertyNames: function getOwnPropertyNames() { + return Object.getOwnPropertyNames(colorbrewerTypes); + } + }) : colorbrewer; // feel free to comment out anything to rollup // a smaller chroma.js bundle @@ -3873,7 +3885,7 @@ average: average, bezier: bezier$1, blend: blend, - brewer: colorbrewer, + brewer: colorbrewerProxy, Color: Color, colors: w3cx11, contrast: contrast, diff --git a/dist/chroma.min.cjs b/dist/chroma.min.cjs index 4fa5f456..f9397b5e 100644 --- a/dist/chroma.min.cjs +++ b/dist/chroma.min.cjs @@ -55,4 +55,4 @@ * @preserve */ -!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(r="undefined"!=typeof globalThis?globalThis:r||self).chroma=t()}(this,(function(){"use strict";function r(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),l(s(t,r),n)}function t(t){t._clipped=!1,t._unclipped=t.slice(0);for(var n=0;n<=3;n++)n<3?((t[n]<0||t[n]>255)&&(t._clipped=!0),t[n]=r(t[n],0,255)):3===n&&(t[n]=r(t[n],0,1));return t}for(var n={},e=0,a=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];e=3?Array.prototype.slice.call(r):"object"==o(r[0])&&t?t.split("").filter((function(t){return void 0!==r[0][t]})).map((function(t){return r[0][t]})):r[0].slice(0)}function c(r){if(r.length<2)return null;var t=r.length-1;return"string"==o(r[t])?r[t].toLowerCase():null}var i=Math.PI,l=Math.min,s=Math.max,h=function(r){return Math.round(100*r)/100},d=function(r){return Math.round(100*r)/100},b=2*i,g=i/3,v=i/180,p=180/i,m={format:{},autodetect:[]},y=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=this;if("object"===o(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=c(r),f=!1;if(!a){f=!0,m.sorted||(m.autodetect=m.autodetect.sort((function(r,t){return t.p-r.p})),m.sorted=!0);for(var u=0,i=m.autodetect;u4?r[4]:1;return 1===f?[0,0,0,o]:[n>=1?0:255*(1-n)*(1-f),e>=1?0:255*(1-e)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"cmyk"))&&4===r.length)return"cmyk"}});var N=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a=(r=u(r,"rgba"))[0],f=r[1],o=r[2],c=l(a/=255,f/=255,o/=255),i=s(a,f,o),h=(i+c)/2;return i===c?(n=0,e=Number.NaN):n=h<.5?(i-c)/(i+c):(i-c)/(2-i-c),a==i?e=(f-o)/(i-c):f==i?e=2+(o-a)/(i-c):o==i&&(e=4+(a-f)/(i-c)),(e*=60)<0&&(e+=360),r.length>3&&void 0!==r[3]?[e,n,h,r[3]]:[e,n,h]},_={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,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}},x=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 A(r){var t=x.get(String(r).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+r);_.labWhitePoint=r,_.Xn=t[0],_.Zn=t[1]}function j(){return _.labWhitePoint}var E=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=F(e,a,f),i=function(r,t,n){var e=_.Xn,a=_.Yn,f=_.Zn,o=_.kE,u=_.kK,c=r/e,i=t/a,l=n/f,s=c>o?Math.pow(c,1/3):(u*c+16)/116,h=i>o?Math.pow(i,1/3):(u*i+16)/116,d=l>o?Math.pow(l,1/3):(u*l+16)/116;return[116*h-16,500*(s-h),200*(h-d)]}(c[0],c[1],c[2]);return[i[0],i[1],i[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function O(r){var t=Math.sign(r);return((r=Math.abs(r))<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4))*t}var F=function(r,t,n){r=O(r/255),t=O(t/255),n=O(n/255);var e=_.MtxRGB2XYZ,a=_.MtxAdaptMa,f=_.MtxAdaptMaI,o=_.Xn,u=_.Yn,c=_.Zn,i=_.As,l=_.Bs,s=_.Cs,h=r*e.m00+t*e.m10+n*e.m20,d=r*e.m01+t*e.m11+n*e.m21,b=r*e.m02+t*e.m12+n*e.m22,g=o*a.m00+u*a.m10+c*a.m20,v=o*a.m01+u*a.m11+c*a.m21,p=o*a.m02+u*a.m12+c*a.m22,m=h*a.m00+d*a.m10+b*a.m20,y=h*a.m01+d*a.m11+b*a.m21,w=h*a.m02+d*a.m12+b*a.m22;return y*=v/l,w*=p/s,[h=(m*=g/i)*f.m00+y*f.m10+w*f.m20,d=m*f.m01+y*f.m11+w*f.m21,b=m*f.m02+y*f.m12+w*f.m22]},L=Math.sqrt,P=Math.atan2,B=Math.round,G=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab"),e=n[0],a=n[1],f=n[2],o=L(a*a+f*f),c=(P(f,a)*p+360)%360;return 0===B(1e4*o)&&(c=Number.NaN),[e,o,c]},R=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=E(e,a,f),i=c[0],l=c[1],s=c[2],h=G(i,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function Y(r,t){var n=r.length;Array.isArray(r[0])||(r=[r]),Array.isArray(t[0])||(t=t.map((function(r){return[r]})));var e=t[0].length,a=t[0].map((function(r,n){return t.map((function(r){return r[n]}))})),f=r.map((function(r){return a.map((function(t){return Array.isArray(r)?r.reduce((function(r,n,e){return r+n*(t[e]||0)}),0):t.reduce((function(t,n){return t+n*r}),0)}))}));return 1===n&&(f=f[0]),1===e?f.map((function(r){return r[0]})):f}var $=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a=u(r,"rgb"),f=a[0],o=a[1],c=a[2],i=a.slice(3),l=F(f,o,c);return(n=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],e=Y([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],l),Y(n,e.map((function(r){return Math.cbrt(r)})))).concat(i.length>0&&i[0]<1?[i[0]]:[])};var q=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=$(e,a,f),i=c[0],l=c[1],s=c[2],h=G(i,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])},X=Math.round,C=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba"),e=c(r)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"hsla"),e=c(r)||"lsa";return n[0]=h(n[0]||0)+"deg",n[1]=h(100*n[1])+"%",n[2]=h(100*n[2])+"%","hsla"===e||n.length>3&&n[3]<1?(n[3]="/ "+(n.length>3?n[3]:1),e="hsla"):n.length=3,e.substr(0,3)+"("+n.join(" ")+")"}(N(n),e);if("lab"===e.substr(0,3)){var a=j();A("d50");var f=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab"),e=c(r)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(E(n),e);return A(a),f}if("lch"===e.substr(0,3)){var o=j();A("d50");var i=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lch"),e=c(r)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(R(n),e);return A(o),i}return"oklab"===e.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab");return n[0]=h(100*n[0])+"%",n[1]=d(n[1]),n[2]=d(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}($(n)):"oklch"===e.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab");return n[0]=h(100*n[0])+"%",n[1]=d(n[1]),n[2]=h(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(q(n)):(n[0]=X(n[0]),n[1]=X(n[1]),n[2]=X(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},Z=function(){for(var r,t=[],n=arguments.length;n--;)t[n]=arguments[n];var e,a,f,o=(t=u(t,"hsl"))[0],c=t[1],i=t[2];if(0===c)e=a=f=255*i;else{var l=[0,0,0],s=[0,0,0],h=i<.5?i*(1+c):i+c-i*c,d=2*i-h,b=o/360;l[0]=b+1/3,l[1]=b,l[2]=b-1/3;for(var g=0;g<3;g++)l[g]<0&&(l[g]+=1),l[g]>1&&(l[g]-=1),6*l[g]<1?s[g]=d+6*(h-d)*l[g]:2*l[g]<1?s[g]=h:3*l[g]<2?s[g]=d+(h-d)*(2/3-l[g])*6:s[g]=d;e=(r=[255*s[0],255*s[1],255*s[2]])[0],a=r[1],f=r[2]}return t.length>3?[e,a,f,t[3]]:[e,a,f,1]},S=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lab"))[0],e=r[1],a=r[2],f=W(n,e,a),o=f[0],c=f[1],i=f[2],l=K(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},W=function(r,t,n){var e=_.kE,a=_.kK,f=_.kKE,o=_.Xn,u=_.Yn,c=_.Zn,i=(r+16)/116,l=.002*t+i,s=i-.005*n,h=l*l*l,d=s*s*s;return[(h>e?h:(116*l-16)/a)*o,(r>f?Math.pow((r+16)/116,3):r/a)*u,(d>e?d:(116*s-16)/a)*c]},I=function(r){var t=Math.sign(r);return((r=Math.abs(r))<=.0031308?12.92*r:1.055*Math.pow(r,1/2.4)-.055)*t},K=function(r,t,n){var e=_.MtxAdaptMa,a=_.MtxAdaptMaI,f=_.MtxXYZ2RGB,o=_.RefWhiteRGB,u=_.Xn,c=_.Yn,i=_.Zn,l=u*e.m00+c*e.m10+i*e.m20,s=u*e.m01+c*e.m11+i*e.m21,h=u*e.m02+c*e.m12+i*e.m22,d=o.X*e.m00+o.Y*e.m10+o.Z*e.m20,b=o.X*e.m01+o.Y*e.m11+o.Z*e.m21,g=o.X*e.m02+o.Y*e.m12+o.Z*e.m22,v=(r*e.m00+t*e.m10+n*e.m20)*(d/l),p=(r*e.m01+t*e.m11+n*e.m21)*(b/s),m=(r*e.m02+t*e.m12+n*e.m22)*(g/h),y=v*a.m00+p*a.m10+m*a.m20,w=v*a.m01+p*a.m11+m*a.m21,k=v*a.m02+p*a.m12+m*a.m22;return[255*I(y*f.m00+w*f.m10+k*f.m20),255*I(y*f.m01+w*f.m11+k*f.m21),255*I(y*f.m02+w*f.m12+k*f.m22)]},z=Math.sin,U=Math.cos,V=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lch"),e=n[0],a=n[1],f=n[2];return isNaN(f)&&(f=0),[e,U(f*=v)*a,z(f)*a]},D=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lch"))[0],e=r[1],a=r[2],f=V(n,e,a),o=f[0],c=f[1],i=f[2],l=S(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},T=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a=(r=u(r,"lab"))[0],f=r[1],o=r[2],c=r.slice(3),i=(n=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],e=Y([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,f,o]),Y(n,e.map((function(r){return Math.pow(r,3)})))),l=i[0],s=i[1],h=i[2],d=K(l,s,h);return[d[0],d[1],d[2]].concat(c.length>0&&c[0]<1?[c[0]]:[])};var H=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lch"))[0],e=r[1],a=r[2],f=r.slice(3),o=V(n,e,a),c=o[0],i=o[1],l=o[2],s=T(c,i,l);return[s[0],s[1],s[2]].concat(f.length>0&&f[0]<1?[f[0]]:[])},J=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,Q=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,rr=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,tr=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,nr=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,er=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,ar=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,fr=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,or=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,ur=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,cr=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,ir=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,lr=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,sr=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,hr=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,dr=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,br=Math.round,gr=function(t){return t.map((function(t,n){return n<=2?r(br(t),0,255):t}))},vr=function(r,t,n,e){return void 0===t&&(t=0),void 0===n&&(n=100),void 0===e&&(e=!1),"string"==typeof r&&r.endsWith("%")&&(r=parseFloat(r.substring(0,r.length-1))/100,r=e?t+.5*(r+1)*(n-t):t+r*(n-t)),+r},pr=function(r,t){return"none"===r?t:r},mr=function(r){var t;if(r=r.toLowerCase().trim(),m.format.named)try{return m.format.named(r)}catch(r){}if((t=r.match(J))||(t=r.match(Q))){for(var n=t.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if((t=r.match(rr))||(t=r.match(tr))){for(var a=t.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if((t=r.match(nr))||(t=r.match(er))){for(var o=t.slice(1,4),u=0;u<3;u++)o[u]=br(2.55*o[u]);return o[3]=1,o}if((t=r.match(ar))||(t=r.match(fr))){for(var c=t.slice(1,5),i=0;i<3;i++)c[i]=br(2.55*c[i]);return c[3]=+c[3],c}if((t=r.match(or))||(t=r.match(ur))){var l=t.slice(1,4);l[1]*=.01,l[2]*=.01;for(var s=Z(l),h=0;h<3;h++)s[h]=br(s[h]);return s[3]=1,s}if((t=r.match(cr))||(t=r.match(ir))){var d=t.slice(1,4);d[1]*=.01,d[2]*=.01;for(var b=Z(d),g=0;g<3;g++)b[g]=br(b[g]);return b[3]=+t[4],b}if(t=r.match(lr)){var v=t.slice(1,4);v[0]=vr(v[0],0,100),v[1]=vr(v[1],-125,125,!0),v[2]=vr(v[2],-125,125,!0);var p=j();A("d50");var y=gr(S(v));return A(p),y[3]=void 0!==t[4]?+t[4]:1,y}if(t=r.match(sr)){var w=t.slice(1,4);w[0]=vr(w[0],0,100),w[1]=vr(pr(w[1],0),0,150,!1),w[2]=+pr(w[2].replace("deg",""),0);var k=j();A("d50");var M=gr(D(w));return A(k),M[3]=void 0!==t[4]?+t[4]:1,M}if(t=r.match(hr)){var N=t.slice(1,4);N[0]=vr(N[0],0,1),N[1]=vr(N[1],-.4,.4,!0),N[2]=vr(N[2],-.4,.4,!0);var _=gr(T(N));return _[3]=void 0!==t[4]?+t[4]:1,_}if(t=r.match(dr)){var x=t.slice(1,4);x[0]=vr(x[0],0,1),x[1]=vr(pr(x[1],0),0,.4,!1),x[2]=+pr(x[2].replace("deg",""),0);var E=gr(H(x));return E[3]=void 0!==t[4]?+t[4]:1,E}};mr.test=function(r){return J.test(r)||rr.test(r)||nr.test(r)||ar.test(r)||or.test(r)||cr.test(r)||lr.test(r)||sr.test(r)||hr.test(r)||dr.test(r)||Q.test(r)||tr.test(r)||er.test(r)||fr.test(r)||ur.test(r)||ir.test(r)},y.prototype.css=function(r){return C(this._rgb,r)};var yr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["css"])))};w.css=yr,m.format.css=mr,m.autodetect.push({p:5,test:function(r){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&mr.test(r))return"css"}}),m.format.gl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba");return n[0]*=255,n[1]*=255,n[2]*=255,n};var wr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["gl"])))};w.gl=wr,y.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var kr=Math.floor;y.prototype.hcg=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e=u(r,"rgb"),a=e[0],f=e[1],o=e[2],c=l(a,f,o),i=s(a,f,o),h=i-c,d=100*h/255,b=c/(255-h)*100;return 0===h?n=Number.NaN:(a===i&&(n=(f-o)/h),f===i&&(n=2+(o-a)/h),o===i&&(n=4+(a-f)/h),(n*=60)<0&&(n+=360)),[n,d,b]}(this._rgb)};var Mr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hcg"])))};w.hcg=Mr,m.format.hcg=function(){for(var r,t,n,e,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,s,h=(o=u(o,"hcg"))[0],d=o[1],b=o[2];b*=255;var g=255*d;if(0===d)i=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var v=kr(h/=60),p=h-v,m=b*(1-d),y=m+g*(1-p),w=m+g*p,k=m+g;switch(v){case 0:i=(r=[k,w,m])[0],l=r[1],s=r[2];break;case 1:i=(t=[y,k,m])[0],l=t[1],s=t[2];break;case 2:i=(n=[m,k,w])[0],l=n[1],s=n[2];break;case 3:i=(e=[m,y,k])[0],l=e[1],s=e[2];break;case 4:i=(a=[w,m,k])[0],l=a[1],s=a[2];break;case 5:i=(f=[k,m,y])[0],l=f[1],s=f[2]}}return[i,l,s,o.length>3?o[3]:1]},m.autodetect.push({p:1,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hcg"))&&3===r.length)return"hcg"}});var Nr=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,_r=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,xr=function(r){if(r.match(Nr)){4!==r.length&&7!==r.length||(r=r.substr(1)),3===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]);var t=parseInt(r,16);return[t>>16,t>>8&255,255&t,1]}if(r.match(_r)){5!==r.length&&9!==r.length||(r=r.substr(1)),4===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]);var n=parseInt(r,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+r)},Ar=Math.round,jr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba"),e=n[0],a=n[1],f=n[2],o=n[3],i=c(r)||"auto";void 0===o&&(o=1),"auto"===i&&(i=o<1?"rgba":"rgb");var l="000000"+((e=Ar(e))<<16|(a=Ar(a))<<8|(f=Ar(f))).toString(16);l=l.substr(l.length-6);var s="0"+Ar(255*o).toString(16);switch(s=s.substr(s.length-2),i.toLowerCase()){case"rgba":return"#"+l+s;case"argb":return"#"+s+l;default:return"#"+l}};y.prototype.hex=function(r){return jr(this._rgb,r)};var Er=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hex"])))};w.hex=Er,m.format.hex=xr,m.autodetect.push({p:4,test:function(r){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var Or=Math.cos,Fr=Math.min,Lr=Math.sqrt,Pr=Math.acos;y.prototype.hsi=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e=u(r,"rgb"),a=e[0],f=e[1],o=e[2],c=Fr(a/=255,f/=255,o/=255),i=(a+f+o)/3,l=i>0?1-c/i:0;return 0===l?n=NaN:(n=(a-f+(a-o))/2,n/=Lr((a-f)*(a-f)+(a-o)*(f-o)),n=Pr(n),o>f&&(n=b-n),n/=b),[360*n,l,i]}(this._rgb)};var Br=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hsi"])))};w.hsi=Br,m.format.hsi=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var e,a,f,o=(t=u(t,"hsi"))[0],c=t[1],i=t[2];return isNaN(o)&&(o=0),isNaN(c)&&(c=0),o>360&&(o-=360),o<0&&(o+=360),(o/=360)<1/3?a=1-((f=(1-c)/3)+(e=(1+c*Or(b*o)/Or(g-b*o))/3)):o<2/3?f=1-((e=(1-c)/3)+(a=(1+c*Or(b*(o-=1/3))/Or(g-b*o))/3)):e=1-((a=(1-c)/3)+(f=(1+c*Or(b*(o-=2/3))/Or(g-b*o))/3)),[255*(e=r(i*e*3)),255*(a=r(i*a*3)),255*(f=r(i*f*3)),t.length>3?t[3]:1]},m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsi"))&&3===r.length)return"hsi"}}),y.prototype.hsl=function(){return N(this._rgb)};var Gr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hsl"])))};w.hsl=Gr,m.format.hsl=Z,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsl"))&&3===r.length)return"hsl"}});var Rr=Math.floor,Yr=Math.min,$r=Math.max;y.prototype.hsv=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a,f=(r=u(r,"rgb"))[0],o=r[1],c=r[2],i=Yr(f,o,c),l=$r(f,o,c),s=l-i;return a=l/255,0===l?(n=Number.NaN,e=0):(e=s/l,f===l&&(n=(o-c)/s),o===l&&(n=2+(c-f)/s),c===l&&(n=4+(f-o)/s),(n*=60)<0&&(n+=360)),[n,e,a]}(this._rgb)};var qr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hsv"])))};w.hsv=qr,m.format.hsv=function(){for(var r,t,n,e,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,s,h=(o=u(o,"hsv"))[0],d=o[1],b=o[2];if(b*=255,0===d)i=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var g=Rr(h/=60),v=h-g,p=b*(1-d),m=b*(1-d*v),y=b*(1-d*(1-v));switch(g){case 0:i=(r=[b,y,p])[0],l=r[1],s=r[2];break;case 1:i=(t=[m,b,p])[0],l=t[1],s=t[2];break;case 2:i=(n=[p,b,y])[0],l=n[1],s=n[2];break;case 3:i=(e=[p,m,b])[0],l=e[1],s=e[2];break;case 4:i=(a=[y,p,b])[0],l=a[1],s=a[2];break;case 5:i=(f=[b,p,m])[0],l=f[1],s=f[2]}}return[i,l,s,o.length>3?o[3]:1]},m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsv"))&&3===r.length)return"hsv"}}),y.prototype.lab=function(){return E(this._rgb)};var Xr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["lab"])))};Object.assign(w,{lab:Xr,getLabWhitePoint:j,setLabWhitePoint:A}),m.format.lab=S,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"lab"))&&3===r.length)return"lab"}});y.prototype.lch=function(){return R(this._rgb)},y.prototype.hcl=function(){return R(this._rgb).reverse()};var Cr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["lch"])))},Zr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hcl"])))};Object.assign(w,{lch:Cr,hcl:Zr}),m.format.lch=D,m.format.hcl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"hcl").reverse();return D.apply(void 0,n)},["lch","hcl"].forEach((function(r){return m.autodetect.push({p:2,test:function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];if("array"===o(t=u(t,r))&&3===t.length)return r}})}));y.prototype.num=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb");return(n[0]<<16)+(n[1]<<8)+n[2]}(this._rgb)};var Sr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["num"])))};Object.assign(w,{num:Sr}),m.format.num=function(r){if("number"==o(r)&&r>=0&&r<=16777215)return[r>>16,r>>8&255,255&r,1];throw new Error("unknown num color: "+r)},m.autodetect.push({p:5,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if(1===r.length&&"number"===o(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var Wr=Math.round;y.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Wr)},y.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(t,n){return n<3?!1===r?t:Wr(t):t}))};var Ir=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["rgb"])))};Object.assign(w,{rgb:Ir}),m.format.rgb=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba");return void 0===n[3]&&(n[3]=1),n},m.autodetect.push({p:3,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"rgba"))&&(3===r.length||4===r.length&&"number"==o(r[3])&&r[3]>=0&&r[3]<=1))return"rgb"}});var Kr=Math.log,zr=function(r){var t,n,e,a=r/100;return a<66?(t=255,n=a<6?0:-155.25485562709179-.44596950469579133*(n=a-2)+104.49216199393888*Kr(n),e=a<20?0:.8274096064007395*(e=a-10)-254.76935184120902+115.67994401066147*Kr(e)):(t=351.97690566805693+.114206453784165*(t=a-55)-40.25366309332127*Kr(t),n=325.4494125711974+.07943456536662342*(n=a-50)-28.0852963507957*Kr(n),e=255),[t,n,e,1]},Ur=Math.round;y.prototype.temp=y.prototype.kelvin=y.prototype.temperature=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];for(var n,e=u(r,"rgb"),a=e[0],f=e[2],o=1e3,c=4e4;c-o>.4;){var i=zr(n=.5*(c+o));i[2]/i[0]>=f/a?c=n:o=n}return Ur(n)}(this._rgb)};var Vr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["temp"])))};Object.assign(w,{temp:Vr,kelvin:Vr,temperature:Vr}),m.format.temp=m.format.kelvin=m.format.temperature=zr,y.prototype.oklab=function(){return $(this._rgb)};var Dr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["oklab"])))};Object.assign(w,{oklab:Dr}),m.format.oklab=T,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"oklab"))&&3===r.length)return"oklab"}}),y.prototype.oklch=function(){return q(this._rgb)};var Tr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["oklch"])))};Object.assign(w,{oklch:Tr}),m.format.oklch=H,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"oklch"))&&3===r.length)return"oklch"}});var Hr={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"};y.prototype.name=function(){for(var r=jr(this._rgb,"rgb"),t=0,n=Object.keys(Hr);t0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&Hr[r.toLowerCase()])return"named"}}),y.prototype.alpha=function(r,t){return void 0===t&&(t=!1),void 0!==r&&"number"===o(r)?t?(this._rgb[3]=r,this):new y([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},y.prototype.clipped=function(){return this._rgb._clipped||!1},y.prototype.darken=function(r){void 0===r&&(r=1);var t=this.lab();return t[0]-=_.Kn*r,new y(t,"lab").alpha(this.alpha(),!0)},y.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},y.prototype.darker=y.prototype.darken,y.prototype.brighter=y.prototype.brighten,y.prototype.get=function(r){var t=r.split("."),n=t[0],e=t[1],a=this[n]();if(e){var f=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+e+" in mode "+n)}return a};var Jr=Math.pow;y.prototype.luminance=function(r,t){if(void 0===t&&(t="rgb"),void 0!==r&&"number"===o(r)){if(0===r)return new y([0,0,0,this._rgb[3]],"rgb");if(1===r)return new y([255,255,255,this._rgb[3]],"rgb");var n=this.luminance(),e=20,a=function(n,f){var o=n.interpolate(f,.5,t),u=o.luminance();return Math.abs(r-u)<1e-7||!e--?o:u>r?a(n,o):a(o,f)},f=(n>r?a(new y([0,0,0]),this):a(this,new y([255,255,255]))).rgb();return new y(f.concat([this._rgb[3]]))}return Qr.apply(void 0,this._rgb.slice(0,3))};var Qr=function(r,t,n){return.2126*(r=rt(r))+.7152*(t=rt(t))+.0722*(n=rt(n))},rt=function(r){return(r/=255)<=.03928?r/12.92:Jr((r+.055)/1.055,2.4)},tt={};function nt(r,t,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var f=e[0]||"lrgb";if(tt[f]||e.length||(f=Object.keys(tt)[0]),!tt[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==o(r)&&(r=new y(r)),"object"!==o(t)&&(t=new y(t)),tt[f](r,t,n).alpha(r.alpha()+n*(t.alpha()-r.alpha()))}y.prototype.mix=y.prototype.interpolate=function(r,t){void 0===t&&(t=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return nt.apply(void 0,[this,r,t].concat(n))},y.prototype.premultiply=function(r){void 0===r&&(r=!1);var t=this._rgb,n=t[3];return r?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new y([t[0]*n,t[1]*n,t[2]*n,n],"rgb")},y.prototype.saturate=function(r){void 0===r&&(r=1);var t=this.lch();return t[1]+=_.Kn*r,t[1]<0&&(t[1]=0),new y(t,"lch").alpha(this.alpha(),!0)},y.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},y.prototype.set=function(r,t,n){void 0===n&&(n=!1);var e=r.split("."),a=e[0],f=e[1],u=this[a]();if(f){var c=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(c>-1){if("string"==o(t))switch(t.charAt(0)){case"+":case"-":u[c]+=+t;break;case"*":u[c]*=+t.substr(1);break;case"/":u[c]/=+t.substr(1);break;default:u[c]=+t}else{if("number"!==o(t))throw new Error("unsupported value for Color.set");u[c]=t}var i=new y(u,a);return n?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return u},y.prototype.tint=function(r){void 0===r&&(r=.5);for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return nt.apply(void 0,[this,"white",r].concat(t))},y.prototype.shade=function(r){void 0===r&&(r=.5);for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return nt.apply(void 0,[this,"black",r].concat(t))};tt.rgb=function(r,t,n){var e=r._rgb,a=t._rgb;return new y(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"rgb")};var et=Math.sqrt,at=Math.pow;tt.lrgb=function(r,t,n){var e=r._rgb,a=e[0],f=e[1],o=e[2],u=t._rgb,c=u[0],i=u[1],l=u[2];return new y(et(at(a,2)*(1-n)+at(c,2)*n),et(at(f,2)*(1-n)+at(i,2)*n),et(at(o,2)*(1-n)+at(l,2)*n),"rgb")};function ft(r,t,n,e){var a,f,o,u,c,i,l,s,h,d,b,g,v;return"hsl"===e?(o=r.hsl(),u=t.hsl()):"hsv"===e?(o=r.hsv(),u=t.hsv()):"hcg"===e?(o=r.hcg(),u=t.hcg()):"hsi"===e?(o=r.hsi(),u=t.hsi()):"lch"===e||"hcl"===e?(e="hcl",o=r.hcl(),u=t.hcl()):"oklch"===e&&(o=r.oklch().reverse(),u=t.oklch().reverse()),"h"!==e.substr(0,1)&&"oklch"!==e||(c=(a=o)[0],l=a[1],h=a[2],i=(f=u)[0],s=f[1],d=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=h&&0!=h||"hsv"==e||(b=s)):(g=c,1!=d&&0!=d||"hsv"==e||(b=l)):g=c+n*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+n*(s-l)),v=h+n*(d-h),new y("oklch"===e?[v,b,g]:[g,b,v],e)}tt.lab=function(r,t,n){var e=r.lab(),a=t.lab();return new y(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"lab")};var ot=function(r,t,n){return ft(r,t,n,"lch")};tt.lch=ot,tt.hcl=ot;tt.num=function(r,t,n){var e=r.num(),a=t.num();return new y(e+n*(a-e),"num")};tt.hcg=function(r,t,n){return ft(r,t,n,"hcg")};tt.hsi=function(r,t,n){return ft(r,t,n,"hsi")};tt.hsl=function(r,t,n){return ft(r,t,n,"hsl")};tt.hsv=function(r,t,n){return ft(r,t,n,"hsv")};tt.oklab=function(r,t,n){var e=r.oklab(),a=t.oklab();return new y(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")};tt.oklch=function(r,t,n){return ft(r,t,n,"oklch")};var ut=Math.pow,ct=Math.sqrt,it=Math.PI,lt=Math.cos,st=Math.sin,ht=Math.atan2;var dt=function(r,n){for(var e=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new y(t(a))},bt=Math.pow;function gt(t){var n="rgb",e=w("#ccc"),a=0,f=[0,1],u=[],c=[0,0],i=!1,l=[],s=!1,h=0,d=1,b=!1,g={},v=!0,p=1,m=function(r){if((r=r||["#fff","#000"])&&"string"===o(r)&&w.brewer&&w.brewer[r.toLowerCase()]&&(r=w.brewer[r.toLowerCase()]),"array"===o(r)){1===r.length&&(r=[r[0],r[0]]),r=r.slice(0);for(var t=0;t2){var b=function(r){if(null!=i){for(var t=i.length-1,n=0;n=i[n];)n++;return n-1}return 0}(t);s=b/(i.length-2)}else s=d!==h?(t-h)/(d-h):1;s=k(s),a||(s=y(s)),1!==p&&(s=bt(s,p)),s=r(s=c[0]+s*(1-c[0]-c[1]),0,1);var m=Math.floor(1e4*s);if(v&&g[m])f=g[m];else{if("array"===o(l))for(var M=0;M=N&&M===u.length-1){f=l[M];break}if(s>N&&s2){var c=r.map((function(t,n){return n/(r.length-1)})),i=r.map((function(r){return(r-h)/(d-h)}));i.every((function(r,t){return c[t]===r}))||(k=function(r){if(r<=0||r>=1)return r;for(var t=0;r>=i[t+1];)t++;var n=(r-i[t])/(i[t+1]-i[t]);return c[t]+n*(c[t+1]-c[t])})}}return f=[h,d],_},_.mode=function(r){return arguments.length?(n=r,N(),_):n},_.range=function(r,t){return m(r),_},_.out=function(r){return s=r,_},_.spread=function(r){return arguments.length?(a=r,_):a},_.correctLightness=function(r){return null==r&&(r=!0),b=r,N(),y=b?function(r){for(var t=M(0,!0).lab()[0],n=M(1,!0).lab()[0],e=t>n,a=M(r,!0).lab()[0],f=t+(n-t)*r,o=a-f,u=0,c=1,i=20;Math.abs(o)>.01&&i-- >0;)e&&(o*=-1),o<0?(u=r,r+=.5*(c-r)):(c=r,r+=.5*(u-r)),a=M(r,!0).lab()[0],o=a-f;return r}:function(r){return r},_},_.padding=function(r){return null!=r?("number"===o(r)&&(r=[r,r]),c=r,_):c},_.colors=function(r,n){arguments.length<2&&(n="hex");var e=[];if(0===arguments.length)e=l.slice(0);else if(1===r)e=[_(.5)];else if(r>1){var a=f[0],o=f[1]-a;e=function(r,t){for(var n=[],e=ra;e?f++:f--)n.push(f);return n}(0,r).map((function(t){return _(a+t/(r-1)*o)}))}else{t=[];var u=[];if(i&&i.length>2)for(var c=1,s=i.length,h=1<=s;h?cs;h?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;e=u.map((function(r){return _(r)}))}return w[n]&&(e=e.map((function(r){return r[n]()}))),e},_.cache=function(r){return null!=r?(v=r,_):v},_.gamma=function(r){return null!=r?(p=r,_):p},_.nodata=function(r){return null!=r?(e=w(r),_):e},_}var vt=function(r,t,n){if(!vt[n])throw new Error("unknown blend mode "+n);return vt[n](r,t)},pt=function(r){return function(t,n){var e=w(n).rgb(),a=w(t).rgb();return w.rgb(r(e,a))}},mt=function(r){return function(t,n){var e=[];return e[0]=r(t[0],n[0]),e[1]=r(t[1],n[1]),e[2]=r(t[2],n[2]),e}};vt.normal=pt(mt((function(r){return r}))),vt.multiply=pt(mt((function(r,t){return r*t/255}))),vt.screen=pt(mt((function(r,t){return 255*(1-(1-r/255)*(1-t/255))}))),vt.overlay=pt(mt((function(r,t){return t<128?2*r*t/255:255*(1-2*(1-r/255)*(1-t/255))}))),vt.darken=pt(mt((function(r,t){return r>t?t:r}))),vt.lighten=pt(mt((function(r,t){return r>t?r:t}))),vt.dodge=pt(mt((function(r,t){return 255===r||(r=t/255*255/(1-r/255))>255?255:r}))),vt.burn=pt(mt((function(r,t){return 255*(1-(1-t/255)/(r/255))})));var yt=Math.pow,wt=Math.sin,kt=Math.cos;var Mt=Math.floor,Nt=Math.random;var _t=Math.log,xt=Math.pow,At=Math.floor,jt=Math.abs;function Et(r,t){void 0===t&&(t=null);var n={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===o(r)&&(r=Object.values(r)),r.forEach((function(r){t&&"object"===o(r)&&(r=r[t]),null==r||isNaN(r)||(n.values.push(r),n.sum+=r,rn.max&&(n.max=r),n.count+=1)})),n.domain=[n.min,n.max],n.limits=function(r,t){return Ot(n,r,t)},n}function Ot(r,t,n){void 0===t&&(t="equal"),void 0===n&&(n=7),"array"==o(r)&&(r=Et(r));var e=r.min,a=r.max,f=r.values.sort((function(r,t){return r-t}));if(1===n)return[e,a];var u=[];if("c"===t.substr(0,1)&&(u.push(e),u.push(a)),"e"===t.substr(0,1)){u.push(e);for(var c=1;c 0");var i=Math.LOG10E*_t(e),l=Math.LOG10E*_t(a);u.push(e);for(var s=1;s200&&(w=!1)}for(var Y={},$=0;$=360;)b-=360;o[d]=b}else o[d]=o[d]/u[d];return h/=e,new y(o,t).alpha(h>.99999?1:h,!0)},bezier:function(r){var t=function(r){var t,n,e,a,f,o,u;if(2===(r=r.map((function(r){return new y(r)}))).length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],a=function(r){var t=[0,1,2].map((function(t){return f[t]+r*(o[t]-f[t])}));return new y(t,"lab")};else if(3===r.length)n=r.map((function(r){return r.lab()})),f=n[0],o=n[1],u=n[2],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*f[t]+2*(1-r)*r*o[t]+r*r*u[t]}));return new y(t,"lab")};else if(4===r.length){var c;e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],u=e[2],c=e[3],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*(1-r)*f[t]+3*(1-r)*(1-r)*r*o[t]+3*(1-r)*r*r*u[t]+r*r*r*c[t]}));return new y(t,"lab")}}else{if(!(r.length>=5))throw new RangeError("No point in running bezier with only one color.");var i,l,s;i=r.map((function(r){return r.lab()})),s=r.length-1,l=function(r){for(var t=[1,1],n=1;ne?(n+.05)/(e+.05):(e+.05)/(n+.05)},cubehelix:function(r,n,e,a,f){void 0===r&&(r=300),void 0===n&&(n=-1.5),void 0===e&&(e=1),void 0===a&&(a=1),void 0===f&&(f=[0,1]);var u,c=0;"array"===o(f)?u=f[1]-f[0]:(u=0,f=[f,f]);var i=function(o){var i=b*((r+120)/360+n*o),l=yt(f[0]+u*o,a),s=(0!==c?e[0]+o*c:e)*l*(1-l)/2,h=kt(i),d=wt(i);return w(t([255*(l+s*(-.14861*h+1.78277*d)),255*(l+s*(-.29227*h-.90649*d)),255*(l+s*(1.97294*h)),1]))};return i.start=function(t){return null==t?r:(r=t,i)},i.rotations=function(r){return null==r?n:(n=r,i)},i.gamma=function(r){return null==r?a:(a=r,i)},i.hue=function(r){return null==r?e:("array"===o(e=r)?0===(c=e[1]-e[0])&&(e=e[1]):c=0,i)},i.lightness=function(r){return null==r?f:("array"===o(r)?(f=r,u=r[1]-r[0]):(f=[r,r],u=0),i)},i.scale=function(){return w.scale(i)},i.hue(e),i},deltaE:function(r,t,n,e,a){void 0===n&&(n=1),void 0===e&&(e=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*Xt)},o=function(r){return 2*Xt*r/360};r=new y(r),t=new y(t);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],s=Array.from(t.lab()),h=s[0],d=s[1],b=s[2],g=(c+h)/2,v=(Ft(Lt(i,2)+Lt(l,2))+Ft(Lt(d,2)+Lt(b,2)))/2,p=.5*(1-Ft(Lt(v,7)/(Lt(v,7)+Lt(25,7)))),m=i*(1+p),w=d*(1+p),k=Ft(Lt(m,2)+Lt(l,2)),M=Ft(Lt(w,2)+Lt(b,2)),N=(k+M)/2,_=f(Gt(l,m)),x=f(Gt(b,w)),A=_>=0?_:_+360,j=x>=0?x:x+360,E=Rt(A-j)>180?(A+j+360)/2:(A+j)/2,O=1-.17*Yt(o(E-30))+.24*Yt(o(2*E))+.32*Yt(o(3*E+6))-.2*Yt(o(4*E-63)),F=j-A;F=Rt(F)<=180?F:j<=A?F+360:F-360,F=2*Ft(k*M)*$t(o(F)/2);var L=h-c,P=M-k,B=1+.015*Lt(g-50,2)/Ft(20+Lt(g-50,2)),G=1+.045*N,R=1+.015*N*O,Y=30*qt(-Lt((E-275)/25,2)),$=-(2*Ft(Lt(N,7)/(Lt(N,7)+Lt(25,7))))*$t(2*o(Y)),q=Ft(Lt(L/(n*B),2)+Lt(P/(e*G),2)+Lt(F/(a*R),2)+$*(P/(e*G))*(F/(a*R)));return Bt(0,Pt(100,q))},distance:function(r,t,n){void 0===n&&(n="lab"),r=new y(r),t=new y(t);var e=r.get(n),a=t.get(n),f=0;for(var o in e){var u=(e[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)},input:m,interpolate:nt,limits:Ot,mix:nt,random:function(){for(var r="#",t=0;t<6;t++)r+="0123456789abcdef".charAt(Mt(16*Nt()));return new y(r,"hex")},scale:gt,scales:Ct,valid:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];try{return new(Function.prototype.bind.apply(y,[null].concat(r))),!0}catch(r){return!1}},cmyk:M,css:yr,gl:wr,hcg:Mr,hex:Er,hsi:Br,hsl:Gr,hsv:qr,lab:Xr,lch:Cr,hcl:Zr,num:Sr,rgb:Ir,temp:Vr,kelvin:Vr,temperature:Vr,oklab:Dr,oklch:Tr,getLabWhitePoint:j,setLabWhitePoint:A}),w})); +!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(r="undefined"!=typeof globalThis?globalThis:r||self).chroma=t()}(this,(function(){"use strict";var r=Math.min,t=Math.max;function e(e,n,a){return void 0===n&&(n=0),void 0===a&&(a=1),r(t(n,e),a)}function n(r){r._clipped=!1,r._unclipped=r.slice(0);for(var t=0;t<=3;t++)t<3?((r[t]<0||r[t]>255)&&(r._clipped=!0),r[t]=e(r[t],0,255)):3===t&&(r[t]=e(r[t],0,1));return r}for(var a={},f=0,o=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];f=3?Array.prototype.slice.call(r):"object"==c(r[0])&&t?t.split("").filter((function(t){return void 0!==r[0][t]})).map((function(t){return r[0][t]})):r[0].slice(0)}function l(r){if(r.length<2)return null;var t=r.length-1;return"string"==c(r[t])?r[t].toLowerCase():null}var s=Math.PI,h=Math.min,d=Math.max,b=function(r){return Math.round(100*r)/100},g=function(r){return Math.round(100*r)/100},v=2*s,p=s/3,m=s/180,y=180/s,w={format:{},autodetect:[]},k=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=this;if("object"===c(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=l(r),f=!1;if(!a){f=!0,w.sorted||(w.autodetect=w.autodetect.sort((function(r,t){return t.p-r.p})),w.sorted=!0);for(var o=0,u=w.autodetect;o4?r[4]:1;return 1===f?[0,0,0,o]:[e>=1?0:255*(1-e)*(1-f),n>=1?0:255*(1-n)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"cmyk"))&&4===r.length)return"cmyk"}});var x=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n,a=(r=i(r,"rgba"))[0],f=r[1],o=r[2],u=h(a/=255,f/=255,o/=255),c=d(a,f,o),l=(c+u)/2;return c===u?(e=0,n=Number.NaN):e=l<.5?(c-u)/(c+u):(c-u)/(2-c-u),a==c?n=(f-o)/(c-u):f==c?n=2+(o-a)/(c-u):o==c&&(n=4+(a-f)/(c-u)),(n*=60)<0&&(n+=360),r.length>3&&void 0!==r[3]?[n,e,l,r[3]]:[n,e,l]},A={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,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}},j=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(r){var t=j.get(String(r).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+r);A.labWhitePoint=r,A.Xn=t[0],A.Zn=t[1]}function O(){return A.labWhitePoint}var P=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgb"),n=e[0],a=e[1],f=e[2],o=e.slice(3),u=L(n,a,f),c=function(r,t,e){var n=A.Xn,a=A.Yn,f=A.Zn,o=A.kE,u=A.kK,c=r/n,i=t/a,l=e/f,s=c>o?Math.pow(c,1/3):(u*c+16)/116,h=i>o?Math.pow(i,1/3):(u*i+16)/116,d=l>o?Math.pow(l,1/3):(u*l+16)/116;return[116*h-16,500*(s-h),200*(h-d)]}(u[0],u[1],u[2]);return[c[0],c[1],c[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function F(r){var t=Math.sign(r);return((r=Math.abs(r))<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4))*t}var L=function(r,t,e){r=F(r/255),t=F(t/255),e=F(e/255);var n=A.MtxRGB2XYZ,a=A.MtxAdaptMa,f=A.MtxAdaptMaI,o=A.Xn,u=A.Yn,c=A.Zn,i=A.As,l=A.Bs,s=A.Cs,h=r*n.m00+t*n.m10+e*n.m20,d=r*n.m01+t*n.m11+e*n.m21,b=r*n.m02+t*n.m12+e*n.m22,g=o*a.m00+u*a.m10+c*a.m20,v=o*a.m01+u*a.m11+c*a.m21,p=o*a.m02+u*a.m12+c*a.m22,m=h*a.m00+d*a.m10+b*a.m20,y=h*a.m01+d*a.m11+b*a.m21,w=h*a.m02+d*a.m12+b*a.m22;return y*=v/l,w*=p/s,[h=(m*=g/i)*f.m00+y*f.m10+w*f.m20,d=m*f.m01+y*f.m11+w*f.m21,b=m*f.m02+y*f.m12+w*f.m22]},B=Math.sqrt,G=Math.atan2,R=Math.round,Y=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lab"),n=e[0],a=e[1],f=e[2],o=B(a*a+f*f),u=(G(f,a)*y+360)%360;return 0===R(1e4*o)&&(u=Number.NaN),[n,o,u]},$=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgb"),n=e[0],a=e[1],f=e[2],o=e.slice(3),u=P(n,a,f),c=u[0],l=u[1],s=u[2],h=Y(c,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function q(r,t){var e=r.length;Array.isArray(r[0])||(r=[r]),Array.isArray(t[0])||(t=t.map((function(r){return[r]})));var n=t[0].length,a=t[0].map((function(r,e){return t.map((function(r){return r[e]}))})),f=r.map((function(r){return a.map((function(t){return Array.isArray(r)?r.reduce((function(r,e,n){return r+e*(t[n]||0)}),0):t.reduce((function(t,e){return t+e*r}),0)}))}));return 1===e&&(f=f[0]),1===n?f.map((function(r){return r[0]})):f}var X=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n,a=i(r,"rgb"),f=a[0],o=a[1],u=a[2],c=a.slice(3),l=L(f,o,u);return(e=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],n=q([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],l),q(e,n.map((function(r){return Math.cbrt(r)})))).concat(c.length>0&&c[0]<1?[c[0]]:[])};var C=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgb"),n=e[0],a=e[1],f=e[2],o=e.slice(3),u=X(n,a,f),c=u[0],l=u[1],s=u[2],h=Y(c,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])},Z=Math.round,S=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgba"),n=l(r)||"rgb";if("hsl"===n.substr(0,3))return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"hsla"),n=l(r)||"lsa";return e[0]=b(e[0]||0)+"deg",e[1]=b(100*e[1])+"%",e[2]=b(100*e[2])+"%","hsla"===n||e.length>3&&e[3]<1?(e[3]="/ "+(e.length>3?e[3]:1),n="hsla"):e.length=3,n.substr(0,3)+"("+e.join(" ")+")"}(x(e),n);if("lab"===n.substr(0,3)){var a=O();E("d50");var f=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lab"),n=l(r)||"lab";return e[0]=b(e[0])+"%",e[1]=b(e[1]),e[2]=b(e[2]),"laba"===n||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,"lab("+e.join(" ")+")"}(P(e),n);return E(a),f}if("lch"===n.substr(0,3)){var o=O();E("d50");var u=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lch"),n=l(r)||"lab";return e[0]=b(e[0])+"%",e[1]=b(e[1]),e[2]=b(e[2])+"deg","lcha"===n||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,"lch("+e.join(" ")+")"}($(e),n);return E(o),u}return"oklab"===n.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lab");return e[0]=b(100*e[0])+"%",e[1]=g(e[1]),e[2]=g(e[2]),e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,"oklab("+e.join(" ")+")"}(X(e)):"oklch"===n.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lab");return e[0]=b(100*e[0])+"%",e[1]=g(e[1]),e[2]=b(e[2])+"deg",e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,"oklch("+e.join(" ")+")"}(C(e)):(e[0]=Z(e[0]),e[1]=Z(e[1]),e[2]=Z(e[2]),("rgba"===n||e.length>3&&e[3]<1)&&(e[3]="/ "+(e.length>3?e[3]:1),n="rgba"),n.substr(0,3)+"("+e.slice(0,"rgb"===n?3:4).join(" ")+")")},W=function(){for(var r,t=[],e=arguments.length;e--;)t[e]=arguments[e];var n,a,f,o=(t=i(t,"hsl"))[0],u=t[1],c=t[2];if(0===u)n=a=f=255*c;else{var l=[0,0,0],s=[0,0,0],h=c<.5?c*(1+u):c+u-c*u,d=2*c-h,b=o/360;l[0]=b+1/3,l[1]=b,l[2]=b-1/3;for(var g=0;g<3;g++)l[g]<0&&(l[g]+=1),l[g]>1&&(l[g]-=1),6*l[g]<1?s[g]=d+6*(h-d)*l[g]:2*l[g]<1?s[g]=h:3*l[g]<2?s[g]=d+(h-d)*(2/3-l[g])*6:s[g]=d;n=(r=[255*s[0],255*s[1],255*s[2]])[0],a=r[1],f=r[2]}return t.length>3?[n,a,f,t[3]]:[n,a,f,1]},I=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=(r=i(r,"lab"))[0],n=r[1],a=r[2],f=K(e,n,a),o=f[0],u=f[1],c=f[2],l=U(o,u,c);return[l[0],l[1],l[2],r.length>3?r[3]:1]},K=function(r,t,e){var n=A.kE,a=A.kK,f=A.kKE,o=A.Xn,u=A.Yn,c=A.Zn,i=(r+16)/116,l=.002*t+i,s=i-.005*e,h=l*l*l,d=s*s*s;return[(h>n?h:(116*l-16)/a)*o,(r>f?Math.pow((r+16)/116,3):r/a)*u,(d>n?d:(116*s-16)/a)*c]},z=function(r){var t=Math.sign(r);return((r=Math.abs(r))<=.0031308?12.92*r:1.055*Math.pow(r,1/2.4)-.055)*t},U=function(r,t,e){var n=A.MtxAdaptMa,a=A.MtxAdaptMaI,f=A.MtxXYZ2RGB,o=A.RefWhiteRGB,u=A.Xn,c=A.Yn,i=A.Zn,l=u*n.m00+c*n.m10+i*n.m20,s=u*n.m01+c*n.m11+i*n.m21,h=u*n.m02+c*n.m12+i*n.m22,d=o.X*n.m00+o.Y*n.m10+o.Z*n.m20,b=o.X*n.m01+o.Y*n.m11+o.Z*n.m21,g=o.X*n.m02+o.Y*n.m12+o.Z*n.m22,v=(r*n.m00+t*n.m10+e*n.m20)*(d/l),p=(r*n.m01+t*n.m11+e*n.m21)*(b/s),m=(r*n.m02+t*n.m12+e*n.m22)*(g/h),y=v*a.m00+p*a.m10+m*a.m20,w=v*a.m01+p*a.m11+m*a.m21,k=v*a.m02+p*a.m12+m*a.m22;return[255*z(y*f.m00+w*f.m10+k*f.m20),255*z(y*f.m01+w*f.m11+k*f.m21),255*z(y*f.m02+w*f.m12+k*f.m22)]},V=Math.sin,D=Math.cos,T=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lch"),n=e[0],a=e[1],f=e[2];return isNaN(f)&&(f=0),[n,D(f*=m)*a,V(f)*a]},H=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=(r=i(r,"lch"))[0],n=r[1],a=r[2],f=T(e,n,a),o=f[0],u=f[1],c=f[2],l=I(o,u,c);return[l[0],l[1],l[2],r.length>3?r[3]:1]},J=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n,a=(r=i(r,"lab"))[0],f=r[1],o=r[2],u=r.slice(3),c=(e=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],n=q([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,f,o]),q(e,n.map((function(r){return Math.pow(r,3)})))),l=c[0],s=c[1],h=c[2],d=U(l,s,h);return[d[0],d[1],d[2]].concat(u.length>0&&u[0]<1?[u[0]]:[])};var Q=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=(r=i(r,"lch"))[0],n=r[1],a=r[2],f=r.slice(3),o=T(e,n,a),u=o[0],c=o[1],l=o[2],s=J(u,c,l);return[s[0],s[1],s[2]].concat(f.length>0&&f[0]<1?[f[0]]:[])},rr=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,tr=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,er=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,nr=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,ar=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,fr=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,or=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,ur=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,cr=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,ir=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,lr=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,sr=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,hr=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,dr=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,br=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,gr=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,vr=Math.round,pr=function(r){return r.map((function(r,t){return t<=2?e(vr(r),0,255):r}))},mr=function(r,t,e,n){return void 0===t&&(t=0),void 0===e&&(e=100),void 0===n&&(n=!1),"string"==typeof r&&r.endsWith("%")&&(r=parseFloat(r.substring(0,r.length-1))/100,r=n?t+.5*(r+1)*(e-t):t+r*(e-t)),+r},yr=function(r,t){return"none"===r?t:r},wr=function(r){var t;if(r=r.toLowerCase().trim(),w.format.named)try{return w.format.named(r)}catch(r){}if((t=r.match(rr))||(t=r.match(tr))){for(var e=t.slice(1,4),n=0;n<3;n++)e[n]=+e[n];return e[3]=1,e}if((t=r.match(er))||(t=r.match(nr))){for(var a=t.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if((t=r.match(ar))||(t=r.match(fr))){for(var o=t.slice(1,4),u=0;u<3;u++)o[u]=vr(2.55*o[u]);return o[3]=1,o}if((t=r.match(or))||(t=r.match(ur))){for(var c=t.slice(1,5),i=0;i<3;i++)c[i]=vr(2.55*c[i]);return c[3]=+c[3],c}if((t=r.match(cr))||(t=r.match(ir))){var l=t.slice(1,4);l[1]*=.01,l[2]*=.01;for(var s=W(l),h=0;h<3;h++)s[h]=vr(s[h]);return s[3]=1,s}if((t=r.match(lr))||(t=r.match(sr))){var d=t.slice(1,4);d[1]*=.01,d[2]*=.01;for(var b=W(d),g=0;g<3;g++)b[g]=vr(b[g]);return b[3]=+t[4],b}if(t=r.match(hr)){var v=t.slice(1,4);v[0]=mr(v[0],0,100),v[1]=mr(v[1],-125,125,!0),v[2]=mr(v[2],-125,125,!0);var p=O();E("d50");var m=pr(I(v));return E(p),m[3]=void 0!==t[4]?+t[4]:1,m}if(t=r.match(dr)){var y=t.slice(1,4);y[0]=mr(y[0],0,100),y[1]=mr(yr(y[1],0),0,150,!1),y[2]=+yr(y[2].replace("deg",""),0);var k=O();E("d50");var M=pr(H(y));return E(k),M[3]=void 0!==t[4]?+t[4]:1,M}if(t=r.match(br)){var N=t.slice(1,4);N[0]=mr(N[0],0,1),N[1]=mr(N[1],-.4,.4,!0),N[2]=mr(N[2],-.4,.4,!0);var _=pr(J(N));return _[3]=void 0!==t[4]?+t[4]:1,_}if(t=r.match(gr)){var x=t.slice(1,4);x[0]=mr(x[0],0,1),x[1]=mr(yr(x[1],0),0,.4,!1),x[2]=+yr(x[2].replace("deg",""),0);var A=pr(Q(x));return A[3]=void 0!==t[4]?+t[4]:1,A}};wr.test=function(r){return rr.test(r)||er.test(r)||ar.test(r)||or.test(r)||cr.test(r)||lr.test(r)||hr.test(r)||dr.test(r)||br.test(r)||gr.test(r)||tr.test(r)||nr.test(r)||fr.test(r)||ur.test(r)||ir.test(r)||sr.test(r)},k.prototype.css=function(r){return S(this._rgb,r)};var kr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["css"])))};M.css=kr,w.format.css=wr,w.autodetect.push({p:5,test:function(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];if(!t.length&&"string"===c(r)&&wr.test(r))return"css"}}),w.format.gl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgba");return e[0]*=255,e[1]*=255,e[2]*=255,e};var Mr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["gl"])))};M.gl=Mr,k.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var Nr=Math.floor;k.prototype.hcg=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n=i(r,"rgb"),a=n[0],f=n[1],o=n[2],u=h(a,f,o),c=d(a,f,o),l=c-u,s=100*l/255,b=u/(255-l)*100;return 0===l?e=Number.NaN:(a===c&&(e=(f-o)/l),f===c&&(e=2+(o-a)/l),o===c&&(e=4+(a-f)/l),(e*=60)<0&&(e+=360)),[e,s,b]}(this._rgb)};var _r=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hcg"])))};M.hcg=_r,w.format.hcg=function(){for(var r,t,e,n,a,f,o=[],u=arguments.length;u--;)o[u]=arguments[u];var c,l,s,h=(o=i(o,"hcg"))[0],d=o[1],b=o[2];b*=255;var g=255*d;if(0===d)c=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var v=Nr(h/=60),p=h-v,m=b*(1-d),y=m+g*(1-p),w=m+g*p,k=m+g;switch(v){case 0:c=(r=[k,w,m])[0],l=r[1],s=r[2];break;case 1:c=(t=[y,k,m])[0],l=t[1],s=t[2];break;case 2:c=(e=[m,k,w])[0],l=e[1],s=e[2];break;case 3:c=(n=[m,y,k])[0],l=n[1],s=n[2];break;case 4:c=(a=[w,m,k])[0],l=a[1],s=a[2];break;case 5:c=(f=[k,m,y])[0],l=f[1],s=f[2]}}return[c,l,s,o.length>3?o[3]:1]},w.autodetect.push({p:1,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"hcg"))&&3===r.length)return"hcg"}});var xr=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Ar=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,jr=function(r){if(r.match(xr)){4!==r.length&&7!==r.length||(r=r.substr(1)),3===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]);var t=parseInt(r,16);return[t>>16,t>>8&255,255&t,1]}if(r.match(Ar)){5!==r.length&&9!==r.length||(r=r.substr(1)),4===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]);var e=parseInt(r,16);return[e>>24&255,e>>16&255,e>>8&255,Math.round((255&e)/255*100)/100]}throw new Error("unknown hex color: "+r)},Er=Math.round,Or=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgba"),n=e[0],a=e[1],f=e[2],o=e[3],u=l(r)||"auto";void 0===o&&(o=1),"auto"===u&&(u=o<1?"rgba":"rgb");var c="000000"+((n=Er(n))<<16|(a=Er(a))<<8|(f=Er(f))).toString(16);c=c.substr(c.length-6);var s="0"+Er(255*o).toString(16);switch(s=s.substr(s.length-2),u.toLowerCase()){case"rgba":return"#"+c+s;case"argb":return"#"+s+c;default:return"#"+c}};k.prototype.hex=function(r){return Or(this._rgb,r)};var Pr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hex"])))};M.hex=Pr,w.format.hex=jr,w.autodetect.push({p:4,test:function(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];if(!t.length&&"string"===c(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var Fr=Math.cos,Lr=Math.min,Br=Math.sqrt,Gr=Math.acos;k.prototype.hsi=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n=i(r,"rgb"),a=n[0],f=n[1],o=n[2],u=Lr(a/=255,f/=255,o/=255),c=(a+f+o)/3,l=c>0?1-u/c:0;return 0===l?e=NaN:(e=(a-f+(a-o))/2,e/=Br((a-f)*(a-f)+(a-o)*(f-o)),e=Gr(e),o>f&&(e=v-e),e/=v),[360*e,l,c]}(this._rgb)};var Rr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hsi"])))};M.hsi=Rr,w.format.hsi=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,a,f,o=(r=i(r,"hsi"))[0],u=r[1],c=r[2];return isNaN(o)&&(o=0),isNaN(u)&&(u=0),o>360&&(o-=360),o<0&&(o+=360),(o/=360)<1/3?a=1-((f=(1-u)/3)+(n=(1+u*Fr(v*o)/Fr(p-v*o))/3)):o<2/3?f=1-((n=(1-u)/3)+(a=(1+u*Fr(v*(o-=1/3))/Fr(p-v*o))/3)):n=1-((a=(1-u)/3)+(f=(1+u*Fr(v*(o-=2/3))/Fr(p-v*o))/3)),[255*(n=e(c*n*3)),255*(a=e(c*a*3)),255*(f=e(c*f*3)),r.length>3?r[3]:1]},w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"hsi"))&&3===r.length)return"hsi"}}),k.prototype.hsl=function(){return x(this._rgb)};var Yr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hsl"])))};M.hsl=Yr,w.format.hsl=W,w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"hsl"))&&3===r.length)return"hsl"}});var $r=Math.floor,qr=Math.min,Xr=Math.max;k.prototype.hsv=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n,a,f=(r=i(r,"rgb"))[0],o=r[1],u=r[2],c=qr(f,o,u),l=Xr(f,o,u),s=l-c;return a=l/255,0===l?(e=Number.NaN,n=0):(n=s/l,f===l&&(e=(o-u)/s),o===l&&(e=2+(u-f)/s),u===l&&(e=4+(f-o)/s),(e*=60)<0&&(e+=360)),[e,n,a]}(this._rgb)};var Cr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hsv"])))};M.hsv=Cr,w.format.hsv=function(){for(var r,t,e,n,a,f,o=[],u=arguments.length;u--;)o[u]=arguments[u];var c,l,s,h=(o=i(o,"hsv"))[0],d=o[1],b=o[2];if(b*=255,0===d)c=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var g=$r(h/=60),v=h-g,p=b*(1-d),m=b*(1-d*v),y=b*(1-d*(1-v));switch(g){case 0:c=(r=[b,y,p])[0],l=r[1],s=r[2];break;case 1:c=(t=[m,b,p])[0],l=t[1],s=t[2];break;case 2:c=(e=[p,b,y])[0],l=e[1],s=e[2];break;case 3:c=(n=[p,m,b])[0],l=n[1],s=n[2];break;case 4:c=(a=[y,p,b])[0],l=a[1],s=a[2];break;case 5:c=(f=[b,p,m])[0],l=f[1],s=f[2]}}return[c,l,s,o.length>3?o[3]:1]},w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"hsv"))&&3===r.length)return"hsv"}}),k.prototype.lab=function(){return P(this._rgb)};var Zr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["lab"])))};Object.assign(M,{lab:Zr,getLabWhitePoint:O,setLabWhitePoint:E}),w.format.lab=I,w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"lab"))&&3===r.length)return"lab"}});k.prototype.lch=function(){return $(this._rgb)},k.prototype.hcl=function(){return $(this._rgb).reverse()};var Sr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["lch"])))},Wr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hcl"])))};Object.assign(M,{lch:Sr,hcl:Wr}),w.format.lch=H,w.format.hcl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"hcl").reverse();return H.apply(void 0,e)},["lch","hcl"].forEach((function(r){return w.autodetect.push({p:2,test:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if("array"===c(t=i(t,r))&&3===t.length)return r}})}));k.prototype.num=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgb");return(e[0]<<16)+(e[1]<<8)+e[2]}(this._rgb)};var Ir=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["num"])))};Object.assign(M,{num:Ir}),w.format.num=function(r){if("number"==c(r)&&r>=0&&r<=16777215)return[r>>16,r>>8&255,255&r,1];throw new Error("unknown num color: "+r)},w.autodetect.push({p:5,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if(1===r.length&&"number"===c(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var Kr=Math.round;k.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Kr)},k.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(t,e){return e<3?!1===r?t:Kr(t):t}))};var zr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["rgb"])))};Object.assign(M,{rgb:zr}),w.format.rgb=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgba");return void 0===e[3]&&(e[3]=1),e},w.autodetect.push({p:3,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"rgba"))&&(3===r.length||4===r.length&&"number"==c(r[3])&&r[3]>=0&&r[3]<=1))return"rgb"}});var Ur=Math.log,Vr=function(r){var t,e,n,a=r/100;return a<66?(t=255,e=a<6?0:-155.25485562709179-.44596950469579133*(e=a-2)+104.49216199393888*Ur(e),n=a<20?0:.8274096064007395*(n=a-10)-254.76935184120902+115.67994401066147*Ur(n)):(t=351.97690566805693+.114206453784165*(t=a-55)-40.25366309332127*Ur(t),e=325.4494125711974+.07943456536662342*(e=a-50)-28.0852963507957*Ur(e),n=255),[t,e,n,1]},Dr=Math.round;k.prototype.temp=k.prototype.kelvin=k.prototype.temperature=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];for(var e,n=i(r,"rgb"),a=n[0],f=n[2],o=1e3,u=4e4;u-o>.4;){var c=Vr(e=.5*(u+o));c[2]/c[0]>=f/a?u=e:o=e}return Dr(e)}(this._rgb)};var Tr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["temp"])))};Object.assign(M,{temp:Tr,kelvin:Tr,temperature:Tr}),w.format.temp=w.format.kelvin=w.format.temperature=Vr,k.prototype.oklab=function(){return X(this._rgb)};var Hr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["oklab"])))};Object.assign(M,{oklab:Hr}),w.format.oklab=J,w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"oklab"))&&3===r.length)return"oklab"}}),k.prototype.oklch=function(){return C(this._rgb)};var Jr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["oklch"])))};Object.assign(M,{oklch:Jr}),w.format.oklch=Q,w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"oklch"))&&3===r.length)return"oklch"}});var Qr={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"};k.prototype.name=function(){for(var r=Or(this._rgb,"rgb"),t=0,e=Object.keys(Qr);t0;)t[e]=arguments[e+1];if(!t.length&&"string"===c(r)&&Qr[r.toLowerCase()])return"named"}}),k.prototype.alpha=function(r,t){return void 0===t&&(t=!1),void 0!==r&&"number"===c(r)?t?(this._rgb[3]=r,this):new k([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},k.prototype.clipped=function(){return this._rgb._clipped||!1},k.prototype.darken=function(r){void 0===r&&(r=1);var t=this.lab();return t[0]-=A.Kn*r,new k(t,"lab").alpha(this.alpha(),!0)},k.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},k.prototype.darker=k.prototype.darken,k.prototype.brighter=k.prototype.brighten,k.prototype.get=function(r){var t=r.split("."),e=t[0],n=t[1],a=this[e]();if(n){var f=e.indexOf(n)-("ok"===e.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+n+" in mode "+e)}return a};var rt=Math.pow;k.prototype.luminance=function(r,t){if(void 0===t&&(t="rgb"),void 0!==r&&"number"===c(r)){if(0===r)return new k([0,0,0,this._rgb[3]],"rgb");if(1===r)return new k([255,255,255,this._rgb[3]],"rgb");var e=this.luminance(),n=20,a=function(e,f){var o=e.interpolate(f,.5,t),u=o.luminance();return Math.abs(r-u)<1e-7||!n--?o:u>r?a(e,o):a(o,f)},f=(e>r?a(new k([0,0,0]),this):a(this,new k([255,255,255]))).rgb();return new k(f.concat([this._rgb[3]]))}return tt.apply(void 0,this._rgb.slice(0,3))};var tt=function(r,t,e){return.2126*(r=et(r))+.7152*(t=et(t))+.0722*(e=et(e))},et=function(r){return(r/=255)<=.03928?r/12.92:rt((r+.055)/1.055,2.4)},nt={};function at(r,t,e){void 0===e&&(e=.5);for(var n=[],a=arguments.length-3;a-- >0;)n[a]=arguments[a+3];var f=n[0]||"lrgb";if(nt[f]||n.length||(f=Object.keys(nt)[0]),!nt[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==c(r)&&(r=new k(r)),"object"!==c(t)&&(t=new k(t)),nt[f](r,t,e).alpha(r.alpha()+e*(t.alpha()-r.alpha()))}k.prototype.mix=k.prototype.interpolate=function(r,t){void 0===t&&(t=.5);for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return at.apply(void 0,[this,r,t].concat(e))},k.prototype.premultiply=function(r){void 0===r&&(r=!1);var t=this._rgb,e=t[3];return r?(this._rgb=[t[0]*e,t[1]*e,t[2]*e,e],this):new k([t[0]*e,t[1]*e,t[2]*e,e],"rgb")},k.prototype.saturate=function(r){void 0===r&&(r=1);var t=this.lch();return t[1]+=A.Kn*r,t[1]<0&&(t[1]=0),new k(t,"lch").alpha(this.alpha(),!0)},k.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},k.prototype.set=function(r,t,e){void 0===e&&(e=!1);var n=r.split("."),a=n[0],f=n[1],o=this[a]();if(f){var u=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(u>-1){if("string"==c(t))switch(t.charAt(0)){case"+":case"-":o[u]+=+t;break;case"*":o[u]*=+t.substr(1);break;case"/":o[u]/=+t.substr(1);break;default:o[u]=+t}else{if("number"!==c(t))throw new Error("unsupported value for Color.set");o[u]=t}var i=new k(o,a);return e?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return o},k.prototype.tint=function(r){void 0===r&&(r=.5);for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return at.apply(void 0,[this,"white",r].concat(t))},k.prototype.shade=function(r){void 0===r&&(r=.5);for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return at.apply(void 0,[this,"black",r].concat(t))};nt.rgb=function(r,t,e){var n=r._rgb,a=t._rgb;return new k(n[0]+e*(a[0]-n[0]),n[1]+e*(a[1]-n[1]),n[2]+e*(a[2]-n[2]),"rgb")};var ft=Math.sqrt,ot=Math.pow;nt.lrgb=function(r,t,e){var n=r._rgb,a=n[0],f=n[1],o=n[2],u=t._rgb,c=u[0],i=u[1],l=u[2];return new k(ft(ot(a,2)*(1-e)+ot(c,2)*e),ft(ot(f,2)*(1-e)+ot(i,2)*e),ft(ot(o,2)*(1-e)+ot(l,2)*e),"rgb")};function ut(r,t,e,n){var a,f,o,u,c,i,l,s,h,d,b,g,v;return"hsl"===n?(o=r.hsl(),u=t.hsl()):"hsv"===n?(o=r.hsv(),u=t.hsv()):"hcg"===n?(o=r.hcg(),u=t.hcg()):"hsi"===n?(o=r.hsi(),u=t.hsi()):"lch"===n||"hcl"===n?(n="hcl",o=r.hcl(),u=t.hcl()):"oklch"===n&&(o=r.oklch().reverse(),u=t.oklch().reverse()),"h"!==n.substr(0,1)&&"oklch"!==n||(c=(a=o)[0],l=a[1],h=a[2],i=(f=u)[0],s=f[1],d=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=h&&0!=h||"hsv"==n||(b=s)):(g=c,1!=d&&0!=d||"hsv"==n||(b=l)):g=c+e*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+e*(s-l)),v=h+e*(d-h),new k("oklch"===n?[v,b,g]:[g,b,v],n)}nt.lab=function(r,t,e){var n=r.lab(),a=t.lab();return new k(n[0]+e*(a[0]-n[0]),n[1]+e*(a[1]-n[1]),n[2]+e*(a[2]-n[2]),"lab")};var ct=function(r,t,e){return ut(r,t,e,"lch")};nt.lch=ct,nt.hcl=ct;nt.num=function(r,t,e){var n=r.num(),a=t.num();return new k(n+e*(a-n),"num")};nt.hcg=function(r,t,e){return ut(r,t,e,"hcg")};nt.hsi=function(r,t,e){return ut(r,t,e,"hsi")};nt.hsl=function(r,t,e){return ut(r,t,e,"hsl")};nt.hsv=function(r,t,e){return ut(r,t,e,"hsv")};nt.oklab=function(r,t,e){var n=r.oklab(),a=t.oklab();return new k(n[0]+e*(a[0]-n[0]),n[1]+e*(a[1]-n[1]),n[2]+e*(a[2]-n[2]),"oklab")};nt.oklch=function(r,t,e){return ut(r,t,e,"oklch")};var it=Math.pow,lt=Math.sqrt,st=Math.PI,ht=Math.cos,dt=Math.sin,bt=Math.atan2;var gt=function(r,t){for(var e=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new k(n(a))},vt=Math.pow;function pt(r){var t="rgb",n=M("#ccc"),a=0,f=[0,1],o=[],u=[0,0],i=!1,l=[],s=!1,h=0,d=1,b=!1,g={},v=!0,p=1,m=function(r){if((r=r||["#fff","#000"])&&"string"===c(r)&&M.brewer&&M.brewer[r.toLowerCase()]&&(r=M.brewer[r.toLowerCase()]),"array"===c(r)){1===r.length&&(r=[r[0],r[0]]),r=r.slice(0);for(var t=0;t2){var b=function(r){if(null!=i){for(var t=i.length-1,e=0;e=i[e];)e++;return e-1}return 0}(r);s=b/(i.length-2)}else s=d!==h?(r-h)/(d-h):1;s=w(s),a||(s=y(s)),1!==p&&(s=vt(s,p)),s=e(s=u[0]+s*(1-u[0]-u[1]),0,1);var m=Math.floor(1e4*s);if(v&&g[m])f=g[m];else{if("array"===c(l))for(var k=0;k=N&&k===o.length-1){f=l[k];break}if(s>N&&s2){var c=r.map((function(t,e){return e/(r.length-1)})),i=r.map((function(r){return(r-h)/(d-h)}));i.every((function(r,t){return c[t]===r}))||(w=function(r){if(r<=0||r>=1)return r;for(var t=0;r>=i[t+1];)t++;var e=(r-i[t])/(i[t+1]-i[t]);return c[t]+e*(c[t+1]-c[t])})}}return f=[h,d],_},_.mode=function(r){return arguments.length?(t=r,N(),_):t},_.range=function(r,t){return m(r),_},_.out=function(r){return s=r,_},_.spread=function(r){return arguments.length?(a=r,_):a},_.correctLightness=function(r){return null==r&&(r=!0),b=r,N(),y=b?function(r){for(var t=k(0,!0).lab()[0],e=k(1,!0).lab()[0],n=t>e,a=k(r,!0).lab()[0],f=t+(e-t)*r,o=a-f,u=0,c=1,i=20;Math.abs(o)>.01&&i-- >0;)n&&(o*=-1),o<0?(u=r,r+=.5*(c-r)):(c=r,r+=.5*(u-r)),a=k(r,!0).lab()[0],o=a-f;return r}:function(r){return r},_},_.padding=function(r){return null!=r?("number"===c(r)&&(r=[r,r]),u=r,_):u},_.colors=function(t,e){arguments.length<2&&(e="hex");var n=[];if(0===arguments.length)n=l.slice(0);else if(1===t)n=[_(.5)];else if(t>1){var a=f[0],o=f[1]-a;n=function(r,t){for(var e=[],n=ra;n?f++:f--)e.push(f);return e}(0,t).map((function(r){return _(a+r/(t-1)*o)}))}else{r=[];var u=[];if(i&&i.length>2)for(var c=1,s=i.length,h=1<=s;h?cs;h?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;n=u.map((function(r){return _(r)}))}return M[e]&&(n=n.map((function(r){return r[e]()}))),n},_.cache=function(r){return null!=r?(v=r,_):v},_.gamma=function(r){return null!=r?(p=r,_):p},_.nodata=function(r){return null!=r?(n=M(r),_):n},_}var mt=function(r,t,e){if(!mt[e])throw new Error("unknown blend mode "+e);return mt[e](r,t)},yt=function(r){return function(t,e){var n=M(e).rgb(),a=M(t).rgb();return M.rgb(r(n,a))}},wt=function(r){return function(t,e){var n=[];return n[0]=r(t[0],e[0]),n[1]=r(t[1],e[1]),n[2]=r(t[2],e[2]),n}};mt.normal=yt(wt((function(r){return r}))),mt.multiply=yt(wt((function(r,t){return r*t/255}))),mt.screen=yt(wt((function(r,t){return 255*(1-(1-r/255)*(1-t/255))}))),mt.overlay=yt(wt((function(r,t){return t<128?2*r*t/255:255*(1-2*(1-r/255)*(1-t/255))}))),mt.darken=yt(wt((function(r,t){return r>t?t:r}))),mt.lighten=yt(wt((function(r,t){return r>t?r:t}))),mt.dodge=yt(wt((function(r,t){return 255===r||(r=t/255*255/(1-r/255))>255?255:r}))),mt.burn=yt(wt((function(r,t){return 255*(1-(1-t/255)/(r/255))})));var kt=Math.pow,Mt=Math.sin,Nt=Math.cos;var _t=Math.floor,xt=Math.random;var At=Math.log,jt=Math.pow,Et=Math.floor,Ot=Math.abs;function Pt(r,t){void 0===t&&(t=null);var e={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===c(r)&&(r=Object.values(r)),r.forEach((function(r){t&&"object"===c(r)&&(r=r[t]),null==r||isNaN(r)||(e.values.push(r),e.sum+=r,re.max&&(e.max=r),e.count+=1)})),e.domain=[e.min,e.max],e.limits=function(r,t){return Ft(e,r,t)},e}function Ft(r,t,e){void 0===t&&(t="equal"),void 0===e&&(e=7),"array"==c(r)&&(r=Pt(r));var n=r.min,a=r.max,f=r.values.sort((function(r,t){return r-t}));if(1===e)return[n,a];var o=[];if("c"===t.substr(0,1)&&(o.push(n),o.push(a)),"e"===t.substr(0,1)){o.push(n);for(var u=1;u 0");var i=Math.LOG10E*At(n),l=Math.LOG10E*At(a);o.push(n);for(var s=1;s200&&(w=!1)}for(var Y={},$=0;$=360;)b-=360;o[d]=b}else o[d]=o[d]/u[d];return h/=n,new k(o,t).alpha(h>.99999?1:h,!0)},bezier:function(r){var t=function(r){var t,e,n,a,f,o,u;if(2===(r=r.map((function(r){return new k(r)}))).length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],a=function(r){var t=[0,1,2].map((function(t){return f[t]+r*(o[t]-f[t])}));return new k(t,"lab")};else if(3===r.length)e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],u=e[2],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*f[t]+2*(1-r)*r*o[t]+r*r*u[t]}));return new k(t,"lab")};else if(4===r.length){var c;n=r.map((function(r){return r.lab()})),f=n[0],o=n[1],u=n[2],c=n[3],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*(1-r)*f[t]+3*(1-r)*(1-r)*r*o[t]+3*(1-r)*r*r*u[t]+r*r*r*c[t]}));return new k(t,"lab")}}else{if(!(r.length>=5))throw new RangeError("No point in running bezier with only one color.");var i,l,s;i=r.map((function(r){return r.lab()})),s=r.length-1,l=function(r){for(var t=[1,1],e=1;en?(e+.05)/(n+.05):(n+.05)/(e+.05)},cubehelix:function(r,t,e,a,f){void 0===r&&(r=300),void 0===t&&(t=-1.5),void 0===e&&(e=1),void 0===a&&(a=1),void 0===f&&(f=[0,1]);var o,u=0;"array"===c(f)?o=f[1]-f[0]:(o=0,f=[f,f]);var i=function(c){var i=v*((r+120)/360+t*c),l=kt(f[0]+o*c,a),s=(0!==u?e[0]+c*u:e)*l*(1-l)/2,h=Nt(i),d=Mt(i);return M(n([255*(l+s*(-.14861*h+1.78277*d)),255*(l+s*(-.29227*h-.90649*d)),255*(l+s*(1.97294*h)),1]))};return i.start=function(t){return null==t?r:(r=t,i)},i.rotations=function(r){return null==r?t:(t=r,i)},i.gamma=function(r){return null==r?a:(a=r,i)},i.hue=function(r){return null==r?e:("array"===c(e=r)?0===(u=e[1]-e[0])&&(e=e[1]):u=0,i)},i.lightness=function(r){return null==r?f:("array"===c(r)?(f=r,o=r[1]-r[0]):(f=[r,r],o=0),i)},i.scale=function(){return M.scale(i)},i.hue(e),i},deltaE:function(r,t,e,n,a){void 0===e&&(e=1),void 0===n&&(n=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*Zt)},o=function(r){return 2*Zt*r/360};r=new k(r),t=new k(t);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],s=Array.from(t.lab()),h=s[0],d=s[1],b=s[2],g=(c+h)/2,v=(Lt(Bt(i,2)+Bt(l,2))+Lt(Bt(d,2)+Bt(b,2)))/2,p=.5*(1-Lt(Bt(v,7)/(Bt(v,7)+Bt(25,7)))),m=i*(1+p),y=d*(1+p),w=Lt(Bt(m,2)+Bt(l,2)),M=Lt(Bt(y,2)+Bt(b,2)),N=(w+M)/2,_=f(Yt(l,m)),x=f(Yt(b,y)),A=_>=0?_:_+360,j=x>=0?x:x+360,E=$t(A-j)>180?(A+j+360)/2:(A+j)/2,O=1-.17*qt(o(E-30))+.24*qt(o(2*E))+.32*qt(o(3*E+6))-.2*qt(o(4*E-63)),P=j-A;P=$t(P)<=180?P:j<=A?P+360:P-360,P=2*Lt(w*M)*Xt(o(P)/2);var F=h-c,L=M-w,B=1+.015*Bt(g-50,2)/Lt(20+Bt(g-50,2)),G=1+.045*N,R=1+.015*N*O,Y=30*Ct(-Bt((E-275)/25,2)),$=-(2*Lt(Bt(N,7)/(Bt(N,7)+Bt(25,7))))*Xt(2*o(Y)),q=Lt(Bt(F/(e*B),2)+Bt(L/(n*G),2)+Bt(P/(a*R),2)+$*(L/(n*G))*(P/(a*R)));return Rt(0,Gt(100,q))},distance:function(r,t,e){void 0===e&&(e="lab"),r=new k(r),t=new k(t);var n=r.get(e),a=t.get(e),f=0;for(var o in n){var u=(n[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)},input:w,interpolate:at,limits:Ft,mix:at,random:function(){for(var r="#",t=0;t<6;t++)r+="0123456789abcdef".charAt(_t(16*xt()));return new k(r,"hex")},scale:pt,scales:St,valid:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];try{return new(Function.prototype.bind.apply(k,[null].concat(r))),!0}catch(r){return!1}},cmyk:_,css:kr,gl:Mr,hcg:_r,hex:Pr,hsi:Rr,hsl:Yr,hsv:Cr,lab:Zr,lch:Sr,hcl:Wr,num:Ir,rgb:zr,temp:Tr,kelvin:Tr,temperature:Tr,oklab:Hr,oklch:Jr,getLabWhitePoint:O,setLabWhitePoint:E}),M})); diff --git a/docs/index.html b/docs/index.html index acb1c6a6..1f9acb78 100644 --- a/docs/index.html +++ b/docs/index.html @@ -277,9 +277,26 @@

(color1, color2, Kl=1, Kc=1, Kh=1)

chroma.brewer

-

chroma.brewer is an map of ColorBrewer scales that are included in chroma.js for convenience. chroma.scale uses the colors to construct.

+

chroma.brewer is an map of ColorBrewer palettes that are included in chroma.js for convenience. chroma.scale uses the colors to construct.

chroma.brewer.OrRd
 
+

Note that chroma.js only includes the 9-step versions of the palettes (11 steps for the diverging palettes). So, for instance, if you use chroma.js to construct a 5-color palette, they will be different from the "official" 5-color palettes in ColorBrewer (which have lower contrast).

+
chroma.scale('RdBu').colors(5);
+// offical 5-color RdBu:
+['#ca0020', '#f4a582', '#f7f7f7', '#92c5de', '#0571b0']
+
+

One way to compensate for this would be to "slice off" the extreme colors:

+
chroma
+    .scale(chroma.brewer.RdBu.slice(1,-1))
+    .colors(5);
+
+

Of course you can also just construct the scale from the official 5-step colors that you can copy and paste from colorbrewer2.org:

+
chroma.scale(['#ca0020', '#f4a582', '#f7f7f7', '#92c5de', '#0571b0'])
+
+

You can access a list of all available palettes via Object.keys(chroma.brewer):

+
Object.keys(chroma.brewer)
+// ['OrRd', 'PuBu', 'BuPu', 'Oranges', 'BuGn', 'YlOrBr', 'YlGn', 'Reds', 'RdPu', 'Greens', 'YlGnBu', 'Purples', 'GnBu', 'Greys', 'YlOrRd', 'PuRd', 'Blues', 'PuBuGn', 'Viridis', 'Spectral', 'RdYlGn', 'RdBu', 'PiYG', 'PRGn', 'RdYlBu', 'BrBG', 'RdGy', 'PuOr', 'Set2', 'Accent', 'Set1', 'Set3', 'Dark2', 'Paired', 'Pastel2', 'Pastel1']
+

chroma.limits

(data, mode, n)

A helper function that computes class breaks for you, based on data. It supports the modes equidistant (e), quantile (q), logarithmic (l), and k-means (k). Let's take a few numbers as sample data.

diff --git a/docs/libs/chroma-light.cjs b/docs/libs/chroma-light.cjs index bb58b840..595258b4 100644 --- a/docs/libs/chroma-light.cjs +++ b/docs/libs/chroma-light.cjs @@ -61,10 +61,13 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory()); })(this, (function () { 'use strict'; + var min$1 = Math.min; + var max$1 = Math.max; + function limit (x, low, high) { if ( high === void 0 ) high = 1; - return min(max(low, x), high); + return min$1(max$1(low, x), high); } function clip_rgb (rgb) { diff --git a/docs/libs/chroma-light.min.cjs b/docs/libs/chroma-light.min.cjs index 1e876062..ddc330ad 100644 --- a/docs/libs/chroma-light.min.cjs +++ b/docs/libs/chroma-light.min.cjs @@ -55,4 +55,4 @@ * @preserve */ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).chroma=r()}(this,(function(){"use strict";function t(t,r,n){return void 0===n&&(n=1),l(c(r,t),n)}for(var r={},n=0,e=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];n=3?Array.prototype.slice.call(t):"object"==o(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0].slice(0)}function s(t){if(t.length<2)return null;var r=t.length-1;return"string"==o(t[r])?t[r].toLowerCase():null}var u=Math.PI,l=Math.min,c=Math.max,h=function(t){return Math.round(100*t)/100},f=function(t){return Math.round(100*t)/100},d=u/180,g=180/u,m={format:{},autodetect:[]},p=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=this;if("object"===o(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=s(r),i=!1;if(!a){i=!0,m.sorted||(m.autodetect=m.autodetect.sort((function(t,r){return r.p-t.p})),m.sorted=!0);for(var u=0,l=m.autodetect;u255)&&(r._clipped=!0),r[n]=t(r[n],0,255)):3===n&&(r[n]=t(r[n],0,1));return r}(h),3===e._rgb.length&&e._rgb.push(1)};p.prototype.toString=function(){return"function"==o(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var v=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t)))};v.version="3.0.0";var b=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=i(t,"rgba"))[0],o=t[1],s=t[2],u=l(a/=255,o/=255,s/=255),h=c(a,o,s),f=(h+u)/2;return h===u?(n=0,e=Number.NaN):n=f<.5?(h-u)/(h+u):(h-u)/(2-h-u),a==h?e=(o-s)/(h-u):o==h?e=2+(s-a)/(h-u):s==h&&(e=4+(a-o)/(h-u)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,f,t[3]]:[e,n,f]},y={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,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}},w=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 M(t){var r=w.get(String(t).toLowerCase());if(!r)throw new Error("unknown Lab illuminant "+t);y.labWhitePoint=t,y.Xn=r[0],y.Zn=r[1]}function k(){return y.labWhitePoint}var x=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],a=n[1],o=n[2],s=n.slice(3),u=A(e,a,o),l=function(t,r,n){var e=y.Xn,a=y.Yn,o=y.Zn,i=y.kE,s=y.kK,u=t/e,l=r/a,c=n/o,h=u>i?Math.pow(u,1/3):(s*u+16)/116,f=l>i?Math.pow(l,1/3):(s*l+16)/116,d=c>i?Math.pow(c,1/3):(s*c+16)/116;return[116*f-16,500*(h-f),200*(f-d)]}(u[0],u[1],u[2]);return[l[0],l[1],l[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])};function _(t){var r=Math.sign(t);return((t=Math.abs(t))<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4))*r}var A=function(t,r,n){t=_(t/255),r=_(r/255),n=_(n/255);var e=y.MtxRGB2XYZ,a=y.MtxAdaptMa,o=y.MtxAdaptMaI,i=y.Xn,s=y.Yn,u=y.Zn,l=y.As,c=y.Bs,h=y.Cs,f=t*e.m00+r*e.m10+n*e.m20,d=t*e.m01+r*e.m11+n*e.m21,g=t*e.m02+r*e.m12+n*e.m22,m=i*a.m00+s*a.m10+u*a.m20,p=i*a.m01+s*a.m11+u*a.m21,v=i*a.m02+s*a.m12+u*a.m22,b=f*a.m00+d*a.m10+g*a.m20,w=f*a.m01+d*a.m11+g*a.m21,M=f*a.m02+d*a.m12+g*a.m22;return w*=p/c,M*=v/h,[f=(b*=m/l)*o.m00+w*o.m10+M*o.m20,d=b*o.m01+w*o.m11+M*o.m21,g=b*o.m02+w*o.m12+M*o.m22]},j=Math.sqrt,$=Math.atan2,F=Math.round,X=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab"),e=n[0],a=n[1],o=n[2],s=j(a*a+o*o),u=($(o,a)*g+360)%360;return 0===F(1e4*s)&&(u=Number.NaN),[e,s,u]};function Z(t,r){var n=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(r[0])||(r=r.map((function(t){return[t]})));var e=r[0].length,a=r[0].map((function(t,n){return r.map((function(t){return t[n]}))})),o=t.map((function(t){return a.map((function(r){return Array.isArray(t)?t.reduce((function(t,n,e){return t+n*(r[e]||0)}),0):r.reduce((function(r,n){return r+n*t}),0)}))}));return 1===n&&(o=o[0]),1===e?o.map((function(t){return t[0]})):o}var E=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=i(t,"rgb"),o=a[0],s=a[1],u=a[2],l=a.slice(3),c=A(o,s,u);return(n=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],e=Z([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],c),Z(n,e.map((function(t){return Math.cbrt(t)})))).concat(l.length>0&&l[0]<1?[l[0]]:[])};var Y=Math.round,N=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=s(t)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"hsla"),e=s(t)||"lsa";return n[0]=h(n[0]||0)+"deg",n[1]=h(100*n[1])+"%",n[2]=h(100*n[2])+"%","hsla"===e||n.length>3&&n[3]<1?(n[3]="/ "+(n.length>3?n[3]:1),e="hsla"):n.length=3,e.substr(0,3)+"("+n.join(" ")+")"}(b(n),e);if("lab"===e.substr(0,3)){var a=k();M("d50");var o=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab"),e=s(t)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(x(n),e);return M(a),o}if("lch"===e.substr(0,3)){var u=k();M("d50");var l=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lch"),e=s(t)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],a=n[1],o=n[2],s=n.slice(3),u=x(e,a,o),l=u[0],c=u[1],h=u[2],f=X(l,c,h);return[f[0],f[1],f[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])}(n),e);return M(u),l}return"oklab"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab");return n[0]=h(100*n[0])+"%",n[1]=f(n[1]),n[2]=f(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}(E(n)):"oklch"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab");return n[0]=h(100*n[0])+"%",n[1]=f(n[1]),n[2]=h(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],a=n[1],o=n[2],s=n.slice(3),u=E(e,a,o),l=u[0],c=u[1],h=u[2],f=X(l,c,h);return[f[0],f[1],f[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])}(n)):(n[0]=Y(n[0]),n[1]=Y(n[1]),n[2]=Y(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},B=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,a,o,s=(r=i(r,"hsl"))[0],u=r[1],l=r[2];if(0===u)e=a=o=255*l;else{var c=[0,0,0],h=[0,0,0],f=l<.5?l*(1+u):l+u-l*u,d=2*l-f,g=s/360;c[0]=g+1/3,c[1]=g,c[2]=g-1/3;for(var m=0;m<3;m++)c[m]<0&&(c[m]+=1),c[m]>1&&(c[m]-=1),6*c[m]<1?h[m]=d+6*(f-d)*c[m]:2*c[m]<1?h[m]=f:3*c[m]<2?h[m]=d+(f-d)*(2/3-c[m])*6:h[m]=d;e=(t=[255*h[0],255*h[1],255*h[2]])[0],a=t[1],o=t[2]}return r.length>3?[e,a,o,r[3]]:[e,a,o,1]},C=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lab"))[0],e=t[1],a=t[2],o=O(n,e,a),s=o[0],u=o[1],l=o[2],c=L(s,u,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]},O=function(t,r,n){var e=y.kE,a=y.kK,o=y.kKE,i=y.Xn,s=y.Yn,u=y.Zn,l=(t+16)/116,c=.002*r+l,h=l-.005*n,f=c*c*c,d=h*h*h;return[(f>e?f:(116*c-16)/a)*i,(t>o?Math.pow((t+16)/116,3):t/a)*s,(d>e?d:(116*h-16)/a)*u]},R=function(t){var r=Math.sign(t);return((t=Math.abs(t))<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)*r},L=function(t,r,n){var e=y.MtxAdaptMa,a=y.MtxAdaptMaI,o=y.MtxXYZ2RGB,i=y.RefWhiteRGB,s=y.Xn,u=y.Yn,l=y.Zn,c=s*e.m00+u*e.m10+l*e.m20,h=s*e.m01+u*e.m11+l*e.m21,f=s*e.m02+u*e.m12+l*e.m22,d=i.X*e.m00+i.Y*e.m10+i.Z*e.m20,g=i.X*e.m01+i.Y*e.m11+i.Z*e.m21,m=i.X*e.m02+i.Y*e.m12+i.Z*e.m22,p=(t*e.m00+r*e.m10+n*e.m20)*(d/c),v=(t*e.m01+r*e.m11+n*e.m21)*(g/h),b=(t*e.m02+r*e.m12+n*e.m22)*(m/f),w=p*a.m00+v*a.m10+b*a.m20,M=p*a.m01+v*a.m11+b*a.m21,k=p*a.m02+v*a.m12+b*a.m22;return[255*R(w*o.m00+M*o.m10+k*o.m20),255*R(w*o.m01+M*o.m11+k*o.m21),255*R(w*o.m02+M*o.m12+k*o.m22)]},W=Math.sin,K=Math.cos,G=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lch"),e=n[0],a=n[1],o=n[2];return isNaN(o)&&(o=0),[e,K(o*=d)*a,W(o)*a]},I=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=i(t,"lab"))[0],o=t[1],s=t[2],u=t.slice(3),l=(n=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],e=Z([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,o,s]),Z(n,e.map((function(t){return Math.pow(t,3)})))),c=l[0],h=l[1],f=l[2],d=L(c,h,f);return[d[0],d[1],d[2]].concat(u.length>0&&u[0]<1?[u[0]]:[])};var P=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,S=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,q=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,T=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,D=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,U=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,z=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,H=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,J=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,Q=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,V=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,tt=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,rt=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,nt=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,et=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,at=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,ot=Math.round,it=function(r){return r.map((function(r,n){return n<=2?t(ot(r),0,255):r}))},st=function(t,r,n,e){return void 0===r&&(r=0),void 0===n&&(n=100),void 0===e&&(e=!1),"string"==typeof t&&t.endsWith("%")&&(t=parseFloat(t.substring(0,t.length-1))/100,t=e?r+.5*(t+1)*(n-r):r+t*(n-r)),+t},ut=function(t,r){return"none"===t?r:t},lt=function(t){var r;if(t=t.toLowerCase().trim(),m.format.named)try{return m.format.named(t)}catch(t){}if((r=t.match(P))||(r=t.match(S))){for(var n=r.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if((r=t.match(q))||(r=t.match(T))){for(var a=r.slice(1,5),o=0;o<4;o++)a[o]=+a[o];return a}if((r=t.match(D))||(r=t.match(U))){for(var s=r.slice(1,4),u=0;u<3;u++)s[u]=ot(2.55*s[u]);return s[3]=1,s}if((r=t.match(z))||(r=t.match(H))){for(var l=r.slice(1,5),c=0;c<3;c++)l[c]=ot(2.55*l[c]);return l[3]=+l[3],l}if((r=t.match(J))||(r=t.match(Q))){var h=r.slice(1,4);h[1]*=.01,h[2]*=.01;for(var f=B(h),d=0;d<3;d++)f[d]=ot(f[d]);return f[3]=1,f}if((r=t.match(V))||(r=t.match(tt))){var g=r.slice(1,4);g[1]*=.01,g[2]*=.01;for(var p=B(g),v=0;v<3;v++)p[v]=ot(p[v]);return p[3]=+r[4],p}if(r=t.match(rt)){var b=r.slice(1,4);b[0]=st(b[0],0,100),b[1]=st(b[1],-125,125,!0),b[2]=st(b[2],-125,125,!0);var y=k();M("d50");var w=it(C(b));return M(y),w[3]=void 0!==r[4]?+r[4]:1,w}if(r=t.match(nt)){var x=r.slice(1,4);x[0]=st(x[0],0,100),x[1]=st(ut(x[1],0),0,150,!1),x[2]=+ut(x[2].replace("deg",""),0);var _=k();M("d50");var A=it(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lch"))[0],e=t[1],a=t[2],o=G(n,e,a),s=o[0],u=o[1],l=o[2],c=C(s,u,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]}(x));return M(_),A[3]=void 0!==r[4]?+r[4]:1,A}if(r=t.match(et)){var j=r.slice(1,4);j[0]=st(j[0],0,1),j[1]=st(j[1],-.4,.4,!0),j[2]=st(j[2],-.4,.4,!0);var $=it(I(j));return $[3]=void 0!==r[4]?+r[4]:1,$}if(r=t.match(at)){var F=r.slice(1,4);F[0]=st(F[0],0,1),F[1]=st(ut(F[1],0),0,.4,!1),F[2]=+ut(F[2].replace("deg",""),0);var X=it(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lch"))[0],e=t[1],a=t[2],o=t.slice(3),s=G(n,e,a),u=s[0],l=s[1],c=s[2],h=I(u,l,c);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])}(F));return X[3]=void 0!==r[4]?+r[4]:1,X}};lt.test=function(t){return P.test(t)||q.test(t)||D.test(t)||z.test(t)||J.test(t)||V.test(t)||rt.test(t)||nt.test(t)||et.test(t)||at.test(t)||S.test(t)||T.test(t)||U.test(t)||H.test(t)||Q.test(t)||tt.test(t)},p.prototype.css=function(t){return N(this._rgb,t)};var ct=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["css"])))};v.css=ct,m.format.css=lt,m.autodetect.push({p:5,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===o(t)&<.test(t))return"css"}});var ht=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,ft=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,dt=Math.round;p.prototype.hex=function(t){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=n[0],a=n[1],o=n[2],u=n[3],l=s(t)||"auto";void 0===u&&(u=1),"auto"===l&&(l=u<1?"rgba":"rgb");var c="000000"+((e=dt(e))<<16|(a=dt(a))<<8|(o=dt(o))).toString(16);c=c.substr(c.length-6);var h="0"+dt(255*u).toString(16);switch(h=h.substr(h.length-2),l.toLowerCase()){case"rgba":return"#"+c+h;case"argb":return"#"+h+c;default:return"#"+c}}(this._rgb,t)};var gt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["hex"])))};v.hex=gt,m.format.hex=function(t){if(t.match(ht)){4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var r=parseInt(t,16);return[r>>16,r>>8&255,255&r,1]}if(t.match(ft)){5!==t.length&&9!==t.length||(t=t.substr(1)),4===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);var n=parseInt(t,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+t)},m.autodetect.push({p:4,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===o(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}}),p.prototype.hsl=function(){return b(this._rgb)};var mt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["hsl"])))};v.hsl=mt,m.format.hsl=B,m.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"hsl"))&&3===t.length)return"hsl"}}),p.prototype.lab=function(){return x(this._rgb)};var pt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["lab"])))};Object.assign(v,{lab:pt,getLabWhitePoint:k,setLabWhitePoint:M}),m.format.lab=C,m.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"lab"))&&3===t.length)return"lab"}}),p.prototype.oklab=function(){return E(this._rgb)};var vt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["oklab"])))};Object.assign(v,{oklab:vt}),m.format.oklab=I,m.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"oklab"))&&3===t.length)return"oklab"}});var bt=Math.round;p.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(bt)},p.prototype.rgba=function(t){return void 0===t&&(t=!0),this._rgb.slice(0,4).map((function(r,n){return n<3?!1===t?r:bt(r):r}))};var yt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["rgb"])))};Object.assign(v,{rgb:yt}),m.format.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba");return void 0===n[3]&&(n[3]=1),n},m.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"rgba"))&&(3===t.length||4===t.length&&"number"==o(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}}),p.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===o(t)?r?(this._rgb[3]=t,this):new p([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},p.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=y.Kn*t,new p(r,"lab").alpha(this.alpha(),!0)},p.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},p.prototype.darker=p.prototype.darken,p.prototype.brighter=p.prototype.brighten,p.prototype.get=function(t){var r=t.split("."),n=r[0],e=r[1],a=this[n]();if(e){var o=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(o>-1)return a[o];throw new Error("unknown channel "+e+" in mode "+n)}return a};var wt={};function Mt(t,r,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var i=e[0]||"lrgb";if(wt[i]||e.length||(i=Object.keys(wt)[0]),!wt[i])throw new Error("interpolation mode "+i+" is not defined");return"object"!==o(t)&&(t=new p(t)),"object"!==o(r)&&(r=new p(r)),wt[i](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}p.prototype.mix=p.prototype.interpolate=function(t,r){void 0===r&&(r=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return Mt.apply(void 0,[this,t,r].concat(n))},p.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),a=e[0],i=e[1],s=this[a]();if(i){var u=a.indexOf(i)-("ok"===a.substr(0,2)?2:0);if(u>-1){if("string"==o(r))switch(r.charAt(0)){case"+":case"-":s[u]+=+r;break;case"*":s[u]*=+r.substr(1);break;case"/":s[u]/=+r.substr(1);break;default:s[u]=+r}else{if("number"!==o(r))throw new Error("unsupported value for Color.set");s[u]=r}var l=new p(s,a);return n?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+i+" in mode "+a)}return s},p.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Mt.apply(void 0,[this,"white",t].concat(r))},p.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Mt.apply(void 0,[this,"black",t].concat(r))};var kt=Math.sqrt,xt=Math.pow;wt.lrgb=function(t,r,n){var e=t._rgb,a=e[0],o=e[1],i=e[2],s=r._rgb,u=s[0],l=s[1],c=s[2];return new p(kt(xt(a,2)*(1-n)+xt(u,2)*n),kt(xt(o,2)*(1-n)+xt(l,2)*n),kt(xt(i,2)*(1-n)+xt(c,2)*n),"rgb")};return wt.oklab=function(t,r,n){var e=t.oklab(),a=r.oklab();return new p(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")},Object.assign(v,{Color:p,valid:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{return new(Function.prototype.bind.apply(p,[null].concat(t))),!0}catch(t){return!1}},css:ct,hex:gt,hsl:mt,lab:pt,oklab:vt,rgb:yt,mix:Mt,interpolate:Mt}),v})); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).chroma=r()}(this,(function(){"use strict";var t=Math.min,r=Math.max;function n(n,e,a){return void 0===a&&(a=1),t(r(e,n),a)}for(var e={},a=0,o=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];a=3?Array.prototype.slice.call(t):"object"==s(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0].slice(0)}function l(t){if(t.length<2)return null;var r=t.length-1;return"string"==s(t[r])?t[r].toLowerCase():null}var c=Math.PI,h=Math.min,f=Math.max,d=function(t){return Math.round(100*t)/100},g=function(t){return Math.round(100*t)/100},m=c/180,p=180/c,v={format:{},autodetect:[]},b=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var e=this;if("object"===s(t[0])&&t[0].constructor&&t[0].constructor===this.constructor)return t[0];var a=l(t),o=!1;if(!a){o=!0,v.sorted||(v.autodetect=v.autodetect.sort((function(t,r){return r.p-t.p})),v.sorted=!0);for(var i=0,u=v.autodetect;i255)&&(t._clipped=!0),t[r]=n(t[r],0,255)):3===r&&(t[r]=n(t[r],0,1));return t}(h),3===e._rgb.length&&e._rgb.push(1)};b.prototype.toString=function(){return"function"==s(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var y=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t)))};y.version="3.0.0";var w=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=u(t,"rgba"))[0],o=t[1],i=t[2],s=h(a/=255,o/=255,i/=255),l=f(a,o,i),c=(l+s)/2;return l===s?(n=0,e=Number.NaN):n=c<.5?(l-s)/(l+s):(l-s)/(2-l-s),a==l?e=(o-i)/(l-s):o==l?e=2+(i-a)/(l-s):i==l&&(e=4+(a-o)/(l-s)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,c,t[3]]:[e,n,c]},M={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,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}},k=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 x(t){var r=k.get(String(t).toLowerCase());if(!r)throw new Error("unknown Lab illuminant "+t);M.labWhitePoint=t,M.Xn=r[0],M.Zn=r[1]}function _(){return M.labWhitePoint}var A=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgb"),e=n[0],a=n[1],o=n[2],i=n.slice(3),s=$(e,a,o),l=function(t,r,n){var e=M.Xn,a=M.Yn,o=M.Zn,i=M.kE,s=M.kK,u=t/e,l=r/a,c=n/o,h=u>i?Math.pow(u,1/3):(s*u+16)/116,f=l>i?Math.pow(l,1/3):(s*l+16)/116,d=c>i?Math.pow(c,1/3):(s*c+16)/116;return[116*f-16,500*(h-f),200*(f-d)]}(s[0],s[1],s[2]);return[l[0],l[1],l[2]].concat(i.length>0&&i[0]<1?[i[0]]:[])};function j(t){var r=Math.sign(t);return((t=Math.abs(t))<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4))*r}var $=function(t,r,n){t=j(t/255),r=j(r/255),n=j(n/255);var e=M.MtxRGB2XYZ,a=M.MtxAdaptMa,o=M.MtxAdaptMaI,i=M.Xn,s=M.Yn,u=M.Zn,l=M.As,c=M.Bs,h=M.Cs,f=t*e.m00+r*e.m10+n*e.m20,d=t*e.m01+r*e.m11+n*e.m21,g=t*e.m02+r*e.m12+n*e.m22,m=i*a.m00+s*a.m10+u*a.m20,p=i*a.m01+s*a.m11+u*a.m21,v=i*a.m02+s*a.m12+u*a.m22,b=f*a.m00+d*a.m10+g*a.m20,y=f*a.m01+d*a.m11+g*a.m21,w=f*a.m02+d*a.m12+g*a.m22;return y*=p/c,w*=v/h,[f=(b*=m/l)*o.m00+y*o.m10+w*o.m20,d=b*o.m01+y*o.m11+w*o.m21,g=b*o.m02+y*o.m12+w*o.m22]},F=Math.sqrt,X=Math.atan2,Z=Math.round,E=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lab"),e=n[0],a=n[1],o=n[2],i=F(a*a+o*o),s=(X(o,a)*p+360)%360;return 0===Z(1e4*i)&&(s=Number.NaN),[e,i,s]};function Y(t,r){var n=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(r[0])||(r=r.map((function(t){return[t]})));var e=r[0].length,a=r[0].map((function(t,n){return r.map((function(t){return t[n]}))})),o=t.map((function(t){return a.map((function(r){return Array.isArray(t)?t.reduce((function(t,n,e){return t+n*(r[e]||0)}),0):r.reduce((function(r,n){return r+n*t}),0)}))}));return 1===n&&(o=o[0]),1===e?o.map((function(t){return t[0]})):o}var N=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=u(t,"rgb"),o=a[0],i=a[1],s=a[2],l=a.slice(3),c=$(o,i,s);return(n=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],e=Y([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],c),Y(n,e.map((function(t){return Math.cbrt(t)})))).concat(l.length>0&&l[0]<1?[l[0]]:[])};var B=Math.round,C=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgba"),e=l(t)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"hsla"),e=l(t)||"lsa";return n[0]=d(n[0]||0)+"deg",n[1]=d(100*n[1])+"%",n[2]=d(100*n[2])+"%","hsla"===e||n.length>3&&n[3]<1?(n[3]="/ "+(n.length>3?n[3]:1),e="hsla"):n.length=3,e.substr(0,3)+"("+n.join(" ")+")"}(w(n),e);if("lab"===e.substr(0,3)){var a=_();x("d50");var o=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lab"),e=l(t)||"lab";return n[0]=d(n[0])+"%",n[1]=d(n[1]),n[2]=d(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(A(n),e);return x(a),o}if("lch"===e.substr(0,3)){var i=_();x("d50");var s=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lch"),e=l(t)||"lab";return n[0]=d(n[0])+"%",n[1]=d(n[1]),n[2]=d(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgb"),e=n[0],a=n[1],o=n[2],i=n.slice(3),s=A(e,a,o),l=s[0],c=s[1],h=s[2],f=E(l,c,h);return[f[0],f[1],f[2]].concat(i.length>0&&i[0]<1?[i[0]]:[])}(n),e);return x(i),s}return"oklab"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lab");return n[0]=d(100*n[0])+"%",n[1]=g(n[1]),n[2]=g(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}(N(n)):"oklch"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lab");return n[0]=d(100*n[0])+"%",n[1]=g(n[1]),n[2]=d(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgb"),e=n[0],a=n[1],o=n[2],i=n.slice(3),s=N(e,a,o),l=s[0],c=s[1],h=s[2],f=E(l,c,h);return[f[0],f[1],f[2]].concat(i.length>0&&i[0]<1?[i[0]]:[])}(n)):(n[0]=B(n[0]),n[1]=B(n[1]),n[2]=B(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},O=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,a,o,i=(r=u(r,"hsl"))[0],s=r[1],l=r[2];if(0===s)e=a=o=255*l;else{var c=[0,0,0],h=[0,0,0],f=l<.5?l*(1+s):l+s-l*s,d=2*l-f,g=i/360;c[0]=g+1/3,c[1]=g,c[2]=g-1/3;for(var m=0;m<3;m++)c[m]<0&&(c[m]+=1),c[m]>1&&(c[m]-=1),6*c[m]<1?h[m]=d+6*(f-d)*c[m]:2*c[m]<1?h[m]=f:3*c[m]<2?h[m]=d+(f-d)*(2/3-c[m])*6:h[m]=d;e=(t=[255*h[0],255*h[1],255*h[2]])[0],a=t[1],o=t[2]}return r.length>3?[e,a,o,r[3]]:[e,a,o,1]},R=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=u(t,"lab"))[0],e=t[1],a=t[2],o=L(n,e,a),i=o[0],s=o[1],l=o[2],c=K(i,s,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]},L=function(t,r,n){var e=M.kE,a=M.kK,o=M.kKE,i=M.Xn,s=M.Yn,u=M.Zn,l=(t+16)/116,c=.002*r+l,h=l-.005*n,f=c*c*c,d=h*h*h;return[(f>e?f:(116*c-16)/a)*i,(t>o?Math.pow((t+16)/116,3):t/a)*s,(d>e?d:(116*h-16)/a)*u]},W=function(t){var r=Math.sign(t);return((t=Math.abs(t))<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)*r},K=function(t,r,n){var e=M.MtxAdaptMa,a=M.MtxAdaptMaI,o=M.MtxXYZ2RGB,i=M.RefWhiteRGB,s=M.Xn,u=M.Yn,l=M.Zn,c=s*e.m00+u*e.m10+l*e.m20,h=s*e.m01+u*e.m11+l*e.m21,f=s*e.m02+u*e.m12+l*e.m22,d=i.X*e.m00+i.Y*e.m10+i.Z*e.m20,g=i.X*e.m01+i.Y*e.m11+i.Z*e.m21,m=i.X*e.m02+i.Y*e.m12+i.Z*e.m22,p=(t*e.m00+r*e.m10+n*e.m20)*(d/c),v=(t*e.m01+r*e.m11+n*e.m21)*(g/h),b=(t*e.m02+r*e.m12+n*e.m22)*(m/f),y=p*a.m00+v*a.m10+b*a.m20,w=p*a.m01+v*a.m11+b*a.m21,k=p*a.m02+v*a.m12+b*a.m22;return[255*W(y*o.m00+w*o.m10+k*o.m20),255*W(y*o.m01+w*o.m11+k*o.m21),255*W(y*o.m02+w*o.m12+k*o.m22)]},G=Math.sin,I=Math.cos,P=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"lch"),e=n[0],a=n[1],o=n[2];return isNaN(o)&&(o=0),[e,I(o*=m)*a,G(o)*a]},S=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=u(t,"lab"))[0],o=t[1],i=t[2],s=t.slice(3),l=(n=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],e=Y([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,o,i]),Y(n,e.map((function(t){return Math.pow(t,3)})))),c=l[0],h=l[1],f=l[2],d=K(c,h,f);return[d[0],d[1],d[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])};var q=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,T=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,D=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,U=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,z=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,H=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,J=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,Q=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,V=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,tt=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,rt=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,nt=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,et=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,at=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,ot=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,it=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,st=Math.round,ut=function(t){return t.map((function(t,r){return r<=2?n(st(t),0,255):t}))},lt=function(t,r,n,e){return void 0===r&&(r=0),void 0===n&&(n=100),void 0===e&&(e=!1),"string"==typeof t&&t.endsWith("%")&&(t=parseFloat(t.substring(0,t.length-1))/100,t=e?r+.5*(t+1)*(n-r):r+t*(n-r)),+t},ct=function(t,r){return"none"===t?r:t},ht=function(t){var r;if(t=t.toLowerCase().trim(),v.format.named)try{return v.format.named(t)}catch(t){}if((r=t.match(q))||(r=t.match(T))){for(var n=r.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if((r=t.match(D))||(r=t.match(U))){for(var a=r.slice(1,5),o=0;o<4;o++)a[o]=+a[o];return a}if((r=t.match(z))||(r=t.match(H))){for(var i=r.slice(1,4),s=0;s<3;s++)i[s]=st(2.55*i[s]);return i[3]=1,i}if((r=t.match(J))||(r=t.match(Q))){for(var l=r.slice(1,5),c=0;c<3;c++)l[c]=st(2.55*l[c]);return l[3]=+l[3],l}if((r=t.match(V))||(r=t.match(tt))){var h=r.slice(1,4);h[1]*=.01,h[2]*=.01;for(var f=O(h),d=0;d<3;d++)f[d]=st(f[d]);return f[3]=1,f}if((r=t.match(rt))||(r=t.match(nt))){var g=r.slice(1,4);g[1]*=.01,g[2]*=.01;for(var m=O(g),p=0;p<3;p++)m[p]=st(m[p]);return m[3]=+r[4],m}if(r=t.match(et)){var b=r.slice(1,4);b[0]=lt(b[0],0,100),b[1]=lt(b[1],-125,125,!0),b[2]=lt(b[2],-125,125,!0);var y=_();x("d50");var w=ut(R(b));return x(y),w[3]=void 0!==r[4]?+r[4]:1,w}if(r=t.match(at)){var M=r.slice(1,4);M[0]=lt(M[0],0,100),M[1]=lt(ct(M[1],0),0,150,!1),M[2]=+ct(M[2].replace("deg",""),0);var k=_();x("d50");var A=ut(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=u(t,"lch"))[0],e=t[1],a=t[2],o=P(n,e,a),i=o[0],s=o[1],l=o[2],c=R(i,s,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]}(M));return x(k),A[3]=void 0!==r[4]?+r[4]:1,A}if(r=t.match(ot)){var j=r.slice(1,4);j[0]=lt(j[0],0,1),j[1]=lt(j[1],-.4,.4,!0),j[2]=lt(j[2],-.4,.4,!0);var $=ut(S(j));return $[3]=void 0!==r[4]?+r[4]:1,$}if(r=t.match(it)){var F=r.slice(1,4);F[0]=lt(F[0],0,1),F[1]=lt(ct(F[1],0),0,.4,!1),F[2]=+ct(F[2].replace("deg",""),0);var X=ut(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=u(t,"lch"))[0],e=t[1],a=t[2],o=t.slice(3),i=P(n,e,a),s=i[0],l=i[1],c=i[2],h=S(s,l,c);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])}(F));return X[3]=void 0!==r[4]?+r[4]:1,X}};ht.test=function(t){return q.test(t)||D.test(t)||z.test(t)||J.test(t)||V.test(t)||rt.test(t)||et.test(t)||at.test(t)||ot.test(t)||it.test(t)||T.test(t)||U.test(t)||H.test(t)||Q.test(t)||tt.test(t)||nt.test(t)},b.prototype.css=function(t){return C(this._rgb,t)};var ft=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["css"])))};y.css=ft,v.format.css=ht,v.autodetect.push({p:5,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===s(t)&&ht.test(t))return"css"}});var dt=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,gt=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,mt=Math.round;b.prototype.hex=function(t){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgba"),e=n[0],a=n[1],o=n[2],i=n[3],s=l(t)||"auto";void 0===i&&(i=1),"auto"===s&&(s=i<1?"rgba":"rgb");var c="000000"+((e=mt(e))<<16|(a=mt(a))<<8|(o=mt(o))).toString(16);c=c.substr(c.length-6);var h="0"+mt(255*i).toString(16);switch(h=h.substr(h.length-2),s.toLowerCase()){case"rgba":return"#"+c+h;case"argb":return"#"+h+c;default:return"#"+c}}(this._rgb,t)};var pt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["hex"])))};y.hex=pt,v.format.hex=function(t){if(t.match(dt)){4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var r=parseInt(t,16);return[r>>16,r>>8&255,255&r,1]}if(t.match(gt)){5!==t.length&&9!==t.length||(t=t.substr(1)),4===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);var n=parseInt(t,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+t)},v.autodetect.push({p:4,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===s(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}}),b.prototype.hsl=function(){return w(this._rgb)};var vt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["hsl"])))};y.hsl=vt,v.format.hsl=O,v.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===s(t=u(t,"hsl"))&&3===t.length)return"hsl"}}),b.prototype.lab=function(){return A(this._rgb)};var bt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["lab"])))};Object.assign(y,{lab:bt,getLabWhitePoint:_,setLabWhitePoint:x}),v.format.lab=R,v.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===s(t=u(t,"lab"))&&3===t.length)return"lab"}}),b.prototype.oklab=function(){return N(this._rgb)};var yt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["oklab"])))};Object.assign(y,{oklab:yt}),v.format.oklab=S,v.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===s(t=u(t,"oklab"))&&3===t.length)return"oklab"}});var wt=Math.round;b.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(wt)},b.prototype.rgba=function(t){return void 0===t&&(t=!0),this._rgb.slice(0,4).map((function(r,n){return n<3?!1===t?r:wt(r):r}))};var Mt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(b,[null].concat(t,["rgb"])))};Object.assign(y,{rgb:Mt}),v.format.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgba");return void 0===n[3]&&(n[3]=1),n},v.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===s(t=u(t,"rgba"))&&(3===t.length||4===t.length&&"number"==s(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}}),b.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===s(t)?r?(this._rgb[3]=t,this):new b([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},b.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=M.Kn*t,new b(r,"lab").alpha(this.alpha(),!0)},b.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},b.prototype.darker=b.prototype.darken,b.prototype.brighter=b.prototype.brighten,b.prototype.get=function(t){var r=t.split("."),n=r[0],e=r[1],a=this[n]();if(e){var o=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(o>-1)return a[o];throw new Error("unknown channel "+e+" in mode "+n)}return a};var kt={};function xt(t,r,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var o=e[0]||"lrgb";if(kt[o]||e.length||(o=Object.keys(kt)[0]),!kt[o])throw new Error("interpolation mode "+o+" is not defined");return"object"!==s(t)&&(t=new b(t)),"object"!==s(r)&&(r=new b(r)),kt[o](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}b.prototype.mix=b.prototype.interpolate=function(t,r){void 0===r&&(r=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return xt.apply(void 0,[this,t,r].concat(n))},b.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),a=e[0],o=e[1],i=this[a]();if(o){var u=a.indexOf(o)-("ok"===a.substr(0,2)?2:0);if(u>-1){if("string"==s(r))switch(r.charAt(0)){case"+":case"-":i[u]+=+r;break;case"*":i[u]*=+r.substr(1);break;case"/":i[u]/=+r.substr(1);break;default:i[u]=+r}else{if("number"!==s(r))throw new Error("unsupported value for Color.set");i[u]=r}var l=new b(i,a);return n?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+o+" in mode "+a)}return i},b.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return xt.apply(void 0,[this,"white",t].concat(r))},b.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return xt.apply(void 0,[this,"black",t].concat(r))};var _t=Math.sqrt,At=Math.pow;kt.lrgb=function(t,r,n){var e=t._rgb,a=e[0],o=e[1],i=e[2],s=r._rgb,u=s[0],l=s[1],c=s[2];return new b(_t(At(a,2)*(1-n)+At(u,2)*n),_t(At(o,2)*(1-n)+At(l,2)*n),_t(At(i,2)*(1-n)+At(c,2)*n),"rgb")};return kt.oklab=function(t,r,n){var e=t.oklab(),a=r.oklab();return new b(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")},Object.assign(y,{Color:b,valid:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{return new(Function.prototype.bind.apply(b,[null].concat(t))),!0}catch(t){return!1}},css:ft,hex:pt,hsl:vt,lab:bt,oklab:yt,rgb:Mt,mix:xt,interpolate:xt}),y})); diff --git a/docs/libs/chroma.cjs b/docs/libs/chroma.cjs index 0769b043..5e914159 100644 --- a/docs/libs/chroma.cjs +++ b/docs/libs/chroma.cjs @@ -61,11 +61,14 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory()); })(this, (function () { 'use strict'; + var min$4 = Math.min; + var max$4 = Math.max; + function limit (x, low, high) { if ( low === void 0 ) low = 0; if ( high === void 0 ) high = 1; - return min$3(max$3(low, x), high); + return min$4(max$4(low, x), high); } function clip_rgb (rgb) { @@ -84,7 +87,7 @@ // ported from jQuery's $.type var classToType = {}; - for (var i$1 = 0, list$1 = [ + for (var i = 0, list = [ 'Boolean', 'Number', 'String', @@ -94,8 +97,8 @@ 'RegExp', 'Undefined', 'Null' - ]; i$1 < list$1.length; i$1 += 1) { - var name = list$1[i$1]; + ]; i < list.length; i += 1) { + var name = list[i]; classToType[("[object " + name + "]")] = name.toLowerCase(); } @@ -3858,12 +3861,21 @@ Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2'] }; - // add lowercase aliases for case-insensitive matches - for (var i = 0, list = Object.keys(colorbrewer); i < list.length; i += 1) { - var key = list[i]; + var colorbrewerTypes = Object.keys(colorbrewer); + var typeMap = new Map(colorbrewerTypes.map(function (key) { return [key.toLowerCase(), key]; })); - colorbrewer[key.toLowerCase()] = colorbrewer[key]; - } + // use Proxy to allow case-insensitive access to palettes + var colorbrewerProxy = typeof Proxy === 'function' ? new Proxy(colorbrewer, { + get: function get(target, prop) { + var lower = prop.toLowerCase(); + if (typeMap.has(lower)) { + return target[typeMap.get(lower)]; + } + }, + getOwnPropertyNames: function getOwnPropertyNames() { + return Object.getOwnPropertyNames(colorbrewerTypes); + } + }) : colorbrewer; // feel free to comment out anything to rollup // a smaller chroma.js bundle @@ -3873,7 +3885,7 @@ average: average, bezier: bezier$1, blend: blend, - brewer: colorbrewer, + brewer: colorbrewerProxy, Color: Color, colors: w3cx11, contrast: contrast, diff --git a/docs/libs/chroma.min.cjs b/docs/libs/chroma.min.cjs index 4fa5f456..f9397b5e 100644 --- a/docs/libs/chroma.min.cjs +++ b/docs/libs/chroma.min.cjs @@ -55,4 +55,4 @@ * @preserve */ -!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(r="undefined"!=typeof globalThis?globalThis:r||self).chroma=t()}(this,(function(){"use strict";function r(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),l(s(t,r),n)}function t(t){t._clipped=!1,t._unclipped=t.slice(0);for(var n=0;n<=3;n++)n<3?((t[n]<0||t[n]>255)&&(t._clipped=!0),t[n]=r(t[n],0,255)):3===n&&(t[n]=r(t[n],0,1));return t}for(var n={},e=0,a=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];e=3?Array.prototype.slice.call(r):"object"==o(r[0])&&t?t.split("").filter((function(t){return void 0!==r[0][t]})).map((function(t){return r[0][t]})):r[0].slice(0)}function c(r){if(r.length<2)return null;var t=r.length-1;return"string"==o(r[t])?r[t].toLowerCase():null}var i=Math.PI,l=Math.min,s=Math.max,h=function(r){return Math.round(100*r)/100},d=function(r){return Math.round(100*r)/100},b=2*i,g=i/3,v=i/180,p=180/i,m={format:{},autodetect:[]},y=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=this;if("object"===o(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=c(r),f=!1;if(!a){f=!0,m.sorted||(m.autodetect=m.autodetect.sort((function(r,t){return t.p-r.p})),m.sorted=!0);for(var u=0,i=m.autodetect;u4?r[4]:1;return 1===f?[0,0,0,o]:[n>=1?0:255*(1-n)*(1-f),e>=1?0:255*(1-e)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"cmyk"))&&4===r.length)return"cmyk"}});var N=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a=(r=u(r,"rgba"))[0],f=r[1],o=r[2],c=l(a/=255,f/=255,o/=255),i=s(a,f,o),h=(i+c)/2;return i===c?(n=0,e=Number.NaN):n=h<.5?(i-c)/(i+c):(i-c)/(2-i-c),a==i?e=(f-o)/(i-c):f==i?e=2+(o-a)/(i-c):o==i&&(e=4+(a-f)/(i-c)),(e*=60)<0&&(e+=360),r.length>3&&void 0!==r[3]?[e,n,h,r[3]]:[e,n,h]},_={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,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}},x=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 A(r){var t=x.get(String(r).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+r);_.labWhitePoint=r,_.Xn=t[0],_.Zn=t[1]}function j(){return _.labWhitePoint}var E=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=F(e,a,f),i=function(r,t,n){var e=_.Xn,a=_.Yn,f=_.Zn,o=_.kE,u=_.kK,c=r/e,i=t/a,l=n/f,s=c>o?Math.pow(c,1/3):(u*c+16)/116,h=i>o?Math.pow(i,1/3):(u*i+16)/116,d=l>o?Math.pow(l,1/3):(u*l+16)/116;return[116*h-16,500*(s-h),200*(h-d)]}(c[0],c[1],c[2]);return[i[0],i[1],i[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function O(r){var t=Math.sign(r);return((r=Math.abs(r))<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4))*t}var F=function(r,t,n){r=O(r/255),t=O(t/255),n=O(n/255);var e=_.MtxRGB2XYZ,a=_.MtxAdaptMa,f=_.MtxAdaptMaI,o=_.Xn,u=_.Yn,c=_.Zn,i=_.As,l=_.Bs,s=_.Cs,h=r*e.m00+t*e.m10+n*e.m20,d=r*e.m01+t*e.m11+n*e.m21,b=r*e.m02+t*e.m12+n*e.m22,g=o*a.m00+u*a.m10+c*a.m20,v=o*a.m01+u*a.m11+c*a.m21,p=o*a.m02+u*a.m12+c*a.m22,m=h*a.m00+d*a.m10+b*a.m20,y=h*a.m01+d*a.m11+b*a.m21,w=h*a.m02+d*a.m12+b*a.m22;return y*=v/l,w*=p/s,[h=(m*=g/i)*f.m00+y*f.m10+w*f.m20,d=m*f.m01+y*f.m11+w*f.m21,b=m*f.m02+y*f.m12+w*f.m22]},L=Math.sqrt,P=Math.atan2,B=Math.round,G=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab"),e=n[0],a=n[1],f=n[2],o=L(a*a+f*f),c=(P(f,a)*p+360)%360;return 0===B(1e4*o)&&(c=Number.NaN),[e,o,c]},R=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=E(e,a,f),i=c[0],l=c[1],s=c[2],h=G(i,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function Y(r,t){var n=r.length;Array.isArray(r[0])||(r=[r]),Array.isArray(t[0])||(t=t.map((function(r){return[r]})));var e=t[0].length,a=t[0].map((function(r,n){return t.map((function(r){return r[n]}))})),f=r.map((function(r){return a.map((function(t){return Array.isArray(r)?r.reduce((function(r,n,e){return r+n*(t[e]||0)}),0):t.reduce((function(t,n){return t+n*r}),0)}))}));return 1===n&&(f=f[0]),1===e?f.map((function(r){return r[0]})):f}var $=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a=u(r,"rgb"),f=a[0],o=a[1],c=a[2],i=a.slice(3),l=F(f,o,c);return(n=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],e=Y([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],l),Y(n,e.map((function(r){return Math.cbrt(r)})))).concat(i.length>0&&i[0]<1?[i[0]]:[])};var q=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=$(e,a,f),i=c[0],l=c[1],s=c[2],h=G(i,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])},X=Math.round,C=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba"),e=c(r)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"hsla"),e=c(r)||"lsa";return n[0]=h(n[0]||0)+"deg",n[1]=h(100*n[1])+"%",n[2]=h(100*n[2])+"%","hsla"===e||n.length>3&&n[3]<1?(n[3]="/ "+(n.length>3?n[3]:1),e="hsla"):n.length=3,e.substr(0,3)+"("+n.join(" ")+")"}(N(n),e);if("lab"===e.substr(0,3)){var a=j();A("d50");var f=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab"),e=c(r)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(E(n),e);return A(a),f}if("lch"===e.substr(0,3)){var o=j();A("d50");var i=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lch"),e=c(r)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(R(n),e);return A(o),i}return"oklab"===e.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab");return n[0]=h(100*n[0])+"%",n[1]=d(n[1]),n[2]=d(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}($(n)):"oklch"===e.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab");return n[0]=h(100*n[0])+"%",n[1]=d(n[1]),n[2]=h(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(q(n)):(n[0]=X(n[0]),n[1]=X(n[1]),n[2]=X(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},Z=function(){for(var r,t=[],n=arguments.length;n--;)t[n]=arguments[n];var e,a,f,o=(t=u(t,"hsl"))[0],c=t[1],i=t[2];if(0===c)e=a=f=255*i;else{var l=[0,0,0],s=[0,0,0],h=i<.5?i*(1+c):i+c-i*c,d=2*i-h,b=o/360;l[0]=b+1/3,l[1]=b,l[2]=b-1/3;for(var g=0;g<3;g++)l[g]<0&&(l[g]+=1),l[g]>1&&(l[g]-=1),6*l[g]<1?s[g]=d+6*(h-d)*l[g]:2*l[g]<1?s[g]=h:3*l[g]<2?s[g]=d+(h-d)*(2/3-l[g])*6:s[g]=d;e=(r=[255*s[0],255*s[1],255*s[2]])[0],a=r[1],f=r[2]}return t.length>3?[e,a,f,t[3]]:[e,a,f,1]},S=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lab"))[0],e=r[1],a=r[2],f=W(n,e,a),o=f[0],c=f[1],i=f[2],l=K(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},W=function(r,t,n){var e=_.kE,a=_.kK,f=_.kKE,o=_.Xn,u=_.Yn,c=_.Zn,i=(r+16)/116,l=.002*t+i,s=i-.005*n,h=l*l*l,d=s*s*s;return[(h>e?h:(116*l-16)/a)*o,(r>f?Math.pow((r+16)/116,3):r/a)*u,(d>e?d:(116*s-16)/a)*c]},I=function(r){var t=Math.sign(r);return((r=Math.abs(r))<=.0031308?12.92*r:1.055*Math.pow(r,1/2.4)-.055)*t},K=function(r,t,n){var e=_.MtxAdaptMa,a=_.MtxAdaptMaI,f=_.MtxXYZ2RGB,o=_.RefWhiteRGB,u=_.Xn,c=_.Yn,i=_.Zn,l=u*e.m00+c*e.m10+i*e.m20,s=u*e.m01+c*e.m11+i*e.m21,h=u*e.m02+c*e.m12+i*e.m22,d=o.X*e.m00+o.Y*e.m10+o.Z*e.m20,b=o.X*e.m01+o.Y*e.m11+o.Z*e.m21,g=o.X*e.m02+o.Y*e.m12+o.Z*e.m22,v=(r*e.m00+t*e.m10+n*e.m20)*(d/l),p=(r*e.m01+t*e.m11+n*e.m21)*(b/s),m=(r*e.m02+t*e.m12+n*e.m22)*(g/h),y=v*a.m00+p*a.m10+m*a.m20,w=v*a.m01+p*a.m11+m*a.m21,k=v*a.m02+p*a.m12+m*a.m22;return[255*I(y*f.m00+w*f.m10+k*f.m20),255*I(y*f.m01+w*f.m11+k*f.m21),255*I(y*f.m02+w*f.m12+k*f.m22)]},z=Math.sin,U=Math.cos,V=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lch"),e=n[0],a=n[1],f=n[2];return isNaN(f)&&(f=0),[e,U(f*=v)*a,z(f)*a]},D=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lch"))[0],e=r[1],a=r[2],f=V(n,e,a),o=f[0],c=f[1],i=f[2],l=S(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},T=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a=(r=u(r,"lab"))[0],f=r[1],o=r[2],c=r.slice(3),i=(n=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],e=Y([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,f,o]),Y(n,e.map((function(r){return Math.pow(r,3)})))),l=i[0],s=i[1],h=i[2],d=K(l,s,h);return[d[0],d[1],d[2]].concat(c.length>0&&c[0]<1?[c[0]]:[])};var H=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lch"))[0],e=r[1],a=r[2],f=r.slice(3),o=V(n,e,a),c=o[0],i=o[1],l=o[2],s=T(c,i,l);return[s[0],s[1],s[2]].concat(f.length>0&&f[0]<1?[f[0]]:[])},J=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,Q=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,rr=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,tr=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,nr=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,er=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,ar=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,fr=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,or=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,ur=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,cr=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,ir=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,lr=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,sr=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,hr=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,dr=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,br=Math.round,gr=function(t){return t.map((function(t,n){return n<=2?r(br(t),0,255):t}))},vr=function(r,t,n,e){return void 0===t&&(t=0),void 0===n&&(n=100),void 0===e&&(e=!1),"string"==typeof r&&r.endsWith("%")&&(r=parseFloat(r.substring(0,r.length-1))/100,r=e?t+.5*(r+1)*(n-t):t+r*(n-t)),+r},pr=function(r,t){return"none"===r?t:r},mr=function(r){var t;if(r=r.toLowerCase().trim(),m.format.named)try{return m.format.named(r)}catch(r){}if((t=r.match(J))||(t=r.match(Q))){for(var n=t.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if((t=r.match(rr))||(t=r.match(tr))){for(var a=t.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if((t=r.match(nr))||(t=r.match(er))){for(var o=t.slice(1,4),u=0;u<3;u++)o[u]=br(2.55*o[u]);return o[3]=1,o}if((t=r.match(ar))||(t=r.match(fr))){for(var c=t.slice(1,5),i=0;i<3;i++)c[i]=br(2.55*c[i]);return c[3]=+c[3],c}if((t=r.match(or))||(t=r.match(ur))){var l=t.slice(1,4);l[1]*=.01,l[2]*=.01;for(var s=Z(l),h=0;h<3;h++)s[h]=br(s[h]);return s[3]=1,s}if((t=r.match(cr))||(t=r.match(ir))){var d=t.slice(1,4);d[1]*=.01,d[2]*=.01;for(var b=Z(d),g=0;g<3;g++)b[g]=br(b[g]);return b[3]=+t[4],b}if(t=r.match(lr)){var v=t.slice(1,4);v[0]=vr(v[0],0,100),v[1]=vr(v[1],-125,125,!0),v[2]=vr(v[2],-125,125,!0);var p=j();A("d50");var y=gr(S(v));return A(p),y[3]=void 0!==t[4]?+t[4]:1,y}if(t=r.match(sr)){var w=t.slice(1,4);w[0]=vr(w[0],0,100),w[1]=vr(pr(w[1],0),0,150,!1),w[2]=+pr(w[2].replace("deg",""),0);var k=j();A("d50");var M=gr(D(w));return A(k),M[3]=void 0!==t[4]?+t[4]:1,M}if(t=r.match(hr)){var N=t.slice(1,4);N[0]=vr(N[0],0,1),N[1]=vr(N[1],-.4,.4,!0),N[2]=vr(N[2],-.4,.4,!0);var _=gr(T(N));return _[3]=void 0!==t[4]?+t[4]:1,_}if(t=r.match(dr)){var x=t.slice(1,4);x[0]=vr(x[0],0,1),x[1]=vr(pr(x[1],0),0,.4,!1),x[2]=+pr(x[2].replace("deg",""),0);var E=gr(H(x));return E[3]=void 0!==t[4]?+t[4]:1,E}};mr.test=function(r){return J.test(r)||rr.test(r)||nr.test(r)||ar.test(r)||or.test(r)||cr.test(r)||lr.test(r)||sr.test(r)||hr.test(r)||dr.test(r)||Q.test(r)||tr.test(r)||er.test(r)||fr.test(r)||ur.test(r)||ir.test(r)},y.prototype.css=function(r){return C(this._rgb,r)};var yr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["css"])))};w.css=yr,m.format.css=mr,m.autodetect.push({p:5,test:function(r){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&mr.test(r))return"css"}}),m.format.gl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba");return n[0]*=255,n[1]*=255,n[2]*=255,n};var wr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["gl"])))};w.gl=wr,y.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var kr=Math.floor;y.prototype.hcg=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e=u(r,"rgb"),a=e[0],f=e[1],o=e[2],c=l(a,f,o),i=s(a,f,o),h=i-c,d=100*h/255,b=c/(255-h)*100;return 0===h?n=Number.NaN:(a===i&&(n=(f-o)/h),f===i&&(n=2+(o-a)/h),o===i&&(n=4+(a-f)/h),(n*=60)<0&&(n+=360)),[n,d,b]}(this._rgb)};var Mr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hcg"])))};w.hcg=Mr,m.format.hcg=function(){for(var r,t,n,e,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,s,h=(o=u(o,"hcg"))[0],d=o[1],b=o[2];b*=255;var g=255*d;if(0===d)i=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var v=kr(h/=60),p=h-v,m=b*(1-d),y=m+g*(1-p),w=m+g*p,k=m+g;switch(v){case 0:i=(r=[k,w,m])[0],l=r[1],s=r[2];break;case 1:i=(t=[y,k,m])[0],l=t[1],s=t[2];break;case 2:i=(n=[m,k,w])[0],l=n[1],s=n[2];break;case 3:i=(e=[m,y,k])[0],l=e[1],s=e[2];break;case 4:i=(a=[w,m,k])[0],l=a[1],s=a[2];break;case 5:i=(f=[k,m,y])[0],l=f[1],s=f[2]}}return[i,l,s,o.length>3?o[3]:1]},m.autodetect.push({p:1,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hcg"))&&3===r.length)return"hcg"}});var Nr=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,_r=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,xr=function(r){if(r.match(Nr)){4!==r.length&&7!==r.length||(r=r.substr(1)),3===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]);var t=parseInt(r,16);return[t>>16,t>>8&255,255&t,1]}if(r.match(_r)){5!==r.length&&9!==r.length||(r=r.substr(1)),4===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]);var n=parseInt(r,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+r)},Ar=Math.round,jr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba"),e=n[0],a=n[1],f=n[2],o=n[3],i=c(r)||"auto";void 0===o&&(o=1),"auto"===i&&(i=o<1?"rgba":"rgb");var l="000000"+((e=Ar(e))<<16|(a=Ar(a))<<8|(f=Ar(f))).toString(16);l=l.substr(l.length-6);var s="0"+Ar(255*o).toString(16);switch(s=s.substr(s.length-2),i.toLowerCase()){case"rgba":return"#"+l+s;case"argb":return"#"+s+l;default:return"#"+l}};y.prototype.hex=function(r){return jr(this._rgb,r)};var Er=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hex"])))};w.hex=Er,m.format.hex=xr,m.autodetect.push({p:4,test:function(r){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var Or=Math.cos,Fr=Math.min,Lr=Math.sqrt,Pr=Math.acos;y.prototype.hsi=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e=u(r,"rgb"),a=e[0],f=e[1],o=e[2],c=Fr(a/=255,f/=255,o/=255),i=(a+f+o)/3,l=i>0?1-c/i:0;return 0===l?n=NaN:(n=(a-f+(a-o))/2,n/=Lr((a-f)*(a-f)+(a-o)*(f-o)),n=Pr(n),o>f&&(n=b-n),n/=b),[360*n,l,i]}(this._rgb)};var Br=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hsi"])))};w.hsi=Br,m.format.hsi=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var e,a,f,o=(t=u(t,"hsi"))[0],c=t[1],i=t[2];return isNaN(o)&&(o=0),isNaN(c)&&(c=0),o>360&&(o-=360),o<0&&(o+=360),(o/=360)<1/3?a=1-((f=(1-c)/3)+(e=(1+c*Or(b*o)/Or(g-b*o))/3)):o<2/3?f=1-((e=(1-c)/3)+(a=(1+c*Or(b*(o-=1/3))/Or(g-b*o))/3)):e=1-((a=(1-c)/3)+(f=(1+c*Or(b*(o-=2/3))/Or(g-b*o))/3)),[255*(e=r(i*e*3)),255*(a=r(i*a*3)),255*(f=r(i*f*3)),t.length>3?t[3]:1]},m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsi"))&&3===r.length)return"hsi"}}),y.prototype.hsl=function(){return N(this._rgb)};var Gr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hsl"])))};w.hsl=Gr,m.format.hsl=Z,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsl"))&&3===r.length)return"hsl"}});var Rr=Math.floor,Yr=Math.min,$r=Math.max;y.prototype.hsv=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a,f=(r=u(r,"rgb"))[0],o=r[1],c=r[2],i=Yr(f,o,c),l=$r(f,o,c),s=l-i;return a=l/255,0===l?(n=Number.NaN,e=0):(e=s/l,f===l&&(n=(o-c)/s),o===l&&(n=2+(c-f)/s),c===l&&(n=4+(f-o)/s),(n*=60)<0&&(n+=360)),[n,e,a]}(this._rgb)};var qr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hsv"])))};w.hsv=qr,m.format.hsv=function(){for(var r,t,n,e,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,s,h=(o=u(o,"hsv"))[0],d=o[1],b=o[2];if(b*=255,0===d)i=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var g=Rr(h/=60),v=h-g,p=b*(1-d),m=b*(1-d*v),y=b*(1-d*(1-v));switch(g){case 0:i=(r=[b,y,p])[0],l=r[1],s=r[2];break;case 1:i=(t=[m,b,p])[0],l=t[1],s=t[2];break;case 2:i=(n=[p,b,y])[0],l=n[1],s=n[2];break;case 3:i=(e=[p,m,b])[0],l=e[1],s=e[2];break;case 4:i=(a=[y,p,b])[0],l=a[1],s=a[2];break;case 5:i=(f=[b,p,m])[0],l=f[1],s=f[2]}}return[i,l,s,o.length>3?o[3]:1]},m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsv"))&&3===r.length)return"hsv"}}),y.prototype.lab=function(){return E(this._rgb)};var Xr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["lab"])))};Object.assign(w,{lab:Xr,getLabWhitePoint:j,setLabWhitePoint:A}),m.format.lab=S,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"lab"))&&3===r.length)return"lab"}});y.prototype.lch=function(){return R(this._rgb)},y.prototype.hcl=function(){return R(this._rgb).reverse()};var Cr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["lch"])))},Zr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hcl"])))};Object.assign(w,{lch:Cr,hcl:Zr}),m.format.lch=D,m.format.hcl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"hcl").reverse();return D.apply(void 0,n)},["lch","hcl"].forEach((function(r){return m.autodetect.push({p:2,test:function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];if("array"===o(t=u(t,r))&&3===t.length)return r}})}));y.prototype.num=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb");return(n[0]<<16)+(n[1]<<8)+n[2]}(this._rgb)};var Sr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["num"])))};Object.assign(w,{num:Sr}),m.format.num=function(r){if("number"==o(r)&&r>=0&&r<=16777215)return[r>>16,r>>8&255,255&r,1];throw new Error("unknown num color: "+r)},m.autodetect.push({p:5,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if(1===r.length&&"number"===o(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var Wr=Math.round;y.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Wr)},y.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(t,n){return n<3?!1===r?t:Wr(t):t}))};var Ir=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["rgb"])))};Object.assign(w,{rgb:Ir}),m.format.rgb=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba");return void 0===n[3]&&(n[3]=1),n},m.autodetect.push({p:3,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"rgba"))&&(3===r.length||4===r.length&&"number"==o(r[3])&&r[3]>=0&&r[3]<=1))return"rgb"}});var Kr=Math.log,zr=function(r){var t,n,e,a=r/100;return a<66?(t=255,n=a<6?0:-155.25485562709179-.44596950469579133*(n=a-2)+104.49216199393888*Kr(n),e=a<20?0:.8274096064007395*(e=a-10)-254.76935184120902+115.67994401066147*Kr(e)):(t=351.97690566805693+.114206453784165*(t=a-55)-40.25366309332127*Kr(t),n=325.4494125711974+.07943456536662342*(n=a-50)-28.0852963507957*Kr(n),e=255),[t,n,e,1]},Ur=Math.round;y.prototype.temp=y.prototype.kelvin=y.prototype.temperature=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];for(var n,e=u(r,"rgb"),a=e[0],f=e[2],o=1e3,c=4e4;c-o>.4;){var i=zr(n=.5*(c+o));i[2]/i[0]>=f/a?c=n:o=n}return Ur(n)}(this._rgb)};var Vr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["temp"])))};Object.assign(w,{temp:Vr,kelvin:Vr,temperature:Vr}),m.format.temp=m.format.kelvin=m.format.temperature=zr,y.prototype.oklab=function(){return $(this._rgb)};var Dr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["oklab"])))};Object.assign(w,{oklab:Dr}),m.format.oklab=T,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"oklab"))&&3===r.length)return"oklab"}}),y.prototype.oklch=function(){return q(this._rgb)};var Tr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["oklch"])))};Object.assign(w,{oklch:Tr}),m.format.oklch=H,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"oklch"))&&3===r.length)return"oklch"}});var Hr={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"};y.prototype.name=function(){for(var r=jr(this._rgb,"rgb"),t=0,n=Object.keys(Hr);t0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&Hr[r.toLowerCase()])return"named"}}),y.prototype.alpha=function(r,t){return void 0===t&&(t=!1),void 0!==r&&"number"===o(r)?t?(this._rgb[3]=r,this):new y([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},y.prototype.clipped=function(){return this._rgb._clipped||!1},y.prototype.darken=function(r){void 0===r&&(r=1);var t=this.lab();return t[0]-=_.Kn*r,new y(t,"lab").alpha(this.alpha(),!0)},y.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},y.prototype.darker=y.prototype.darken,y.prototype.brighter=y.prototype.brighten,y.prototype.get=function(r){var t=r.split("."),n=t[0],e=t[1],a=this[n]();if(e){var f=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+e+" in mode "+n)}return a};var Jr=Math.pow;y.prototype.luminance=function(r,t){if(void 0===t&&(t="rgb"),void 0!==r&&"number"===o(r)){if(0===r)return new y([0,0,0,this._rgb[3]],"rgb");if(1===r)return new y([255,255,255,this._rgb[3]],"rgb");var n=this.luminance(),e=20,a=function(n,f){var o=n.interpolate(f,.5,t),u=o.luminance();return Math.abs(r-u)<1e-7||!e--?o:u>r?a(n,o):a(o,f)},f=(n>r?a(new y([0,0,0]),this):a(this,new y([255,255,255]))).rgb();return new y(f.concat([this._rgb[3]]))}return Qr.apply(void 0,this._rgb.slice(0,3))};var Qr=function(r,t,n){return.2126*(r=rt(r))+.7152*(t=rt(t))+.0722*(n=rt(n))},rt=function(r){return(r/=255)<=.03928?r/12.92:Jr((r+.055)/1.055,2.4)},tt={};function nt(r,t,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var f=e[0]||"lrgb";if(tt[f]||e.length||(f=Object.keys(tt)[0]),!tt[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==o(r)&&(r=new y(r)),"object"!==o(t)&&(t=new y(t)),tt[f](r,t,n).alpha(r.alpha()+n*(t.alpha()-r.alpha()))}y.prototype.mix=y.prototype.interpolate=function(r,t){void 0===t&&(t=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return nt.apply(void 0,[this,r,t].concat(n))},y.prototype.premultiply=function(r){void 0===r&&(r=!1);var t=this._rgb,n=t[3];return r?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new y([t[0]*n,t[1]*n,t[2]*n,n],"rgb")},y.prototype.saturate=function(r){void 0===r&&(r=1);var t=this.lch();return t[1]+=_.Kn*r,t[1]<0&&(t[1]=0),new y(t,"lch").alpha(this.alpha(),!0)},y.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},y.prototype.set=function(r,t,n){void 0===n&&(n=!1);var e=r.split("."),a=e[0],f=e[1],u=this[a]();if(f){var c=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(c>-1){if("string"==o(t))switch(t.charAt(0)){case"+":case"-":u[c]+=+t;break;case"*":u[c]*=+t.substr(1);break;case"/":u[c]/=+t.substr(1);break;default:u[c]=+t}else{if("number"!==o(t))throw new Error("unsupported value for Color.set");u[c]=t}var i=new y(u,a);return n?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return u},y.prototype.tint=function(r){void 0===r&&(r=.5);for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return nt.apply(void 0,[this,"white",r].concat(t))},y.prototype.shade=function(r){void 0===r&&(r=.5);for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return nt.apply(void 0,[this,"black",r].concat(t))};tt.rgb=function(r,t,n){var e=r._rgb,a=t._rgb;return new y(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"rgb")};var et=Math.sqrt,at=Math.pow;tt.lrgb=function(r,t,n){var e=r._rgb,a=e[0],f=e[1],o=e[2],u=t._rgb,c=u[0],i=u[1],l=u[2];return new y(et(at(a,2)*(1-n)+at(c,2)*n),et(at(f,2)*(1-n)+at(i,2)*n),et(at(o,2)*(1-n)+at(l,2)*n),"rgb")};function ft(r,t,n,e){var a,f,o,u,c,i,l,s,h,d,b,g,v;return"hsl"===e?(o=r.hsl(),u=t.hsl()):"hsv"===e?(o=r.hsv(),u=t.hsv()):"hcg"===e?(o=r.hcg(),u=t.hcg()):"hsi"===e?(o=r.hsi(),u=t.hsi()):"lch"===e||"hcl"===e?(e="hcl",o=r.hcl(),u=t.hcl()):"oklch"===e&&(o=r.oklch().reverse(),u=t.oklch().reverse()),"h"!==e.substr(0,1)&&"oklch"!==e||(c=(a=o)[0],l=a[1],h=a[2],i=(f=u)[0],s=f[1],d=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=h&&0!=h||"hsv"==e||(b=s)):(g=c,1!=d&&0!=d||"hsv"==e||(b=l)):g=c+n*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+n*(s-l)),v=h+n*(d-h),new y("oklch"===e?[v,b,g]:[g,b,v],e)}tt.lab=function(r,t,n){var e=r.lab(),a=t.lab();return new y(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"lab")};var ot=function(r,t,n){return ft(r,t,n,"lch")};tt.lch=ot,tt.hcl=ot;tt.num=function(r,t,n){var e=r.num(),a=t.num();return new y(e+n*(a-e),"num")};tt.hcg=function(r,t,n){return ft(r,t,n,"hcg")};tt.hsi=function(r,t,n){return ft(r,t,n,"hsi")};tt.hsl=function(r,t,n){return ft(r,t,n,"hsl")};tt.hsv=function(r,t,n){return ft(r,t,n,"hsv")};tt.oklab=function(r,t,n){var e=r.oklab(),a=t.oklab();return new y(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")};tt.oklch=function(r,t,n){return ft(r,t,n,"oklch")};var ut=Math.pow,ct=Math.sqrt,it=Math.PI,lt=Math.cos,st=Math.sin,ht=Math.atan2;var dt=function(r,n){for(var e=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new y(t(a))},bt=Math.pow;function gt(t){var n="rgb",e=w("#ccc"),a=0,f=[0,1],u=[],c=[0,0],i=!1,l=[],s=!1,h=0,d=1,b=!1,g={},v=!0,p=1,m=function(r){if((r=r||["#fff","#000"])&&"string"===o(r)&&w.brewer&&w.brewer[r.toLowerCase()]&&(r=w.brewer[r.toLowerCase()]),"array"===o(r)){1===r.length&&(r=[r[0],r[0]]),r=r.slice(0);for(var t=0;t2){var b=function(r){if(null!=i){for(var t=i.length-1,n=0;n=i[n];)n++;return n-1}return 0}(t);s=b/(i.length-2)}else s=d!==h?(t-h)/(d-h):1;s=k(s),a||(s=y(s)),1!==p&&(s=bt(s,p)),s=r(s=c[0]+s*(1-c[0]-c[1]),0,1);var m=Math.floor(1e4*s);if(v&&g[m])f=g[m];else{if("array"===o(l))for(var M=0;M=N&&M===u.length-1){f=l[M];break}if(s>N&&s2){var c=r.map((function(t,n){return n/(r.length-1)})),i=r.map((function(r){return(r-h)/(d-h)}));i.every((function(r,t){return c[t]===r}))||(k=function(r){if(r<=0||r>=1)return r;for(var t=0;r>=i[t+1];)t++;var n=(r-i[t])/(i[t+1]-i[t]);return c[t]+n*(c[t+1]-c[t])})}}return f=[h,d],_},_.mode=function(r){return arguments.length?(n=r,N(),_):n},_.range=function(r,t){return m(r),_},_.out=function(r){return s=r,_},_.spread=function(r){return arguments.length?(a=r,_):a},_.correctLightness=function(r){return null==r&&(r=!0),b=r,N(),y=b?function(r){for(var t=M(0,!0).lab()[0],n=M(1,!0).lab()[0],e=t>n,a=M(r,!0).lab()[0],f=t+(n-t)*r,o=a-f,u=0,c=1,i=20;Math.abs(o)>.01&&i-- >0;)e&&(o*=-1),o<0?(u=r,r+=.5*(c-r)):(c=r,r+=.5*(u-r)),a=M(r,!0).lab()[0],o=a-f;return r}:function(r){return r},_},_.padding=function(r){return null!=r?("number"===o(r)&&(r=[r,r]),c=r,_):c},_.colors=function(r,n){arguments.length<2&&(n="hex");var e=[];if(0===arguments.length)e=l.slice(0);else if(1===r)e=[_(.5)];else if(r>1){var a=f[0],o=f[1]-a;e=function(r,t){for(var n=[],e=ra;e?f++:f--)n.push(f);return n}(0,r).map((function(t){return _(a+t/(r-1)*o)}))}else{t=[];var u=[];if(i&&i.length>2)for(var c=1,s=i.length,h=1<=s;h?cs;h?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;e=u.map((function(r){return _(r)}))}return w[n]&&(e=e.map((function(r){return r[n]()}))),e},_.cache=function(r){return null!=r?(v=r,_):v},_.gamma=function(r){return null!=r?(p=r,_):p},_.nodata=function(r){return null!=r?(e=w(r),_):e},_}var vt=function(r,t,n){if(!vt[n])throw new Error("unknown blend mode "+n);return vt[n](r,t)},pt=function(r){return function(t,n){var e=w(n).rgb(),a=w(t).rgb();return w.rgb(r(e,a))}},mt=function(r){return function(t,n){var e=[];return e[0]=r(t[0],n[0]),e[1]=r(t[1],n[1]),e[2]=r(t[2],n[2]),e}};vt.normal=pt(mt((function(r){return r}))),vt.multiply=pt(mt((function(r,t){return r*t/255}))),vt.screen=pt(mt((function(r,t){return 255*(1-(1-r/255)*(1-t/255))}))),vt.overlay=pt(mt((function(r,t){return t<128?2*r*t/255:255*(1-2*(1-r/255)*(1-t/255))}))),vt.darken=pt(mt((function(r,t){return r>t?t:r}))),vt.lighten=pt(mt((function(r,t){return r>t?r:t}))),vt.dodge=pt(mt((function(r,t){return 255===r||(r=t/255*255/(1-r/255))>255?255:r}))),vt.burn=pt(mt((function(r,t){return 255*(1-(1-t/255)/(r/255))})));var yt=Math.pow,wt=Math.sin,kt=Math.cos;var Mt=Math.floor,Nt=Math.random;var _t=Math.log,xt=Math.pow,At=Math.floor,jt=Math.abs;function Et(r,t){void 0===t&&(t=null);var n={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===o(r)&&(r=Object.values(r)),r.forEach((function(r){t&&"object"===o(r)&&(r=r[t]),null==r||isNaN(r)||(n.values.push(r),n.sum+=r,rn.max&&(n.max=r),n.count+=1)})),n.domain=[n.min,n.max],n.limits=function(r,t){return Ot(n,r,t)},n}function Ot(r,t,n){void 0===t&&(t="equal"),void 0===n&&(n=7),"array"==o(r)&&(r=Et(r));var e=r.min,a=r.max,f=r.values.sort((function(r,t){return r-t}));if(1===n)return[e,a];var u=[];if("c"===t.substr(0,1)&&(u.push(e),u.push(a)),"e"===t.substr(0,1)){u.push(e);for(var c=1;c 0");var i=Math.LOG10E*_t(e),l=Math.LOG10E*_t(a);u.push(e);for(var s=1;s200&&(w=!1)}for(var Y={},$=0;$=360;)b-=360;o[d]=b}else o[d]=o[d]/u[d];return h/=e,new y(o,t).alpha(h>.99999?1:h,!0)},bezier:function(r){var t=function(r){var t,n,e,a,f,o,u;if(2===(r=r.map((function(r){return new y(r)}))).length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],a=function(r){var t=[0,1,2].map((function(t){return f[t]+r*(o[t]-f[t])}));return new y(t,"lab")};else if(3===r.length)n=r.map((function(r){return r.lab()})),f=n[0],o=n[1],u=n[2],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*f[t]+2*(1-r)*r*o[t]+r*r*u[t]}));return new y(t,"lab")};else if(4===r.length){var c;e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],u=e[2],c=e[3],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*(1-r)*f[t]+3*(1-r)*(1-r)*r*o[t]+3*(1-r)*r*r*u[t]+r*r*r*c[t]}));return new y(t,"lab")}}else{if(!(r.length>=5))throw new RangeError("No point in running bezier with only one color.");var i,l,s;i=r.map((function(r){return r.lab()})),s=r.length-1,l=function(r){for(var t=[1,1],n=1;ne?(n+.05)/(e+.05):(e+.05)/(n+.05)},cubehelix:function(r,n,e,a,f){void 0===r&&(r=300),void 0===n&&(n=-1.5),void 0===e&&(e=1),void 0===a&&(a=1),void 0===f&&(f=[0,1]);var u,c=0;"array"===o(f)?u=f[1]-f[0]:(u=0,f=[f,f]);var i=function(o){var i=b*((r+120)/360+n*o),l=yt(f[0]+u*o,a),s=(0!==c?e[0]+o*c:e)*l*(1-l)/2,h=kt(i),d=wt(i);return w(t([255*(l+s*(-.14861*h+1.78277*d)),255*(l+s*(-.29227*h-.90649*d)),255*(l+s*(1.97294*h)),1]))};return i.start=function(t){return null==t?r:(r=t,i)},i.rotations=function(r){return null==r?n:(n=r,i)},i.gamma=function(r){return null==r?a:(a=r,i)},i.hue=function(r){return null==r?e:("array"===o(e=r)?0===(c=e[1]-e[0])&&(e=e[1]):c=0,i)},i.lightness=function(r){return null==r?f:("array"===o(r)?(f=r,u=r[1]-r[0]):(f=[r,r],u=0),i)},i.scale=function(){return w.scale(i)},i.hue(e),i},deltaE:function(r,t,n,e,a){void 0===n&&(n=1),void 0===e&&(e=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*Xt)},o=function(r){return 2*Xt*r/360};r=new y(r),t=new y(t);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],s=Array.from(t.lab()),h=s[0],d=s[1],b=s[2],g=(c+h)/2,v=(Ft(Lt(i,2)+Lt(l,2))+Ft(Lt(d,2)+Lt(b,2)))/2,p=.5*(1-Ft(Lt(v,7)/(Lt(v,7)+Lt(25,7)))),m=i*(1+p),w=d*(1+p),k=Ft(Lt(m,2)+Lt(l,2)),M=Ft(Lt(w,2)+Lt(b,2)),N=(k+M)/2,_=f(Gt(l,m)),x=f(Gt(b,w)),A=_>=0?_:_+360,j=x>=0?x:x+360,E=Rt(A-j)>180?(A+j+360)/2:(A+j)/2,O=1-.17*Yt(o(E-30))+.24*Yt(o(2*E))+.32*Yt(o(3*E+6))-.2*Yt(o(4*E-63)),F=j-A;F=Rt(F)<=180?F:j<=A?F+360:F-360,F=2*Ft(k*M)*$t(o(F)/2);var L=h-c,P=M-k,B=1+.015*Lt(g-50,2)/Ft(20+Lt(g-50,2)),G=1+.045*N,R=1+.015*N*O,Y=30*qt(-Lt((E-275)/25,2)),$=-(2*Ft(Lt(N,7)/(Lt(N,7)+Lt(25,7))))*$t(2*o(Y)),q=Ft(Lt(L/(n*B),2)+Lt(P/(e*G),2)+Lt(F/(a*R),2)+$*(P/(e*G))*(F/(a*R)));return Bt(0,Pt(100,q))},distance:function(r,t,n){void 0===n&&(n="lab"),r=new y(r),t=new y(t);var e=r.get(n),a=t.get(n),f=0;for(var o in e){var u=(e[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)},input:m,interpolate:nt,limits:Ot,mix:nt,random:function(){for(var r="#",t=0;t<6;t++)r+="0123456789abcdef".charAt(Mt(16*Nt()));return new y(r,"hex")},scale:gt,scales:Ct,valid:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];try{return new(Function.prototype.bind.apply(y,[null].concat(r))),!0}catch(r){return!1}},cmyk:M,css:yr,gl:wr,hcg:Mr,hex:Er,hsi:Br,hsl:Gr,hsv:qr,lab:Xr,lch:Cr,hcl:Zr,num:Sr,rgb:Ir,temp:Vr,kelvin:Vr,temperature:Vr,oklab:Dr,oklch:Tr,getLabWhitePoint:j,setLabWhitePoint:A}),w})); +!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(r="undefined"!=typeof globalThis?globalThis:r||self).chroma=t()}(this,(function(){"use strict";var r=Math.min,t=Math.max;function e(e,n,a){return void 0===n&&(n=0),void 0===a&&(a=1),r(t(n,e),a)}function n(r){r._clipped=!1,r._unclipped=r.slice(0);for(var t=0;t<=3;t++)t<3?((r[t]<0||r[t]>255)&&(r._clipped=!0),r[t]=e(r[t],0,255)):3===t&&(r[t]=e(r[t],0,1));return r}for(var a={},f=0,o=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];f=3?Array.prototype.slice.call(r):"object"==c(r[0])&&t?t.split("").filter((function(t){return void 0!==r[0][t]})).map((function(t){return r[0][t]})):r[0].slice(0)}function l(r){if(r.length<2)return null;var t=r.length-1;return"string"==c(r[t])?r[t].toLowerCase():null}var s=Math.PI,h=Math.min,d=Math.max,b=function(r){return Math.round(100*r)/100},g=function(r){return Math.round(100*r)/100},v=2*s,p=s/3,m=s/180,y=180/s,w={format:{},autodetect:[]},k=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=this;if("object"===c(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=l(r),f=!1;if(!a){f=!0,w.sorted||(w.autodetect=w.autodetect.sort((function(r,t){return t.p-r.p})),w.sorted=!0);for(var o=0,u=w.autodetect;o4?r[4]:1;return 1===f?[0,0,0,o]:[e>=1?0:255*(1-e)*(1-f),n>=1?0:255*(1-n)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"cmyk"))&&4===r.length)return"cmyk"}});var x=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n,a=(r=i(r,"rgba"))[0],f=r[1],o=r[2],u=h(a/=255,f/=255,o/=255),c=d(a,f,o),l=(c+u)/2;return c===u?(e=0,n=Number.NaN):e=l<.5?(c-u)/(c+u):(c-u)/(2-c-u),a==c?n=(f-o)/(c-u):f==c?n=2+(o-a)/(c-u):o==c&&(n=4+(a-f)/(c-u)),(n*=60)<0&&(n+=360),r.length>3&&void 0!==r[3]?[n,e,l,r[3]]:[n,e,l]},A={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,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}},j=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(r){var t=j.get(String(r).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+r);A.labWhitePoint=r,A.Xn=t[0],A.Zn=t[1]}function O(){return A.labWhitePoint}var P=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgb"),n=e[0],a=e[1],f=e[2],o=e.slice(3),u=L(n,a,f),c=function(r,t,e){var n=A.Xn,a=A.Yn,f=A.Zn,o=A.kE,u=A.kK,c=r/n,i=t/a,l=e/f,s=c>o?Math.pow(c,1/3):(u*c+16)/116,h=i>o?Math.pow(i,1/3):(u*i+16)/116,d=l>o?Math.pow(l,1/3):(u*l+16)/116;return[116*h-16,500*(s-h),200*(h-d)]}(u[0],u[1],u[2]);return[c[0],c[1],c[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function F(r){var t=Math.sign(r);return((r=Math.abs(r))<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4))*t}var L=function(r,t,e){r=F(r/255),t=F(t/255),e=F(e/255);var n=A.MtxRGB2XYZ,a=A.MtxAdaptMa,f=A.MtxAdaptMaI,o=A.Xn,u=A.Yn,c=A.Zn,i=A.As,l=A.Bs,s=A.Cs,h=r*n.m00+t*n.m10+e*n.m20,d=r*n.m01+t*n.m11+e*n.m21,b=r*n.m02+t*n.m12+e*n.m22,g=o*a.m00+u*a.m10+c*a.m20,v=o*a.m01+u*a.m11+c*a.m21,p=o*a.m02+u*a.m12+c*a.m22,m=h*a.m00+d*a.m10+b*a.m20,y=h*a.m01+d*a.m11+b*a.m21,w=h*a.m02+d*a.m12+b*a.m22;return y*=v/l,w*=p/s,[h=(m*=g/i)*f.m00+y*f.m10+w*f.m20,d=m*f.m01+y*f.m11+w*f.m21,b=m*f.m02+y*f.m12+w*f.m22]},B=Math.sqrt,G=Math.atan2,R=Math.round,Y=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lab"),n=e[0],a=e[1],f=e[2],o=B(a*a+f*f),u=(G(f,a)*y+360)%360;return 0===R(1e4*o)&&(u=Number.NaN),[n,o,u]},$=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgb"),n=e[0],a=e[1],f=e[2],o=e.slice(3),u=P(n,a,f),c=u[0],l=u[1],s=u[2],h=Y(c,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function q(r,t){var e=r.length;Array.isArray(r[0])||(r=[r]),Array.isArray(t[0])||(t=t.map((function(r){return[r]})));var n=t[0].length,a=t[0].map((function(r,e){return t.map((function(r){return r[e]}))})),f=r.map((function(r){return a.map((function(t){return Array.isArray(r)?r.reduce((function(r,e,n){return r+e*(t[n]||0)}),0):t.reduce((function(t,e){return t+e*r}),0)}))}));return 1===e&&(f=f[0]),1===n?f.map((function(r){return r[0]})):f}var X=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n,a=i(r,"rgb"),f=a[0],o=a[1],u=a[2],c=a.slice(3),l=L(f,o,u);return(e=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],n=q([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],l),q(e,n.map((function(r){return Math.cbrt(r)})))).concat(c.length>0&&c[0]<1?[c[0]]:[])};var C=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgb"),n=e[0],a=e[1],f=e[2],o=e.slice(3),u=X(n,a,f),c=u[0],l=u[1],s=u[2],h=Y(c,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])},Z=Math.round,S=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgba"),n=l(r)||"rgb";if("hsl"===n.substr(0,3))return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"hsla"),n=l(r)||"lsa";return e[0]=b(e[0]||0)+"deg",e[1]=b(100*e[1])+"%",e[2]=b(100*e[2])+"%","hsla"===n||e.length>3&&e[3]<1?(e[3]="/ "+(e.length>3?e[3]:1),n="hsla"):e.length=3,n.substr(0,3)+"("+e.join(" ")+")"}(x(e),n);if("lab"===n.substr(0,3)){var a=O();E("d50");var f=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lab"),n=l(r)||"lab";return e[0]=b(e[0])+"%",e[1]=b(e[1]),e[2]=b(e[2]),"laba"===n||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,"lab("+e.join(" ")+")"}(P(e),n);return E(a),f}if("lch"===n.substr(0,3)){var o=O();E("d50");var u=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lch"),n=l(r)||"lab";return e[0]=b(e[0])+"%",e[1]=b(e[1]),e[2]=b(e[2])+"deg","lcha"===n||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,"lch("+e.join(" ")+")"}($(e),n);return E(o),u}return"oklab"===n.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lab");return e[0]=b(100*e[0])+"%",e[1]=g(e[1]),e[2]=g(e[2]),e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,"oklab("+e.join(" ")+")"}(X(e)):"oklch"===n.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lab");return e[0]=b(100*e[0])+"%",e[1]=g(e[1]),e[2]=b(e[2])+"deg",e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,"oklch("+e.join(" ")+")"}(C(e)):(e[0]=Z(e[0]),e[1]=Z(e[1]),e[2]=Z(e[2]),("rgba"===n||e.length>3&&e[3]<1)&&(e[3]="/ "+(e.length>3?e[3]:1),n="rgba"),n.substr(0,3)+"("+e.slice(0,"rgb"===n?3:4).join(" ")+")")},W=function(){for(var r,t=[],e=arguments.length;e--;)t[e]=arguments[e];var n,a,f,o=(t=i(t,"hsl"))[0],u=t[1],c=t[2];if(0===u)n=a=f=255*c;else{var l=[0,0,0],s=[0,0,0],h=c<.5?c*(1+u):c+u-c*u,d=2*c-h,b=o/360;l[0]=b+1/3,l[1]=b,l[2]=b-1/3;for(var g=0;g<3;g++)l[g]<0&&(l[g]+=1),l[g]>1&&(l[g]-=1),6*l[g]<1?s[g]=d+6*(h-d)*l[g]:2*l[g]<1?s[g]=h:3*l[g]<2?s[g]=d+(h-d)*(2/3-l[g])*6:s[g]=d;n=(r=[255*s[0],255*s[1],255*s[2]])[0],a=r[1],f=r[2]}return t.length>3?[n,a,f,t[3]]:[n,a,f,1]},I=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=(r=i(r,"lab"))[0],n=r[1],a=r[2],f=K(e,n,a),o=f[0],u=f[1],c=f[2],l=U(o,u,c);return[l[0],l[1],l[2],r.length>3?r[3]:1]},K=function(r,t,e){var n=A.kE,a=A.kK,f=A.kKE,o=A.Xn,u=A.Yn,c=A.Zn,i=(r+16)/116,l=.002*t+i,s=i-.005*e,h=l*l*l,d=s*s*s;return[(h>n?h:(116*l-16)/a)*o,(r>f?Math.pow((r+16)/116,3):r/a)*u,(d>n?d:(116*s-16)/a)*c]},z=function(r){var t=Math.sign(r);return((r=Math.abs(r))<=.0031308?12.92*r:1.055*Math.pow(r,1/2.4)-.055)*t},U=function(r,t,e){var n=A.MtxAdaptMa,a=A.MtxAdaptMaI,f=A.MtxXYZ2RGB,o=A.RefWhiteRGB,u=A.Xn,c=A.Yn,i=A.Zn,l=u*n.m00+c*n.m10+i*n.m20,s=u*n.m01+c*n.m11+i*n.m21,h=u*n.m02+c*n.m12+i*n.m22,d=o.X*n.m00+o.Y*n.m10+o.Z*n.m20,b=o.X*n.m01+o.Y*n.m11+o.Z*n.m21,g=o.X*n.m02+o.Y*n.m12+o.Z*n.m22,v=(r*n.m00+t*n.m10+e*n.m20)*(d/l),p=(r*n.m01+t*n.m11+e*n.m21)*(b/s),m=(r*n.m02+t*n.m12+e*n.m22)*(g/h),y=v*a.m00+p*a.m10+m*a.m20,w=v*a.m01+p*a.m11+m*a.m21,k=v*a.m02+p*a.m12+m*a.m22;return[255*z(y*f.m00+w*f.m10+k*f.m20),255*z(y*f.m01+w*f.m11+k*f.m21),255*z(y*f.m02+w*f.m12+k*f.m22)]},V=Math.sin,D=Math.cos,T=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"lch"),n=e[0],a=e[1],f=e[2];return isNaN(f)&&(f=0),[n,D(f*=m)*a,V(f)*a]},H=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=(r=i(r,"lch"))[0],n=r[1],a=r[2],f=T(e,n,a),o=f[0],u=f[1],c=f[2],l=I(o,u,c);return[l[0],l[1],l[2],r.length>3?r[3]:1]},J=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n,a=(r=i(r,"lab"))[0],f=r[1],o=r[2],u=r.slice(3),c=(e=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],n=q([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,f,o]),q(e,n.map((function(r){return Math.pow(r,3)})))),l=c[0],s=c[1],h=c[2],d=U(l,s,h);return[d[0],d[1],d[2]].concat(u.length>0&&u[0]<1?[u[0]]:[])};var Q=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=(r=i(r,"lch"))[0],n=r[1],a=r[2],f=r.slice(3),o=T(e,n,a),u=o[0],c=o[1],l=o[2],s=J(u,c,l);return[s[0],s[1],s[2]].concat(f.length>0&&f[0]<1?[f[0]]:[])},rr=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,tr=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,er=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,nr=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,ar=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,fr=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,or=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,ur=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,cr=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,ir=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,lr=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,sr=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,hr=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,dr=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,br=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,gr=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,vr=Math.round,pr=function(r){return r.map((function(r,t){return t<=2?e(vr(r),0,255):r}))},mr=function(r,t,e,n){return void 0===t&&(t=0),void 0===e&&(e=100),void 0===n&&(n=!1),"string"==typeof r&&r.endsWith("%")&&(r=parseFloat(r.substring(0,r.length-1))/100,r=n?t+.5*(r+1)*(e-t):t+r*(e-t)),+r},yr=function(r,t){return"none"===r?t:r},wr=function(r){var t;if(r=r.toLowerCase().trim(),w.format.named)try{return w.format.named(r)}catch(r){}if((t=r.match(rr))||(t=r.match(tr))){for(var e=t.slice(1,4),n=0;n<3;n++)e[n]=+e[n];return e[3]=1,e}if((t=r.match(er))||(t=r.match(nr))){for(var a=t.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if((t=r.match(ar))||(t=r.match(fr))){for(var o=t.slice(1,4),u=0;u<3;u++)o[u]=vr(2.55*o[u]);return o[3]=1,o}if((t=r.match(or))||(t=r.match(ur))){for(var c=t.slice(1,5),i=0;i<3;i++)c[i]=vr(2.55*c[i]);return c[3]=+c[3],c}if((t=r.match(cr))||(t=r.match(ir))){var l=t.slice(1,4);l[1]*=.01,l[2]*=.01;for(var s=W(l),h=0;h<3;h++)s[h]=vr(s[h]);return s[3]=1,s}if((t=r.match(lr))||(t=r.match(sr))){var d=t.slice(1,4);d[1]*=.01,d[2]*=.01;for(var b=W(d),g=0;g<3;g++)b[g]=vr(b[g]);return b[3]=+t[4],b}if(t=r.match(hr)){var v=t.slice(1,4);v[0]=mr(v[0],0,100),v[1]=mr(v[1],-125,125,!0),v[2]=mr(v[2],-125,125,!0);var p=O();E("d50");var m=pr(I(v));return E(p),m[3]=void 0!==t[4]?+t[4]:1,m}if(t=r.match(dr)){var y=t.slice(1,4);y[0]=mr(y[0],0,100),y[1]=mr(yr(y[1],0),0,150,!1),y[2]=+yr(y[2].replace("deg",""),0);var k=O();E("d50");var M=pr(H(y));return E(k),M[3]=void 0!==t[4]?+t[4]:1,M}if(t=r.match(br)){var N=t.slice(1,4);N[0]=mr(N[0],0,1),N[1]=mr(N[1],-.4,.4,!0),N[2]=mr(N[2],-.4,.4,!0);var _=pr(J(N));return _[3]=void 0!==t[4]?+t[4]:1,_}if(t=r.match(gr)){var x=t.slice(1,4);x[0]=mr(x[0],0,1),x[1]=mr(yr(x[1],0),0,.4,!1),x[2]=+yr(x[2].replace("deg",""),0);var A=pr(Q(x));return A[3]=void 0!==t[4]?+t[4]:1,A}};wr.test=function(r){return rr.test(r)||er.test(r)||ar.test(r)||or.test(r)||cr.test(r)||lr.test(r)||hr.test(r)||dr.test(r)||br.test(r)||gr.test(r)||tr.test(r)||nr.test(r)||fr.test(r)||ur.test(r)||ir.test(r)||sr.test(r)},k.prototype.css=function(r){return S(this._rgb,r)};var kr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["css"])))};M.css=kr,w.format.css=wr,w.autodetect.push({p:5,test:function(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];if(!t.length&&"string"===c(r)&&wr.test(r))return"css"}}),w.format.gl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgba");return e[0]*=255,e[1]*=255,e[2]*=255,e};var Mr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["gl"])))};M.gl=Mr,k.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var Nr=Math.floor;k.prototype.hcg=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n=i(r,"rgb"),a=n[0],f=n[1],o=n[2],u=h(a,f,o),c=d(a,f,o),l=c-u,s=100*l/255,b=u/(255-l)*100;return 0===l?e=Number.NaN:(a===c&&(e=(f-o)/l),f===c&&(e=2+(o-a)/l),o===c&&(e=4+(a-f)/l),(e*=60)<0&&(e+=360)),[e,s,b]}(this._rgb)};var _r=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hcg"])))};M.hcg=_r,w.format.hcg=function(){for(var r,t,e,n,a,f,o=[],u=arguments.length;u--;)o[u]=arguments[u];var c,l,s,h=(o=i(o,"hcg"))[0],d=o[1],b=o[2];b*=255;var g=255*d;if(0===d)c=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var v=Nr(h/=60),p=h-v,m=b*(1-d),y=m+g*(1-p),w=m+g*p,k=m+g;switch(v){case 0:c=(r=[k,w,m])[0],l=r[1],s=r[2];break;case 1:c=(t=[y,k,m])[0],l=t[1],s=t[2];break;case 2:c=(e=[m,k,w])[0],l=e[1],s=e[2];break;case 3:c=(n=[m,y,k])[0],l=n[1],s=n[2];break;case 4:c=(a=[w,m,k])[0],l=a[1],s=a[2];break;case 5:c=(f=[k,m,y])[0],l=f[1],s=f[2]}}return[c,l,s,o.length>3?o[3]:1]},w.autodetect.push({p:1,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"hcg"))&&3===r.length)return"hcg"}});var xr=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Ar=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,jr=function(r){if(r.match(xr)){4!==r.length&&7!==r.length||(r=r.substr(1)),3===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]);var t=parseInt(r,16);return[t>>16,t>>8&255,255&t,1]}if(r.match(Ar)){5!==r.length&&9!==r.length||(r=r.substr(1)),4===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]);var e=parseInt(r,16);return[e>>24&255,e>>16&255,e>>8&255,Math.round((255&e)/255*100)/100]}throw new Error("unknown hex color: "+r)},Er=Math.round,Or=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgba"),n=e[0],a=e[1],f=e[2],o=e[3],u=l(r)||"auto";void 0===o&&(o=1),"auto"===u&&(u=o<1?"rgba":"rgb");var c="000000"+((n=Er(n))<<16|(a=Er(a))<<8|(f=Er(f))).toString(16);c=c.substr(c.length-6);var s="0"+Er(255*o).toString(16);switch(s=s.substr(s.length-2),u.toLowerCase()){case"rgba":return"#"+c+s;case"argb":return"#"+s+c;default:return"#"+c}};k.prototype.hex=function(r){return Or(this._rgb,r)};var Pr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hex"])))};M.hex=Pr,w.format.hex=jr,w.autodetect.push({p:4,test:function(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];if(!t.length&&"string"===c(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var Fr=Math.cos,Lr=Math.min,Br=Math.sqrt,Gr=Math.acos;k.prototype.hsi=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n=i(r,"rgb"),a=n[0],f=n[1],o=n[2],u=Lr(a/=255,f/=255,o/=255),c=(a+f+o)/3,l=c>0?1-u/c:0;return 0===l?e=NaN:(e=(a-f+(a-o))/2,e/=Br((a-f)*(a-f)+(a-o)*(f-o)),e=Gr(e),o>f&&(e=v-e),e/=v),[360*e,l,c]}(this._rgb)};var Rr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hsi"])))};M.hsi=Rr,w.format.hsi=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,a,f,o=(r=i(r,"hsi"))[0],u=r[1],c=r[2];return isNaN(o)&&(o=0),isNaN(u)&&(u=0),o>360&&(o-=360),o<0&&(o+=360),(o/=360)<1/3?a=1-((f=(1-u)/3)+(n=(1+u*Fr(v*o)/Fr(p-v*o))/3)):o<2/3?f=1-((n=(1-u)/3)+(a=(1+u*Fr(v*(o-=1/3))/Fr(p-v*o))/3)):n=1-((a=(1-u)/3)+(f=(1+u*Fr(v*(o-=2/3))/Fr(p-v*o))/3)),[255*(n=e(c*n*3)),255*(a=e(c*a*3)),255*(f=e(c*f*3)),r.length>3?r[3]:1]},w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"hsi"))&&3===r.length)return"hsi"}}),k.prototype.hsl=function(){return x(this._rgb)};var Yr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hsl"])))};M.hsl=Yr,w.format.hsl=W,w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"hsl"))&&3===r.length)return"hsl"}});var $r=Math.floor,qr=Math.min,Xr=Math.max;k.prototype.hsv=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e,n,a,f=(r=i(r,"rgb"))[0],o=r[1],u=r[2],c=qr(f,o,u),l=Xr(f,o,u),s=l-c;return a=l/255,0===l?(e=Number.NaN,n=0):(n=s/l,f===l&&(e=(o-u)/s),o===l&&(e=2+(u-f)/s),u===l&&(e=4+(f-o)/s),(e*=60)<0&&(e+=360)),[e,n,a]}(this._rgb)};var Cr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hsv"])))};M.hsv=Cr,w.format.hsv=function(){for(var r,t,e,n,a,f,o=[],u=arguments.length;u--;)o[u]=arguments[u];var c,l,s,h=(o=i(o,"hsv"))[0],d=o[1],b=o[2];if(b*=255,0===d)c=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var g=$r(h/=60),v=h-g,p=b*(1-d),m=b*(1-d*v),y=b*(1-d*(1-v));switch(g){case 0:c=(r=[b,y,p])[0],l=r[1],s=r[2];break;case 1:c=(t=[m,b,p])[0],l=t[1],s=t[2];break;case 2:c=(e=[p,b,y])[0],l=e[1],s=e[2];break;case 3:c=(n=[p,m,b])[0],l=n[1],s=n[2];break;case 4:c=(a=[y,p,b])[0],l=a[1],s=a[2];break;case 5:c=(f=[b,p,m])[0],l=f[1],s=f[2]}}return[c,l,s,o.length>3?o[3]:1]},w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"hsv"))&&3===r.length)return"hsv"}}),k.prototype.lab=function(){return P(this._rgb)};var Zr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["lab"])))};Object.assign(M,{lab:Zr,getLabWhitePoint:O,setLabWhitePoint:E}),w.format.lab=I,w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"lab"))&&3===r.length)return"lab"}});k.prototype.lch=function(){return $(this._rgb)},k.prototype.hcl=function(){return $(this._rgb).reverse()};var Sr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["lch"])))},Wr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["hcl"])))};Object.assign(M,{lch:Sr,hcl:Wr}),w.format.lch=H,w.format.hcl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"hcl").reverse();return H.apply(void 0,e)},["lch","hcl"].forEach((function(r){return w.autodetect.push({p:2,test:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if("array"===c(t=i(t,r))&&3===t.length)return r}})}));k.prototype.num=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgb");return(e[0]<<16)+(e[1]<<8)+e[2]}(this._rgb)};var Ir=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["num"])))};Object.assign(M,{num:Ir}),w.format.num=function(r){if("number"==c(r)&&r>=0&&r<=16777215)return[r>>16,r>>8&255,255&r,1];throw new Error("unknown num color: "+r)},w.autodetect.push({p:5,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if(1===r.length&&"number"===c(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var Kr=Math.round;k.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Kr)},k.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(t,e){return e<3?!1===r?t:Kr(t):t}))};var zr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["rgb"])))};Object.assign(M,{rgb:zr}),w.format.rgb=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var e=i(r,"rgba");return void 0===e[3]&&(e[3]=1),e},w.autodetect.push({p:3,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"rgba"))&&(3===r.length||4===r.length&&"number"==c(r[3])&&r[3]>=0&&r[3]<=1))return"rgb"}});var Ur=Math.log,Vr=function(r){var t,e,n,a=r/100;return a<66?(t=255,e=a<6?0:-155.25485562709179-.44596950469579133*(e=a-2)+104.49216199393888*Ur(e),n=a<20?0:.8274096064007395*(n=a-10)-254.76935184120902+115.67994401066147*Ur(n)):(t=351.97690566805693+.114206453784165*(t=a-55)-40.25366309332127*Ur(t),e=325.4494125711974+.07943456536662342*(e=a-50)-28.0852963507957*Ur(e),n=255),[t,e,n,1]},Dr=Math.round;k.prototype.temp=k.prototype.kelvin=k.prototype.temperature=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];for(var e,n=i(r,"rgb"),a=n[0],f=n[2],o=1e3,u=4e4;u-o>.4;){var c=Vr(e=.5*(u+o));c[2]/c[0]>=f/a?u=e:o=e}return Dr(e)}(this._rgb)};var Tr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["temp"])))};Object.assign(M,{temp:Tr,kelvin:Tr,temperature:Tr}),w.format.temp=w.format.kelvin=w.format.temperature=Vr,k.prototype.oklab=function(){return X(this._rgb)};var Hr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["oklab"])))};Object.assign(M,{oklab:Hr}),w.format.oklab=J,w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"oklab"))&&3===r.length)return"oklab"}}),k.prototype.oklch=function(){return C(this._rgb)};var Jr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(k,[null].concat(r,["oklch"])))};Object.assign(M,{oklch:Jr}),w.format.oklch=Q,w.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===c(r=i(r,"oklch"))&&3===r.length)return"oklch"}});var Qr={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"};k.prototype.name=function(){for(var r=Or(this._rgb,"rgb"),t=0,e=Object.keys(Qr);t0;)t[e]=arguments[e+1];if(!t.length&&"string"===c(r)&&Qr[r.toLowerCase()])return"named"}}),k.prototype.alpha=function(r,t){return void 0===t&&(t=!1),void 0!==r&&"number"===c(r)?t?(this._rgb[3]=r,this):new k([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},k.prototype.clipped=function(){return this._rgb._clipped||!1},k.prototype.darken=function(r){void 0===r&&(r=1);var t=this.lab();return t[0]-=A.Kn*r,new k(t,"lab").alpha(this.alpha(),!0)},k.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},k.prototype.darker=k.prototype.darken,k.prototype.brighter=k.prototype.brighten,k.prototype.get=function(r){var t=r.split("."),e=t[0],n=t[1],a=this[e]();if(n){var f=e.indexOf(n)-("ok"===e.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+n+" in mode "+e)}return a};var rt=Math.pow;k.prototype.luminance=function(r,t){if(void 0===t&&(t="rgb"),void 0!==r&&"number"===c(r)){if(0===r)return new k([0,0,0,this._rgb[3]],"rgb");if(1===r)return new k([255,255,255,this._rgb[3]],"rgb");var e=this.luminance(),n=20,a=function(e,f){var o=e.interpolate(f,.5,t),u=o.luminance();return Math.abs(r-u)<1e-7||!n--?o:u>r?a(e,o):a(o,f)},f=(e>r?a(new k([0,0,0]),this):a(this,new k([255,255,255]))).rgb();return new k(f.concat([this._rgb[3]]))}return tt.apply(void 0,this._rgb.slice(0,3))};var tt=function(r,t,e){return.2126*(r=et(r))+.7152*(t=et(t))+.0722*(e=et(e))},et=function(r){return(r/=255)<=.03928?r/12.92:rt((r+.055)/1.055,2.4)},nt={};function at(r,t,e){void 0===e&&(e=.5);for(var n=[],a=arguments.length-3;a-- >0;)n[a]=arguments[a+3];var f=n[0]||"lrgb";if(nt[f]||n.length||(f=Object.keys(nt)[0]),!nt[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==c(r)&&(r=new k(r)),"object"!==c(t)&&(t=new k(t)),nt[f](r,t,e).alpha(r.alpha()+e*(t.alpha()-r.alpha()))}k.prototype.mix=k.prototype.interpolate=function(r,t){void 0===t&&(t=.5);for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return at.apply(void 0,[this,r,t].concat(e))},k.prototype.premultiply=function(r){void 0===r&&(r=!1);var t=this._rgb,e=t[3];return r?(this._rgb=[t[0]*e,t[1]*e,t[2]*e,e],this):new k([t[0]*e,t[1]*e,t[2]*e,e],"rgb")},k.prototype.saturate=function(r){void 0===r&&(r=1);var t=this.lch();return t[1]+=A.Kn*r,t[1]<0&&(t[1]=0),new k(t,"lch").alpha(this.alpha(),!0)},k.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},k.prototype.set=function(r,t,e){void 0===e&&(e=!1);var n=r.split("."),a=n[0],f=n[1],o=this[a]();if(f){var u=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(u>-1){if("string"==c(t))switch(t.charAt(0)){case"+":case"-":o[u]+=+t;break;case"*":o[u]*=+t.substr(1);break;case"/":o[u]/=+t.substr(1);break;default:o[u]=+t}else{if("number"!==c(t))throw new Error("unsupported value for Color.set");o[u]=t}var i=new k(o,a);return e?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return o},k.prototype.tint=function(r){void 0===r&&(r=.5);for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return at.apply(void 0,[this,"white",r].concat(t))},k.prototype.shade=function(r){void 0===r&&(r=.5);for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return at.apply(void 0,[this,"black",r].concat(t))};nt.rgb=function(r,t,e){var n=r._rgb,a=t._rgb;return new k(n[0]+e*(a[0]-n[0]),n[1]+e*(a[1]-n[1]),n[2]+e*(a[2]-n[2]),"rgb")};var ft=Math.sqrt,ot=Math.pow;nt.lrgb=function(r,t,e){var n=r._rgb,a=n[0],f=n[1],o=n[2],u=t._rgb,c=u[0],i=u[1],l=u[2];return new k(ft(ot(a,2)*(1-e)+ot(c,2)*e),ft(ot(f,2)*(1-e)+ot(i,2)*e),ft(ot(o,2)*(1-e)+ot(l,2)*e),"rgb")};function ut(r,t,e,n){var a,f,o,u,c,i,l,s,h,d,b,g,v;return"hsl"===n?(o=r.hsl(),u=t.hsl()):"hsv"===n?(o=r.hsv(),u=t.hsv()):"hcg"===n?(o=r.hcg(),u=t.hcg()):"hsi"===n?(o=r.hsi(),u=t.hsi()):"lch"===n||"hcl"===n?(n="hcl",o=r.hcl(),u=t.hcl()):"oklch"===n&&(o=r.oklch().reverse(),u=t.oklch().reverse()),"h"!==n.substr(0,1)&&"oklch"!==n||(c=(a=o)[0],l=a[1],h=a[2],i=(f=u)[0],s=f[1],d=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=h&&0!=h||"hsv"==n||(b=s)):(g=c,1!=d&&0!=d||"hsv"==n||(b=l)):g=c+e*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+e*(s-l)),v=h+e*(d-h),new k("oklch"===n?[v,b,g]:[g,b,v],n)}nt.lab=function(r,t,e){var n=r.lab(),a=t.lab();return new k(n[0]+e*(a[0]-n[0]),n[1]+e*(a[1]-n[1]),n[2]+e*(a[2]-n[2]),"lab")};var ct=function(r,t,e){return ut(r,t,e,"lch")};nt.lch=ct,nt.hcl=ct;nt.num=function(r,t,e){var n=r.num(),a=t.num();return new k(n+e*(a-n),"num")};nt.hcg=function(r,t,e){return ut(r,t,e,"hcg")};nt.hsi=function(r,t,e){return ut(r,t,e,"hsi")};nt.hsl=function(r,t,e){return ut(r,t,e,"hsl")};nt.hsv=function(r,t,e){return ut(r,t,e,"hsv")};nt.oklab=function(r,t,e){var n=r.oklab(),a=t.oklab();return new k(n[0]+e*(a[0]-n[0]),n[1]+e*(a[1]-n[1]),n[2]+e*(a[2]-n[2]),"oklab")};nt.oklch=function(r,t,e){return ut(r,t,e,"oklch")};var it=Math.pow,lt=Math.sqrt,st=Math.PI,ht=Math.cos,dt=Math.sin,bt=Math.atan2;var gt=function(r,t){for(var e=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new k(n(a))},vt=Math.pow;function pt(r){var t="rgb",n=M("#ccc"),a=0,f=[0,1],o=[],u=[0,0],i=!1,l=[],s=!1,h=0,d=1,b=!1,g={},v=!0,p=1,m=function(r){if((r=r||["#fff","#000"])&&"string"===c(r)&&M.brewer&&M.brewer[r.toLowerCase()]&&(r=M.brewer[r.toLowerCase()]),"array"===c(r)){1===r.length&&(r=[r[0],r[0]]),r=r.slice(0);for(var t=0;t2){var b=function(r){if(null!=i){for(var t=i.length-1,e=0;e=i[e];)e++;return e-1}return 0}(r);s=b/(i.length-2)}else s=d!==h?(r-h)/(d-h):1;s=w(s),a||(s=y(s)),1!==p&&(s=vt(s,p)),s=e(s=u[0]+s*(1-u[0]-u[1]),0,1);var m=Math.floor(1e4*s);if(v&&g[m])f=g[m];else{if("array"===c(l))for(var k=0;k=N&&k===o.length-1){f=l[k];break}if(s>N&&s2){var c=r.map((function(t,e){return e/(r.length-1)})),i=r.map((function(r){return(r-h)/(d-h)}));i.every((function(r,t){return c[t]===r}))||(w=function(r){if(r<=0||r>=1)return r;for(var t=0;r>=i[t+1];)t++;var e=(r-i[t])/(i[t+1]-i[t]);return c[t]+e*(c[t+1]-c[t])})}}return f=[h,d],_},_.mode=function(r){return arguments.length?(t=r,N(),_):t},_.range=function(r,t){return m(r),_},_.out=function(r){return s=r,_},_.spread=function(r){return arguments.length?(a=r,_):a},_.correctLightness=function(r){return null==r&&(r=!0),b=r,N(),y=b?function(r){for(var t=k(0,!0).lab()[0],e=k(1,!0).lab()[0],n=t>e,a=k(r,!0).lab()[0],f=t+(e-t)*r,o=a-f,u=0,c=1,i=20;Math.abs(o)>.01&&i-- >0;)n&&(o*=-1),o<0?(u=r,r+=.5*(c-r)):(c=r,r+=.5*(u-r)),a=k(r,!0).lab()[0],o=a-f;return r}:function(r){return r},_},_.padding=function(r){return null!=r?("number"===c(r)&&(r=[r,r]),u=r,_):u},_.colors=function(t,e){arguments.length<2&&(e="hex");var n=[];if(0===arguments.length)n=l.slice(0);else if(1===t)n=[_(.5)];else if(t>1){var a=f[0],o=f[1]-a;n=function(r,t){for(var e=[],n=ra;n?f++:f--)e.push(f);return e}(0,t).map((function(r){return _(a+r/(t-1)*o)}))}else{r=[];var u=[];if(i&&i.length>2)for(var c=1,s=i.length,h=1<=s;h?cs;h?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;n=u.map((function(r){return _(r)}))}return M[e]&&(n=n.map((function(r){return r[e]()}))),n},_.cache=function(r){return null!=r?(v=r,_):v},_.gamma=function(r){return null!=r?(p=r,_):p},_.nodata=function(r){return null!=r?(n=M(r),_):n},_}var mt=function(r,t,e){if(!mt[e])throw new Error("unknown blend mode "+e);return mt[e](r,t)},yt=function(r){return function(t,e){var n=M(e).rgb(),a=M(t).rgb();return M.rgb(r(n,a))}},wt=function(r){return function(t,e){var n=[];return n[0]=r(t[0],e[0]),n[1]=r(t[1],e[1]),n[2]=r(t[2],e[2]),n}};mt.normal=yt(wt((function(r){return r}))),mt.multiply=yt(wt((function(r,t){return r*t/255}))),mt.screen=yt(wt((function(r,t){return 255*(1-(1-r/255)*(1-t/255))}))),mt.overlay=yt(wt((function(r,t){return t<128?2*r*t/255:255*(1-2*(1-r/255)*(1-t/255))}))),mt.darken=yt(wt((function(r,t){return r>t?t:r}))),mt.lighten=yt(wt((function(r,t){return r>t?r:t}))),mt.dodge=yt(wt((function(r,t){return 255===r||(r=t/255*255/(1-r/255))>255?255:r}))),mt.burn=yt(wt((function(r,t){return 255*(1-(1-t/255)/(r/255))})));var kt=Math.pow,Mt=Math.sin,Nt=Math.cos;var _t=Math.floor,xt=Math.random;var At=Math.log,jt=Math.pow,Et=Math.floor,Ot=Math.abs;function Pt(r,t){void 0===t&&(t=null);var e={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===c(r)&&(r=Object.values(r)),r.forEach((function(r){t&&"object"===c(r)&&(r=r[t]),null==r||isNaN(r)||(e.values.push(r),e.sum+=r,re.max&&(e.max=r),e.count+=1)})),e.domain=[e.min,e.max],e.limits=function(r,t){return Ft(e,r,t)},e}function Ft(r,t,e){void 0===t&&(t="equal"),void 0===e&&(e=7),"array"==c(r)&&(r=Pt(r));var n=r.min,a=r.max,f=r.values.sort((function(r,t){return r-t}));if(1===e)return[n,a];var o=[];if("c"===t.substr(0,1)&&(o.push(n),o.push(a)),"e"===t.substr(0,1)){o.push(n);for(var u=1;u 0");var i=Math.LOG10E*At(n),l=Math.LOG10E*At(a);o.push(n);for(var s=1;s200&&(w=!1)}for(var Y={},$=0;$=360;)b-=360;o[d]=b}else o[d]=o[d]/u[d];return h/=n,new k(o,t).alpha(h>.99999?1:h,!0)},bezier:function(r){var t=function(r){var t,e,n,a,f,o,u;if(2===(r=r.map((function(r){return new k(r)}))).length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],a=function(r){var t=[0,1,2].map((function(t){return f[t]+r*(o[t]-f[t])}));return new k(t,"lab")};else if(3===r.length)e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],u=e[2],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*f[t]+2*(1-r)*r*o[t]+r*r*u[t]}));return new k(t,"lab")};else if(4===r.length){var c;n=r.map((function(r){return r.lab()})),f=n[0],o=n[1],u=n[2],c=n[3],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*(1-r)*f[t]+3*(1-r)*(1-r)*r*o[t]+3*(1-r)*r*r*u[t]+r*r*r*c[t]}));return new k(t,"lab")}}else{if(!(r.length>=5))throw new RangeError("No point in running bezier with only one color.");var i,l,s;i=r.map((function(r){return r.lab()})),s=r.length-1,l=function(r){for(var t=[1,1],e=1;en?(e+.05)/(n+.05):(n+.05)/(e+.05)},cubehelix:function(r,t,e,a,f){void 0===r&&(r=300),void 0===t&&(t=-1.5),void 0===e&&(e=1),void 0===a&&(a=1),void 0===f&&(f=[0,1]);var o,u=0;"array"===c(f)?o=f[1]-f[0]:(o=0,f=[f,f]);var i=function(c){var i=v*((r+120)/360+t*c),l=kt(f[0]+o*c,a),s=(0!==u?e[0]+c*u:e)*l*(1-l)/2,h=Nt(i),d=Mt(i);return M(n([255*(l+s*(-.14861*h+1.78277*d)),255*(l+s*(-.29227*h-.90649*d)),255*(l+s*(1.97294*h)),1]))};return i.start=function(t){return null==t?r:(r=t,i)},i.rotations=function(r){return null==r?t:(t=r,i)},i.gamma=function(r){return null==r?a:(a=r,i)},i.hue=function(r){return null==r?e:("array"===c(e=r)?0===(u=e[1]-e[0])&&(e=e[1]):u=0,i)},i.lightness=function(r){return null==r?f:("array"===c(r)?(f=r,o=r[1]-r[0]):(f=[r,r],o=0),i)},i.scale=function(){return M.scale(i)},i.hue(e),i},deltaE:function(r,t,e,n,a){void 0===e&&(e=1),void 0===n&&(n=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*Zt)},o=function(r){return 2*Zt*r/360};r=new k(r),t=new k(t);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],s=Array.from(t.lab()),h=s[0],d=s[1],b=s[2],g=(c+h)/2,v=(Lt(Bt(i,2)+Bt(l,2))+Lt(Bt(d,2)+Bt(b,2)))/2,p=.5*(1-Lt(Bt(v,7)/(Bt(v,7)+Bt(25,7)))),m=i*(1+p),y=d*(1+p),w=Lt(Bt(m,2)+Bt(l,2)),M=Lt(Bt(y,2)+Bt(b,2)),N=(w+M)/2,_=f(Yt(l,m)),x=f(Yt(b,y)),A=_>=0?_:_+360,j=x>=0?x:x+360,E=$t(A-j)>180?(A+j+360)/2:(A+j)/2,O=1-.17*qt(o(E-30))+.24*qt(o(2*E))+.32*qt(o(3*E+6))-.2*qt(o(4*E-63)),P=j-A;P=$t(P)<=180?P:j<=A?P+360:P-360,P=2*Lt(w*M)*Xt(o(P)/2);var F=h-c,L=M-w,B=1+.015*Bt(g-50,2)/Lt(20+Bt(g-50,2)),G=1+.045*N,R=1+.015*N*O,Y=30*Ct(-Bt((E-275)/25,2)),$=-(2*Lt(Bt(N,7)/(Bt(N,7)+Bt(25,7))))*Xt(2*o(Y)),q=Lt(Bt(F/(e*B),2)+Bt(L/(n*G),2)+Bt(P/(a*R),2)+$*(L/(n*G))*(P/(a*R)));return Rt(0,Gt(100,q))},distance:function(r,t,e){void 0===e&&(e="lab"),r=new k(r),t=new k(t);var n=r.get(e),a=t.get(e),f=0;for(var o in n){var u=(n[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)},input:w,interpolate:at,limits:Ft,mix:at,random:function(){for(var r="#",t=0;t<6;t++)r+="0123456789abcdef".charAt(_t(16*xt()));return new k(r,"hex")},scale:pt,scales:St,valid:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];try{return new(Function.prototype.bind.apply(k,[null].concat(r))),!0}catch(r){return!1}},cmyk:_,css:kr,gl:Mr,hcg:_r,hex:Pr,hsi:Rr,hsl:Yr,hsv:Cr,lab:Zr,lch:Sr,hcl:Wr,num:Ir,rgb:zr,temp:Tr,kelvin:Tr,temperature:Tr,oklab:Hr,oklch:Jr,getLabWhitePoint:O,setLabWhitePoint:E}),M})); diff --git a/docs/src/index.md b/docs/src/index.md index 82655771..12a1c9a7 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -378,12 +378,41 @@ chroma.deltaE('#000000', '#ffffff'); ### chroma.brewer -chroma.brewer is an map of [ColorBrewer scales](http://colorbrewer2.org/) that are included in chroma.js for convenience. chroma.scale uses the colors to construct. +chroma.brewer is an map of [ColorBrewer palettes](http://colorbrewer2.org/) that are included in chroma.js for convenience. chroma.scale uses the colors to construct. ```js chroma.brewer.OrRd ``` +Note that chroma.js only includes the 9-step versions of the palettes (11 steps for the diverging palettes). So, for instance, if you use chroma.js to construct a 5-color palette, they will be different from the "official" 5-color palettes in ColorBrewer (which have lower contrast). + +```js +chroma.scale('RdBu').colors(5); +// offical 5-color RdBu: +['#ca0020', '#f4a582', '#f7f7f7', '#92c5de', '#0571b0'] +``` + +One way to compensate for this would be to "slice off" the extreme colors: + +```js +chroma + .scale(chroma.brewer.RdBu.slice(1,-1)) + .colors(5); +``` + +Of course you can also just construct the scale from the official 5-step colors that you can copy and paste from [colorbrewer2.org](https://colorbrewer2.org/#type=diverging&scheme=RdBu&n=5): + +```js +chroma.scale(['#ca0020', '#f4a582', '#f7f7f7', '#92c5de', '#0571b0']) +``` + +You can access a list of all available palettes via `Object.keys(chroma.brewer)`: + +```js +Object.keys(chroma.brewer) +// ['OrRd', 'PuBu', 'BuPu', 'Oranges', 'BuGn', 'YlOrBr', 'YlGn', 'Reds', 'RdPu', 'Greens', 'YlGnBu', 'Purples', 'GnBu', 'Greys', 'YlOrRd', 'PuRd', 'Blues', 'PuBuGn', 'Viridis', 'Spectral', 'RdYlGn', 'RdBu', 'PiYG', 'PRGn', 'RdYlBu', 'BrBG', 'RdGy', 'PuOr', 'Set2', 'Accent', 'Set1', 'Set3', 'Dark2', 'Paired', 'Pastel2', 'Pastel1'] +``` + ### chroma.limits #### (data, mode, n) diff --git a/src/colors/colorbrewer.js b/src/colors/colorbrewer.js index ba62998c..eaeb9e1f 100644 --- a/src/colors/colorbrewer.js +++ b/src/colors/colorbrewer.js @@ -59,9 +59,23 @@ const colorbrewer = { Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2'] }; -// add lowercase aliases for case-insensitive matches -for (let key of Object.keys(colorbrewer)) { - colorbrewer[key.toLowerCase()] = colorbrewer[key]; -} +const colorbrewerTypes = Object.keys(colorbrewer); +const typeMap = new Map(colorbrewerTypes.map((key) => [key.toLowerCase(), key])); -export default colorbrewer; +// use Proxy to allow case-insensitive access to palettes +const colorbrewerProxy = + typeof Proxy === 'function' + ? new Proxy(colorbrewer, { + get(target, prop) { + const lower = prop.toLowerCase(); + if (typeMap.has(lower)) { + return target[typeMap.get(lower)]; + } + }, + getOwnPropertyNames() { + return Object.getOwnPropertyNames(colorbrewerTypes); + } + }) + : colorbrewer; + +export default colorbrewerProxy; diff --git a/src/utils/limit.js b/src/utils/limit.js index 2c7550bc..1d9b5314 100644 --- a/src/utils/limit.js +++ b/src/utils/limit.js @@ -1,4 +1,4 @@ -import { min, max } from './index.js'; +const { min, max } = Math; export default (x, low = 0, high = 1) => { return min(max(low, x), high); diff --git a/test/colorbrewer.test.js b/test/colorbrewer.test.js new file mode 100644 index 00000000..6f1fcb6e --- /dev/null +++ b/test/colorbrewer.test.js @@ -0,0 +1,24 @@ +import { describe, it, expect } from 'vitest'; +import chroma from 'chroma-js'; + +describe('ColorBrewer palettes', () => { + it('should have all palettes', () => { + expect(chroma.brewer).toBeDefined(); + expect(Object.keys(chroma.brewer).length).toBe(36); + }); + + it('brewer keys are camel-cased', () => { + expect(Object.keys(chroma.brewer)[0]).toBe('OrRd'); + expect(Object.keys(chroma.brewer)[1]).toBe('PuBu'); + }); + + it('supports case-insensitive access to palettes', () => { + expect(chroma.brewer.RdYlBu).toBeDefined(); + expect(chroma.brewer.rdylbu).toBeDefined(); + expect(chroma.brewer.RdylBU).toBeDefined(); + }); + + it('non existing palettes are still undefined', () => { + expect(chroma.brewer.notHere).toBeUndefined(); + }); +}); diff --git a/test/scales.test.js b/test/scales.test.js index d8d9e2df..80338913 100644 --- a/test/scales.test.js +++ b/test/scales.test.js @@ -126,6 +126,10 @@ describe('Some tests for scale()', () => { it('ends black', () => { expect(f(100).hex()).toBe('#006837'); }); + + it('returns domain', () => { + expect(f.domain()).toEqual([0, 100]); + }); }); describe('colorbrewer scale - lowercase', () => {