palette-gen
Version:
A module for generating a palette that including a series colors
10 lines (8 loc) • 26.4 kB
JavaScript
/**
* Bundle of palette-gen
* Generated: 2022-03-30
* Version: 0.1.0
* License: MIT
* Author: 2631541504@qq.com
*/
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((r="undefined"!=typeof globalThis?globalThis:r||self).PaletteGen={})}(this,function(r){"use strict";function h(r){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}function l(r,n){return function(r){if(Array.isArray(r))return r}(r)||function(r,n){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,a,o=[],l=!0,i=!1;try{for(t=t.call(r);!(l=(e=t.next()).done)&&(o.push(e.value),!n||o.length!==n);l=!0);}catch(r){i=!0,a=r}finally{try{l||null==t.return||t.return()}finally{if(i)throw a}}return o}}(r,n)||i(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(r,n){if(r){if("string"==typeof r)return e(r,n);var t=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(t="Object"===t&&r.constructor?r.constructor.name:t)||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?e(r,n):void 0}}function e(r,n){(null==n||n>r.length)&&(n=r.length);for(var t=0,e=new Array(n);t<n;t++)e[t]=r[t];return e}function s(r,n){var t,e="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!e){if(Array.isArray(r)||(e=i(r))||n&&r&&"number"==typeof r.length)return e&&(r=e),t=0,{s:n=function(){},n:function(){return t>=r.length?{done:!0}:{done:!1,value:r[t++]}},e:function(r){throw r},f:n};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){e=e.call(r)},n:function(){var r=e.next();return o=r.done,r},e:function(r){l=!0,a=r},f:function(){try{o||null==e.return||e.return()}finally{if(l)throw a}}}}function n(r,n){return r(n={exports:{}},n.exports),n.exports}for(var u={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},o=n(function(r){var l=Array.prototype.concat,i=Array.prototype.slice,n=r.exports=function(r){for(var n,t=[],e=0,a=r.length;e<a;e++){var o=r[e];(n=o)&&"string"!=typeof n&&(n instanceof Array||Array.isArray(n)||0<=n.length&&(n.splice instanceof Function||Object.getOwnPropertyDescriptor(n,n.length-1)&&"String"!==n.constructor.name))?t=l.call(t,i.call(o)):t.push(o)}return t};n.wrap=function(r){return function(){return r(n(arguments))}}}),c=n(function(r){var n,l=Object.hasOwnProperty,t={};for(n in u)l.call(u,n)&&(t[u[n]]=n);var e=r.exports={to:{},get:{}};function i(r,n,t){return Math.min(Math.max(n,r),t)}function a(r){r=Math.round(r).toString(16).toUpperCase();return r.length<2?"0"+r:r}e.get=function(r){var n,t;switch(r.substring(0,3).toLowerCase()){case"hsl":n=e.get.hsl(r),t="hsl";break;case"hwb":n=e.get.hwb(r),t="hwb";break;default:n=e.get.rgb(r),t="rgb"}return n?{model:t,value:n}:null},e.get.rgb=function(r){if(!r)return null;var n,t,e,a=[0,0,0,1];if(n=r.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(e=n[2],n=n[1],t=0;t<3;t++){var o=2*t;a[t]=parseInt(n.slice(o,2+o),16)}e&&(a[3]=parseInt(e,16)/255)}else if(n=r.match(/^#([a-f0-9]{3,4})$/i)){for(e=(n=n[1])[3],t=0;t<3;t++)a[t]=parseInt(n[t]+n[t],16);e&&(a[3]=parseInt(e+e,16)/255)}else if(n=r.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(t=0;t<3;t++)a[t]=parseInt(n[t+1],0);n[4]&&(n[5]?a[3]=.01*parseFloat(n[4]):a[3]=parseFloat(n[4]))}else{if(!(n=r.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(n=r.match(/^(\w+)$/))?"transparent"===n[1]?[0,0,0,0]:l.call(u,n[1])?((a=u[n[1]])[3]=1,a):null:null;for(t=0;t<3;t++)a[t]=Math.round(2.55*parseFloat(n[t+1]));n[4]&&(n[5]?a[3]=.01*parseFloat(n[4]):a[3]=parseFloat(n[4]))}for(t=0;t<3;t++)a[t]=i(a[t],0,255);return a[3]=i(a[3],0,1),a},e.get.hsl=function(r){if(!r)return null;var n,r=r.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);return r?(n=parseFloat(r[4]),[(parseFloat(r[1])%360+360)%360,i(parseFloat(r[2]),0,100),i(parseFloat(r[3]),0,100),i(isNaN(n)?1:n,0,1)]):null},e.get.hwb=function(r){if(!r)return null;var n,r=r.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);return r?(n=parseFloat(r[4]),[(parseFloat(r[1])%360+360)%360,i(parseFloat(r[2]),0,100),i(parseFloat(r[3]),0,100),i(isNaN(n)?1:n,0,1)]):null},e.to.hex=function(){var r=o(arguments);return"#"+a(r[0])+a(r[1])+a(r[2])+(r[3]<1?a(Math.round(255*r[3])):"")},e.to.rgb=function(){var r=o(arguments);return r.length<4||1===r[3]?"rgb("+Math.round(r[0])+", "+Math.round(r[1])+", "+Math.round(r[2])+")":"rgba("+Math.round(r[0])+", "+Math.round(r[1])+", "+Math.round(r[2])+", "+r[3]+")"},e.to.rgb.percent=function(){var r=o(arguments),n=Math.round(r[0]/255*100),t=Math.round(r[1]/255*100),e=Math.round(r[2]/255*100);return r.length<4||1===r[3]?"rgb("+n+"%, "+t+"%, "+e+"%)":"rgba("+n+"%, "+t+"%, "+e+"%, "+r[3]+")"},e.to.hsl=function(){var r=o(arguments);return r.length<4||1===r[3]?"hsl("+r[0]+", "+r[1]+"%, "+r[2]+"%)":"hsla("+r[0]+", "+r[1]+"%, "+r[2]+"%, "+r[3]+")"},e.to.hwb=function(){var r=o(arguments),n="";return 4<=r.length&&1!==r[3]&&(n=", "+r[3]),"hwb("+r[0]+", "+r[1]+"%, "+r[2]+"%"+n+")"},e.to.keyword=function(r){return t[r.slice(0,3)]}}),f=(c.to,c.get,{}),t=0,a=Object.keys(u);t<a.length;t++){var g=a[t];f[u[g]]=g}for(var b={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},d=b,p=0,v=Object.keys(b);p<v.length;p++){var y=v[p];if(!("channels"in b[y]))throw new Error("missing channels property: "+y);if(!("labels"in b[y]))throw new Error("missing channel labels property: "+y);if(b[y].labels.length!==b[y].channels)throw new Error("channel and label counts mismatch: "+y);var m=b[y],$=m.channels,m=m.labels;delete b[y].channels,delete b[y].labels,Object.defineProperty(b[y],"channels",{value:$}),Object.defineProperty(b[y],"labels",{value:m})}function C(r){var n=function(){for(var r={},n=Object.keys(d),t=n.length,e=0;e<t;e++)r[n[e]]={distance:-1,parent:null};return r}(),t=[r];for(n[r].distance=0;t.length;)for(var e=t.pop(),a=Object.keys(d[e]),o=a.length,l=0;l<o;l++){var i=a[l],h=n[i];-1===h.distance&&(h.distance=n[e].distance+1,h.parent=e,t.unshift(i))}return n}function T(r,n){for(var t=[n[r].parent,r],e=d[n[r].parent][r],a=n[r].parent;n[a].parent;)t.unshift(n[a].parent),e=function(n,t){return function(r){return t(n(r))}}(d[n[a].parent][a],e),a=n[a].parent;return e.conversion=t,e}b.rgb.hsl=function(r){var n,t=r[0]/255,e=r[1]/255,r=r[2]/255,a=Math.min(t,e,r),o=Math.max(t,e,r),l=o-a,r=(o===a?n=0:t===o?n=(e-r)/l:e===o?n=2+(r-t)/l:r===o&&(n=4+(t-e)/l),(n=Math.min(60*n,360))<0&&(n+=360),(a+o)/2),t=o===a?0:r<=.5?l/(o+a):l/(2-o-a);return[n,100*t,100*r]},b.rgb.hsv=function(r){function n(r){return(s-r)/6/u+.5}var t,e,a,o,l,i=r[0]/255,h=r[1]/255,r=r[2]/255,s=Math.max(i,h,r),u=s-Math.min(i,h,r);return 0==u?l=o=0:(l=u/s,t=n(i),e=n(h),a=n(r),i===s?o=a-e:h===s?o=1/3+t-a:r===s&&(o=2/3+e-t),o<0?o+=1:1<o&&--o),[360*o,100*l,100*s]},b.rgb.hwb=function(r){var n=r[0],t=r[1],e=r[2];return[b.rgb.hsl(r)[0],100*(1/255*Math.min(n,Math.min(t,e))),100*(1-1/255*Math.max(n,Math.max(t,e)))]},b.rgb.cmyk=function(r){var n=r[0]/255,t=r[1]/255,r=r[2]/255,e=Math.min(1-n,1-t,1-r);return[100*((1-n-e)/(1-e)||0),100*((1-t-e)/(1-e)||0),100*((1-r-e)/(1-e)||0),100*e]},b.rgb.keyword=function(r){var n=f[r];if(n)return n;for(var t,e,a=1/0,o=0,l=Object.keys(u);o<l.length;o++){var i=l[o],h=(h=r,e=u[i],Math.pow(h[0]-e[0],2)+Math.pow(h[1]-e[1],2)+Math.pow(h[2]-e[2],2));h<a&&(a=h,t=i)}return t},b.keyword.rgb=function(r){return u[r]},b.rgb.xyz=function(r){var n=r[0]/255,t=r[1]/255,r=r[2]/255;return[100*(.4124*(n=.04045<n?Math.pow((n+.055)/1.055,2.4):n/12.92)+.3576*(t=.04045<t?Math.pow((t+.055)/1.055,2.4):t/12.92)+.1805*(r=.04045<r?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*n+.7152*t+.0722*r),100*(.0193*n+.1192*t+.9505*r)]},b.rgb.lab=function(r){var r=b.rgb.xyz(r),n=r[0],t=r[1],r=r[2];return t/=100,r/=108.883,n=.008856<(n/=95.047)?Math.pow(n,1/3):7.787*n+16/116,[116*(t=.008856<t?Math.pow(t,1/3):7.787*t+16/116)-16,500*(n-t),200*(t-(r=.008856<r?Math.pow(r,1/3):7.787*r+16/116))]},b.hsl.rgb=function(r){var n,t,e=r[0]/360,a=r[1]/100,r=r[2]/100;if(0==a)return[t=255*r,t,t];for(var o,l=2*r-(o=r<.5?r*(1+a):r+a-r*a),i=[0,0,0],h=0;h<3;h++)(n=e+1/3*-(h-1))<0&&n++,1<n&&n--,i[h]=255*(t=6*n<1?l+6*(o-l)*n:2*n<1?o:3*n<2?l+(o-l)*(2/3-n)*6:l);return i},b.hsl.hsv=function(r){var n=r[0],t=r[1]/100,r=r[2]/100,e=t,a=Math.max(r,.01),o=(e*=a<=1?a:2-a,((r*=2)+(t*=r<=1?r:2-r))/2);return[n,100*(0==r?2*e/(a+e):2*t/(r+t)),100*o]},b.hsv.rgb=function(r){var n=r[0]/60,t=r[1]/100,e=r[2]/100,r=Math.floor(n)%6,n=n-Math.floor(n),a=255*e*(1-t),o=255*e*(1-t*n),l=255*e*(1-t*(1-n));switch(e*=255,r){case 0:return[e,l,a];case 1:return[o,e,a];case 2:return[a,e,l];case 3:return[a,o,e];case 4:return[l,a,e];case 5:return[e,a,o]}},b.hsv.hsl=function(r){var n=r[0],t=r[1]/100,r=r[2]/100,e=Math.max(r,.01),r=(2-t)*r,a=(2-t)*e,t=t*e;return[n,100*((t/=a<=1?a:2-a)||0),100*(r/=2)]},b.hwb.rgb=function(r){var n,t,e,a=r[0]/360,o=r[1]/100,r=r[2]/100,l=o+r,l=(1<l&&(o/=l,r/=l),Math.floor(6*a)),i=1-r,r=6*a-l,h=o+(r=0!=(1&l)?1-r:r)*(i-o);switch(l){default:case 6:case 0:n=i,t=h,e=o;break;case 1:n=h,t=i,e=o;break;case 2:n=o,t=i,e=h;break;case 3:n=o,t=h,e=i;break;case 4:n=h,t=o,e=i;break;case 5:n=i,t=o,e=h}return[255*n,255*t,255*e]},b.cmyk.rgb=function(r){var n=r[0]/100,t=r[1]/100,e=r[2]/100,r=r[3]/100;return[255*(1-Math.min(1,n*(1-r)+r)),255*(1-Math.min(1,t*(1-r)+r)),255*(1-Math.min(1,e*(1-r)+r))]},b.xyz.rgb=function(r){var n=r[0]/100,t=r[1]/100,r=r[2]/100,e=3.2406*n+-1.5372*t+-.4986*r,a=-.9689*n+1.8758*t+.0415*r,n=.0557*n+-.204*t+1.057*r;return e=.0031308<e?1.055*Math.pow(e,1/2.4)-.055:12.92*e,a=.0031308<a?1.055*Math.pow(a,1/2.4)-.055:12.92*a,n=.0031308<n?1.055*Math.pow(n,1/2.4)-.055:12.92*n,[255*(e=Math.min(Math.max(0,e),1)),255*(a=Math.min(Math.max(0,a),1)),255*(n=Math.min(Math.max(0,n),1))]},b.xyz.lab=function(r){var n=r[0],t=r[1],r=r[2];return t/=100,r/=108.883,n=.008856<(n/=95.047)?Math.pow(n,1/3):7.787*n+16/116,[116*(t=.008856<t?Math.pow(t,1/3):7.787*t+16/116)-16,500*(n-t),200*(t-(r=.008856<r?Math.pow(r,1/3):7.787*r+16/116))]},b.lab.xyz=function(r){var n=(r[0]+16)/116,t=r[1]/500+n,r=n-r[2]/200,e=Math.pow(n,3),a=Math.pow(t,3),o=Math.pow(r,3);return n=.008856<e?e:(n-16/116)/7.787,t=.008856<a?a:(t-16/116)/7.787,r=.008856<o?o:(r-16/116)/7.787,[t*=95.047,n*=100,r*=108.883]},b.lab.lch=function(r){var n=r[0],t=r[1],r=r[2],e=360*Math.atan2(r,t)/2/Math.PI;return e<0&&(e+=360),[n,Math.sqrt(t*t+r*r),e]},b.lch.lab=function(r){var n=r[0],t=r[1],r=r[2]/360*2*Math.PI;return[n,t*Math.cos(r),t*Math.sin(r)]},b.rgb.ansi16=function(r){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,t=l(r,3),e=t[0],a=t[1],t=t[2],r=null===n?b.rgb.hsv(r)[2]:n;if(0===(r=Math.round(r/50)))return 30;n=30+(Math.round(t/255)<<2|Math.round(a/255)<<1|Math.round(e/255));return 2===r&&(n+=60),n},b.hsv.ansi16=function(r){return b.rgb.ansi16(b.hsv.rgb(r),r[2])},b.rgb.ansi256=function(r){var n=r[0],t=r[1],r=r[2];return n===t&&t===r?n<8?16:248<n?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5)},b.ansi16.rgb=function(r){var n=r%10;if(0===n||7===n)return 50<r&&(n+=3.5),[n=n/10.5*255,n,n];r=.5*(1+~~(50<r));return[(1&n)*r*255,(n>>1&1)*r*255,(n>>2&1)*r*255]},b.ansi256.rgb=function(r){var n;return 232<=r?[n=10*(r-232)+8,n,n]:(r-=16,[Math.floor(r/36)/5*255,Math.floor((n=r%36)/6)/5*255,n%6/5*255])},b.rgb.hex=function(r){r=(((255&Math.round(r[0]))<<16)+((255&Math.round(r[1]))<<8)+(255&Math.round(r[2]))).toString(16).toUpperCase();return"000000".substring(r.length)+r},b.hex.rgb=function(r){r=r.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!r)return[0,0,0];var n=r[0],r=(3===r[0].length&&(n=n.split("").map(function(r){return r+r}).join("")),parseInt(n,16));return[r>>16&255,r>>8&255,255&r]},b.rgb.hcg=function(r){var n=r[0]/255,t=r[1]/255,r=r[2]/255,e=Math.max(Math.max(n,t),r),a=Math.min(Math.min(n,t),r),o=e-a,a=o<1?a/(1-o):0,e=o<=0?0:e===n?(t-r)/o%6:e===t?2+(r-n)/o:4+(n-t)/o;return[360*(e=e/6%1),100*o,100*a]},b.hsl.hcg=function(r){var n=r[1]/100,t=r[2]/100,n=t<.5?2*n*t:2*n*(1-t),t=n<1?(t-.5*n)/(1-n):0;return[r[0],100*n,100*t]},b.hsv.hcg=function(r){var n=r[1]/100,t=r[2]/100,n=n*t,t=n<1?(t-n)/(1-n):0;return[r[0],100*n,100*t]},b.hcg.rgb=function(r){var n=r[0]/360,t=r[1]/100,r=r[2]/100;if(0==t)return[255*r,255*r,255*r];var e=[0,0,0],n=n%1*6,a=n%1,o=1-a;switch(Math.floor(n)){case 0:e[0]=1,e[1]=a,e[2]=0;break;case 1:e[0]=o,e[1]=1,e[2]=0;break;case 2:e[0]=0,e[1]=1,e[2]=a;break;case 3:e[0]=0,e[1]=o,e[2]=1;break;case 4:e[0]=a,e[1]=0,e[2]=1;break;default:e[0]=1,e[1]=0,e[2]=o}return[255*(t*e[0]+(n=(1-t)*r)),255*(t*e[1]+n),255*(t*e[2]+n)]},b.hcg.hsv=function(r){var n=r[1]/100,t=n+r[2]/100*(1-n),n=0<t?n/t:0;return[r[0],100*n,100*t]},b.hcg.hsl=function(r){var n=r[1]/100,t=r[2]/100*(1-n)+.5*n,e=0;return 0<t&&t<.5?e=n/(2*t):.5<=t&&t<1&&(e=n/(2*(1-t))),[r[0],100*e,100*t]},b.hcg.hwb=function(r){var n=r[1]/100,t=n+r[2]/100*(1-n);return[r[0],100*(t-n),100*(1-t)]},b.hwb.hcg=function(r){var n=r[1]/100,t=1-r[2]/100,n=t-n,t=n<1?(t-n)/(1-n):0;return[r[0],100*n,100*t]},b.apple.rgb=function(r){return[r[0]/65535*255,r[1]/65535*255,r[2]/65535*255]},b.rgb.apple=function(r){return[r[0]/255*65535,r[1]/255*65535,r[2]/255*65535]},b.gray.rgb=function(r){return[r[0]/100*255,r[0]/100*255,r[0]/100*255]},b.gray.hsl=function(r){return[0,0,r[0]]},b.gray.hsv=b.gray.hsl,b.gray.hwb=function(r){return[0,100,r[0]]},b.gray.cmyk=function(r){return[0,0,0,r[0]]},b.gray.lab=function(r){return[r[0],0,0]},b.gray.hex=function(r){r=255&Math.round(r[0]/100*255),r=((r<<16)+(r<<8)+r).toString(16).toUpperCase();return"000000".substring(r.length)+r},b.rgb.gray=function(r){return[(r[0]+r[1]+r[2])/3/255*100]};var w={};function D(a){function r(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];var e=n[0];return null==e?e:(1<e.length&&(n=e),a(n))}return"conversion"in a&&(r.conversion=a.conversion),r}function J(i){function r(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];var e=n[0];if(null==e)return e;1<e.length&&(n=e);var a=i(n);if("object"===h(a))for(var o=a.length,l=0;l<o;l++)a[l]=Math.round(a[l]);return a}return"conversion"in i&&(r.conversion=i.conversion),r}Object.keys(d).forEach(function(t){w[t]={},Object.defineProperty(w[t],"channels",{value:d[t].channels}),Object.defineProperty(w[t],"labels",{value:d[t].labels});var e=function(r){for(var n=C(r),t={},e=Object.keys(n),a=e.length,o=0;o<a;o++){var l=e[o];null!==n[l].parent&&(t[l]=T(l,n))}return t}(t);Object.keys(e).forEach(function(r){var n=e[r];w[t][r]=J(n),w[t][r].raw=D(n)})});for(var M=w,k=[].slice,x=["keyword","gray","hex"],j={},O=0,A=Object.keys(M);O<A.length;O++){var S=A[O];j[k.call(M[S].labels).sort().join("")]=S}var F={};function z(r,n){if(!(this instanceof z))return new z(r,n);if((n=n&&n in x?null:n)&&!(n in M))throw new Error("Unknown model: "+n);if(null==r)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(r instanceof z)this.model=r.model,this.color=r.color.slice(),this.valpha=r.valpha;else if("string"==typeof r){var t=c.get(r);if(null===t)throw new Error("Unable to parse color from string: "+r);this.model=t.model,e=M[this.model].channels,this.color=t.value.slice(0,e),this.valpha="number"==typeof t.value[e]?t.value[e]:1}else if(0<r.length){this.model=n||"rgb";var e=M[this.model].channels,t=k.call(r,0,e);this.color=N(t,e),this.valpha="number"==typeof r[e]?r[e]:1}else if("number"==typeof r)this.model="rgb",this.color=[r>>16&255,r>>8&255,255&r],this.valpha=1;else{this.valpha=1;n=Object.keys(r),t=("alpha"in r&&(n.splice(n.indexOf("alpha"),1),this.valpha="number"==typeof r.alpha?r.alpha:0),n.sort().join(""));if(!(t in j))throw new Error("Unable to parse color from object: "+JSON.stringify(r));this.model=j[t];for(var a=M[this.model].labels,o=[],l=0;l<a.length;l++)o.push(r[a[l]]);this.color=N(o)}if(F[this.model])for(e=M[this.model].channels,l=0;l<e;l++){var i=F[this.model][l];i&&(this.color[l]=i(this.color[l]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}z.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(r){var n=this.model in c.to?this:this.rgb(),r=1===(n=n.round("number"==typeof r?r:1)).valpha?n.color:n.color.concat(this.valpha);return c.to[n.model](r)},percentString:function(r){r=this.rgb().round("number"==typeof r?r:1),r=1===r.valpha?r.color:r.color.concat(this.valpha);return c.to.rgb.percent(r)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var r={},n=M[this.model].channels,t=M[this.model].labels,e=0;e<n;e++)r[t[e]]=this.color[e];return 1!==this.valpha&&(r.alpha=this.valpha),r},unitArray:function(){var r=this.rgb().color;return r[0]/=255,r[1]/=255,r[2]/=255,1!==this.valpha&&r.push(this.valpha),r},unitObject:function(){var r=this.rgb().object();return r.r/=255,r.g/=255,r.b/=255,1!==this.valpha&&(r.alpha=this.valpha),r},round:function(r){return r=Math.max(r||0,0),new z(this.color.map((n=r,function(r){return Number(r.toFixed(n))})).concat(this.valpha),this.model);var n},alpha:function(r){return 0<arguments.length?new z(this.color.concat(Math.max(0,Math.min(1,r))),this.model):this.valpha},red:q("rgb",0,P(255)),green:q("rgb",1,P(255)),blue:q("rgb",2,P(255)),hue:q(["hsl","hsv","hsl","hwb","hcg"],0,function(r){return(r%360+360)%360}),saturationl:q("hsl",1,P(100)),lightness:q("hsl",2,P(100)),saturationv:q("hsv",1,P(100)),value:q("hsv",2,P(100)),chroma:q("hcg",1,P(100)),gray:q("hcg",2,P(100)),white:q("hwb",1,P(100)),wblack:q("hwb",2,P(100)),cyan:q("cmyk",0,P(100)),magenta:q("cmyk",1,P(100)),yellow:q("cmyk",2,P(100)),black:q("cmyk",3,P(100)),x:q("xyz",0,P(100)),y:q("xyz",1,P(100)),z:q("xyz",2,P(100)),l:q("lab",0,P(100)),a:q("lab",1),b:q("lab",2),keyword:function(r){return 0<arguments.length?new z(r):M[this.model].keyword(this.color)},hex:function(r){return 0<arguments.length?new z(r):c.to.hex(this.rgb().round().color)},hexa:function(r){if(0<arguments.length)return new z(r);var r=this.rgb().round().color,n=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===n.length&&(n="0"+n),c.to.hex(r)+n},rgbNumber:function(){var r=this.rgb().color;return(255&r[0])<<16|(255&r[1])<<8|255&r[2]},luminosity:function(){var r,n=[],t=s(this.rgb().color.entries());try{for(t.s();!(r=t.n()).done;){var e=l(r.value,2),a=e[0],o=e[1]/255;n[a]=o<=.03928?o/12.92:Math.pow((.055+o)/1.055,2.4)}}catch(r){t.e(r)}finally{t.f()}return.2126*n[0]+.7152*n[1]+.0722*n[2]},contrast:function(r){var n=this.luminosity(),r=r.luminosity();return r<n?(n+.05)/(r+.05):(r+.05)/(n+.05)},level:function(r){r=this.contrast(r);return 7.1<=r?"AAA":4.5<=r?"AA":""},isDark:function(){var r=this.rgb().color;return(299*r[0]+587*r[1]+114*r[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var r=this.rgb(),n=0;n<3;n++)r.color[n]=255-r.color[n];return r},lighten:function(r){var n=this.hsl();return n.color[2]+=n.color[2]*r,n},darken:function(r){var n=this.hsl();return n.color[2]-=n.color[2]*r,n},saturate:function(r){var n=this.hsl();return n.color[1]+=n.color[1]*r,n},desaturate:function(r){var n=this.hsl();return n.color[1]-=n.color[1]*r,n},whiten:function(r){var n=this.hwb();return n.color[1]+=n.color[1]*r,n},blacken:function(r){var n=this.hwb();return n.color[2]+=n.color[2]*r,n},grayscale:function(){var r=this.rgb().color,r=.3*r[0]+.59*r[1]+.11*r[2];return z.rgb(r,r,r)},fade:function(r){return this.alpha(this.valpha-this.valpha*r)},opaquer:function(r){return this.alpha(this.valpha+this.valpha*r)},rotate:function(r){var n=this.hsl(),t=((t=n.color[0])+r)%360;return n.color[0]=t=t<0?360+t:t,n},mix:function(r,n){if(!r||!r.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+h(r));var r=r.rgb(),t=this.rgb(),n=void 0===n?.5:n,e=2*n-1,a=r.alpha()-t.alpha(),e=(1+(e*a==-1?e:(e+a)/(1+e*a)))/2,a=1-e;return z.rgb(e*r.red()+a*t.red(),e*r.green()+a*t.green(),e*r.blue()+a*t.blue(),r.alpha()*n+t.alpha()*(1-n))}};for(var L=function(){var t=I[E];if(x.includes(t))return"continue";var e=M[t].channels;z.prototype[t]=function(){if(this.model===t)return new z(this);if(0<arguments.length)return new z(arguments,t);var r,n="number"==typeof arguments[e]?e:this.valpha;return new z((r=M[this.model][t].raw(this.color),(Array.isArray(r)?r:[r]).concat(n)),t)},z[t]=function(r){return new z(r="number"==typeof r?N(k.call(arguments),e):r,t)}},E=0,I=Object.keys(M);E<I.length;E++)L();function q(t,e,a){var r,n=s(t=Array.isArray(t)?t:[t]);try{for(n.s();!(r=n.n()).done;){var o=r.value;(F[o]||(F[o]=[]))[e]=a}}catch(r){n.e(r)}finally{n.f()}return t=t[0],function(r){var n;return 0<arguments.length?(a&&(r=a(r)),(n=this[t]()).color[e]=r,n):(n=this[t]().color[e],a?a(n):n)}}function P(n){return function(r){return Math.max(0,Math.min(n,r))}}function N(r,n){for(var t=0;t<n;t++)"number"!=typeof r[t]&&(r[t]=0);return r}var U=z;function R(){var r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=["hsla(0, 0%, 0%)","hsla(359, 100%, 100%)"],t=r.len,e=void 0===t?10:t,t=r.rgbaRange,a=r.hslaRange,a=void 0===a?n:a,r=r.alpha;if(t){for(var o={r:0,g:0,b:0,a:0},l=U(t[0]||"#f00"),t=U(t[1]||"#000"),i=(o.r=(t.red()-l.red())/(e-1),o.g=(t.green()-l.green())/(e-1),o.b=(t.blue()-l.blue())/(e-1),r&&(o.a=(t.alpha()-l.alpha())/(e-1)),[l.rgb().string()]),h=1;h<e-1;h+=1)i[h]=l.red(l.red()+o.r*h).green(l.green()+o.g*h).blue(l.blue()+o.b*h).alpha(l.alpha()+o.a*h).rgb().string();return i.push(t.rgb().string()),i}for(var s={h:0,s:0,l:0,a:0},u=U(a[0]||n[0]),t=U(a[1]||n[1]),c=(s.h=(t.hue()-u.hue())/(e-1),s.s=(t.saturationl()-u.saturationl())/(e-1),s.l=(t.lightness()-u.lightness())/(e-1),r&&(s.a=(t.alpha()-u.alpha())/(e-1)),[u.rgb().string()]),f=1;f<e-1;f+=1)c[f]=u.hue(u.hue()+s.h*f).saturationl(u.saturationl()+s.s*f).lightness(u.lightness()+s.l*f).alpha(u.alpha()+s.a*f).rgb().string();return c.push(t.rgb().string()),c}r.default=R,r.genPalette=R,Object.defineProperty(r,"__esModule",{value:!0})});