From 43847f52d87c452937210698baaba6e4429b809a Mon Sep 17 00:00:00 2001 From: Gregor Aisch Date: Sat, 17 Aug 2024 11:42:44 +0000 Subject: [PATCH] chore: fix UMD build (#349) * 2.6.1-0 * create separate index files for ES6 + UMD bundles --- dist/chroma-light.cjs | 47 +++++++---- dist/chroma-light.min.cjs | 2 +- dist/chroma.cjs | 75 +++++++++++------ dist/chroma.min.cjs | 2 +- index.js | 36 ++++----- index.umd.js | 117 +++++++++++++++++++++++++++ index-light.js => index.umd.light.js | 23 +++--- package.json | 6 +- pnpm-lock.yaml | 9 --- rollup.config.js | 6 +- src/Color.js | 2 + src/io/cmyk/index.js | 5 +- src/io/css/css2rgb.js | 17 ++++ src/io/css/index.js | 5 +- src/io/gl/index.js | 5 +- src/io/hcg/index.js | 5 +- src/io/hex/index.js | 7 +- src/io/hsi/index.js | 5 +- src/io/hsl/index.js | 5 +- src/io/hsv/index.js | 5 +- src/io/lab/index.js | 7 +- src/io/lch/index.js | 8 +- src/io/num/index.js | 6 +- src/io/oklab/index.js | 7 +- src/io/oklch/index.js | 7 +- src/io/rgb/index.js | 5 +- src/io/temp/index.js | 8 +- src/version.js | 2 +- test/io/css2rgb.test.js | 1 + test/io/rgb2css.test.js | 2 +- 30 files changed, 325 insertions(+), 112 deletions(-) create mode 100644 index.umd.js rename index-light.js => index.umd.light.js (66%) diff --git a/dist/chroma-light.cjs b/dist/chroma-light.cjs index cafb3000..497620d7 100644 --- a/dist/chroma-light.cjs +++ b/dist/chroma-light.cjs @@ -56,10 +56,10 @@ */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory()); -})(this, (function () { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.chroma = {})); +})(this, (function (exports) { 'use strict'; function limit (x, low, high) { if ( high === void 0 ) high = 1; @@ -183,16 +183,15 @@ }; // this gets updated automatically - var version = '2.6.0'; + var version = '2.6.1-0'; var chroma = function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; - return new (Function.prototype.bind.apply( chroma.Color, [ null ].concat( args) )); + return new (Function.prototype.bind.apply( Color, [ null ].concat( args) )); }; - chroma.Color = Color; chroma.version = version; var rnd = function (a) { return Math.round(a * 100) / 100; }; @@ -270,7 +269,7 @@ return [h, s, l]; }; - var round$4 = Math.round; + var round$3 = Math.round; /* * supported arguments: @@ -289,9 +288,9 @@ if (mode.substr(0, 3) == 'hsl') { return hsl2css(rgb2hsl(rgba), mode); } - rgba[0] = round$4(rgba[0]); - rgba[1] = round$4(rgba[1]); - rgba[2] = round$4(rgba[2]); + rgba[0] = round$3(rgba[0]); + rgba[1] = round$3(rgba[1]); + rgba[2] = round$3(rgba[2]); if (mode === 'rgba' || (rgba.length > 3 && rgba[3] < 1)) { rgba[3] = rgba.length > 3 ? rgba[3] : 1; mode = 'rgba'; @@ -299,8 +298,6 @@ return (mode + "(" + (rgba.slice(0, mode === 'rgb' ? 3 : 4).join(',')) + ")"); }; - var round$3 = Math.round; - var hsl2rgb = function () { var assign; @@ -330,7 +327,7 @@ else if (3 * t3[i] < 2) { c[i] = t1 + (t2 - t1) * (2 / 3 - t3[i]) * 6; } else { c[i] = t1; } } - (assign = [round$3(c[0] * 255), round$3(c[1] * 255), round$3(c[2] * 255)], r = assign[0], g = assign[1], b = assign[2]); + (assign = [c[0] * 255, c[1] * 255, c[2] * 255], r = assign[0], g = assign[1], b = assign[2]); } if (args.length > 3) { // keep alpha channel @@ -409,6 +406,9 @@ hsl[1] *= 0.01; hsl[2] *= 0.01; var rgb$4 = hsl2rgb(hsl); + for (var i$4 = 0; i$4 < 3; i$4++) { + rgb$4[i$4] = round$2(rgb$4[i$4]); + } rgb$4[3] = 1; return rgb$4; } @@ -419,6 +419,9 @@ hsl$1[1] *= 0.01; hsl$1[2] *= 0.01; var rgb$5 = hsl2rgb(hsl$1); + for (var i$5 = 0; i$5 < 3; i$5++) { + rgb$5[i$5] = round$2(rgb$5[i$5]); + } rgb$5[3] = +m[4]; // default alpha = 1 return rgb$5; } @@ -1076,9 +1079,19 @@ } } - chroma.mix = chroma.interpolate = mix; - chroma.valid = valid; + Object.assign(chroma, { + Color: Color, + valid: valid, + mix: mix, + interpolate: mix + }); + + exports.Color = Color; + exports.default = chroma; + exports.interpolate = mix; + exports.mix = mix; + exports.valid = valid; - return chroma; + Object.defineProperty(exports, '__esModule', { value: true }); })); diff --git a/dist/chroma-light.min.cjs b/dist/chroma-light.min.cjs index 90bed88d..131d0606 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(s(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"==a(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0]}function u(t){if(t.length<2)return null;var r=t.length-1;return"string"==a(t[r])?t[r].toLowerCase():null}var l=Math.min,s=Math.max,c={format:{},autodetect:[]},h=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=this;if("object"===a(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var o=u(r),i=!1;if(!o){i=!0,c.sorted||(c.autodetect=c.autodetect.sort((function(t,r){return r.p-t.p})),c.sorted=!0);for(var l=0,s=c.autodetect;l255)&&(r._clipped=!0),r[n]=t(r[n],0,255)):3===n&&(r[n]=t(r[n],0,1));return r}(f),3===e._rgb.length&&e._rgb.push(1)};h.prototype.toString=function(){return"function"==a(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var f=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f.Color,[null].concat(t)))};f.Color=h,f.version="2.6.0";var p=function(t){return Math.round(100*t)/100},g=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,o=(t=i(t,"rgba"))[0],a=t[1],u=t[2],c=l(o/=255,a/=255,u/=255),h=s(o,a,u),f=(h+c)/2;return h===c?(n=0,e=Number.NaN):n=f<.5?(h-c)/(h+c):(h-c)/(2-h-c),o==h?e=(a-u)/(h-c):a==h?e=2+(u-o)/(h-c):u==h&&(e=4+(o-a)/(h-c)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,f,t[3]]:[e,n,f]},b=Math.round,d=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=u(t)||"rgb";return"hsl"==e.substr(0,3)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"hsla"),e=u(t)||"lsa";return n[0]=p(n[0]||0),n[1]=p(100*n[1])+"%",n[2]=p(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+"("+n.join(",")+")"}(g(n),e):(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+"("+n.slice(0,"rgb"===e?3:4).join(",")+")")},v=Math.round,y=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,o,a,u=(r=i(r,"hsl"))[0],l=r[1],s=r[2];if(0===l)e=o=a=255*s;else{var c=[0,0,0],h=[0,0,0],f=s<.5?s*(1+l):s+l-s*l,p=2*s-f,g=u/360;c[0]=g+1/3,c[1]=g,c[2]=g-1/3;for(var b=0;b<3;b++)c[b]<0&&(c[b]+=1),c[b]>1&&(c[b]-=1),6*c[b]<1?h[b]=p+6*(f-p)*c[b]:2*c[b]<1?h[b]=f:3*c[b]<2?h[b]=p+(f-p)*(2/3-c[b])*6:h[b]=p;e=(t=[v(255*h[0]),v(255*h[1]),v(255*h[2])])[0],o=t[1],a=t[2]}return r.length>3?[e,o,a,r[3]]:[e,o,a,1]},w=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,m=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,k=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,_=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,M=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,x=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,F=Math.round,j=function(t){var r;if(t=t.toLowerCase().trim(),c.format.named)try{return c.format.named(t)}catch(t){}if(r=t.match(w)){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(m)){for(var o=r.slice(1,5),a=0;a<4;a++)o[a]=+o[a];return o}if(r=t.match(k)){for(var i=r.slice(1,4),u=0;u<3;u++)i[u]=F(2.55*i[u]);return i[3]=1,i}if(r=t.match(_)){for(var l=r.slice(1,5),s=0;s<3;s++)l[s]=F(2.55*l[s]);return l[3]=+l[3],l}if(r=t.match(M)){var h=r.slice(1,4);h[1]*=.01,h[2]*=.01;var f=y(h);return f[3]=1,f}if(r=t.match(x)){var p=r.slice(1,4);p[1]*=.01,p[2]*=.01;var g=y(p);return g[3]=+r[4],g}};j.test=function(t){return w.test(t)||m.test(t)||k.test(t)||_.test(t)||M.test(t)||x.test(t)},h.prototype.css=function(t){return d(this._rgb,t)},f.css=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["css"])))},c.format.css=j,c.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"===a(t)&&j.test(t))return"css"}});var N=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,$=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,A=Math.round;h.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],o=n[1],a=n[2],l=n[3],s=u(t)||"auto";void 0===l&&(l=1),"auto"===s&&(s=l<1?"rgba":"rgb");var c="000000"+((e=A(e))<<16|(o=A(o))<<8|(a=A(a))).toString(16);c=c.substr(c.length-6);var h="0"+A(255*l).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)},f.hex=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["hex"])))},c.format.hex=function(t){if(t.match(N)){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($)){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)},c.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"===a(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}}),h.prototype.hsl=function(){return g(this._rgb)},f.hsl=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["hsl"])))},c.format.hsl=y,c.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"hsl"))&&3===t.length)return"hsl"}});var C=18,E=.95047,O=1,S=1.08883,L=.137931034,I=.206896552,T=.12841855,q=.008856452,B=Math.pow,D=function(t){return 255*(t<=.00304?12.92*t:1.055*B(t,1/2.4)-.055)},R=function(t){return t>I?t*t*t:T*(t-L)},U=Math.pow,z=function(t){return(t/=255)<=.04045?t/12.92:U((t+.055)/1.055,2.4)},G=function(t){return t>q?U(t,1/3):t/T+L},H=function(t,r,n){return t=z(t),r=z(r),n=z(n),[G((.4124564*t+.3575761*r+.1804375*n)/E),G((.2126729*t+.7151522*r+.072175*n)/O),G((.0193339*t+.119192*r+.9503041*n)/S)]};h.prototype.lab=function(){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],o=n[1],a=n[2],u=H(e,o,a),l=u[0],s=u[1],c=116*s-16;return[c<0?0:c,500*(l-s),200*(s-u[2])]}(this._rgb)},f.lab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["lab"])))},c.format.lab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,o,a=(t=i(t,"lab"))[0],u=t[1],l=t[2];return e=(a+16)/116,n=isNaN(u)?e:e+u/500,o=isNaN(l)?e:e-l/200,e=O*R(e),n=E*R(n),o=S*R(o),[D(3.2404542*n-1.5371385*e-.4985314*o),D(-.969266*n+1.8760108*e+.041556*o),D(.0556434*n-.2040259*e+1.0572252*o),t.length>3?t[3]:1]},c.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"lab"))&&3===t.length)return"lab"}});var J=Math.pow,K=Math.sign;function P(t){var r=Math.abs(t);return r>.0031308?(K(t)||1)*(1.055*J(r,1/2.4)-.055):12.92*t}var Q=Math.cbrt,V=Math.pow,W=Math.sign;function X(t){var r=Math.abs(t);return r<.04045?t/12.92:(W(t)||1)*V((r+.055)/1.055,2.4)}h.prototype.oklab=function(){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],o=n[1],a=n[2],u=[X(e/255),X(o/255),X(a/255)],l=u[0],s=u[1],c=u[2],h=Q(.4122214708*l+.5363325363*s+.0514459929*c),f=Q(.2119034982*l+.6806995451*s+.1073969566*c),p=Q(.0883024619*l+.2817188376*s+.6299787005*c);return[.2104542553*h+.793617785*f-.0040720468*p,1.9779984951*h-2.428592205*f+.4505937099*p,.0259040371*h+.7827717662*f-.808675766*p]}(this._rgb)},f.oklab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["oklab"])))},c.format.oklab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lab"))[0],e=t[1],o=t[2],a=J(n+.3963377774*e+.2158037573*o,3),u=J(n-.1055613458*e-.0638541728*o,3),l=J(n-.0894841775*e-1.291485548*o,3);return[255*P(4.0767416621*a-3.3077115913*u+.2309699292*l),255*P(-1.2684380046*a+2.6097574011*u-.3413193965*l),255*P(-.0041960863*a-.7034186147*u+1.707614701*l),t.length>3?t[3]:1]},c.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"oklab"))&&3===t.length)return"oklab"}});var Y=Math.round;h.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Y)},h.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:Y(r):r}))},f.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["rgb"])))},c.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},c.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"rgba"))&&(3===t.length||4===t.length&&"number"==a(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}}),h.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===a(t)?r?(this._rgb[3]=t,this):new h([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},h.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=C*t,new h(r,"lab").alpha(this.alpha(),!0)},h.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},h.prototype.darker=h.prototype.darken,h.prototype.brighter=h.prototype.brighten,h.prototype.get=function(t){var r=t.split("."),n=r[0],e=r[1],o=this[n]();if(e){var a=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(a>-1)return o[a];throw new Error("unknown channel "+e+" in mode "+n)}return o};var Z={};function tt(t,r,n){void 0===n&&(n=.5);for(var e=[],o=arguments.length-3;o-- >0;)e[o]=arguments[o+3];var i=e[0]||"lrgb";if(Z[i]||e.length||(i=Object.keys(Z)[0]),!Z[i])throw new Error("interpolation mode "+i+" is not defined");return"object"!==a(t)&&(t=new h(t)),"object"!==a(r)&&(r=new h(r)),Z[i](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}h.prototype.mix=h.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 tt.apply(void 0,[this,t,r].concat(n))},h.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),o=e[0],i=e[1],u=this[o]();if(i){var l=o.indexOf(i)-("ok"===o.substr(0,2)?2:0);if(l>-1){if("string"==a(r))switch(r.charAt(0)){case"+":case"-":u[l]+=+r;break;case"*":u[l]*=+r.substr(1);break;case"/":u[l]/=+r.substr(1);break;default:u[l]=+r}else{if("number"!==a(r))throw new Error("unsupported value for Color.set");u[l]=r}var s=new h(u,o);return n?(this._rgb=s._rgb,this):s}throw new Error("unknown channel "+i+" in mode "+o)}return u},h.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return tt.apply(void 0,[this,"white",t].concat(r))},h.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return tt.apply(void 0,[this,"black",t].concat(r))};var rt=Math.sqrt,nt=Math.pow;Z.lrgb=function(t,r,n){var e=t._rgb,o=e[0],a=e[1],i=e[2],u=r._rgb,l=u[0],s=u[1],c=u[2];return new h(rt(nt(o,2)*(1-n)+nt(l,2)*n),rt(nt(a,2)*(1-n)+nt(s,2)*n),rt(nt(i,2)*(1-n)+nt(c,2)*n),"rgb")};return Z.oklab=function(t,r,n){var e=t.oklab(),o=r.oklab();return new h(e[0]+n*(o[0]-e[0]),e[1]+n*(o[1]-e[1]),e[2]+n*(o[2]-e[2]),"oklab")},f.mix=f.interpolate=tt,f.valid=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{return new(Function.prototype.bind.apply(h,[null].concat(t))),!0}catch(t){return!1}},f})); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).chroma={})}(this,(function(t){"use strict";function r(t,r,n){return void 0===n&&(n=1),s(c(r,t),n)}for(var n={},e=0,o=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];e=3?Array.prototype.slice.call(t):"object"==i(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0]}function l(t){if(t.length<2)return null;var r=t.length-1;return"string"==i(t[r])?t[r].toLowerCase():null}var s=Math.min,c=Math.max,h={format:{},autodetect:[]},f=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var e=this;if("object"===i(t[0])&&t[0].constructor&&t[0].constructor===this.constructor)return t[0];var o=l(t),a=!1;if(!o){a=!0,h.sorted||(h.autodetect=h.autodetect.sort((function(t,r){return r.p-t.p})),h.sorted=!0);for(var u=0,s=h.autodetect;u255)&&(t._clipped=!0),t[n]=r(t[n],0,255)):3===n&&(t[n]=r(t[n],0,1));return t}(f),3===e._rgb.length&&e._rgb.push(1)};f.prototype.toString=function(){return"function"==i(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var p=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f,[null].concat(t)))};p.version="2.6.1-0";var g=function(t){return Math.round(100*t)/100},b=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,o=(t=u(t,"rgba"))[0],a=t[1],i=t[2],l=s(o/=255,a/=255,i/=255),h=c(o,a,i),f=(h+l)/2;return h===l?(n=0,e=Number.NaN):n=f<.5?(h-l)/(h+l):(h-l)/(2-h-l),o==h?e=(a-i)/(h-l):a==h?e=2+(i-o)/(h-l):i==h&&(e=4+(o-a)/(h-l)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,f,t[3]]:[e,n,f]},d=Math.round,v=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgba"),e=l(t)||"rgb";return"hsl"==e.substr(0,3)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"hsla"),e=l(t)||"lsa";return n[0]=g(n[0]||0),n[1]=g(100*n[1])+"%",n[2]=g(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+"("+n.join(",")+")"}(b(n),e):(n[0]=d(n[0]),n[1]=d(n[1]),n[2]=d(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]=n.length>3?n[3]:1,e="rgba"),e+"("+n.slice(0,"rgb"===e?3:4).join(",")+")")},y=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,o,a,i=(r=u(r,"hsl"))[0],l=r[1],s=r[2];if(0===l)e=o=a=255*s;else{var c=[0,0,0],h=[0,0,0],f=s<.5?s*(1+l):s+l-s*l,p=2*s-f,g=i/360;c[0]=g+1/3,c[1]=g,c[2]=g-1/3;for(var b=0;b<3;b++)c[b]<0&&(c[b]+=1),c[b]>1&&(c[b]-=1),6*c[b]<1?h[b]=p+6*(f-p)*c[b]:2*c[b]<1?h[b]=f:3*c[b]<2?h[b]=p+(f-p)*(2/3-c[b])*6:h[b]=p;e=(t=[255*h[0],255*h[1],255*h[2]])[0],o=t[1],a=t[2]}return r.length>3?[e,o,a,r[3]]:[e,o,a,1]},w=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,m=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,k=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,_=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,M=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,x=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,j=Math.round,F=function(t){var r;if(t=t.toLowerCase().trim(),h.format.named)try{return h.format.named(t)}catch(t){}if(r=t.match(w)){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(m)){for(var o=r.slice(1,5),a=0;a<4;a++)o[a]=+o[a];return o}if(r=t.match(k)){for(var i=r.slice(1,4),u=0;u<3;u++)i[u]=j(2.55*i[u]);return i[3]=1,i}if(r=t.match(_)){for(var l=r.slice(1,5),s=0;s<3;s++)l[s]=j(2.55*l[s]);return l[3]=+l[3],l}if(r=t.match(M)){var c=r.slice(1,4);c[1]*=.01,c[2]*=.01;for(var f=y(c),p=0;p<3;p++)f[p]=j(f[p]);return f[3]=1,f}if(r=t.match(x)){var g=r.slice(1,4);g[1]*=.01,g[2]*=.01;for(var b=y(g),d=0;d<3;d++)b[d]=j(b[d]);return b[3]=+r[4],b}};F.test=function(t){return w.test(t)||m.test(t)||k.test(t)||_.test(t)||M.test(t)||x.test(t)},f.prototype.css=function(t){return v(this._rgb,t)},p.css=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f,[null].concat(t,["css"])))},h.format.css=F,h.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"===i(t)&&F.test(t))return"css"}});var N=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,$=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,A=Math.round;f.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],o=n[1],a=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=A(e))<<16|(o=A(o))<<8|(a=A(a))).toString(16);c=c.substr(c.length-6);var h="0"+A(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)},p.hex=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f,[null].concat(t,["hex"])))},h.format.hex=function(t){if(t.match(N)){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($)){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)},h.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"===i(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}}),f.prototype.hsl=function(){return b(this._rgb)},p.hsl=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f,[null].concat(t,["hsl"])))},h.format.hsl=y,h.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===i(t=u(t,"hsl"))&&3===t.length)return"hsl"}});var C=18,E=.95047,O=1,S=1.08883,L=.137931034,I=.206896552,T=.12841855,q=.008856452,B=Math.pow,D=function(t){return 255*(t<=.00304?12.92*t:1.055*B(t,1/2.4)-.055)},P=function(t){return t>I?t*t*t:T*(t-L)},R=Math.pow,U=function(t){return(t/=255)<=.04045?t/12.92:R((t+.055)/1.055,2.4)},z=function(t){return t>q?R(t,1/3):t/T+L},G=function(t,r,n){return t=U(t),r=U(r),n=U(n),[z((.4124564*t+.3575761*r+.1804375*n)/E),z((.2126729*t+.7151522*r+.072175*n)/O),z((.0193339*t+.119192*r+.9503041*n)/S)]};f.prototype.lab=function(){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgb"),e=n[0],o=n[1],a=n[2],i=G(e,o,a),l=i[0],s=i[1],c=116*s-16;return[c<0?0:c,500*(l-s),200*(s-i[2])]}(this._rgb)},p.lab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f,[null].concat(t,["lab"])))},h.format.lab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,o,a=(t=u(t,"lab"))[0],i=t[1],l=t[2];return e=(a+16)/116,n=isNaN(i)?e:e+i/500,o=isNaN(l)?e:e-l/200,e=O*P(e),n=E*P(n),o=S*P(o),[D(3.2404542*n-1.5371385*e-.4985314*o),D(-.969266*n+1.8760108*e+.041556*o),D(.0556434*n-.2040259*e+1.0572252*o),t.length>3?t[3]:1]},h.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===i(t=u(t,"lab"))&&3===t.length)return"lab"}});var H=Math.pow,J=Math.sign;function K(t){var r=Math.abs(t);return r>.0031308?(J(t)||1)*(1.055*H(r,1/2.4)-.055):12.92*t}var Q=Math.cbrt,V=Math.pow,W=Math.sign;function X(t){var r=Math.abs(t);return r<.04045?t/12.92:(W(t)||1)*V((r+.055)/1.055,2.4)}f.prototype.oklab=function(){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=u(t,"rgb"),e=n[0],o=n[1],a=n[2],i=[X(e/255),X(o/255),X(a/255)],l=i[0],s=i[1],c=i[2],h=Q(.4122214708*l+.5363325363*s+.0514459929*c),f=Q(.2119034982*l+.6806995451*s+.1073969566*c),p=Q(.0883024619*l+.2817188376*s+.6299787005*c);return[.2104542553*h+.793617785*f-.0040720468*p,1.9779984951*h-2.428592205*f+.4505937099*p,.0259040371*h+.7827717662*f-.808675766*p]}(this._rgb)},p.oklab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f,[null].concat(t,["oklab"])))},h.format.oklab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=u(t,"lab"))[0],e=t[1],o=t[2],a=H(n+.3963377774*e+.2158037573*o,3),i=H(n-.1055613458*e-.0638541728*o,3),l=H(n-.0894841775*e-1.291485548*o,3);return[255*K(4.0767416621*a-3.3077115913*i+.2309699292*l),255*K(-1.2684380046*a+2.6097574011*i-.3413193965*l),255*K(-.0041960863*a-.7034186147*i+1.707614701*l),t.length>3?t[3]:1]},h.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===i(t=u(t,"oklab"))&&3===t.length)return"oklab"}});var Y=Math.round;f.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Y)},f.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:Y(r):r}))},p.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f,[null].concat(t,["rgb"])))},h.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},h.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===i(t=u(t,"rgba"))&&(3===t.length||4===t.length&&"number"==i(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}}),f.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===i(t)?r?(this._rgb[3]=t,this):new f([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},f.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=C*t,new f(r,"lab").alpha(this.alpha(),!0)},f.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},f.prototype.darker=f.prototype.darken,f.prototype.brighter=f.prototype.brighten,f.prototype.get=function(t){var r=t.split("."),n=r[0],e=r[1],o=this[n]();if(e){var a=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(a>-1)return o[a];throw new Error("unknown channel "+e+" in mode "+n)}return o};var Z={};function tt(t,r,n){void 0===n&&(n=.5);for(var e=[],o=arguments.length-3;o-- >0;)e[o]=arguments[o+3];var a=e[0]||"lrgb";if(Z[a]||e.length||(a=Object.keys(Z)[0]),!Z[a])throw new Error("interpolation mode "+a+" is not defined");return"object"!==i(t)&&(t=new f(t)),"object"!==i(r)&&(r=new f(r)),Z[a](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}f.prototype.mix=f.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 tt.apply(void 0,[this,t,r].concat(n))},f.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),o=e[0],a=e[1],u=this[o]();if(a){var l=o.indexOf(a)-("ok"===o.substr(0,2)?2:0);if(l>-1){if("string"==i(r))switch(r.charAt(0)){case"+":case"-":u[l]+=+r;break;case"*":u[l]*=+r.substr(1);break;case"/":u[l]/=+r.substr(1);break;default:u[l]=+r}else{if("number"!==i(r))throw new Error("unsupported value for Color.set");u[l]=r}var s=new f(u,o);return n?(this._rgb=s._rgb,this):s}throw new Error("unknown channel "+a+" in mode "+o)}return u},f.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return tt.apply(void 0,[this,"white",t].concat(r))},f.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return tt.apply(void 0,[this,"black",t].concat(r))};var rt=Math.sqrt,nt=Math.pow;Z.lrgb=function(t,r,n){var e=t._rgb,o=e[0],a=e[1],i=e[2],u=r._rgb,l=u[0],s=u[1],c=u[2];return new f(rt(nt(o,2)*(1-n)+nt(l,2)*n),rt(nt(a,2)*(1-n)+nt(s,2)*n),rt(nt(i,2)*(1-n)+nt(c,2)*n),"rgb")};function et(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{return new(Function.prototype.bind.apply(f,[null].concat(t))),!0}catch(t){return!1}}Z.oklab=function(t,r,n){var e=t.oklab(),o=r.oklab();return new f(e[0]+n*(o[0]-e[0]),e[1]+n*(o[1]-e[1]),e[2]+n*(o[2]-e[2]),"oklab")},Object.assign(p,{Color:f,valid:et,mix:tt,interpolate:tt}),t.Color=f,t.default=p,t.interpolate=tt,t.mix=tt,t.valid=et,Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/dist/chroma.cjs b/dist/chroma.cjs index 1eef66f3..02449904 100644 --- a/dist/chroma.cjs +++ b/dist/chroma.cjs @@ -56,10 +56,10 @@ */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory()); -})(this, (function () { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.chroma = {})); +})(this, (function (exports) { 'use strict'; function limit (x, low, high) { if ( low === void 0 ) low = 0; @@ -190,16 +190,15 @@ }; // this gets updated automatically - var version = '2.6.0'; + var version = '2.6.1-0'; var chroma = function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; - return new (Function.prototype.bind.apply( chroma.Color, [ null ].concat( args) )); + return new (Function.prototype.bind.apply( Color, [ null ].concat( args) )); }; - chroma.Color = Color; chroma.version = version; var cmyk2rgb = function () { @@ -343,7 +342,7 @@ return [h, s, l]; }; - var round$6 = Math.round; + var round$5 = Math.round; /* * supported arguments: @@ -362,9 +361,9 @@ if (mode.substr(0, 3) == 'hsl') { return hsl2css(rgb2hsl$1(rgba), mode); } - rgba[0] = round$6(rgba[0]); - rgba[1] = round$6(rgba[1]); - rgba[2] = round$6(rgba[2]); + rgba[0] = round$5(rgba[0]); + rgba[1] = round$5(rgba[1]); + rgba[2] = round$5(rgba[2]); if (mode === 'rgba' || (rgba.length > 3 && rgba[3] < 1)) { rgba[3] = rgba.length > 3 ? rgba[3] : 1; mode = 'rgba'; @@ -372,8 +371,6 @@ return (mode + "(" + (rgba.slice(0, mode === 'rgb' ? 3 : 4).join(',')) + ")"); }; - var round$5 = Math.round; - var hsl2rgb = function () { var assign; @@ -403,7 +400,7 @@ else if (3 * t3[i] < 2) { c[i] = t1 + (t2 - t1) * (2 / 3 - t3[i]) * 6; } else { c[i] = t1; } } - (assign = [round$5(c[0] * 255), round$5(c[1] * 255), round$5(c[2] * 255)], r = assign[0], g = assign[1], b = assign[2]); + (assign = [c[0] * 255, c[1] * 255, c[2] * 255], r = assign[0], g = assign[1], b = assign[2]); } if (args.length > 3) { // keep alpha channel @@ -482,6 +479,9 @@ hsl[1] *= 0.01; hsl[2] *= 0.01; var rgb$4 = hsl2rgb(hsl); + for (var i$4 = 0; i$4 < 3; i$4++) { + rgb$4[i$4] = round$4(rgb$4[i$4]); + } rgb$4[3] = 1; return rgb$4; } @@ -492,6 +492,9 @@ hsl$1[1] *= 0.01; hsl$1[2] *= 0.01; var rgb$5 = hsl2rgb(hsl$1); + for (var i$5 = 0; i$5 < 3; i$5++) { + rgb$5[i$5] = round$4(rgb$5[i$5]); + } rgb$5[3] = +m[4]; // default alpha = 1 return rgb$5; } @@ -3362,26 +3365,48 @@ } Object.assign(chroma, { + analyze: analyze, average: average, bezier: bezier$1, blend: blend, - cubehelix: cubehelix, - mix: mix, - interpolate: mix, - random: random$1, - scale: scale, - analyze: analyze, + brewer: colorbrewer, + Color: Color, + colors: w3cx11, contrast: contrast, + cubehelix: cubehelix, deltaE: deltaE, distance: distance, + input: input, + interpolate: mix, limits: limits, - valid: valid, + mix: mix, + random: random$1, + scale: scale, scales: scales, - input: input, - colors: w3cx11, - brewer: colorbrewer + valid: valid }); - return chroma; + exports.Color = Color; + exports.analyze = analyze; + exports.average = average; + exports.bezier = bezier$1; + exports.blend = blend; + exports.brewer = colorbrewer; + exports.colors = w3cx11; + exports.contrast = contrast; + exports.cubehelix = cubehelix; + exports.default = chroma; + exports.deltaE = deltaE; + exports.distance = distance; + exports.input = input; + exports.interpolate = mix; + exports.limits = limits; + exports.mix = mix; + exports.random = random$1; + exports.scale = scale; + exports.scales = scales; + exports.valid = valid; + + Object.defineProperty(exports, '__esModule', { value: true }); })); diff --git a/dist/chroma.min.cjs b/dist/chroma.min.cjs index c86b7a2b..84cac9b9 100644 --- a/dist/chroma.min.cjs +++ b/dist/chroma.min.cjs @@ -55,4 +55,4 @@ * @preserve */ -!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).chroma=e()}(this,(function(){"use strict";function r(r,e,t){return void 0===e&&(e=0),void 0===t&&(t=1),l(h(e,r),t)}function e(e){e._clipped=!1,e._unclipped=e.slice(0);for(var t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=r(e[t],0,255)):3===t&&(e[t]=r(e[t],0,1));return e}for(var t={},n=0,a=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];n=3?Array.prototype.slice.call(r):"object"==o(r[0])&&e?e.split("").filter((function(e){return void 0!==r[0][e]})).map((function(e){return r[0][e]})):r[0]}function c(r){if(r.length<2)return null;var e=r.length-1;return"string"==o(r[e])?r[e].toLowerCase():null}var i=Math.PI,l=Math.min,h=Math.max,d=2*i,s=i/3,b=i/180,g=180/i,p={format:{},autodetect:[]},v=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=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,p.sorted||(p.autodetect=p.autodetect.sort((function(r,e){return e.p-r.p})),p.sorted=!0);for(var u=0,i=p.autodetect;u4?r[4]:1;return 1===f?[0,0,0,o]:[t>=1?0:255*(1-t)*(1-f),n>=1?0:255*(1-n)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"cmyk"))&&4===r.length)return"cmyk"}});var w=function(r){return Math.round(100*r)/100},k=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a=(r=u(r,"rgba"))[0],f=r[1],o=r[2],c=l(a/=255,f/=255,o/=255),i=h(a,f,o),d=(i+c)/2;return i===c?(t=0,n=Number.NaN):t=d<.5?(i-c)/(i+c):(i-c)/(2-i-c),a==i?n=(f-o)/(i-c):f==i?n=2+(o-a)/(i-c):o==i&&(n=4+(a-f)/(i-c)),(n*=60)<0&&(n+=360),r.length>3&&void 0!==r[3]?[n,t,d,r[3]]:[n,t,d]},M=Math.round,N=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba"),n=c(r)||"rgb";return"hsl"==n.substr(0,3)?function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"hsla"),n=c(r)||"lsa";return t[0]=w(t[0]||0),t[1]=w(100*t[1])+"%",t[2]=w(100*t[2])+"%","hsla"===n||t.length>3&&t[3]<1?(t[3]=t.length>3?t[3]:1,n="hsla"):t.length=3,n+"("+t.join(",")+")"}(k(t),n):(t[0]=M(t[0]),t[1]=M(t[1]),t[2]=M(t[2]),("rgba"===n||t.length>3&&t[3]<1)&&(t[3]=t.length>3?t[3]:1,n="rgba"),n+"("+t.slice(0,"rgb"===n?3:4).join(",")+")")},_=Math.round,x=function(){for(var r,e=[],t=arguments.length;t--;)e[t]=arguments[t];var n,a,f,o=(e=u(e,"hsl"))[0],c=e[1],i=e[2];if(0===c)n=a=f=255*i;else{var l=[0,0,0],h=[0,0,0],d=i<.5?i*(1+c):i+c-i*c,s=2*i-d,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?h[g]=s+6*(d-s)*l[g]:2*l[g]<1?h[g]=d:3*l[g]<2?h[g]=s+(d-s)*(2/3-l[g])*6:h[g]=s;n=(r=[_(255*h[0]),_(255*h[1]),_(255*h[2])])[0],a=r[1],f=r[2]}return e.length>3?[n,a,f,e[3]]:[n,a,f,1]},A=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,F=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,E=/^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=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,L=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,O=Math.round,P=function(r){var e;if(r=r.toLowerCase().trim(),p.format.named)try{return p.format.named(r)}catch(r){}if(e=r.match(A)){for(var t=e.slice(1,4),n=0;n<3;n++)t[n]=+t[n];return t[3]=1,t}if(e=r.match(F)){for(var a=e.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if(e=r.match(E)){for(var o=e.slice(1,4),u=0;u<3;u++)o[u]=O(2.55*o[u]);return o[3]=1,o}if(e=r.match(j)){for(var c=e.slice(1,5),i=0;i<3;i++)c[i]=O(2.55*c[i]);return c[3]=+c[3],c}if(e=r.match(q)){var l=e.slice(1,4);l[1]*=.01,l[2]*=.01;var h=x(l);return h[3]=1,h}if(e=r.match(L)){var d=e.slice(1,4);d[1]*=.01,d[2]*=.01;var s=x(d);return s[3]=+e[4],s}};P.test=function(r){return A.test(r)||F.test(r)||E.test(r)||j.test(r)||q.test(r)||L.test(r)},v.prototype.css=function(r){return N(this._rgb,r)},m.css=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["css"])))},p.format.css=P,p.autodetect.push({p:5,test:function(r){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(!e.length&&"string"===o(r)&&P.test(r))return"css"}}),p.format.gl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t},m.gl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["gl"])))},v.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var G=Math.floor;v.prototype.hcg=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n=u(r,"rgb"),a=n[0],f=n[1],o=n[2],c=l(a,f,o),i=h(a,f,o),d=i-c,s=100*d/255,b=c/(255-d)*100;return 0===d?t=Number.NaN:(a===i&&(t=(f-o)/d),f===i&&(t=2+(o-a)/d),o===i&&(t=4+(a-f)/d),(t*=60)<0&&(t+=360)),[t,s,b]}(this._rgb)},m.hcg=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hcg"])))},p.format.hcg=function(){for(var r,e,t,n,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,h,d=(o=u(o,"hcg"))[0],s=o[1],b=o[2];b*=255;var g=255*s;if(0===s)i=l=h=b;else{360===d&&(d=0),d>360&&(d-=360),d<0&&(d+=360);var p=G(d/=60),v=d-p,m=b*(1-s),y=m+g*(1-v),w=m+g*v,k=m+g;switch(p){case 0:i=(r=[k,w,m])[0],l=r[1],h=r[2];break;case 1:i=(e=[y,k,m])[0],l=e[1],h=e[2];break;case 2:i=(t=[m,k,w])[0],l=t[1],h=t[2];break;case 3:i=(n=[m,y,k])[0],l=n[1],h=n[2];break;case 4:i=(a=[w,m,k])[0],l=a[1],h=a[2];break;case 5:i=(f=[k,m,y])[0],l=f[1],h=f[2]}}return[i,l,h,o.length>3?o[3]:1]},p.autodetect.push({p:1,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hcg"))&&3===r.length)return"hcg"}});var B=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,C=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,R=function(r){if(r.match(B)){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 e=parseInt(r,16);return[e>>16,e>>8&255,255&e,1]}if(r.match(C)){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 t=parseInt(r,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((255&t)/255*100)/100]}throw new Error("unknown hex color: "+r)},S=Math.round,$=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba"),n=t[0],a=t[1],f=t[2],o=t[3],i=c(r)||"auto";void 0===o&&(o=1),"auto"===i&&(i=o<1?"rgba":"rgb");var l="000000"+((n=S(n))<<16|(a=S(a))<<8|(f=S(f))).toString(16);l=l.substr(l.length-6);var h="0"+S(255*o).toString(16);switch(h=h.substr(h.length-2),i.toLowerCase()){case"rgba":return"#"+l+h;case"argb":return"#"+h+l;default:return"#"+l}};v.prototype.hex=function(r){return $(this._rgb,r)},m.hex=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hex"])))},p.format.hex=R,p.autodetect.push({p:4,test:function(r){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(!e.length&&"string"===o(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var Y=Math.cos,z=Math.min,I=Math.sqrt,U=Math.acos;v.prototype.hsi=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n=u(r,"rgb"),a=n[0],f=n[1],o=n[2],c=z(a/=255,f/=255,o/=255),i=(a+f+o)/3,l=i>0?1-c/i:0;return 0===l?t=NaN:(t=(a-f+(a-o))/2,t/=I((a-f)*(a-f)+(a-o)*(f-o)),t=U(t),o>f&&(t=d-t),t/=d),[360*t,l,i]}(this._rgb)},m.hsi=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hsi"])))},p.format.hsi=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n,a,f,o=(e=u(e,"hsi"))[0],c=e[1],i=e[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)+(n=(1+c*Y(d*o)/Y(s-d*o))/3)):o<2/3?f=1-((n=(1-c)/3)+(a=(1+c*Y(d*(o-=1/3))/Y(s-d*o))/3)):n=1-((a=(1-c)/3)+(f=(1+c*Y(d*(o-=2/3))/Y(s-d*o))/3)),[255*(n=r(i*n*3)),255*(a=r(i*a*3)),255*(f=r(i*f*3)),e.length>3?e[3]:1]},p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hsi"))&&3===r.length)return"hsi"}}),v.prototype.hsl=function(){return k(this._rgb)},m.hsl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hsl"])))},p.format.hsl=x,p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hsl"))&&3===r.length)return"hsl"}});var V=Math.floor,X=Math.min,D=Math.max;v.prototype.hsv=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a,f=(r=u(r,"rgb"))[0],o=r[1],c=r[2],i=X(f,o,c),l=D(f,o,c),h=l-i;return a=l/255,0===l?(t=Number.NaN,n=0):(n=h/l,f===l&&(t=(o-c)/h),o===l&&(t=2+(c-f)/h),c===l&&(t=4+(f-o)/h),(t*=60)<0&&(t+=360)),[t,n,a]}(this._rgb)},m.hsv=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hsv"])))},p.format.hsv=function(){for(var r,e,t,n,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,h,d=(o=u(o,"hsv"))[0],s=o[1],b=o[2];if(b*=255,0===s)i=l=h=b;else{360===d&&(d=0),d>360&&(d-=360),d<0&&(d+=360);var g=V(d/=60),p=d-g,v=b*(1-s),m=b*(1-s*p),y=b*(1-s*(1-p));switch(g){case 0:i=(r=[b,y,v])[0],l=r[1],h=r[2];break;case 1:i=(e=[m,b,v])[0],l=e[1],h=e[2];break;case 2:i=(t=[v,b,y])[0],l=t[1],h=t[2];break;case 3:i=(n=[v,m,b])[0],l=n[1],h=n[2];break;case 4:i=(a=[y,v,b])[0],l=a[1],h=a[2];break;case 5:i=(f=[b,v,m])[0],l=f[1],h=f[2]}}return[i,l,h,o.length>3?o[3]:1]},p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hsv"))&&3===r.length)return"hsv"}});var T=18,H=.95047,J=1,K=1.08883,Q=.137931034,W=.206896552,Z=.12841855,rr=.008856452,er=Math.pow,tr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a,f=(r=u(r,"lab"))[0],o=r[1],c=r[2];return n=(f+16)/116,t=isNaN(o)?n:n+o/500,a=isNaN(c)?n:n-c/200,n=J*ar(n),t=H*ar(t),a=K*ar(a),[nr(3.2404542*t-1.5371385*n-.4985314*a),nr(-.969266*t+1.8760108*n+.041556*a),nr(.0556434*t-.2040259*n+1.0572252*a),r.length>3?r[3]:1]},nr=function(r){return 255*(r<=.00304?12.92*r:1.055*er(r,1/2.4)-.055)},ar=function(r){return r>W?r*r*r:Z*(r-Q)},fr=Math.pow,or=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=ir(n,a,f),c=o[0],i=o[1],l=116*i-16;return[l<0?0:l,500*(c-i),200*(i-o[2])]},ur=function(r){return(r/=255)<=.04045?r/12.92:fr((r+.055)/1.055,2.4)},cr=function(r){return r>rr?fr(r,1/3):r/Z+Q},ir=function(r,e,t){return r=ur(r),e=ur(e),t=ur(t),[cr((.4124564*r+.3575761*e+.1804375*t)/H),cr((.2126729*r+.7151522*e+.072175*t)/J),cr((.0193339*r+.119192*e+.9503041*t)/K)]};v.prototype.lab=function(){return or(this._rgb)},m.lab=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["lab"])))},p.format.lab=tr,p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"lab"))&&3===r.length)return"lab"}});var lr=Math.sin,hr=Math.cos,dr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"lch"),n=t[0],a=t[1],f=t[2];return isNaN(f)&&(f=0),[n,hr(f*=b)*a,lr(f)*a]},sr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=u(r,"lch"))[0],n=r[1],a=r[2],f=dr(t,n,a),o=f[0],c=f[1],i=f[2],l=tr(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},br=Math.sqrt,gr=Math.atan2,pr=Math.round,vr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"lab"),n=t[0],a=t[1],f=t[2],o=br(a*a+f*f),c=(gr(f,a)*g+360)%360;return 0===pr(1e4*o)&&(c=Number.NaN),[n,o,c]},mr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=or(n,a,f),c=o[0],i=o[1],l=o[2];return vr(c,i,l)};v.prototype.lch=function(){return mr(this._rgb)},v.prototype.hcl=function(){return mr(this._rgb).reverse()},m.lch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["lch"])))},m.hcl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hcl"])))},p.format.lch=sr,p.format.hcl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"hcl").reverse();return sr.apply(void 0,t)},["lch","hcl"].forEach((function(r){return p.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if("array"===o(e=u(e,r))&&3===e.length)return r}})}));var yr={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"};v.prototype.name=function(){for(var r=$(this._rgb,"rgb"),e=0,t=Object.keys(yr);e0;)e[t]=arguments[t+1];if(!e.length&&"string"===o(r)&&yr[r.toLowerCase()])return"named"}});v.prototype.num=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb");return(t[0]<<16)+(t[1]<<8)+t[2]}(this._rgb)},m.num=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["num"])))},p.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)},p.autodetect.push({p:5,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if(1===r.length&&"number"===o(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var wr=Math.round;v.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(wr)},v.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(e,t){return t<3?!1===r?e:wr(e):e}))},m.rgb=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["rgb"])))},p.format.rgb=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba");return void 0===t[3]&&(t[3]=1),t},p.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];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,Mr=function(r){var e,t,n,a=r/100;return a<66?(e=255,t=a<6?0:-155.25485562709179-.44596950469579133*(t=a-2)+104.49216199393888*kr(t),n=a<20?0:.8274096064007395*(n=a-10)-254.76935184120902+115.67994401066147*kr(n)):(e=351.97690566805693+.114206453784165*(e=a-55)-40.25366309332127*kr(e),t=325.4494125711974+.07943456536662342*(t=a-50)-28.0852963507957*kr(t),n=255),[e,t,n,1]},Nr=Math.round;v.prototype.temp=v.prototype.kelvin=v.prototype.temperature=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];for(var t,n=u(r,"rgb"),a=n[0],f=n[2],o=1e3,c=4e4;c-o>.4;){var i=Mr(t=.5*(c+o));i[2]/i[0]>=f/a?c=t:o=t}return Nr(t)}(this._rgb)},m.temp=m.kelvin=m.temperature=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["temp"])))},p.format.temp=p.format.kelvin=p.format.temperature=Mr;var _r=Math.pow,xr=Math.sign,Ar=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=u(r,"lab"))[0],n=r[1],a=r[2],f=_r(t+.3963377774*n+.2158037573*a,3),o=_r(t-.1055613458*n-.0638541728*a,3),c=_r(t-.0894841775*n-1.291485548*a,3);return[255*Fr(4.0767416621*f-3.3077115913*o+.2309699292*c),255*Fr(-1.2684380046*f+2.6097574011*o-.3413193965*c),255*Fr(-.0041960863*f-.7034186147*o+1.707614701*c),r.length>3?r[3]:1]};function Fr(r){var e=Math.abs(r);return e>.0031308?(xr(r)||1)*(1.055*_r(e,1/2.4)-.055):12.92*r}var Er=Math.cbrt,jr=Math.pow,qr=Math.sign,Lr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=[Or(n/255),Or(a/255),Or(f/255)],c=o[0],i=o[1],l=o[2],h=Er(.4122214708*c+.5363325363*i+.0514459929*l),d=Er(.2119034982*c+.6806995451*i+.1073969566*l),s=Er(.0883024619*c+.2817188376*i+.6299787005*l);return[.2104542553*h+.793617785*d-.0040720468*s,1.9779984951*h-2.428592205*d+.4505937099*s,.0259040371*h+.7827717662*d-.808675766*s]};function Or(r){var e=Math.abs(r);return e<.04045?r/12.92:(qr(r)||1)*jr((e+.055)/1.055,2.4)}v.prototype.oklab=function(){return Lr(this._rgb)},m.oklab=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["oklab"])))},p.format.oklab=Ar,p.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"oklab"))&&3===r.length)return"oklab"}});v.prototype.oklch=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=Lr(n,a,f),c=o[0],i=o[1],l=o[2];return vr(c,i,l)}(this._rgb)},m.oklch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["oklch"])))},p.format.oklch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=u(r,"lch"))[0],n=r[1],a=r[2],f=dr(t,n,a),o=f[0],c=f[1],i=f[2],l=Ar(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},p.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"oklch"))&&3===r.length)return"oklch"}}),v.prototype.alpha=function(r,e){return void 0===e&&(e=!1),void 0!==r&&"number"===o(r)?e?(this._rgb[3]=r,this):new v([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},v.prototype.clipped=function(){return this._rgb._clipped||!1},v.prototype.darken=function(r){void 0===r&&(r=1);var e=this.lab();return e[0]-=T*r,new v(e,"lab").alpha(this.alpha(),!0)},v.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},v.prototype.darker=v.prototype.darken,v.prototype.brighter=v.prototype.brighten,v.prototype.get=function(r){var e=r.split("."),t=e[0],n=e[1],a=this[t]();if(n){var f=t.indexOf(n)-("ok"===t.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+n+" in mode "+t)}return a};var Pr=Math.pow;v.prototype.luminance=function(r,e){if(void 0===e&&(e="rgb"),void 0!==r&&"number"===o(r)){if(0===r)return new v([0,0,0,this._rgb[3]],"rgb");if(1===r)return new v([255,255,255,this._rgb[3]],"rgb");var t=this.luminance(),n=20,a=function(t,f){var o=t.interpolate(f,.5,e),u=o.luminance();return Math.abs(r-u)<1e-7||!n--?o:u>r?a(t,o):a(o,f)},f=(t>r?a(new v([0,0,0]),this):a(this,new v([255,255,255]))).rgb();return new v(f.concat([this._rgb[3]]))}return Gr.apply(void 0,this._rgb.slice(0,3))};var Gr=function(r,e,t){return.2126*(r=Br(r))+.7152*(e=Br(e))+.0722*(t=Br(t))},Br=function(r){return(r/=255)<=.03928?r/12.92:Pr((r+.055)/1.055,2.4)},Cr={};function Rr(r,e,t){void 0===t&&(t=.5);for(var n=[],a=arguments.length-3;a-- >0;)n[a]=arguments[a+3];var f=n[0]||"lrgb";if(Cr[f]||n.length||(f=Object.keys(Cr)[0]),!Cr[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==o(r)&&(r=new v(r)),"object"!==o(e)&&(e=new v(e)),Cr[f](r,e,t).alpha(r.alpha()+t*(e.alpha()-r.alpha()))}v.prototype.mix=v.prototype.interpolate=function(r,e){void 0===e&&(e=.5);for(var t=[],n=arguments.length-2;n-- >0;)t[n]=arguments[n+2];return Rr.apply(void 0,[this,r,e].concat(t))},v.prototype.premultiply=function(r){void 0===r&&(r=!1);var e=this._rgb,t=e[3];return r?(this._rgb=[e[0]*t,e[1]*t,e[2]*t,t],this):new v([e[0]*t,e[1]*t,e[2]*t,t],"rgb")},v.prototype.saturate=function(r){void 0===r&&(r=1);var e=this.lch();return e[1]+=T*r,e[1]<0&&(e[1]=0),new v(e,"lch").alpha(this.alpha(),!0)},v.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},v.prototype.set=function(r,e,t){void 0===t&&(t=!1);var n=r.split("."),a=n[0],f=n[1],u=this[a]();if(f){var c=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(c>-1){if("string"==o(e))switch(e.charAt(0)){case"+":case"-":u[c]+=+e;break;case"*":u[c]*=+e.substr(1);break;case"/":u[c]/=+e.substr(1);break;default:u[c]=+e}else{if("number"!==o(e))throw new Error("unsupported value for Color.set");u[c]=e}var i=new v(u,a);return t?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return u},v.prototype.tint=function(r){void 0===r&&(r=.5);for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Rr.apply(void 0,[this,"white",r].concat(e))},v.prototype.shade=function(r){void 0===r&&(r=.5);for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Rr.apply(void 0,[this,"black",r].concat(e))};Cr.rgb=function(r,e,t){var n=r._rgb,a=e._rgb;return new v(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"rgb")};var Sr=Math.sqrt,$r=Math.pow;Cr.lrgb=function(r,e,t){var n=r._rgb,a=n[0],f=n[1],o=n[2],u=e._rgb,c=u[0],i=u[1],l=u[2];return new v(Sr($r(a,2)*(1-t)+$r(c,2)*t),Sr($r(f,2)*(1-t)+$r(i,2)*t),Sr($r(o,2)*(1-t)+$r(l,2)*t),"rgb")};function Yr(r,e,t,n){var a,f,o,u,c,i,l,h,d,s,b,g,p;return"hsl"===n?(o=r.hsl(),u=e.hsl()):"hsv"===n?(o=r.hsv(),u=e.hsv()):"hcg"===n?(o=r.hcg(),u=e.hcg()):"hsi"===n?(o=r.hsi(),u=e.hsi()):"lch"===n||"hcl"===n?(n="hcl",o=r.hcl(),u=e.hcl()):"oklch"===n&&(o=r.oklch().reverse(),u=e.oklch().reverse()),"h"!==n.substr(0,1)&&"oklch"!==n||(c=(a=o)[0],l=a[1],d=a[2],i=(f=u)[0],h=f[1],s=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=d&&0!=d||"hsv"==n||(b=h)):(g=c,1!=s&&0!=s||"hsv"==n||(b=l)):g=c+t*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+t*(h-l)),p=d+t*(s-d),new v("oklch"===n?[p,b,g]:[g,b,p],n)}Cr.lab=function(r,e,t){var n=r.lab(),a=e.lab();return new v(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"lab")};var zr=function(r,e,t){return Yr(r,e,t,"lch")};Cr.lch=zr,Cr.hcl=zr;Cr.num=function(r,e,t){var n=r.num(),a=e.num();return new v(n+t*(a-n),"num")};Cr.hcg=function(r,e,t){return Yr(r,e,t,"hcg")};Cr.hsi=function(r,e,t){return Yr(r,e,t,"hsi")};Cr.hsl=function(r,e,t){return Yr(r,e,t,"hsl")};Cr.hsv=function(r,e,t){return Yr(r,e,t,"hsv")};Cr.oklab=function(r,e,t){var n=r.oklab(),a=e.oklab();return new v(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"oklab")};Cr.oklch=function(r,e,t){return Yr(r,e,t,"oklch")};var Ir=Math.pow,Ur=Math.sqrt,Vr=Math.PI,Xr=Math.cos,Dr=Math.sin,Tr=Math.atan2;var Hr=function(r,t){for(var n=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new v(e(a))},Jr=Math.pow;function Kr(e){var t="rgb",n=m("#ccc"),a=0,f=[0,1],u=[],c=[0,0],i=!1,l=[],h=!1,d=0,s=1,b=!1,g={},p=!0,v=1,y=function(r){if((r=r||["#fff","#000"])&&"string"===o(r)&&m.brewer&&m.brewer[r.toLowerCase()]&&(r=m.brewer[r.toLowerCase()]),"array"===o(r)){1===r.length&&(r=[r[0],r[0]]),r=r.slice(0);for(var e=0;e2){var b=function(r){if(null!=i){for(var e=i.length-1,t=0;t=i[t];)t++;return t-1}return 0}(e);h=b/(i.length-2)}else h=s!==d?(e-d)/(s-d):1;h=k(h),a||(h=w(h)),1!==v&&(h=Jr(h,v)),h=r(h=c[0]+h*(1-c[0]-c[1]),0,1);var y=Math.floor(1e4*h);if(p&&g[y])f=g[y];else{if("array"===o(l))for(var M=0;M=N&&M===u.length-1){f=l[M];break}if(h>N&&h2){var c=r.map((function(e,t){return t/(r.length-1)})),i=r.map((function(r){return(r-d)/(s-d)}));i.every((function(r,e){return c[e]===r}))||(k=function(r){if(r<=0||r>=1)return r;for(var e=0;r>=i[e+1];)e++;var t=(r-i[e])/(i[e+1]-i[e]);return c[e]+t*(c[e+1]-c[e])})}}return f=[d,s],_},_.mode=function(r){return arguments.length?(t=r,N(),_):t},_.range=function(r,e){return y(r),_},_.out=function(r){return h=r,_},_.spread=function(r){return arguments.length?(a=r,_):a},_.correctLightness=function(r){return null==r&&(r=!0),b=r,N(),w=b?function(r){for(var e=M(0,!0).lab()[0],t=M(1,!0).lab()[0],n=e>t,a=M(r,!0).lab()[0],f=e+(t-e)*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=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,t){arguments.length<2&&(t="hex");var n=[];if(0===arguments.length)n=l.slice(0);else if(1===r)n=[_(.5)];else if(r>1){var a=f[0],o=f[1]-a;n=function(r,e){for(var t=[],n=ra;n?f++:f--)t.push(f);return t}(0,r).map((function(e){return _(a+e/(r-1)*o)}))}else{e=[];var u=[];if(i&&i.length>2)for(var c=1,h=i.length,d=1<=h;d?ch;d?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;n=u.map((function(r){return _(r)}))}return m[t]&&(n=n.map((function(r){return r[t]()}))),n},_.cache=function(r){return null!=r?(p=r,_):p},_.gamma=function(r){return null!=r?(v=r,_):v},_.nodata=function(r){return null!=r?(n=m(r),_):n},_}var Qr=function(r,e,t){if(!Qr[t])throw new Error("unknown blend mode "+t);return Qr[t](r,e)},Wr=function(r){return function(e,t){var n=m(t).rgb(),a=m(e).rgb();return m.rgb(r(n,a))}},Zr=function(r){return function(e,t){var n=[];return n[0]=r(e[0],t[0]),n[1]=r(e[1],t[1]),n[2]=r(e[2],t[2]),n}};Qr.normal=Wr(Zr((function(r){return r}))),Qr.multiply=Wr(Zr((function(r,e){return r*e/255}))),Qr.screen=Wr(Zr((function(r,e){return 255*(1-(1-r/255)*(1-e/255))}))),Qr.overlay=Wr(Zr((function(r,e){return e<128?2*r*e/255:255*(1-2*(1-r/255)*(1-e/255))}))),Qr.darken=Wr(Zr((function(r,e){return r>e?e:r}))),Qr.lighten=Wr(Zr((function(r,e){return r>e?r:e}))),Qr.dodge=Wr(Zr((function(r,e){return 255===r||(r=e/255*255/(1-r/255))>255?255:r}))),Qr.burn=Wr(Zr((function(r,e){return 255*(1-(1-e/255)/(r/255))})));var re=Math.pow,ee=Math.sin,te=Math.cos;var ne=Math.floor,ae=Math.random;var fe=Math.log,oe=Math.pow,ue=Math.floor,ce=Math.abs;function ie(r,e){void 0===e&&(e=null);var t={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){e&&"object"===o(r)&&(r=r[e]),null==r||isNaN(r)||(t.values.push(r),t.sum+=r,rt.max&&(t.max=r),t.count+=1)})),t.domain=[t.min,t.max],t.limits=function(r,e){return le(t,r,e)},t}function le(r,e,t){void 0===e&&(e="equal"),void 0===t&&(t=7),"array"==o(r)&&(r=ie(r));var n=r.min,a=r.max,f=r.values.sort((function(r,e){return r-e}));if(1===t)return[n,a];var u=[];if("c"===e.substr(0,1)&&(u.push(n),u.push(a)),"e"===e.substr(0,1)){u.push(n);for(var c=1;c 0");var i=Math.LOG10E*fe(n),l=Math.LOG10E*fe(a);u.push(n);for(var h=1;h200&&(w=!1)}for(var C={},R=0;R=360;)b-=360;o[s]=b}else o[s]=o[s]/u[s];return d/=n,new v(o,e).alpha(d>.99999?1:d,!0)},bezier:function(r){var e=function(r){var e,t,n,a,f,o,u;if(2===(r=r.map((function(r){return new v(r)}))).length)e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],a=function(r){var e=[0,1,2].map((function(e){return f[e]+r*(o[e]-f[e])}));return new v(e,"lab")};else if(3===r.length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],u=t[2],a=function(r){var e=[0,1,2].map((function(e){return(1-r)*(1-r)*f[e]+2*(1-r)*r*o[e]+r*r*u[e]}));return new v(e,"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 e=[0,1,2].map((function(e){return(1-r)*(1-r)*(1-r)*f[e]+3*(1-r)*(1-r)*r*o[e]+3*(1-r)*r*r*u[e]+r*r*r*c[e]}));return new v(e,"lab")}}else{if(!(r.length>=5))throw new RangeError("No point in running bezier with only one color.");var i,l,h;i=r.map((function(r){return r.lab()})),h=r.length-1,l=function(r){for(var e=[1,1],t=1;tn?(t+.05)/(n+.05):(n+.05)/(t+.05)},deltaE:function(r,e,t,n,a){void 0===t&&(t=1),void 0===n&&(n=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*we)},o=function(r){return 2*we*r/360};r=new v(r),e=new v(e);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],h=Array.from(e.lab()),d=h[0],s=h[1],b=h[2],g=(c+d)/2,p=(he(de(i,2)+de(l,2))+he(de(s,2)+de(b,2)))/2,m=.5*(1-he(de(p,7)/(de(p,7)+de(25,7)))),y=i*(1+m),w=s*(1+m),k=he(de(y,2)+de(l,2)),M=he(de(w,2)+de(b,2)),N=(k+M)/2,_=f(ge(l,y)),x=f(ge(b,w)),A=_>=0?_:_+360,F=x>=0?x:x+360,E=pe(A-F)>180?(A+F+360)/2:(A+F)/2,j=1-.17*ve(o(E-30))+.24*ve(o(2*E))+.32*ve(o(3*E+6))-.2*ve(o(4*E-63)),q=F-A;q=pe(q)<=180?q:F<=A?q+360:q-360,q=2*he(k*M)*me(o(q)/2);var L=d-c,O=M-k,P=1+.015*de(g-50,2)/he(20+de(g-50,2)),G=1+.045*N,B=1+.015*N*j,C=30*ye(-de((E-275)/25,2)),R=-(2*he(de(N,7)/(de(N,7)+de(25,7))))*me(2*o(C)),S=he(de(L/(t*P),2)+de(O/(n*G),2)+de(q/(a*B),2)+R*(O/(n*G))*(q/(a*B)));return be(0,se(100,S))},distance:function(r,e,t){void 0===t&&(t="lab"),r=new v(r),e=new v(e);var n=r.get(t),a=e.get(t),f=0;for(var o in n){var u=(n[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)},limits:le,valid:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];try{return new(Function.prototype.bind.apply(v,[null].concat(r))),!0}catch(r){return!1}},scales:ke,input:p,colors:yr,brewer:Me}),m})); +!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).chroma={})}(this,(function(r){"use strict";function e(r,e,t){return void 0===e&&(e=0),void 0===t&&(t=1),h(s(e,r),t)}function t(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 n={},a=0,f=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];a=3?Array.prototype.slice.call(r):"object"==u(r[0])&&e?e.split("").filter((function(e){return void 0!==r[0][e]})).map((function(e){return r[0][e]})):r[0]}function i(r){if(r.length<2)return null;var e=r.length-1;return"string"==u(r[e])?r[e].toLowerCase():null}var l=Math.PI,h=Math.min,s=Math.max,d=2*l,b=l/3,g=l/180,p=180/l,v={format:{},autodetect:[]},m=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var n=this;if("object"===u(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=i(r),f=!1;if(!a){f=!0,v.sorted||(v.autodetect=v.autodetect.sort((function(r,e){return e.p-r.p})),v.sorted=!0);for(var o=0,c=v.autodetect;o4?r[4]:1;return 1===f?[0,0,0,o]:[t>=1?0:255*(1-t)*(1-f),n>=1?0:255*(1-n)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},v.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===u(r=c(r,"cmyk"))&&4===r.length)return"cmyk"}});var k=function(r){return Math.round(100*r)/100},M=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a=(r=c(r,"rgba"))[0],f=r[1],o=r[2],u=h(a/=255,f/=255,o/=255),i=s(a,f,o),l=(i+u)/2;return i===u?(t=0,n=Number.NaN):t=l<.5?(i-u)/(i+u):(i-u)/(2-i-u),a==i?n=(f-o)/(i-u):f==i?n=2+(o-a)/(i-u):o==i&&(n=4+(a-f)/(i-u)),(n*=60)<0&&(n+=360),r.length>3&&void 0!==r[3]?[n,t,l,r[3]]:[n,t,l]},N=Math.round,_=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"rgba"),n=i(r)||"rgb";return"hsl"==n.substr(0,3)?function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"hsla"),n=i(r)||"lsa";return t[0]=k(t[0]||0),t[1]=k(100*t[1])+"%",t[2]=k(100*t[2])+"%","hsla"===n||t.length>3&&t[3]<1?(t[3]=t.length>3?t[3]:1,n="hsla"):t.length=3,n+"("+t.join(",")+")"}(M(t),n):(t[0]=N(t[0]),t[1]=N(t[1]),t[2]=N(t[2]),("rgba"===n||t.length>3&&t[3]<1)&&(t[3]=t.length>3?t[3]:1,n="rgba"),n+"("+t.slice(0,"rgb"===n?3:4).join(",")+")")},x=function(){for(var r,e=[],t=arguments.length;t--;)e[t]=arguments[t];var n,a,f,o=(e=c(e,"hsl"))[0],u=e[1],i=e[2];if(0===u)n=a=f=255*i;else{var l=[0,0,0],h=[0,0,0],s=i<.5?i*(1+u):i+u-i*u,d=2*i-s,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?h[g]=d+6*(s-d)*l[g]:2*l[g]<1?h[g]=s:3*l[g]<2?h[g]=d+(s-d)*(2/3-l[g])*6:h[g]=d;n=(r=[255*h[0],255*h[1],255*h[2]])[0],a=r[1],f=r[2]}return e.length>3?[n,a,f,e[3]]:[n,a,f,1]},A=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,E=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,F=/^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+)\)$/,O=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,q=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,L=Math.round,P=function(r){var e;if(r=r.toLowerCase().trim(),v.format.named)try{return v.format.named(r)}catch(r){}if(e=r.match(A)){for(var t=e.slice(1,4),n=0;n<3;n++)t[n]=+t[n];return t[3]=1,t}if(e=r.match(E)){for(var a=e.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if(e=r.match(F)){for(var o=e.slice(1,4),u=0;u<3;u++)o[u]=L(2.55*o[u]);return o[3]=1,o}if(e=r.match(j)){for(var c=e.slice(1,5),i=0;i<3;i++)c[i]=L(2.55*c[i]);return c[3]=+c[3],c}if(e=r.match(O)){var l=e.slice(1,4);l[1]*=.01,l[2]*=.01;for(var h=x(l),s=0;s<3;s++)h[s]=L(h[s]);return h[3]=1,h}if(e=r.match(q)){var d=e.slice(1,4);d[1]*=.01,d[2]*=.01;for(var b=x(d),g=0;g<3;g++)b[g]=L(b[g]);return b[3]=+e[4],b}};P.test=function(r){return A.test(r)||E.test(r)||F.test(r)||j.test(r)||O.test(r)||q.test(r)},m.prototype.css=function(r){return _(this._rgb,r)},y.css=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["css"])))},v.format.css=P,v.autodetect.push({p:5,test:function(r){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(!e.length&&"string"===u(r)&&P.test(r))return"css"}}),v.format.gl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t},y.gl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["gl"])))},m.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var G=Math.floor;m.prototype.hcg=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n=c(r,"rgb"),a=n[0],f=n[1],o=n[2],u=h(a,f,o),i=s(a,f,o),l=i-u,d=100*l/255,b=u/(255-l)*100;return 0===l?t=Number.NaN:(a===i&&(t=(f-o)/l),f===i&&(t=2+(o-a)/l),o===i&&(t=4+(a-f)/l),(t*=60)<0&&(t+=360)),[t,d,b]}(this._rgb)},y.hcg=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["hcg"])))},v.format.hcg=function(){for(var r,e,t,n,a,f,o=[],u=arguments.length;u--;)o[u]=arguments[u];var i,l,h,s=(o=c(o,"hcg"))[0],d=o[1],b=o[2];b*=255;var g=255*d;if(0===d)i=l=h=b;else{360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360);var p=G(s/=60),v=s-p,m=b*(1-d),y=m+g*(1-v),w=m+g*v,k=m+g;switch(p){case 0:i=(r=[k,w,m])[0],l=r[1],h=r[2];break;case 1:i=(e=[y,k,m])[0],l=e[1],h=e[2];break;case 2:i=(t=[m,k,w])[0],l=t[1],h=t[2];break;case 3:i=(n=[m,y,k])[0],l=n[1],h=n[2];break;case 4:i=(a=[w,m,k])[0],l=a[1],h=a[2];break;case 5:i=(f=[k,m,y])[0],l=f[1],h=f[2]}}return[i,l,h,o.length>3?o[3]:1]},v.autodetect.push({p:1,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===u(r=c(r,"hcg"))&&3===r.length)return"hcg"}});var B=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,C=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,R=function(r){if(r.match(B)){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 e=parseInt(r,16);return[e>>16,e>>8&255,255&e,1]}if(r.match(C)){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 t=parseInt(r,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((255&t)/255*100)/100]}throw new Error("unknown hex color: "+r)},S=Math.round,$=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"rgba"),n=t[0],a=t[1],f=t[2],o=t[3],u=i(r)||"auto";void 0===o&&(o=1),"auto"===u&&(u=o<1?"rgba":"rgb");var l="000000"+((n=S(n))<<16|(a=S(a))<<8|(f=S(f))).toString(16);l=l.substr(l.length-6);var h="0"+S(255*o).toString(16);switch(h=h.substr(h.length-2),u.toLowerCase()){case"rgba":return"#"+l+h;case"argb":return"#"+h+l;default:return"#"+l}};m.prototype.hex=function(r){return $(this._rgb,r)},y.hex=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["hex"])))},v.format.hex=R,v.autodetect.push({p:4,test:function(r){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(!e.length&&"string"===u(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var z=Math.cos,Y=Math.min,I=Math.sqrt,U=Math.acos;m.prototype.hsi=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n=c(r,"rgb"),a=n[0],f=n[1],o=n[2],u=Y(a/=255,f/=255,o/=255),i=(a+f+o)/3,l=i>0?1-u/i:0;return 0===l?t=NaN:(t=(a-f+(a-o))/2,t/=I((a-f)*(a-f)+(a-o)*(f-o)),t=U(t),o>f&&(t=d-t),t/=d),[360*t,l,i]}(this._rgb)},y.hsi=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["hsi"])))},v.format.hsi=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,a,f,o=(r=c(r,"hsi"))[0],u=r[1],i=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*z(d*o)/z(b-d*o))/3)):o<2/3?f=1-((n=(1-u)/3)+(a=(1+u*z(d*(o-=1/3))/z(b-d*o))/3)):n=1-((a=(1-u)/3)+(f=(1+u*z(d*(o-=2/3))/z(b-d*o))/3)),[255*(n=e(i*n*3)),255*(a=e(i*a*3)),255*(f=e(i*f*3)),r.length>3?r[3]:1]},v.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===u(r=c(r,"hsi"))&&3===r.length)return"hsi"}}),m.prototype.hsl=function(){return M(this._rgb)},y.hsl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["hsl"])))},v.format.hsl=x,v.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===u(r=c(r,"hsl"))&&3===r.length)return"hsl"}});var V=Math.floor,X=Math.min,D=Math.max;m.prototype.hsv=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a,f=(r=c(r,"rgb"))[0],o=r[1],u=r[2],i=X(f,o,u),l=D(f,o,u),h=l-i;return a=l/255,0===l?(t=Number.NaN,n=0):(n=h/l,f===l&&(t=(o-u)/h),o===l&&(t=2+(u-f)/h),u===l&&(t=4+(f-o)/h),(t*=60)<0&&(t+=360)),[t,n,a]}(this._rgb)},y.hsv=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["hsv"])))},v.format.hsv=function(){for(var r,e,t,n,a,f,o=[],u=arguments.length;u--;)o[u]=arguments[u];var i,l,h,s=(o=c(o,"hsv"))[0],d=o[1],b=o[2];if(b*=255,0===d)i=l=h=b;else{360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360);var g=V(s/=60),p=s-g,v=b*(1-d),m=b*(1-d*p),y=b*(1-d*(1-p));switch(g){case 0:i=(r=[b,y,v])[0],l=r[1],h=r[2];break;case 1:i=(e=[m,b,v])[0],l=e[1],h=e[2];break;case 2:i=(t=[v,b,y])[0],l=t[1],h=t[2];break;case 3:i=(n=[v,m,b])[0],l=n[1],h=n[2];break;case 4:i=(a=[y,v,b])[0],l=a[1],h=a[2];break;case 5:i=(f=[b,v,m])[0],l=f[1],h=f[2]}}return[i,l,h,o.length>3?o[3]:1]},v.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===u(r=c(r,"hsv"))&&3===r.length)return"hsv"}});var T=18,H=.95047,J=1,K=1.08883,Q=.137931034,W=.206896552,Z=.12841855,rr=.008856452,er=Math.pow,tr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a,f=(r=c(r,"lab"))[0],o=r[1],u=r[2];return n=(f+16)/116,t=isNaN(o)?n:n+o/500,a=isNaN(u)?n:n-u/200,n=J*ar(n),t=H*ar(t),a=K*ar(a),[nr(3.2404542*t-1.5371385*n-.4985314*a),nr(-.969266*t+1.8760108*n+.041556*a),nr(.0556434*t-.2040259*n+1.0572252*a),r.length>3?r[3]:1]},nr=function(r){return 255*(r<=.00304?12.92*r:1.055*er(r,1/2.4)-.055)},ar=function(r){return r>W?r*r*r:Z*(r-Q)},fr=Math.pow,or=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"rgb"),n=t[0],a=t[1],f=t[2],o=ir(n,a,f),u=o[0],i=o[1],l=116*i-16;return[l<0?0:l,500*(u-i),200*(i-o[2])]},ur=function(r){return(r/=255)<=.04045?r/12.92:fr((r+.055)/1.055,2.4)},cr=function(r){return r>rr?fr(r,1/3):r/Z+Q},ir=function(r,e,t){return r=ur(r),e=ur(e),t=ur(t),[cr((.4124564*r+.3575761*e+.1804375*t)/H),cr((.2126729*r+.7151522*e+.072175*t)/J),cr((.0193339*r+.119192*e+.9503041*t)/K)]};m.prototype.lab=function(){return or(this._rgb)},y.lab=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["lab"])))},v.format.lab=tr,v.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===u(r=c(r,"lab"))&&3===r.length)return"lab"}});var lr=Math.sin,hr=Math.cos,sr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"lch"),n=t[0],a=t[1],f=t[2];return isNaN(f)&&(f=0),[n,hr(f*=g)*a,lr(f)*a]},dr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=c(r,"lch"))[0],n=r[1],a=r[2],f=sr(t,n,a),o=f[0],u=f[1],i=f[2],l=tr(o,u,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},br=Math.sqrt,gr=Math.atan2,pr=Math.round,vr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"lab"),n=t[0],a=t[1],f=t[2],o=br(a*a+f*f),u=(gr(f,a)*p+360)%360;return 0===pr(1e4*o)&&(u=Number.NaN),[n,o,u]},mr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"rgb"),n=t[0],a=t[1],f=t[2],o=or(n,a,f),u=o[0],i=o[1],l=o[2];return vr(u,i,l)};m.prototype.lch=function(){return mr(this._rgb)},m.prototype.hcl=function(){return mr(this._rgb).reverse()},y.lch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["lch"])))},y.hcl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["hcl"])))},v.format.lch=dr,v.format.hcl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"hcl").reverse();return dr.apply(void 0,t)},["lch","hcl"].forEach((function(r){return v.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if("array"===u(e=c(e,r))&&3===e.length)return r}})}));var yr={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"};m.prototype.name=function(){for(var r=$(this._rgb,"rgb"),e=0,t=Object.keys(yr);e0;)e[t]=arguments[t+1];if(!e.length&&"string"===u(r)&&yr[r.toLowerCase()])return"named"}});m.prototype.num=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"rgb");return(t[0]<<16)+(t[1]<<8)+t[2]}(this._rgb)},y.num=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["num"])))},v.format.num=function(r){if("number"==u(r)&&r>=0&&r<=16777215)return[r>>16,r>>8&255,255&r,1];throw new Error("unknown num color: "+r)},v.autodetect.push({p:5,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if(1===r.length&&"number"===u(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var wr=Math.round;m.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(wr)},m.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(e,t){return t<3?!1===r?e:wr(e):e}))},y.rgb=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["rgb"])))},v.format.rgb=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"rgba");return void 0===t[3]&&(t[3]=1),t},v.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===u(r=c(r,"rgba"))&&(3===r.length||4===r.length&&"number"==u(r[3])&&r[3]>=0&&r[3]<=1))return"rgb"}});var kr=Math.log,Mr=function(r){var e,t,n,a=r/100;return a<66?(e=255,t=a<6?0:-155.25485562709179-.44596950469579133*(t=a-2)+104.49216199393888*kr(t),n=a<20?0:.8274096064007395*(n=a-10)-254.76935184120902+115.67994401066147*kr(n)):(e=351.97690566805693+.114206453784165*(e=a-55)-40.25366309332127*kr(e),t=325.4494125711974+.07943456536662342*(t=a-50)-28.0852963507957*kr(t),n=255),[e,t,n,1]},Nr=Math.round;m.prototype.temp=m.prototype.kelvin=m.prototype.temperature=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];for(var t,n=c(r,"rgb"),a=n[0],f=n[2],o=1e3,u=4e4;u-o>.4;){var i=Mr(t=.5*(u+o));i[2]/i[0]>=f/a?u=t:o=t}return Nr(t)}(this._rgb)},y.temp=y.kelvin=y.temperature=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["temp"])))},v.format.temp=v.format.kelvin=v.format.temperature=Mr;var _r=Math.pow,xr=Math.sign,Ar=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=c(r,"lab"))[0],n=r[1],a=r[2],f=_r(t+.3963377774*n+.2158037573*a,3),o=_r(t-.1055613458*n-.0638541728*a,3),u=_r(t-.0894841775*n-1.291485548*a,3);return[255*Er(4.0767416621*f-3.3077115913*o+.2309699292*u),255*Er(-1.2684380046*f+2.6097574011*o-.3413193965*u),255*Er(-.0041960863*f-.7034186147*o+1.707614701*u),r.length>3?r[3]:1]};function Er(r){var e=Math.abs(r);return e>.0031308?(xr(r)||1)*(1.055*_r(e,1/2.4)-.055):12.92*r}var Fr=Math.cbrt,jr=Math.pow,Or=Math.sign,qr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"rgb"),n=t[0],a=t[1],f=t[2],o=[Lr(n/255),Lr(a/255),Lr(f/255)],u=o[0],i=o[1],l=o[2],h=Fr(.4122214708*u+.5363325363*i+.0514459929*l),s=Fr(.2119034982*u+.6806995451*i+.1073969566*l),d=Fr(.0883024619*u+.2817188376*i+.6299787005*l);return[.2104542553*h+.793617785*s-.0040720468*d,1.9779984951*h-2.428592205*s+.4505937099*d,.0259040371*h+.7827717662*s-.808675766*d]};function Lr(r){var e=Math.abs(r);return e<.04045?r/12.92:(Or(r)||1)*jr((e+.055)/1.055,2.4)}m.prototype.oklab=function(){return qr(this._rgb)},y.oklab=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["oklab"])))},v.format.oklab=Ar,v.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===u(r=c(r,"oklab"))&&3===r.length)return"oklab"}});m.prototype.oklch=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=c(r,"rgb"),n=t[0],a=t[1],f=t[2],o=qr(n,a,f),u=o[0],i=o[1],l=o[2];return vr(u,i,l)}(this._rgb)},y.oklch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(m,[null].concat(r,["oklch"])))},v.format.oklch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=c(r,"lch"))[0],n=r[1],a=r[2],f=sr(t,n,a),o=f[0],u=f[1],i=f[2],l=Ar(o,u,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},v.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===u(r=c(r,"oklch"))&&3===r.length)return"oklch"}}),m.prototype.alpha=function(r,e){return void 0===e&&(e=!1),void 0!==r&&"number"===u(r)?e?(this._rgb[3]=r,this):new m([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},m.prototype.clipped=function(){return this._rgb._clipped||!1},m.prototype.darken=function(r){void 0===r&&(r=1);var e=this.lab();return e[0]-=T*r,new m(e,"lab").alpha(this.alpha(),!0)},m.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},m.prototype.darker=m.prototype.darken,m.prototype.brighter=m.prototype.brighten,m.prototype.get=function(r){var e=r.split("."),t=e[0],n=e[1],a=this[t]();if(n){var f=t.indexOf(n)-("ok"===t.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+n+" in mode "+t)}return a};var Pr=Math.pow;m.prototype.luminance=function(r,e){if(void 0===e&&(e="rgb"),void 0!==r&&"number"===u(r)){if(0===r)return new m([0,0,0,this._rgb[3]],"rgb");if(1===r)return new m([255,255,255,this._rgb[3]],"rgb");var t=this.luminance(),n=20,a=function(t,f){var o=t.interpolate(f,.5,e),u=o.luminance();return Math.abs(r-u)<1e-7||!n--?o:u>r?a(t,o):a(o,f)},f=(t>r?a(new m([0,0,0]),this):a(this,new m([255,255,255]))).rgb();return new m(f.concat([this._rgb[3]]))}return Gr.apply(void 0,this._rgb.slice(0,3))};var Gr=function(r,e,t){return.2126*(r=Br(r))+.7152*(e=Br(e))+.0722*(t=Br(t))},Br=function(r){return(r/=255)<=.03928?r/12.92:Pr((r+.055)/1.055,2.4)},Cr={};function Rr(r,e,t){void 0===t&&(t=.5);for(var n=[],a=arguments.length-3;a-- >0;)n[a]=arguments[a+3];var f=n[0]||"lrgb";if(Cr[f]||n.length||(f=Object.keys(Cr)[0]),!Cr[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==u(r)&&(r=new m(r)),"object"!==u(e)&&(e=new m(e)),Cr[f](r,e,t).alpha(r.alpha()+t*(e.alpha()-r.alpha()))}m.prototype.mix=m.prototype.interpolate=function(r,e){void 0===e&&(e=.5);for(var t=[],n=arguments.length-2;n-- >0;)t[n]=arguments[n+2];return Rr.apply(void 0,[this,r,e].concat(t))},m.prototype.premultiply=function(r){void 0===r&&(r=!1);var e=this._rgb,t=e[3];return r?(this._rgb=[e[0]*t,e[1]*t,e[2]*t,t],this):new m([e[0]*t,e[1]*t,e[2]*t,t],"rgb")},m.prototype.saturate=function(r){void 0===r&&(r=1);var e=this.lch();return e[1]+=T*r,e[1]<0&&(e[1]=0),new m(e,"lch").alpha(this.alpha(),!0)},m.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},m.prototype.set=function(r,e,t){void 0===t&&(t=!1);var n=r.split("."),a=n[0],f=n[1],o=this[a]();if(f){var c=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(c>-1){if("string"==u(e))switch(e.charAt(0)){case"+":case"-":o[c]+=+e;break;case"*":o[c]*=+e.substr(1);break;case"/":o[c]/=+e.substr(1);break;default:o[c]=+e}else{if("number"!==u(e))throw new Error("unsupported value for Color.set");o[c]=e}var i=new m(o,a);return t?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return o},m.prototype.tint=function(r){void 0===r&&(r=.5);for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Rr.apply(void 0,[this,"white",r].concat(e))},m.prototype.shade=function(r){void 0===r&&(r=.5);for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Rr.apply(void 0,[this,"black",r].concat(e))};Cr.rgb=function(r,e,t){var n=r._rgb,a=e._rgb;return new m(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"rgb")};var Sr=Math.sqrt,$r=Math.pow;Cr.lrgb=function(r,e,t){var n=r._rgb,a=n[0],f=n[1],o=n[2],u=e._rgb,c=u[0],i=u[1],l=u[2];return new m(Sr($r(a,2)*(1-t)+$r(c,2)*t),Sr($r(f,2)*(1-t)+$r(i,2)*t),Sr($r(o,2)*(1-t)+$r(l,2)*t),"rgb")};function zr(r,e,t,n){var a,f,o,u,c,i,l,h,s,d,b,g,p;return"hsl"===n?(o=r.hsl(),u=e.hsl()):"hsv"===n?(o=r.hsv(),u=e.hsv()):"hcg"===n?(o=r.hcg(),u=e.hcg()):"hsi"===n?(o=r.hsi(),u=e.hsi()):"lch"===n||"hcl"===n?(n="hcl",o=r.hcl(),u=e.hcl()):"oklch"===n&&(o=r.oklch().reverse(),u=e.oklch().reverse()),"h"!==n.substr(0,1)&&"oklch"!==n||(c=(a=o)[0],l=a[1],s=a[2],i=(f=u)[0],h=f[1],d=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=s&&0!=s||"hsv"==n||(b=h)):(g=c,1!=d&&0!=d||"hsv"==n||(b=l)):g=c+t*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+t*(h-l)),p=s+t*(d-s),new m("oklch"===n?[p,b,g]:[g,b,p],n)}Cr.lab=function(r,e,t){var n=r.lab(),a=e.lab();return new m(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"lab")};var Yr=function(r,e,t){return zr(r,e,t,"lch")};Cr.lch=Yr,Cr.hcl=Yr;Cr.num=function(r,e,t){var n=r.num(),a=e.num();return new m(n+t*(a-n),"num")};Cr.hcg=function(r,e,t){return zr(r,e,t,"hcg")};Cr.hsi=function(r,e,t){return zr(r,e,t,"hsi")};Cr.hsl=function(r,e,t){return zr(r,e,t,"hsl")};Cr.hsv=function(r,e,t){return zr(r,e,t,"hsv")};Cr.oklab=function(r,e,t){var n=r.oklab(),a=e.oklab();return new m(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"oklab")};Cr.oklch=function(r,e,t){return zr(r,e,t,"oklch")};var Ir=Math.pow,Ur=Math.sqrt,Vr=Math.PI,Xr=Math.cos,Dr=Math.sin,Tr=Math.atan2;function Hr(r,e,t){void 0===e&&(e="lrgb"),void 0===t&&(t=null);var n=r.length;t||(t=Array.from(new Array(n)).map((function(){return 1})));var a=n/t.reduce((function(r,e){return r+e}));if(t.forEach((function(r,e){t[e]*=a})),r=r.map((function(r){return new m(r)})),"lrgb"===e)return Jr(r,t);for(var f=r.shift(),o=f.get(e),u=[],c=0,i=0,l=0;l=360;)b-=360;o[d]=b}else o[d]=o[d]/u[d];return s/=n,new m(o,e).alpha(s>.99999?1:s,!0)}var Jr=function(r,e){for(var n=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new m(t(a))},Kr=Math.pow;function Qr(r){var t="rgb",n=y("#ccc"),a=0,f=[0,1],o=[],c=[0,0],i=!1,l=[],h=!1,s=0,d=1,b=!1,g={},p=!0,v=1,m=function(r){if((r=r||["#fff","#000"])&&"string"===u(r)&&y.brewer&&y.brewer[r.toLowerCase()]&&(r=y.brewer[r.toLowerCase()]),"array"===u(r)){1===r.length&&(r=[r[0],r[0]]),r=r.slice(0);for(var e=0;e2){var b=function(r){if(null!=i){for(var e=i.length-1,t=0;t=i[t];)t++;return t-1}return 0}(r);h=b/(i.length-2)}else h=d!==s?(r-s)/(d-s):1;h=k(h),a||(h=w(h)),1!==v&&(h=Kr(h,v)),h=e(h=c[0]+h*(1-c[0]-c[1]),0,1);var m=Math.floor(1e4*h);if(p&&g[m])f=g[m];else{if("array"===u(l))for(var M=0;M=N&&M===o.length-1){f=l[M];break}if(h>N&&h2){var c=r.map((function(e,t){return t/(r.length-1)})),i=r.map((function(r){return(r-s)/(d-s)}));i.every((function(r,e){return c[e]===r}))||(k=function(r){if(r<=0||r>=1)return r;for(var e=0;r>=i[e+1];)e++;var t=(r-i[e])/(i[e+1]-i[e]);return c[e]+t*(c[e+1]-c[e])})}}return f=[s,d],_},_.mode=function(r){return arguments.length?(t=r,N(),_):t},_.range=function(r,e){return m(r),_},_.out=function(r){return h=r,_},_.spread=function(r){return arguments.length?(a=r,_):a},_.correctLightness=function(r){return null==r&&(r=!0),b=r,N(),w=b?function(r){for(var e=M(0,!0).lab()[0],t=M(1,!0).lab()[0],n=e>t,a=M(r,!0).lab()[0],f=e+(t-e)*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=M(r,!0).lab()[0],o=a-f;return r}:function(r){return r},_},_.padding=function(r){return null!=r?("number"===u(r)&&(r=[r,r]),c=r,_):c},_.colors=function(e,t){arguments.length<2&&(t="hex");var n=[];if(0===arguments.length)n=l.slice(0);else if(1===e)n=[_(.5)];else if(e>1){var a=f[0],o=f[1]-a;n=function(r,e){for(var t=[],n=ra;n?f++:f--)t.push(f);return t}(0,e).map((function(r){return _(a+r/(e-1)*o)}))}else{r=[];var u=[];if(i&&i.length>2)for(var c=1,h=i.length,s=1<=h;s?ch;s?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;n=u.map((function(r){return _(r)}))}return y[t]&&(n=n.map((function(r){return r[t]()}))),n},_.cache=function(r){return null!=r?(p=r,_):p},_.gamma=function(r){return null!=r?(v=r,_):v},_.nodata=function(r){return null!=r?(n=y(r),_):n},_}function Wr(r){var e=function(r){var e,t,n,a,f,o,u;if(2===(r=r.map((function(r){return new m(r)}))).length)e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],a=function(r){var e=[0,1,2].map((function(e){return f[e]+r*(o[e]-f[e])}));return new m(e,"lab")};else if(3===r.length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],u=t[2],a=function(r){var e=[0,1,2].map((function(e){return(1-r)*(1-r)*f[e]+2*(1-r)*r*o[e]+r*r*u[e]}));return new m(e,"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 e=[0,1,2].map((function(e){return(1-r)*(1-r)*(1-r)*f[e]+3*(1-r)*(1-r)*r*o[e]+3*(1-r)*r*r*u[e]+r*r*r*c[e]}));return new m(e,"lab")}}else{if(!(r.length>=5))throw new RangeError("No point in running bezier with only one color.");var i,l,h;i=r.map((function(r){return r.lab()})),h=r.length-1,l=function(r){for(var e=[1,1],t=1;te?e:r}))),Zr.lighten=re(ee((function(r,e){return r>e?r:e}))),Zr.dodge=re(ee((function(r,e){return 255===r||(r=e/255*255/(1-r/255))>255?255:r}))),Zr.burn=re(ee((function(r,e){return 255*(1-(1-e/255)/(r/255))})));var te=Math.pow,ne=Math.sin,ae=Math.cos;function fe(r,e,n,a,f){void 0===r&&(r=300),void 0===e&&(e=-1.5),void 0===n&&(n=1),void 0===a&&(a=1),void 0===f&&(f=[0,1]);var o,c=0;"array"===u(f)?o=f[1]-f[0]:(o=0,f=[f,f]);var i=function(u){var i=d*((r+120)/360+e*u),l=te(f[0]+o*u,a),h=(0!==c?n[0]+u*c:n)*l*(1-l)/2,s=ae(i),b=ne(i);return y(t([255*(l+h*(-.14861*s+1.78277*b)),255*(l+h*(-.29227*s-.90649*b)),255*(l+h*(1.97294*s)),1]))};return i.start=function(e){return null==e?r:(r=e,i)},i.rotations=function(r){return null==r?e:(e=r,i)},i.gamma=function(r){return null==r?a:(a=r,i)},i.hue=function(r){return null==r?n:("array"===u(n=r)?0===(c=n[1]-n[0])&&(n=n[1]):c=0,i)},i.lightness=function(r){return null==r?f:("array"===u(r)?(f=r,o=r[1]-r[0]):(f=[r,r],o=0),i)},i.scale=function(){return y.scale(i)},i.hue(n),i}var oe=Math.floor,ue=Math.random;function ce(){for(var r="#",e=0;e<6;e++)r+="0123456789abcdef".charAt(oe(16*ue()));return new m(r,"hex")}var ie=Math.log,le=Math.pow,he=Math.floor,se=Math.abs;function de(r,e){void 0===e&&(e=null);var t={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===u(r)&&(r=Object.values(r)),r.forEach((function(r){e&&"object"===u(r)&&(r=r[e]),null==r||isNaN(r)||(t.values.push(r),t.sum+=r,rt.max&&(t.max=r),t.count+=1)})),t.domain=[t.min,t.max],t.limits=function(r,e){return be(t,r,e)},t}function be(r,e,t){void 0===e&&(e="equal"),void 0===t&&(t=7),"array"==u(r)&&(r=de(r));var n=r.min,a=r.max,f=r.values.sort((function(r,e){return r-e}));if(1===t)return[n,a];var o=[];if("c"===e.substr(0,1)&&(o.push(n),o.push(a)),"e"===e.substr(0,1)){o.push(n);for(var c=1;c 0");var i=Math.LOG10E*ie(n),l=Math.LOG10E*ie(a);o.push(n);for(var h=1;h200&&(w=!1)}for(var C={},R=0;Rn?(t+.05)/(n+.05):(n+.05)/(t+.05)}var pe=Math.sqrt,ve=Math.pow,me=Math.min,ye=Math.max,we=Math.atan2,ke=Math.abs,Me=Math.cos,Ne=Math.sin,_e=Math.exp,xe=Math.PI;function Ae(r,e,t,n,a){void 0===t&&(t=1),void 0===n&&(n=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*xe)},o=function(r){return 2*xe*r/360};r=new m(r),e=new m(e);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],h=Array.from(e.lab()),s=h[0],d=h[1],b=h[2],g=(c+s)/2,p=(pe(ve(i,2)+ve(l,2))+pe(ve(d,2)+ve(b,2)))/2,v=.5*(1-pe(ve(p,7)/(ve(p,7)+ve(25,7)))),y=i*(1+v),w=d*(1+v),k=pe(ve(y,2)+ve(l,2)),M=pe(ve(w,2)+ve(b,2)),N=(k+M)/2,_=f(we(l,y)),x=f(we(b,w)),A=_>=0?_:_+360,E=x>=0?x:x+360,F=ke(A-E)>180?(A+E+360)/2:(A+E)/2,j=1-.17*Me(o(F-30))+.24*Me(o(2*F))+.32*Me(o(3*F+6))-.2*Me(o(4*F-63)),O=E-A;O=ke(O)<=180?O:E<=A?O+360:O-360,O=2*pe(k*M)*Ne(o(O)/2);var q=s-c,L=M-k,P=1+.015*ve(g-50,2)/pe(20+ve(g-50,2)),G=1+.045*N,B=1+.015*N*j,C=30*_e(-ve((F-275)/25,2)),R=-(2*pe(ve(N,7)/(ve(N,7)+ve(25,7))))*Ne(2*o(C)),S=pe(ve(q/(t*P),2)+ve(L/(n*G),2)+ve(O/(a*B),2)+R*(L/(n*G))*(O/(a*B)));return ye(0,me(100,S))}function Ee(r,e,t){void 0===t&&(t="lab"),r=new m(r),e=new m(e);var n=r.get(t),a=e.get(t),f=0;for(var o in n){var u=(n[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)}function Fe(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];try{return new(Function.prototype.bind.apply(m,[null].concat(r))),!0}catch(r){return!1}}for(var je={cool:function(){return Qr([y.hsl(180,1,.9),y.hsl(250,.7,.4)])},hot:function(){return Qr(["#000","#f00","#ff0","#fff"]).mode("rgb")}},Oe={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},qe=0,Le=Object.keys(Oe);qe convert colors -import './src/io/cmyk/index.js'; -import './src/io/css/index.js'; -import './src/io/gl/index.js'; -import './src/io/hcg/index.js'; -import './src/io/hex/index.js'; -import './src/io/hsi/index.js'; -import './src/io/hsl/index.js'; -import './src/io/hsv/index.js'; -import './src/io/lab/index.js'; -import './src/io/lch/index.js'; import './src/io/named/index.js'; -import './src/io/num/index.js'; -import './src/io/rgb/index.js'; -import './src/io/temp/index.js'; -import './src/io/oklab/index.js'; -import './src/io/oklch/index.js'; // operators --> modify existing Colors import './src/ops/alpha.js'; @@ -117,3 +101,19 @@ export { scales, valid }; + +export * from './src/io/cmyk/index.js'; +export * from './src/io/css/index.js'; +export * from './src/io/gl/index.js'; +export * from './src/io/hcg/index.js'; +export * from './src/io/hex/index.js'; +export * from './src/io/hsi/index.js'; +export * from './src/io/hsl/index.js'; +export * from './src/io/hsv/index.js'; +export * from './src/io/lab/index.js'; +export * from './src/io/lch/index.js'; +export * from './src/io/num/index.js'; +export * from './src/io/rgb/index.js'; +export * from './src/io/temp/index.js'; +export * from './src/io/oklab/index.js'; +export * from './src/io/oklch/index.js'; diff --git a/index.umd.js b/index.umd.js new file mode 100644 index 00000000..0dc10314 --- /dev/null +++ b/index.umd.js @@ -0,0 +1,117 @@ +// feel free to comment out anything to rollup +// a smaller chroma.js bundle +import chroma from './src/chroma.js'; + +// io --> convert colors +import { cmyk } from './src/io/cmyk/index.js'; +import { css } from './src/io/css/index.js'; +import { gl } from './src/io/gl/index.js'; +import { hcg } from './src/io/hcg/index.js'; +import { hex } from './src/io/hex/index.js'; +import { hsi } from './src/io/hsi/index.js'; +import { hsl } from './src/io/hsl/index.js'; +import { hsv } from './src/io/hsv/index.js'; +import { lab, getLabWhitePoint, setLabWhitePoint } from './src/io/lab/index.js'; +import { lch, hcl } from './src/io/lch/index.js'; +import { num } from './src/io/num/index.js'; +import { rgb } from './src/io/rgb/index.js'; +import { temp, kelvin, temperature } from './src/io/temp/index.js'; +import { oklab } from './src/io/oklab/index.js'; +import { oklch } from './src/io/oklch/index.js'; + +import './src/io/named/index.js'; + +// operators --> modify existing Colors +import './src/ops/alpha.js'; +import './src/ops/clipped.js'; +import './src/ops/darken.js'; +import './src/ops/get.js'; +import './src/ops/luminance.js'; +import './src/ops/mix.js'; +import './src/ops/premultiply.js'; +import './src/ops/saturate.js'; +import './src/ops/set.js'; +import './src/ops/shade.js'; + +// interpolators +import './src/interpolator/rgb.js'; +import './src/interpolator/lrgb.js'; +import './src/interpolator/lab.js'; +import './src/interpolator/lch.js'; +import './src/interpolator/num.js'; +import './src/interpolator/hcg.js'; +import './src/interpolator/hsi.js'; +import './src/interpolator/hsl.js'; +import './src/interpolator/hsv.js'; +import './src/interpolator/oklab.js'; +import './src/interpolator/oklch.js'; + +// generators -- > create new colors +import average from './src/generator/average.js'; +import bezier from './src/generator/bezier.js'; +import blend from './src/generator/blend.js'; +import cubehelix from './src/generator/cubehelix.js'; +import mix from './src/generator/mix.js'; +import random from './src/generator/random.js'; +import scale from './src/generator/scale.js'; + +// other utility methods +import { analyze } from './src/utils/analyze.js'; +import contrast from './src/utils/contrast.js'; +import deltaE from './src/utils/delta-e.js'; +import distance from './src/utils/distance.js'; +import { limits } from './src/utils/analyze.js'; +import valid from './src/utils/valid.js'; +import input from './src/io/input.js'; + +// scale +import scales from './src/utils/scales.js'; + +// colors +import colors from './src/colors/w3cx11.js'; +import brewer from './src/colors/colorbrewer.js'; +import Color from './src/Color.js'; + +Object.assign(chroma, { + analyze, + average, + bezier, + blend, + brewer, + Color, + colors, + contrast, + cubehelix, + deltaE, + distance, + input, + interpolate: mix, + limits, + mix, + random, + scale, + scales, + valid, + cmyk, + css, + gl, + hcg, + hex, + hsi, + hsl, + hsv, + lab, + lch, + hcl, + num, + rgb, + temp, + kelvin, + temperature, + oklab, + oklch, + getLabWhitePoint, + setLabWhitePoint +}); + +export default chroma; diff --git a/index-light.js b/index.umd.light.js similarity index 66% rename from index-light.js rename to index.umd.light.js index b530fa7f..c8d0402c 100644 --- a/index-light.js +++ b/index.umd.light.js @@ -1,15 +1,15 @@ import chroma from './src/chroma.js'; // feel free to comment out anything to rollup -// a smaller chroma.js built +// a smaller chroma.js bundle // io --> convert colors -import './src/io/css/index.js'; -import './src/io/hex/index.js'; -import './src/io/hsl/index.js'; -import './src/io/lab/index.js'; -import './src/io/oklab/index.js'; -import './src/io/rgb/index.js'; +import { css } from './src/io/css/index.js'; +import { hex } from './src/io/hex/index.js'; +import { hsl } from './src/io/hsl/index.js'; +import { lab } from './src/io/lab/index.js'; +import { oklab } from './src/io/oklab/index.js'; +import { rgb } from './src/io/rgb/index.js'; // operators --> modify existing Colors import './src/ops/alpha.js'; @@ -28,16 +28,19 @@ import mix from './src/generator/mix.js'; // other utility methods import valid from './src/utils/valid.js'; - import Color from './src/Color.js'; Object.assign(chroma, { Color, valid, + css, + hex, + hsl, + lab, + oklab, + rgb, mix, interpolate: mix }); export default chroma; - -export { Color, valid, mix, mix as interpolate }; diff --git a/package.json b/package.json index 1c5f2605..68537b69 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "chroma-js", "description": "JavaScript library for color conversions", - "version": "2.6.0", + "version": "2.6.1-1", "packageManager": "pnpm@9.6.0", "author": "Gregor Aisch", "type": "module", @@ -39,8 +39,8 @@ "docs-preview": "cd docs && make && make preview", "test": "vitest", "test:update": "vitest -u", - "lint": "prettier --check index.js index-light.js src *.config.js test && eslint index.js index-light.js src", - "format": "prettier --write index.js index-light.js src *.config.js test", + "lint": "prettier --check index.js index.umd.js index.umd.light.js src *.config.js test && eslint index.js index.umd.js index.umd.light.js src", + "format": "prettier --write index.js index.umd.js index.umd.light.js src *.config.js test", "prepare": "husky" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 12f56124..51ba2996 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -400,55 +400,46 @@ packages: resolution: {integrity: sha512-MXg1xp+e5GhZ3Vit1gGEyoC+dyQUBy2JgVQ+3hUrD9wZMkUw/ywgkpK7oZgnB6kPpGrxJ41clkPPnsknuD6M2Q==} cpu: [arm] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.19.1': resolution: {integrity: sha512-DZNLwIY4ftPSRVkJEaxYkq7u2zel7aah57HESuNkUnz+3bZHxwkCUkrfS2IWC1sxK6F2QNIR0Qr/YXw7nkF3Pw==} cpu: [arm] os: [linux] - libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.19.1': resolution: {integrity: sha512-C7evongnjyxdngSDRRSQv5GvyfISizgtk9RM+z2biV5kY6S/NF/wta7K+DanmktC5DkuaJQgoKGf7KUDmA7RUw==} cpu: [arm64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.19.1': resolution: {integrity: sha512-89tFWqxfxLLHkAthAcrTs9etAoBFRduNfWdl2xUs/yLV+7XDrJ5yuXMHptNqf1Zw0UCA3cAutkAiAokYCkaPtw==} cpu: [arm64] os: [linux] - libc: [musl] '@rollup/rollup-linux-powerpc64le-gnu@4.19.1': resolution: {integrity: sha512-PromGeV50sq+YfaisG8W3fd+Cl6mnOOiNv2qKKqKCpiiEke2KiKVyDqG/Mb9GWKbYMHj5a01fq/qlUR28PFhCQ==} cpu: [ppc64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.19.1': resolution: {integrity: sha512-/1BmHYh+iz0cNCP0oHCuF8CSiNj0JOGf0jRlSo3L/FAyZyG2rGBuKpkZVH9YF+x58r1jgWxvm1aRg3DHrLDt6A==} cpu: [riscv64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.19.1': resolution: {integrity: sha512-0cYP5rGkQWRZKy9/HtsWVStLXzCF3cCBTRI+qRL8Z+wkYlqN7zrSYm6FuY5Kd5ysS5aH0q5lVgb/WbG4jqXN1Q==} cpu: [s390x] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.19.1': resolution: {integrity: sha512-XUXeI9eM8rMP8aGvii/aOOiMvTs7xlCosq9xCjcqI9+5hBxtjDpD+7Abm1ZhVIFE1J2h2VIg0t2DX/gjespC2Q==} cpu: [x64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-musl@4.19.1': resolution: {integrity: sha512-V7cBw/cKXMfEVhpSvVZhC+iGifD6U1zJ4tbibjjN+Xi3blSXaj/rJynAkCFFQfoG6VZrAiP7uGVzL440Q6Me2Q==} cpu: [x64] os: [linux] - libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.19.1': resolution: {integrity: sha512-88brja2vldW/76jWATlBqHEoGjJLRnP0WOEKAUbMcXaAZnemNhlAHSyj4jIwMoP2T750LE9lblvD4e2jXleZsA==} diff --git a/rollup.config.js b/rollup.config.js index 0cdc12f6..b479a39c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -12,8 +12,8 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); export default [ - bundle('index.js', 'chroma'), - bundle('index-light.js', 'chroma-light') + bundle('index.umd.js', 'chroma'), + bundle('index.umd.light.js', 'chroma-light') ]; function bundle(input, target) { @@ -22,6 +22,8 @@ function bundle(input, target) { output: { file: `dist/${target}${minify ? '.min' : ''}.cjs`, format: 'umd', + globals: {}, // If you have any external dependencies, list them here + exports: 'default', name: 'chroma' }, plugins: [ diff --git a/src/Color.js b/src/Color.js index cef677b2..995c059a 100644 --- a/src/Color.js +++ b/src/Color.js @@ -17,10 +17,12 @@ class Color { let autodetect = false; if (!mode) { autodetect = true; + if (!_input.sorted) { _input.autodetect = _input.autodetect.sort((a, b) => b.p - a.p); _input.sorted = true; } + // auto-detect format for (let chk of _input.autodetect) { mode = chk.test(...args); diff --git a/src/io/cmyk/index.js b/src/io/cmyk/index.js index d0af3743..9bbf6a9c 100644 --- a/src/io/cmyk/index.js +++ b/src/io/cmyk/index.js @@ -9,7 +9,8 @@ Color.prototype.cmyk = function () { return rgb2cmyk(this._rgb); }; -chroma.cmyk = (...args) => new Color(...args, 'cmyk'); +const cmyk = (...args) => new Color(...args, 'cmyk'); +Object.assign(chroma, { cmyk }); input.format.cmyk = cmyk2rgb; @@ -22,3 +23,5 @@ input.autodetect.push({ } } }); + +export { cmyk }; diff --git a/src/io/css/css2rgb.js b/src/io/css/css2rgb.js index ccf141d6..5a6a8b3a 100644 --- a/src/io/css/css2rgb.js +++ b/src/io/css/css2rgb.js @@ -1,5 +1,6 @@ import hsl2rgb from '../hsl/hsl2rgb.js'; import lab2rgb from '../lab/lab2rgb.js'; +import lch2rgb from '../lch/lch2rgb.js'; // import oklab2rgb from '../oklab/oklab2rgb.js'; import input from '../input.js'; import limit from '../../utils/limit.js'; @@ -34,6 +35,8 @@ const RE_HSLA_LEGACY = const RE_LAB = /^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; +const RE_LCH = + /^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; // const RE_OKLAB = // /^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; @@ -56,6 +59,10 @@ const percentToAbsolute = (pct, min = 0, max = 100, signed = false) => { return +pct; }; +const noneToValue = (v, noneValue) => { + return v === 'none' ? noneValue : v; +}; + const css2rgb = (css) => { css = css.toLowerCase().trim(); let m; @@ -142,6 +149,16 @@ const css2rgb = (css) => { return rgb; } + if ((m = css.match(RE_LCH))) { + const lch = m.slice(1, 4); + lch[0] = percentToAbsolute(lch[0], 0, 100); + lch[1] = percentToAbsolute(noneToValue(lch[1], 0), 0, 150, false); + lch[2] = +noneToValue(lch[2].replace('deg', ''), 0); + const rgb = roundRGB(lch2rgb(lch)); + rgb[3] = m[4] !== undefined ? +m[4] : 1; + return rgb; + } + // if ((m = css.match(RE_OKLAB))) { // const oklab = m.slice(1, 4); // oklab[0] = percentToAbsolute(oklab[0], 0, 1); diff --git a/src/io/css/index.js b/src/io/css/index.js index c4592160..2855e64c 100644 --- a/src/io/css/index.js +++ b/src/io/css/index.js @@ -10,7 +10,8 @@ Color.prototype.css = function (mode) { return rgb2css(this._rgb, mode); }; -chroma.css = (...args) => new Color(...args, 'css'); +const css = (...args) => new Color(...args, 'css'); +chroma.css = css; input.format.css = css2rgb; @@ -22,3 +23,5 @@ input.autodetect.push({ } } }); + +export { css }; diff --git a/src/io/gl/index.js b/src/io/gl/index.js index 7c24af9c..8dd07fc4 100644 --- a/src/io/gl/index.js +++ b/src/io/gl/index.js @@ -11,9 +11,12 @@ input.format.gl = (...args) => { return rgb; }; -chroma.gl = (...args) => new Color(...args, 'gl'); +const gl = (...args) => new Color(...args, 'gl'); +chroma.gl = gl; Color.prototype.gl = function () { const rgb = this._rgb; return [rgb[0] / 255, rgb[1] / 255, rgb[2] / 255, rgb[3]]; }; + +export { gl }; diff --git a/src/io/hcg/index.js b/src/io/hcg/index.js index ca71f923..e1d32b5a 100644 --- a/src/io/hcg/index.js +++ b/src/io/hcg/index.js @@ -9,7 +9,8 @@ Color.prototype.hcg = function () { return rgb2hcg(this._rgb); }; -chroma.hcg = (...args) => new Color(...args, 'hcg'); +const hcg = (...args) => new Color(...args, 'hcg'); +chroma.hcg = hcg; input.format.hcg = hcg2rgb; @@ -22,3 +23,5 @@ input.autodetect.push({ } } }); + +export { hcg }; diff --git a/src/io/hex/index.js b/src/io/hex/index.js index db94e868..fc2aace8 100644 --- a/src/io/hex/index.js +++ b/src/io/hex/index.js @@ -1,5 +1,5 @@ -import chroma from '../../chroma.js'; import Color from '../../Color.js'; +import chroma from '../../chroma.js'; import { type } from '../../utils/index.js'; import input from '../input.js'; import hex2rgb from './hex2rgb.js'; @@ -9,7 +9,8 @@ Color.prototype.hex = function (mode) { return rgb2hex(this._rgb, mode); }; -chroma.hex = (...args) => new Color(...args, 'hex'); +const hex = (...args) => new Color(...args, 'hex'); +chroma.hex = hex; input.format.hex = hex2rgb; input.autodetect.push({ @@ -24,3 +25,5 @@ input.autodetect.push({ } } }); + +export { hex }; diff --git a/src/io/hsi/index.js b/src/io/hsi/index.js index 5b1bf3bb..1fe6b7e3 100644 --- a/src/io/hsi/index.js +++ b/src/io/hsi/index.js @@ -9,7 +9,8 @@ Color.prototype.hsi = function () { return rgb2hsi(this._rgb); }; -chroma.hsi = (...args) => new Color(...args, 'hsi'); +const hsi = (...args) => new Color(...args, 'hsi'); +chroma.hsi = hsi; input.format.hsi = hsi2rgb; @@ -22,3 +23,5 @@ input.autodetect.push({ } } }); + +export { hsi }; diff --git a/src/io/hsl/index.js b/src/io/hsl/index.js index 4e88aebf..d47b7d1a 100644 --- a/src/io/hsl/index.js +++ b/src/io/hsl/index.js @@ -9,7 +9,8 @@ Color.prototype.hsl = function () { return rgb2hsl(this._rgb); }; -chroma.hsl = (...args) => new Color(...args, 'hsl'); +const hsl = (...args) => new Color(...args, 'hsl'); +chroma.hsl = hsl; input.format.hsl = hsl2rgb; @@ -22,3 +23,5 @@ input.autodetect.push({ } } }); + +export { hsl }; diff --git a/src/io/hsv/index.js b/src/io/hsv/index.js index 51509445..3ad72bb2 100644 --- a/src/io/hsv/index.js +++ b/src/io/hsv/index.js @@ -9,7 +9,8 @@ Color.prototype.hsv = function () { return rgb2hsv(this._rgb); }; -chroma.hsv = (...args) => new Color(...args, 'hsv'); +const hsv = (...args) => new Color(...args, 'hsv'); +chroma.hsv = hsv; input.format.hsv = hsv2rgb; @@ -22,3 +23,5 @@ input.autodetect.push({ } } }); + +export { hsv }; diff --git a/src/io/lab/index.js b/src/io/lab/index.js index 3e2df1a0..afa5650f 100644 --- a/src/io/lab/index.js +++ b/src/io/lab/index.js @@ -10,9 +10,8 @@ Color.prototype.lab = function () { return rgb2lab(this._rgb); }; -chroma.lab = (...args) => new Color(...args, 'lab'); -chroma.setLabWhitePoint = setLabWhitePoint; -chroma.getLabWhitePoint = getLabWhitePoint; +const lab = (...args) => new Color(...args, 'lab'); +Object.assign(chroma, { lab, getLabWhitePoint, setLabWhitePoint }); input.format.lab = lab2rgb; @@ -25,3 +24,5 @@ input.autodetect.push({ } } }); + +export { lab, getLabWhitePoint, setLabWhitePoint }; diff --git a/src/io/lch/index.js b/src/io/lch/index.js index 9a74608d..04dc2ad5 100644 --- a/src/io/lch/index.js +++ b/src/io/lch/index.js @@ -13,8 +13,10 @@ Color.prototype.hcl = function () { return rgb2lch(this._rgb).reverse(); }; -chroma.lch = (...args) => new Color(...args, 'lch'); -chroma.hcl = (...args) => new Color(...args, 'hcl'); +const lch = (...args) => new Color(...args, 'lch'); +const hcl = (...args) => new Color(...args, 'hcl'); + +Object.assign(chroma, { lch, hcl }); input.format.lch = lch2rgb; input.format.hcl = hcl2rgb; @@ -29,3 +31,5 @@ input.format.hcl = hcl2rgb; } }) ); + +export { lch, hcl }; diff --git a/src/io/num/index.js b/src/io/num/index.js index 2b06e2a1..b8c70cb8 100644 --- a/src/io/num/index.js +++ b/src/io/num/index.js @@ -9,7 +9,9 @@ Color.prototype.num = function () { return rgb2num(this._rgb); }; -chroma.num = (...args) => new Color(...args, 'num'); +const num = (...args) => new Color(...args, 'num'); + +Object.assign(chroma, { num }); input.format.num = num2rgb; @@ -26,3 +28,5 @@ input.autodetect.push({ } } }); + +export { num }; diff --git a/src/io/oklab/index.js b/src/io/oklab/index.js index 653cacf2..a2b628cb 100644 --- a/src/io/oklab/index.js +++ b/src/io/oklab/index.js @@ -9,12 +9,13 @@ Color.prototype.oklab = function () { return rgb2oklab(this._rgb); }; -chroma.oklab = (...args) => new Color(...args, 'oklab'); +const oklab = (...args) => new Color(...args, 'oklab'); +Object.assign(chroma, { oklab }); input.format.oklab = oklab2rgb; input.autodetect.push({ - p: 3, + p: 2, test: (...args) => { args = unpack(args, 'oklab'); if (type(args) === 'array' && args.length === 3) { @@ -22,3 +23,5 @@ input.autodetect.push({ } } }); + +export { oklab }; diff --git a/src/io/oklch/index.js b/src/io/oklch/index.js index 98de7b9d..15e621dd 100644 --- a/src/io/oklch/index.js +++ b/src/io/oklch/index.js @@ -9,12 +9,13 @@ Color.prototype.oklch = function () { return rgb2oklch(this._rgb); }; -chroma.oklch = (...args) => new Color(...args, 'oklch'); +const oklch = (...args) => new Color(...args, 'oklch'); +Object.assign(chroma, { oklch }); input.format.oklch = oklch2rgb; input.autodetect.push({ - p: 3, + p: 2, test: (...args) => { args = unpack(args, 'oklch'); if (type(args) === 'array' && args.length === 3) { @@ -22,3 +23,5 @@ input.autodetect.push({ } } }); + +export { oklch }; diff --git a/src/io/rgb/index.js b/src/io/rgb/index.js index 0585f84b..c903dc96 100644 --- a/src/io/rgb/index.js +++ b/src/io/rgb/index.js @@ -15,7 +15,8 @@ Color.prototype.rgba = function (rnd = true) { }); }; -chroma.rgb = (...args) => new Color(...args, 'rgb'); +const rgb = (...args) => new Color(...args, 'rgb'); +Object.assign(chroma, { rgb }); input.format.rgb = (...args) => { const rgba = unpack(args, 'rgba'); @@ -39,3 +40,5 @@ input.autodetect.push({ } } }); + +export { rgb }; diff --git a/src/io/temp/index.js b/src/io/temp/index.js index 757fc413..0d8b34ac 100644 --- a/src/io/temp/index.js +++ b/src/io/temp/index.js @@ -11,12 +11,12 @@ Color.prototype.temp = return rgb2temperature(this._rgb); }; -chroma.temp = - chroma.kelvin = - chroma.temperature = - (...args) => new Color(...args, 'temp'); +const temp = (...args) => new Color(...args, 'temp'); +Object.assign(chroma, { temp, kelvin: temp, temperature: temp }); input.format.temp = input.format.kelvin = input.format.temperature = temperature2rgb; + +export { temp, temp as kelvin, temp as temperature }; diff --git a/src/version.js b/src/version.js index 9efda466..9a1cc94f 100644 --- a/src/version.js +++ b/src/version.js @@ -1,2 +1,2 @@ // this gets updated automatically -export const version = '2.6.0'; +export const version = '2.6.1-1'; diff --git a/test/io/css2rgb.test.js b/test/io/css2rgb.test.js index 140ade9f..9fe7d1d7 100644 --- a/test/io/css2rgb.test.js +++ b/test/io/css2rgb.test.js @@ -34,6 +34,7 @@ describe('Testing CSS2RGB color conversions', () => { 'lab(47.99% -30.39 -8.98)': [0, 128, 128, 1], 'lab(47.99% -30.39 -8.98 / 0.25)': [0, 128, 128, 0.25], 'lab(47.99% -24.312% -7.13%)': [0, 128, 128, 1] + // 'oklab(92.83% -0.08 0.13)': [212, 248, 128, 1], // 'oklab(92.83% -0.08 0.13 / 0.5)': [212, 248, 128, 0.5] }; diff --git a/test/io/rgb2css.test.js b/test/io/rgb2css.test.js index 055bace6..f2594a6f 100644 --- a/test/io/rgb2css.test.js +++ b/test/io/rgb2css.test.js @@ -51,7 +51,7 @@ const tests = { } }; -describe.only('Testing rgb2css color conversions', () => { +describe('Testing rgb2css color conversions', () => { Object.keys(tests).forEach((key) => { const { rgb, mode, css } = tests[key];