color-interfaces
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -0,0 +0,0 @@ import { Color } from './ColorInterface'; |
@@ -0,0 +0,0 @@ import { Color } from './ColorInterface'; |
@@ -0,0 +0,0 @@ import { Color } from "./ColorInterface"; |
@@ -0,0 +0,0 @@ import { Color as Color_ } from './ColorInterface'; |
@@ -0,0 +0,0 @@ export interface Color { |
@@ -0,0 +0,0 @@ import { RGB } from './ColorInterface'; |
@@ -0,0 +0,0 @@ import { Color, HexAInterface as HexAInterface_, HEXA } from './ColorInterface'; |
@@ -1,2 +0,3 @@ | ||
import { Color, HexInterface as HexInterface_, HEX } from './ColorInterface'; | ||
import { HexInterface as HexInterface_, HEX } from './ColorInterface'; | ||
import Color from './Color'; | ||
declare class HexInterface implements HexInterface_ { | ||
@@ -3,0 +4,0 @@ private color; |
@@ -0,0 +0,0 @@ import { HSLAInterface as HSLAInterface_, HSLA } from './ColorInterface'; |
@@ -0,0 +0,0 @@ import { HSLInterface as HSLInterface_, HSL } from './ColorInterface'; |
@@ -0,0 +0,0 @@ import { HSVAInterface as HSVAInterface_, HSVA } from './ColorInterface'; |
@@ -0,0 +0,0 @@ import { HSVInterface as HSVInterface_, HSV } from './ColorInterface'; |
@@ -0,0 +0,0 @@ import Color from './Color'; |
@@ -114,22 +114,30 @@ module.exports = | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toTwoHex = exports.parseInt10 = exports.hueToRgb = exports.toPercent = exports.mixRgbColors = exports.clamp = exports.parseCSSColor = exports.cssParserTuples = void 0; | ||
exports.toTwoHex = exports.parseInt10 = exports.hueToRgb = exports.toPercent = exports.mixRgbColors = exports.clamp = exports.parseCSSColor = exports.cssParsers = void 0; | ||
var consts_1 = __webpack_require__(1); | ||
var Color_1 = __importDefault(__webpack_require__(2)); | ||
var hex6ToColor = function (match) { | ||
var hex6ToColor = function (match, color) { | ||
if (color === void 0) { color = new Color_1.default(); } | ||
var rgb = match.slice(1).map(function (hex) { return Number.parseInt(hex, 16); }); | ||
return new Color_1.default(rgb, consts_1.ColorType.RGB); | ||
color.rgb.set(rgb); | ||
return color; | ||
}; | ||
var hex3ToColor = function (match) { | ||
var rgb = match.slice(1).map(function (hex) { return Number.parseInt(hex.repeat(2), 16); }); | ||
return new Color_1.default(rgb, consts_1.ColorType.RGB); | ||
var hex3ToColor = function (match, color) { | ||
if (color === void 0) { color = new Color_1.default(); } | ||
var rgb = match | ||
.slice(1) | ||
.map(function (hex) { return Number.parseInt(hex.repeat(2), 16); }); | ||
color.rgb.set(rgb); | ||
return color; | ||
}; | ||
var hex8ToColor = function (match) { | ||
var hex8ToColor = function (match, color) { | ||
if (color === void 0) { color = new Color_1.default(); } | ||
var alpha = Number.parseInt(match.pop(), 16); | ||
var color = hex6ToColor(match); | ||
hex6ToColor(match, color); | ||
color.alpha = alpha === 0 ? alpha : alpha / 255; | ||
return color; | ||
}; | ||
var hex4ToColor = function (match) { | ||
var hex4ToColor = function (match, color) { | ||
if (color === void 0) { color = new Color_1.default(); } | ||
var alpha = Number.parseInt(match.pop().repeat(2), 16); | ||
var color = hex3ToColor(match); | ||
hex3ToColor(match, color); | ||
color.alpha = alpha === 0 ? alpha : alpha / 255; | ||
@@ -158,3 +166,3 @@ return color; | ||
}; | ||
exports.cssParserTuples = [ | ||
var cssParserTuples = [ | ||
[consts_1.RE_HEX_6, hex6ToColor], | ||
@@ -169,4 +177,5 @@ [consts_1.RE_HEX_3, hex3ToColor], | ||
]; | ||
exports.cssParsers = new Map(cssParserTuples); | ||
exports.parseCSSColor = function (input) { | ||
var tuple = exports.cssParserTuples.find(function (_a) { | ||
var tuple = cssParserTuples.find(function (_a) { | ||
var _b = __read(_a, 1), re = _b[0]; | ||
@@ -1308,10 +1317,11 @@ return re.test(input); | ||
HexInterface.prototype.set = function (hex) { | ||
if (!(consts_1.RE_HEX_3.test(hex) || consts_1.RE_HEX_6.test(hex))) { | ||
var re = consts_1.RE_HEX_3.test(hex) | ||
? consts_1.RE_HEX_3 | ||
: consts_1.RE_HEX_6.test(hex) | ||
? consts_1.RE_HEX_6 | ||
: null; | ||
if (!re) { | ||
throw Error('Not valid hex color'); | ||
} | ||
if (consts_1.RE_HEX_3.test(hex)) { | ||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; | ||
} | ||
var temp = Number.parseInt(hex, 16); | ||
this.color.rgb.set([temp >> 16, (temp >> 8) & 0xff, temp & 0xff]); | ||
utils_1.cssParsers.get(re)(hex.match(re), this.color); | ||
return this; | ||
@@ -1318,0 +1328,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=14)}([function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.toTwoHex=t.parseInt10=t.hueToRgb=t.toPercent=t.mixRgbColors=t.clamp=t.parseCSSColor=t.cssParserTuples=void 0;var i=r(1),c=o(r(2)),u=function(e){var t=e.slice(1).map((function(e){return Number.parseInt(e,16)}));return new c.default(t,i.ColorType.RGB)},f=function(e){var t=e.slice(1).map((function(e){return Number.parseInt(e.repeat(2),16)}));return new c.default(t,i.ColorType.RGB)},s=function(e){var t=e.slice(1).map((function(e){return Number.parseInt(e,10)}));return new c.default(t,i.ColorType.RGB)},a=function(e){var t=n(e.slice(1).map((function(e){return Number.parseInt(e,10)})),3),r=t[0],o=t[1],u=t[2];return new c.default([r%360,o/100,u/100],i.ColorType.HSL)};t.cssParserTuples=[[i.RE_HEX_6,u],[i.RE_HEX_3,f],[i.RE_HEX_8,function(e){var t=Number.parseInt(e.pop(),16),r=u(e);return r.alpha=0===t?t:t/255,r}],[i.RE_HEX_4,function(e){var t=Number.parseInt(e.pop().repeat(2),16),r=f(e);return r.alpha=0===t?t:t/255,r}],[i.RE_RGB,s],[i.RE_RGBA,function(e){var t=Number.parseFloat(e.pop()),r=s(e);return r.alpha=t,r}],[i.RE_HSL,a],[i.RE_HSLA,function(e){var t=Number.parseFloat(e.pop()),r=a(e);return r.alpha=t,r}]],t.parseCSSColor=function(e){var r=t.cssParserTuples.find((function(t){return n(t,1)[0].test(e)}));if(r){var o=n(r,2),u=o[0];return(0,o[1])(e.match(u))}return i.colorKeywords.has(e.trim())?new c.default(i.colorKeywords.get(e.trim()),i.ColorType.RGB):new c.default([0,0,0])},t.clamp=function(e,t,r){return Math.min(Math.max(e,t),r)},t.mixRgbColors=function(e,t,r){return[e[0]+r*(t[0]-e[0]),e[1]+r*(t[1]-e[1]),e[2]+r*(t[2]-e[2])]},t.toPercent=function(e){return Math.round(100*e)+"%"},t.hueToRgb=function(e){var t=(e%=360)%60;switch(e-=t,t=Math.round(4.25*t),e){case 0:return[255,t,0];case 60:return[255-t,255,0];case 120:return[0,255,t];case 180:return[0,255-t,255];case 240:return[t,0,255];case 300:return[255,0,255-t]}return[0,0,0]},t.parseInt10=function(e){return Number.parseInt(e,10)},t.toTwoHex=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t}},function(e,t,r){"use strict";var n=this&&this.__makeTemplateObject||function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e};Object.defineProperty(t,"__esModule",{value:!0}),t.colorKeywords=t.RE_HSLA=t.RE_HSL=t.RE_RGBA=t.RE_RGB=t.RE_HEX_4=t.RE_HEX_8=t.RE_HEX_3=t.RE_HEX_6=t.GREY=t.WHITE=t.BLACK=t.DEFAULT_COLOR=t.ColorType=void 0;var o,i,c,u,f,s,a,l,b,h,p,O,j,d,y,z=String.raw,g=z(o||(o=n(["([0-9a-fA-F])"],["([0-9a-fA-F])"]))),_=z(i||(i=n(["([0-9a-fA-F]{2})"],["([0-9a-fA-F]{2})"]))),m=z(c||(c=n(["(d|[1-9]d|1d{2}|2[0-4]d|25[0-5])"],["(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])"]))),v=z(u||(u=n(["(0|1|0?.d{1,20})"],["(0|1|0?\\.\\d{1,20})"]))),w=z(f||(f=n(["(d|[1-9]d|100)"],["(\\d|[1-9]\\d|100)"]))),R=z(s||(s=n(["s*","s*,s*","s*,s*","s*"],["\\s*","\\s*,\\s*","\\s*,\\s*","\\s*"])),m,m,m),H=z(a||(a=n(["s*(d{1,20})s*,s*","%s*,s*","%s*"],["\\s*(\\d{1,20})\\s*,\\s*","%\\s*,\\s*","%\\s*"])),w,w);!function(e){e[e.KEYWORD=1]="KEYWORD",e[e.HEX=2]="HEX",e[e.RGB=3]="RGB",e[e.RGBA=4]="RGBA",e[e.HSL=5]="HSL",e[e.HSLA=6]="HSLA",e[e.HSV=7]="HSV"}(t.ColorType||(t.ColorType={})),t.DEFAULT_COLOR="black",t.BLACK=[0,0,0],t.WHITE=[255,255,255],t.GREY=[127.5,127.5,127.5],t.RE_HEX_6=new RegExp(z(l||(l=n(["^s*#?","","","s*$"],["^\\s*#?","","","\\s*$"])),_,_,_)),t.RE_HEX_3=new RegExp(z(b||(b=n(["^s*#?","","","s*$"],["^\\s*#?","","","\\s*$"])),g,g,g)),t.RE_HEX_8=new RegExp(z(h||(h=n(["^s*#?","","","","s*$"],["^\\s*#?","","","","\\s*$"])),_,_,_,_)),t.RE_HEX_4=new RegExp(z(p||(p=n(["^s*#?","","","","s*$"],["^\\s*#?","","","","\\s*$"])),g,g,g,g)),t.RE_RGB=new RegExp(z(O||(O=n(["^s*rgb(",")s*$"],["^\\s*rgb\\(","\\)\\s*$"])),R)),t.RE_RGBA=new RegExp(z(j||(j=n(["^s*rgba(",",s*","s*)s*$"],["^\\s*rgba\\(",",\\s*","\\s*\\)\\s*$"])),R,v)),t.RE_HSL=new RegExp(z(d||(d=n(["^s*hsl(",")s*$"],["^\\s*hsl\\(","\\)\\s*$"])),H)),t.RE_HSLA=new RegExp(z(y||(y=n(["^s*hsla(",",s*","s*)s*$"],["^\\s*hsla\\(",",\\s*","\\s*\\)\\s*$"])),H,v)),t.colorKeywords=new Map([Object.freeze(["aliceblue",Object.freeze([240,248,255])]),Object.freeze(["antiquewhite",Object.freeze([250,235,215])]),Object.freeze(["aqua",Object.freeze([0,255,255])]),Object.freeze(["aquamarine",Object.freeze([127,255,212])]),Object.freeze(["azure",Object.freeze([240,255,255])]),Object.freeze(["beige",Object.freeze([245,245,220])]),Object.freeze(["bisque",Object.freeze([255,228,196])]),Object.freeze(["black",Object.freeze([0,0,0])]),Object.freeze(["blanchedalmond",Object.freeze([255,235,205])]),Object.freeze(["blue",Object.freeze([0,0,255])]),Object.freeze(["blueviolet",Object.freeze([138,43,226])]),Object.freeze(["brown",Object.freeze([165,42,42])]),Object.freeze(["burlywood",Object.freeze([222,184,135])]),Object.freeze(["cadetblue",Object.freeze([95,158,160])]),Object.freeze(["chartreuse",Object.freeze([127,255,0])]),Object.freeze(["chocolate",Object.freeze([210,105,30])]),Object.freeze(["coral",Object.freeze([255,127,80])]),Object.freeze(["cornflowerblue",Object.freeze([100,149,237])]),Object.freeze(["cornsilk",Object.freeze([255,248,220])]),Object.freeze(["crimson",Object.freeze([220,20,60])]),Object.freeze(["cyan",Object.freeze([0,255,255])]),Object.freeze(["darkblue",Object.freeze([0,0,139])]),Object.freeze(["darkcyan",Object.freeze([0,139,139])]),Object.freeze(["darkgoldenrod",Object.freeze([184,134,11])]),Object.freeze(["darkgray",Object.freeze([169,169,169])]),Object.freeze(["darkgreen",Object.freeze([0,100,0])]),Object.freeze(["darkgrey",Object.freeze([169,169,169])]),Object.freeze(["darkkhaki",Object.freeze([189,183,107])]),Object.freeze(["darkmagenta",Object.freeze([139,0,139])]),Object.freeze(["darkolivegreen",Object.freeze([85,107,47])]),Object.freeze(["darkorange",Object.freeze([255,140,0])]),Object.freeze(["darkorchid",Object.freeze([153,50,204])]),Object.freeze(["darkred",Object.freeze([139,0,0])]),Object.freeze(["darksalmon",Object.freeze([233,150,122])]),Object.freeze(["darkseagreen",Object.freeze([143,188,143])]),Object.freeze(["darkslateblue",Object.freeze([72,61,139])]),Object.freeze(["darkslategray",Object.freeze([47,79,79])]),Object.freeze(["darkslategrey",Object.freeze([47,79,79])]),Object.freeze(["darkturquoise",Object.freeze([0,206,209])]),Object.freeze(["darkviolet",Object.freeze([148,0,211])]),Object.freeze(["deeppink",Object.freeze([255,20,147])]),Object.freeze(["deepskyblue",Object.freeze([0,191,255])]),Object.freeze(["dimgray",Object.freeze([105,105,105])]),Object.freeze(["dimgrey",Object.freeze([105,105,105])]),Object.freeze(["dodgerblue",Object.freeze([30,144,255])]),Object.freeze(["firebrick",Object.freeze([178,34,34])]),Object.freeze(["floralwhite",Object.freeze([255,250,240])]),Object.freeze(["forestgreen",Object.freeze([34,139,34])]),Object.freeze(["fuchsia",Object.freeze([255,0,255])]),Object.freeze(["gainsboro",Object.freeze([220,220,220])]),Object.freeze(["ghostwhite",Object.freeze([248,248,255])]),Object.freeze(["gold",Object.freeze([255,215,0])]),Object.freeze(["goldenrod",Object.freeze([218,165,32])]),Object.freeze(["gray",Object.freeze([128,128,128])]),Object.freeze(["green",Object.freeze([0,128,0])]),Object.freeze(["greenyellow",Object.freeze([173,255,47])]),Object.freeze(["grey",Object.freeze([128,128,128])]),Object.freeze(["honeydew",Object.freeze([240,255,240])]),Object.freeze(["hotpink",Object.freeze([255,105,180])]),Object.freeze(["indianred",Object.freeze([205,92,92])]),Object.freeze(["indigo",Object.freeze([75,0,130])]),Object.freeze(["ivory",Object.freeze([255,255,240])]),Object.freeze(["khaki",Object.freeze([240,230,140])]),Object.freeze(["lavender",Object.freeze([230,230,250])]),Object.freeze(["lavenderblush",Object.freeze([255,240,245])]),Object.freeze(["lawngreen",Object.freeze([124,252,0])]),Object.freeze(["lemonchiffon",Object.freeze([255,250,205])]),Object.freeze(["lightblue",Object.freeze([173,216,230])]),Object.freeze(["lightcoral",Object.freeze([240,128,128])]),Object.freeze(["lightcyan",Object.freeze([224,255,255])]),Object.freeze(["lightgoldenrodyellow",Object.freeze([250,250,210])]),Object.freeze(["lightgray",Object.freeze([211,211,211])]),Object.freeze(["lightgreen",Object.freeze([144,238,144])]),Object.freeze(["lightgrey",Object.freeze([211,211,211])]),Object.freeze(["lightpink",Object.freeze([255,182,193])]),Object.freeze(["lightsalmon",Object.freeze([255,160,122])]),Object.freeze(["lightseagreen",Object.freeze([32,178,170])]),Object.freeze(["lightskyblue",Object.freeze([135,206,250])]),Object.freeze(["lightslategray",Object.freeze([119,136,153])]),Object.freeze(["lightslategrey",Object.freeze([119,136,153])]),Object.freeze(["lightsteelblue",Object.freeze([176,196,222])]),Object.freeze(["lightyellow",Object.freeze([255,255,224])]),Object.freeze(["lime",Object.freeze([0,255,0])]),Object.freeze(["limegreen",Object.freeze([50,205,50])]),Object.freeze(["linen",Object.freeze([250,240,230])]),Object.freeze(["magenta",Object.freeze([255,0,255])]),Object.freeze(["maroon",Object.freeze([128,0,0])]),Object.freeze(["mediumaquamarine",Object.freeze([102,205,170])]),Object.freeze(["mediumblue",Object.freeze([0,0,205])]),Object.freeze(["mediumorchid",Object.freeze([186,85,211])]),Object.freeze(["mediumpurple",Object.freeze([147,112,219])]),Object.freeze(["mediumseagreen",Object.freeze([60,179,113])]),Object.freeze(["mediumslateblue",Object.freeze([123,104,238])]),Object.freeze(["mediumspringgreen",Object.freeze([0,250,154])]),Object.freeze(["mediumturquoise",Object.freeze([72,209,204])]),Object.freeze(["mediumvioletred",Object.freeze([199,21,133])]),Object.freeze(["midnightblue",Object.freeze([25,25,112])]),Object.freeze(["mintcream",Object.freeze([245,255,250])]),Object.freeze(["mistyrose",Object.freeze([255,228,225])]),Object.freeze(["moccasin",Object.freeze([255,228,181])]),Object.freeze(["navajowhite",Object.freeze([255,222,173])]),Object.freeze(["navy",Object.freeze([0,0,128])]),Object.freeze(["oldlace",Object.freeze([253,245,230])]),Object.freeze(["olive",Object.freeze([128,128,0])]),Object.freeze(["olivedrab",Object.freeze([107,142,35])]),Object.freeze(["orange",Object.freeze([255,165,0])]),Object.freeze(["orangered",Object.freeze([255,69,0])]),Object.freeze(["orchid",Object.freeze([218,112,214])]),Object.freeze(["palegoldenrod",Object.freeze([238,232,170])]),Object.freeze(["palegreen",Object.freeze([152,251,152])]),Object.freeze(["paleturquoise",Object.freeze([175,238,238])]),Object.freeze(["palevioletred",Object.freeze([219,112,147])]),Object.freeze(["papayawhip",Object.freeze([255,239,213])]),Object.freeze(["peachpuff",Object.freeze([255,218,185])]),Object.freeze(["peru",Object.freeze([205,133,63])]),Object.freeze(["pink",Object.freeze([255,192,203])]),Object.freeze(["plum",Object.freeze([221,160,221])]),Object.freeze(["powderblue",Object.freeze([176,224,230])]),Object.freeze(["purple",Object.freeze([128,0,128])]),Object.freeze(["red",Object.freeze([255,0,0])]),Object.freeze(["rosybrown",Object.freeze([188,143,143])]),Object.freeze(["royalblue",Object.freeze([65,105,225])]),Object.freeze(["saddlebrown",Object.freeze([139,69,19])]),Object.freeze(["salmon",Object.freeze([250,128,114])]),Object.freeze(["sandybrown",Object.freeze([244,164,96])]),Object.freeze(["seagreen",Object.freeze([46,139,87])]),Object.freeze(["seashell",Object.freeze([255,245,238])]),Object.freeze(["sienna",Object.freeze([160,82,45])]),Object.freeze(["silver",Object.freeze([192,192,192])]),Object.freeze(["skyblue",Object.freeze([135,206,235])]),Object.freeze(["slateblue",Object.freeze([106,90,205])]),Object.freeze(["slategray",Object.freeze([112,128,144])]),Object.freeze(["slategrey",Object.freeze([112,128,144])]),Object.freeze(["snow",Object.freeze([255,250,250])]),Object.freeze(["springgreen",Object.freeze([0,255,127])]),Object.freeze(["steelblue",Object.freeze([70,130,180])]),Object.freeze(["tan",Object.freeze([210,180,140])]),Object.freeze(["teal",Object.freeze([0,128,128])]),Object.freeze(["thistle",Object.freeze([216,191,216])]),Object.freeze(["tomato",Object.freeze([255,99,71])]),Object.freeze(["turquoise",Object.freeze([64,224,208])]),Object.freeze(["violet",Object.freeze([238,130,238])]),Object.freeze(["wheat",Object.freeze([245,222,179])]),Object.freeze(["white",Object.freeze([255,255,255])]),Object.freeze(["whitesmoke",Object.freeze([245,245,245])]),Object.freeze(["yellow",Object.freeze([255,255,0])]),Object.freeze(["yellowgreen",Object.freeze([154,205,50])])])},function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=o(r(3)),c=o(r(5)),u=o(r(6)),f=o(r(8)),s=o(r(9)),a=o(r(11)),l=o(r(12)),b=o(r(13)),h=r(1),p=r(0),O=function(){function e(e,t){if(this._alpha=1,this.red=0,this.green=0,this.blue=0,this.hue=0,this.saturation=0,this.lightness=0,this.saturationV=0,this.value=0,this._rgb=null,this._rgba=null,this._hsl=null,this._hsla=null,this._hsv=null,this._hsva=null,this._hex=null,this._hexa=null,"string"==typeof e&&this.parseCSSColor(e),Array.isArray(e))switch(t){case void 0:case h.ColorType.RGB:this.rgb.set(e);break;case h.ColorType.HSL:this.hsl.set(e);break;case h.ColorType.HSV:this.hsv.set(e)}}return Object.defineProperty(e,"ColorType",{get:function(){return h.ColorType},enumerable:!1,configurable:!0}),e.prototype.parseCSSColor=function(e){this.rgba.set(p.parseCSSColor(e).rgba.get())},Object.defineProperty(e.prototype,"rgb",{get:function(){return null===this._rgb&&(this._rgb=new i.default(this)),this._rgb},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rgba",{get:function(){return null===this._rgba&&(this._rgba=new c.default(this)),this._rgba},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hsl",{get:function(){return this._hsl||(this._hsl=new u.default(this)),this._hsl},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hsla",{get:function(){return this._hsla||(this._hsla=new f.default(this)),this._hsla},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hsv",{get:function(){return this._hsv||(this._hsv=new s.default(this)),this._hsv},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hsva",{get:function(){return this._hsva||(this._hsva=new a.default(this)),this._hsva},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hex",{get:function(){return this._hex||(this._hex=new l.default(this)),this._hex},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hexa",{get:function(){return this._hexa||(this._hexa=new b.default(this)),this._hexa},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return p.clamp(this._alpha,0,1)},set:function(e){this._alpha=e},enumerable:!1,configurable:!0}),e.prototype.setRed=function(e){this.red=p.clamp(e,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},e.prototype.getRed=function(){return Math.round(p.clamp(this.red,0,255))},e.prototype.setGreen=function(e){this.green=p.clamp(e,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},e.prototype.getGreen=function(){return Math.round(p.clamp(this.green,0,255))},e.prototype.setBlue=function(e){this.blue=p.clamp(e,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},e.prototype.getBlue=function(){return Math.round(p.clamp(this.blue,0,255))},e.prototype.setHue=function(e){this.hue=p.clamp(e,0,360),this.updateRgbFromHsl()},e.prototype.getHue=function(){return Math.round(p.clamp(this.hue,0,360))},e.prototype.setSaturation=function(e){this.saturation=p.clamp(e,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},e.prototype.getSaturation=function(){return p.clamp(this.saturation,0,1)},e.prototype.setSaturationV=function(e){this.saturationV=p.clamp(e,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},e.prototype.getSaturationV=function(){return p.clamp(this.saturationV,0,1)},e.prototype.setLightness=function(e){this.lightness=p.clamp(e,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},e.prototype.getLightness=function(){return p.clamp(this.lightness,0,1)},e.prototype.setValue=function(e){this.value=p.clamp(e,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},e.prototype.getValue=function(){return p.clamp(this.value,0,1)},e.prototype.getGreyValue=function(){return.2126*this.red+.7152*this.green+.0722*this.blue},e.prototype.invert=function(){return this.setHue((this.hue+180)%360),this},e.prototype.getLuminance=function(){var e=this.rgb.get().map((function(e){var t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}));return.2126*e[0]+.7152*e[1]+.0722*e[2]},e.prototype.getContrastRatio=function(e){var t=this.getLuminance(),r=e.getLuminance();return t>r?(t+.05)/(r+.05):(r+.05)/(t+.05)},e.prototype.copy=function(){var t=new e;return t.setRed(this.red),t.setGreen(this.green),t.setBlue(this.blue),t.alpha=this.alpha,t},e.prototype.mixWithColor=function(e,t){return this.rgb.set(p.mixRgbColors(this.rgb.get(),e.rgb.get(),t)),this},e.prototype.updateHslFromRgb=function(){var e=this.red/255,t=this.green/255,r=this.blue/255,n=Math.max(e,t,r),o=Math.min(e,t,r),i=n+o,c=n-o;if(this.hue=0,this.saturation=0,this.lightness=i/2,0!==c){this.saturation=c/(1-Math.abs(i-1));var u=60/c;switch(n){case e:this.hue=(360+(t-r)*u)%360;break;case t:this.hue=120+(r-e)*u;break;case r:this.hue=240+(e-t)*u}}},e.prototype.updateRgbFromHsl=function(){var e,t=p.hueToRgb(this.hue),r=p.mixRgbColors(t,h.GREY,1-this.saturation),o=this.lightness<=.5?h.BLACK:h.WHITE,i=1-Math.abs(2*this.lightness-1);e=n(p.mixRgbColors(o,r,i),3),this.red=e[0],this.green=e[1],this.blue=e[2]},e.prototype.updateHsvFromHsl=function(){var e=this.lightness,t=(2*e+this.saturation*(1-Math.abs(2*e-1)))/2;this.saturationV=2*(t-e)/t||0,this.value=t},e.prototype.updateHslFromHsv=function(){var e=this.value,t=this.saturationV,r=.5*e*(2-t);this.saturation=t*e/(1-Math.abs(2*r-1))||0,this.lightness=r},e.parseCSSColor=p.parseCSSColor,e}();t.default=O},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.get=function(){return[this.r,this.g,this.b]},t.prototype.set=function(e){var t;return t=i(e,3),this.r=t[0],this.g=t[1],this.b=t[2],this},t.prototype.toCss=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},t}(c(r(4)).default);t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.color=e}return Object.defineProperty(e.prototype,"r",{get:function(){return this.color.getRed()},set:function(e){this.color.setRed(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this.color.getGreen()},set:function(e){this.color.setGreen(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"b",{get:function(){return this.color.getBlue()},set:function(e){this.color.setBlue(e)},enumerable:!1,configurable:!0}),e}();t.default=n},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"a",{get:function(){return this.color.alpha},set:function(e){this.color.alpha=e},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.r,this.g,this.b,this.a]},t.prototype.set=function(e){var t;return t=i(e,4),this.r=t[0],this.g=t[1],this.b=t[2],this.a=t[3],this},t.prototype.toCss=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.a.toFixed(2)+")"},t}(c(r(4)).default);t.default=u},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=r(0),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.get=function(){return[this.h,this.s,this.l]},t.prototype.set=function(e){var t;return t=i(e,3),this.h=t[0],this.s=t[1],this.l=t[2],this},t.prototype.toCss=function(){var e=u.toPercent(this.s),t=u.toPercent(this.l);return"hsl("+this.h+", "+e+", "+t+")"},t}(c(r(7)).default);t.default=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.color=e}return Object.defineProperty(e.prototype,"h",{get:function(){return this.color.getHue()},set:function(e){this.color.setHue(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"s",{get:function(){return this.color.getSaturation()},set:function(e){this.color.setSaturation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"l",{get:function(){return this.color.getLightness()},set:function(e){this.color.setLightness(e)},enumerable:!1,configurable:!0}),e}();t.default=n},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=r(0),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"a",{get:function(){return this.color.alpha},set:function(e){this.color.alpha=e},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.l,this.a]},t.prototype.set=function(e){var t;return t=i(e,4),this.h=t[0],this.s=t[1],this.l=t[2],this.a=t[3],this},t.prototype.toCss=function(){var e=u.toPercent(this.s),t=u.toPercent(this.l);return"hsla("+this.h+", "+e+", "+t+", "+this.color.alpha.toFixed(2)+")"},t}(c(r(7)).default);t.default=f},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.get=function(){return[this.h,this.s,this.v]},t.prototype.set=function(e){var t;return t=i(e,3),this.h=t[0],this.s=t[1],this.v=t[2],this},t.prototype.toCss=function(){return this.color.hsl.toCss()},t}(c(r(10)).default);t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.color=e}return Object.defineProperty(e.prototype,"h",{get:function(){return this.color.getHue()},set:function(e){this.color.setHue(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"s",{get:function(){return this.color.getSaturationV()},set:function(e){this.color.setSaturationV(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"v",{get:function(){return this.color.getValue()},set:function(e){this.color.setValue(e)},enumerable:!1,configurable:!0}),e}();t.default=n},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"a",{get:function(){return this.color.alpha},set:function(e){this.color.alpha=e},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.v,this.a]},t.prototype.set=function(e){var t;return t=i(e,4),this.h=t[0],this.s=t[1],this.v=t[2],this.a=t[3],this},t.prototype.toCss=function(){return this.color.hsla.toCss()},t}(c(r(10)).default);t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),o=r(0),i=function(){function e(e){this.color=e}return e.prototype.set=function(e){if(!n.RE_HEX_3.test(e)&&!n.RE_HEX_6.test(e))throw Error("Not valid hex color");n.RE_HEX_3.test(e)&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);var t=Number.parseInt(e,16);return this.color.rgb.set([t>>16,t>>8&255,255&t]),this},e.prototype.get=function(){return this.color.rgb.get().map(o.toTwoHex).join("")},e.prototype.toCss=function(){var e=this.get();return e[0]===e[1]&&e[2]===e[3]&&e[4]===e[5]&&(e=""+e[0]+e[2]+e[4]),"#"+e},e}();t.default=i},function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=r(0),c=function(){function e(e){this.color=e}return Object.defineProperty(e.prototype,"a",{get:function(){return this.color.alpha},set:function(e){this.color.alpha=e},enumerable:!1,configurable:!0}),e.prototype.set=function(e){if(!o.RE_HEX_4.test(e)&&!o.RE_HEX_8.test(e))throw Error("Not valid hexa color");o.RE_HEX_4.test(e)&&(e=Array.from(e).flatMap((function(e){return[e,e]})).join(""));var t=n(e.match(/../g).map((function(e){return Number.parseInt(e,16)})),4),r=t[0],i=t[1],c=t[2],u=t[3];return this.color.rgb.set([r,i,c]),this.a=0===u?0:u/255,this},e.prototype.get=function(){return this.color.rgba.get().map((function(e,t){return i.toTwoHex(3===t?Math.round(255*e):e)})).join("")},e.prototype.toCss=function(){var e=this.get();return e[0]===e[1]&&e[2]===e[3]&&e[4]===e[5]&&e[6]===e[7]&&(e=""+e[0]+e[2]+e[4]+e[6]),"#"+e},e}();t.default=c},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2));t.default=o.default;var i=r(3);Object.defineProperty(t,"RGBInterface",{enumerable:!0,get:function(){return i.default}});var c=r(5);Object.defineProperty(t,"RGBAInterface",{enumerable:!0,get:function(){return c.default}});var u=r(6);Object.defineProperty(t,"HSLInterface",{enumerable:!0,get:function(){return u.default}});var f=r(8);Object.defineProperty(t,"HSLAInterface",{enumerable:!0,get:function(){return f.default}});var s=r(9);Object.defineProperty(t,"HSVInterface",{enumerable:!0,get:function(){return s.default}});var a=r(11);Object.defineProperty(t,"HSVAInterface",{enumerable:!0,get:function(){return a.default}});var l=r(12);Object.defineProperty(t,"HexInterface",{enumerable:!0,get:function(){return l.default}});var b=r(13);Object.defineProperty(t,"HexAInterface",{enumerable:!0,get:function(){return b.default}});var h=r(1);Object.defineProperty(t,"ColorType",{enumerable:!0,get:function(){return h.ColorType}});var p=r(0);Object.defineProperty(t,"parseCSSColor",{enumerable:!0,get:function(){return p.parseCSSColor}})}]); | ||
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=14)}([function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.toTwoHex=t.parseInt10=t.hueToRgb=t.toPercent=t.mixRgbColors=t.clamp=t.parseCSSColor=t.cssParsers=void 0;var i=r(1),c=o(r(2)),u=function(e,t){void 0===t&&(t=new c.default);var r=e.slice(1).map((function(e){return Number.parseInt(e,16)}));return t.rgb.set(r),t},f=function(e,t){void 0===t&&(t=new c.default);var r=e.slice(1).map((function(e){return Number.parseInt(e.repeat(2),16)}));return t.rgb.set(r),t},s=function(e){var t=e.slice(1).map((function(e){return Number.parseInt(e,10)}));return new c.default(t,i.ColorType.RGB)},a=function(e){var t=n(e.slice(1).map((function(e){return Number.parseInt(e,10)})),3),r=t[0],o=t[1],u=t[2];return new c.default([r%360,o/100,u/100],i.ColorType.HSL)},l=[[i.RE_HEX_6,u],[i.RE_HEX_3,f],[i.RE_HEX_8,function(e,t){void 0===t&&(t=new c.default);var r=Number.parseInt(e.pop(),16);return u(e,t),t.alpha=0===r?r:r/255,t}],[i.RE_HEX_4,function(e,t){void 0===t&&(t=new c.default);var r=Number.parseInt(e.pop().repeat(2),16);return f(e,t),t.alpha=0===r?r:r/255,t}],[i.RE_RGB,s],[i.RE_RGBA,function(e){var t=Number.parseFloat(e.pop()),r=s(e);return r.alpha=t,r}],[i.RE_HSL,a],[i.RE_HSLA,function(e){var t=Number.parseFloat(e.pop()),r=a(e);return r.alpha=t,r}]];t.cssParsers=new Map(l),t.parseCSSColor=function(e){var t=l.find((function(t){return n(t,1)[0].test(e)}));if(t){var r=n(t,2),o=r[0];return(0,r[1])(e.match(o))}return i.colorKeywords.has(e.trim())?new c.default(i.colorKeywords.get(e.trim()),i.ColorType.RGB):new c.default([0,0,0])},t.clamp=function(e,t,r){return Math.min(Math.max(e,t),r)},t.mixRgbColors=function(e,t,r){return[e[0]+r*(t[0]-e[0]),e[1]+r*(t[1]-e[1]),e[2]+r*(t[2]-e[2])]},t.toPercent=function(e){return Math.round(100*e)+"%"},t.hueToRgb=function(e){var t=(e%=360)%60;switch(e-=t,t=Math.round(4.25*t),e){case 0:return[255,t,0];case 60:return[255-t,255,0];case 120:return[0,255,t];case 180:return[0,255-t,255];case 240:return[t,0,255];case 300:return[255,0,255-t]}return[0,0,0]},t.parseInt10=function(e){return Number.parseInt(e,10)},t.toTwoHex=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t}},function(e,t,r){"use strict";var n=this&&this.__makeTemplateObject||function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e};Object.defineProperty(t,"__esModule",{value:!0}),t.colorKeywords=t.RE_HSLA=t.RE_HSL=t.RE_RGBA=t.RE_RGB=t.RE_HEX_4=t.RE_HEX_8=t.RE_HEX_3=t.RE_HEX_6=t.GREY=t.WHITE=t.BLACK=t.DEFAULT_COLOR=t.ColorType=void 0;var o,i,c,u,f,s,a,l,b,h,p,O,j,d,y,z=String.raw,g=z(o||(o=n(["([0-9a-fA-F])"],["([0-9a-fA-F])"]))),_=z(i||(i=n(["([0-9a-fA-F]{2})"],["([0-9a-fA-F]{2})"]))),v=z(c||(c=n(["(d|[1-9]d|1d{2}|2[0-4]d|25[0-5])"],["(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])"]))),m=z(u||(u=n(["(0|1|0?.d{1,20})"],["(0|1|0?\\.\\d{1,20})"]))),w=z(f||(f=n(["(d|[1-9]d|100)"],["(\\d|[1-9]\\d|100)"]))),R=z(s||(s=n(["s*","s*,s*","s*,s*","s*"],["\\s*","\\s*,\\s*","\\s*,\\s*","\\s*"])),v,v,v),H=z(a||(a=n(["s*(d{1,20})s*,s*","%s*,s*","%s*"],["\\s*(\\d{1,20})\\s*,\\s*","%\\s*,\\s*","%\\s*"])),w,w);!function(e){e[e.KEYWORD=1]="KEYWORD",e[e.HEX=2]="HEX",e[e.RGB=3]="RGB",e[e.RGBA=4]="RGBA",e[e.HSL=5]="HSL",e[e.HSLA=6]="HSLA",e[e.HSV=7]="HSV"}(t.ColorType||(t.ColorType={})),t.DEFAULT_COLOR="black",t.BLACK=[0,0,0],t.WHITE=[255,255,255],t.GREY=[127.5,127.5,127.5],t.RE_HEX_6=new RegExp(z(l||(l=n(["^s*#?","","","s*$"],["^\\s*#?","","","\\s*$"])),_,_,_)),t.RE_HEX_3=new RegExp(z(b||(b=n(["^s*#?","","","s*$"],["^\\s*#?","","","\\s*$"])),g,g,g)),t.RE_HEX_8=new RegExp(z(h||(h=n(["^s*#?","","","","s*$"],["^\\s*#?","","","","\\s*$"])),_,_,_,_)),t.RE_HEX_4=new RegExp(z(p||(p=n(["^s*#?","","","","s*$"],["^\\s*#?","","","","\\s*$"])),g,g,g,g)),t.RE_RGB=new RegExp(z(O||(O=n(["^s*rgb(",")s*$"],["^\\s*rgb\\(","\\)\\s*$"])),R)),t.RE_RGBA=new RegExp(z(j||(j=n(["^s*rgba(",",s*","s*)s*$"],["^\\s*rgba\\(",",\\s*","\\s*\\)\\s*$"])),R,m)),t.RE_HSL=new RegExp(z(d||(d=n(["^s*hsl(",")s*$"],["^\\s*hsl\\(","\\)\\s*$"])),H)),t.RE_HSLA=new RegExp(z(y||(y=n(["^s*hsla(",",s*","s*)s*$"],["^\\s*hsla\\(",",\\s*","\\s*\\)\\s*$"])),H,m)),t.colorKeywords=new Map([Object.freeze(["aliceblue",Object.freeze([240,248,255])]),Object.freeze(["antiquewhite",Object.freeze([250,235,215])]),Object.freeze(["aqua",Object.freeze([0,255,255])]),Object.freeze(["aquamarine",Object.freeze([127,255,212])]),Object.freeze(["azure",Object.freeze([240,255,255])]),Object.freeze(["beige",Object.freeze([245,245,220])]),Object.freeze(["bisque",Object.freeze([255,228,196])]),Object.freeze(["black",Object.freeze([0,0,0])]),Object.freeze(["blanchedalmond",Object.freeze([255,235,205])]),Object.freeze(["blue",Object.freeze([0,0,255])]),Object.freeze(["blueviolet",Object.freeze([138,43,226])]),Object.freeze(["brown",Object.freeze([165,42,42])]),Object.freeze(["burlywood",Object.freeze([222,184,135])]),Object.freeze(["cadetblue",Object.freeze([95,158,160])]),Object.freeze(["chartreuse",Object.freeze([127,255,0])]),Object.freeze(["chocolate",Object.freeze([210,105,30])]),Object.freeze(["coral",Object.freeze([255,127,80])]),Object.freeze(["cornflowerblue",Object.freeze([100,149,237])]),Object.freeze(["cornsilk",Object.freeze([255,248,220])]),Object.freeze(["crimson",Object.freeze([220,20,60])]),Object.freeze(["cyan",Object.freeze([0,255,255])]),Object.freeze(["darkblue",Object.freeze([0,0,139])]),Object.freeze(["darkcyan",Object.freeze([0,139,139])]),Object.freeze(["darkgoldenrod",Object.freeze([184,134,11])]),Object.freeze(["darkgray",Object.freeze([169,169,169])]),Object.freeze(["darkgreen",Object.freeze([0,100,0])]),Object.freeze(["darkgrey",Object.freeze([169,169,169])]),Object.freeze(["darkkhaki",Object.freeze([189,183,107])]),Object.freeze(["darkmagenta",Object.freeze([139,0,139])]),Object.freeze(["darkolivegreen",Object.freeze([85,107,47])]),Object.freeze(["darkorange",Object.freeze([255,140,0])]),Object.freeze(["darkorchid",Object.freeze([153,50,204])]),Object.freeze(["darkred",Object.freeze([139,0,0])]),Object.freeze(["darksalmon",Object.freeze([233,150,122])]),Object.freeze(["darkseagreen",Object.freeze([143,188,143])]),Object.freeze(["darkslateblue",Object.freeze([72,61,139])]),Object.freeze(["darkslategray",Object.freeze([47,79,79])]),Object.freeze(["darkslategrey",Object.freeze([47,79,79])]),Object.freeze(["darkturquoise",Object.freeze([0,206,209])]),Object.freeze(["darkviolet",Object.freeze([148,0,211])]),Object.freeze(["deeppink",Object.freeze([255,20,147])]),Object.freeze(["deepskyblue",Object.freeze([0,191,255])]),Object.freeze(["dimgray",Object.freeze([105,105,105])]),Object.freeze(["dimgrey",Object.freeze([105,105,105])]),Object.freeze(["dodgerblue",Object.freeze([30,144,255])]),Object.freeze(["firebrick",Object.freeze([178,34,34])]),Object.freeze(["floralwhite",Object.freeze([255,250,240])]),Object.freeze(["forestgreen",Object.freeze([34,139,34])]),Object.freeze(["fuchsia",Object.freeze([255,0,255])]),Object.freeze(["gainsboro",Object.freeze([220,220,220])]),Object.freeze(["ghostwhite",Object.freeze([248,248,255])]),Object.freeze(["gold",Object.freeze([255,215,0])]),Object.freeze(["goldenrod",Object.freeze([218,165,32])]),Object.freeze(["gray",Object.freeze([128,128,128])]),Object.freeze(["green",Object.freeze([0,128,0])]),Object.freeze(["greenyellow",Object.freeze([173,255,47])]),Object.freeze(["grey",Object.freeze([128,128,128])]),Object.freeze(["honeydew",Object.freeze([240,255,240])]),Object.freeze(["hotpink",Object.freeze([255,105,180])]),Object.freeze(["indianred",Object.freeze([205,92,92])]),Object.freeze(["indigo",Object.freeze([75,0,130])]),Object.freeze(["ivory",Object.freeze([255,255,240])]),Object.freeze(["khaki",Object.freeze([240,230,140])]),Object.freeze(["lavender",Object.freeze([230,230,250])]),Object.freeze(["lavenderblush",Object.freeze([255,240,245])]),Object.freeze(["lawngreen",Object.freeze([124,252,0])]),Object.freeze(["lemonchiffon",Object.freeze([255,250,205])]),Object.freeze(["lightblue",Object.freeze([173,216,230])]),Object.freeze(["lightcoral",Object.freeze([240,128,128])]),Object.freeze(["lightcyan",Object.freeze([224,255,255])]),Object.freeze(["lightgoldenrodyellow",Object.freeze([250,250,210])]),Object.freeze(["lightgray",Object.freeze([211,211,211])]),Object.freeze(["lightgreen",Object.freeze([144,238,144])]),Object.freeze(["lightgrey",Object.freeze([211,211,211])]),Object.freeze(["lightpink",Object.freeze([255,182,193])]),Object.freeze(["lightsalmon",Object.freeze([255,160,122])]),Object.freeze(["lightseagreen",Object.freeze([32,178,170])]),Object.freeze(["lightskyblue",Object.freeze([135,206,250])]),Object.freeze(["lightslategray",Object.freeze([119,136,153])]),Object.freeze(["lightslategrey",Object.freeze([119,136,153])]),Object.freeze(["lightsteelblue",Object.freeze([176,196,222])]),Object.freeze(["lightyellow",Object.freeze([255,255,224])]),Object.freeze(["lime",Object.freeze([0,255,0])]),Object.freeze(["limegreen",Object.freeze([50,205,50])]),Object.freeze(["linen",Object.freeze([250,240,230])]),Object.freeze(["magenta",Object.freeze([255,0,255])]),Object.freeze(["maroon",Object.freeze([128,0,0])]),Object.freeze(["mediumaquamarine",Object.freeze([102,205,170])]),Object.freeze(["mediumblue",Object.freeze([0,0,205])]),Object.freeze(["mediumorchid",Object.freeze([186,85,211])]),Object.freeze(["mediumpurple",Object.freeze([147,112,219])]),Object.freeze(["mediumseagreen",Object.freeze([60,179,113])]),Object.freeze(["mediumslateblue",Object.freeze([123,104,238])]),Object.freeze(["mediumspringgreen",Object.freeze([0,250,154])]),Object.freeze(["mediumturquoise",Object.freeze([72,209,204])]),Object.freeze(["mediumvioletred",Object.freeze([199,21,133])]),Object.freeze(["midnightblue",Object.freeze([25,25,112])]),Object.freeze(["mintcream",Object.freeze([245,255,250])]),Object.freeze(["mistyrose",Object.freeze([255,228,225])]),Object.freeze(["moccasin",Object.freeze([255,228,181])]),Object.freeze(["navajowhite",Object.freeze([255,222,173])]),Object.freeze(["navy",Object.freeze([0,0,128])]),Object.freeze(["oldlace",Object.freeze([253,245,230])]),Object.freeze(["olive",Object.freeze([128,128,0])]),Object.freeze(["olivedrab",Object.freeze([107,142,35])]),Object.freeze(["orange",Object.freeze([255,165,0])]),Object.freeze(["orangered",Object.freeze([255,69,0])]),Object.freeze(["orchid",Object.freeze([218,112,214])]),Object.freeze(["palegoldenrod",Object.freeze([238,232,170])]),Object.freeze(["palegreen",Object.freeze([152,251,152])]),Object.freeze(["paleturquoise",Object.freeze([175,238,238])]),Object.freeze(["palevioletred",Object.freeze([219,112,147])]),Object.freeze(["papayawhip",Object.freeze([255,239,213])]),Object.freeze(["peachpuff",Object.freeze([255,218,185])]),Object.freeze(["peru",Object.freeze([205,133,63])]),Object.freeze(["pink",Object.freeze([255,192,203])]),Object.freeze(["plum",Object.freeze([221,160,221])]),Object.freeze(["powderblue",Object.freeze([176,224,230])]),Object.freeze(["purple",Object.freeze([128,0,128])]),Object.freeze(["red",Object.freeze([255,0,0])]),Object.freeze(["rosybrown",Object.freeze([188,143,143])]),Object.freeze(["royalblue",Object.freeze([65,105,225])]),Object.freeze(["saddlebrown",Object.freeze([139,69,19])]),Object.freeze(["salmon",Object.freeze([250,128,114])]),Object.freeze(["sandybrown",Object.freeze([244,164,96])]),Object.freeze(["seagreen",Object.freeze([46,139,87])]),Object.freeze(["seashell",Object.freeze([255,245,238])]),Object.freeze(["sienna",Object.freeze([160,82,45])]),Object.freeze(["silver",Object.freeze([192,192,192])]),Object.freeze(["skyblue",Object.freeze([135,206,235])]),Object.freeze(["slateblue",Object.freeze([106,90,205])]),Object.freeze(["slategray",Object.freeze([112,128,144])]),Object.freeze(["slategrey",Object.freeze([112,128,144])]),Object.freeze(["snow",Object.freeze([255,250,250])]),Object.freeze(["springgreen",Object.freeze([0,255,127])]),Object.freeze(["steelblue",Object.freeze([70,130,180])]),Object.freeze(["tan",Object.freeze([210,180,140])]),Object.freeze(["teal",Object.freeze([0,128,128])]),Object.freeze(["thistle",Object.freeze([216,191,216])]),Object.freeze(["tomato",Object.freeze([255,99,71])]),Object.freeze(["turquoise",Object.freeze([64,224,208])]),Object.freeze(["violet",Object.freeze([238,130,238])]),Object.freeze(["wheat",Object.freeze([245,222,179])]),Object.freeze(["white",Object.freeze([255,255,255])]),Object.freeze(["whitesmoke",Object.freeze([245,245,245])]),Object.freeze(["yellow",Object.freeze([255,255,0])]),Object.freeze(["yellowgreen",Object.freeze([154,205,50])])])},function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=o(r(3)),c=o(r(5)),u=o(r(6)),f=o(r(8)),s=o(r(9)),a=o(r(11)),l=o(r(12)),b=o(r(13)),h=r(1),p=r(0),O=function(){function e(e,t){if(this._alpha=1,this.red=0,this.green=0,this.blue=0,this.hue=0,this.saturation=0,this.lightness=0,this.saturationV=0,this.value=0,this._rgb=null,this._rgba=null,this._hsl=null,this._hsla=null,this._hsv=null,this._hsva=null,this._hex=null,this._hexa=null,"string"==typeof e&&this.parseCSSColor(e),Array.isArray(e))switch(t){case void 0:case h.ColorType.RGB:this.rgb.set(e);break;case h.ColorType.HSL:this.hsl.set(e);break;case h.ColorType.HSV:this.hsv.set(e)}}return Object.defineProperty(e,"ColorType",{get:function(){return h.ColorType},enumerable:!1,configurable:!0}),e.prototype.parseCSSColor=function(e){this.rgba.set(p.parseCSSColor(e).rgba.get())},Object.defineProperty(e.prototype,"rgb",{get:function(){return null===this._rgb&&(this._rgb=new i.default(this)),this._rgb},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rgba",{get:function(){return null===this._rgba&&(this._rgba=new c.default(this)),this._rgba},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hsl",{get:function(){return this._hsl||(this._hsl=new u.default(this)),this._hsl},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hsla",{get:function(){return this._hsla||(this._hsla=new f.default(this)),this._hsla},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hsv",{get:function(){return this._hsv||(this._hsv=new s.default(this)),this._hsv},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hsva",{get:function(){return this._hsva||(this._hsva=new a.default(this)),this._hsva},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hex",{get:function(){return this._hex||(this._hex=new l.default(this)),this._hex},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hexa",{get:function(){return this._hexa||(this._hexa=new b.default(this)),this._hexa},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return p.clamp(this._alpha,0,1)},set:function(e){this._alpha=e},enumerable:!1,configurable:!0}),e.prototype.setRed=function(e){this.red=p.clamp(e,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},e.prototype.getRed=function(){return Math.round(p.clamp(this.red,0,255))},e.prototype.setGreen=function(e){this.green=p.clamp(e,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},e.prototype.getGreen=function(){return Math.round(p.clamp(this.green,0,255))},e.prototype.setBlue=function(e){this.blue=p.clamp(e,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},e.prototype.getBlue=function(){return Math.round(p.clamp(this.blue,0,255))},e.prototype.setHue=function(e){this.hue=p.clamp(e,0,360),this.updateRgbFromHsl()},e.prototype.getHue=function(){return Math.round(p.clamp(this.hue,0,360))},e.prototype.setSaturation=function(e){this.saturation=p.clamp(e,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},e.prototype.getSaturation=function(){return p.clamp(this.saturation,0,1)},e.prototype.setSaturationV=function(e){this.saturationV=p.clamp(e,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},e.prototype.getSaturationV=function(){return p.clamp(this.saturationV,0,1)},e.prototype.setLightness=function(e){this.lightness=p.clamp(e,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},e.prototype.getLightness=function(){return p.clamp(this.lightness,0,1)},e.prototype.setValue=function(e){this.value=p.clamp(e,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},e.prototype.getValue=function(){return p.clamp(this.value,0,1)},e.prototype.getGreyValue=function(){return.2126*this.red+.7152*this.green+.0722*this.blue},e.prototype.invert=function(){return this.setHue((this.hue+180)%360),this},e.prototype.getLuminance=function(){var e=this.rgb.get().map((function(e){var t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}));return.2126*e[0]+.7152*e[1]+.0722*e[2]},e.prototype.getContrastRatio=function(e){var t=this.getLuminance(),r=e.getLuminance();return t>r?(t+.05)/(r+.05):(r+.05)/(t+.05)},e.prototype.copy=function(){var t=new e;return t.setRed(this.red),t.setGreen(this.green),t.setBlue(this.blue),t.alpha=this.alpha,t},e.prototype.mixWithColor=function(e,t){return this.rgb.set(p.mixRgbColors(this.rgb.get(),e.rgb.get(),t)),this},e.prototype.updateHslFromRgb=function(){var e=this.red/255,t=this.green/255,r=this.blue/255,n=Math.max(e,t,r),o=Math.min(e,t,r),i=n+o,c=n-o;if(this.hue=0,this.saturation=0,this.lightness=i/2,0!==c){this.saturation=c/(1-Math.abs(i-1));var u=60/c;switch(n){case e:this.hue=(360+(t-r)*u)%360;break;case t:this.hue=120+(r-e)*u;break;case r:this.hue=240+(e-t)*u}}},e.prototype.updateRgbFromHsl=function(){var e,t=p.hueToRgb(this.hue),r=p.mixRgbColors(t,h.GREY,1-this.saturation),o=this.lightness<=.5?h.BLACK:h.WHITE,i=1-Math.abs(2*this.lightness-1);e=n(p.mixRgbColors(o,r,i),3),this.red=e[0],this.green=e[1],this.blue=e[2]},e.prototype.updateHsvFromHsl=function(){var e=this.lightness,t=(2*e+this.saturation*(1-Math.abs(2*e-1)))/2;this.saturationV=2*(t-e)/t||0,this.value=t},e.prototype.updateHslFromHsv=function(){var e=this.value,t=this.saturationV,r=.5*e*(2-t);this.saturation=t*e/(1-Math.abs(2*r-1))||0,this.lightness=r},e.parseCSSColor=p.parseCSSColor,e}();t.default=O},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.get=function(){return[this.r,this.g,this.b]},t.prototype.set=function(e){var t;return t=i(e,3),this.r=t[0],this.g=t[1],this.b=t[2],this},t.prototype.toCss=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},t}(c(r(4)).default);t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.color=e}return Object.defineProperty(e.prototype,"r",{get:function(){return this.color.getRed()},set:function(e){this.color.setRed(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this.color.getGreen()},set:function(e){this.color.setGreen(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"b",{get:function(){return this.color.getBlue()},set:function(e){this.color.setBlue(e)},enumerable:!1,configurable:!0}),e}();t.default=n},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"a",{get:function(){return this.color.alpha},set:function(e){this.color.alpha=e},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.r,this.g,this.b,this.a]},t.prototype.set=function(e){var t;return t=i(e,4),this.r=t[0],this.g=t[1],this.b=t[2],this.a=t[3],this},t.prototype.toCss=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.a.toFixed(2)+")"},t}(c(r(4)).default);t.default=u},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=r(0),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.get=function(){return[this.h,this.s,this.l]},t.prototype.set=function(e){var t;return t=i(e,3),this.h=t[0],this.s=t[1],this.l=t[2],this},t.prototype.toCss=function(){var e=u.toPercent(this.s),t=u.toPercent(this.l);return"hsl("+this.h+", "+e+", "+t+")"},t}(c(r(7)).default);t.default=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.color=e}return Object.defineProperty(e.prototype,"h",{get:function(){return this.color.getHue()},set:function(e){this.color.setHue(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"s",{get:function(){return this.color.getSaturation()},set:function(e){this.color.setSaturation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"l",{get:function(){return this.color.getLightness()},set:function(e){this.color.setLightness(e)},enumerable:!1,configurable:!0}),e}();t.default=n},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=r(0),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"a",{get:function(){return this.color.alpha},set:function(e){this.color.alpha=e},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.l,this.a]},t.prototype.set=function(e){var t;return t=i(e,4),this.h=t[0],this.s=t[1],this.l=t[2],this.a=t[3],this},t.prototype.toCss=function(){var e=u.toPercent(this.s),t=u.toPercent(this.l);return"hsla("+this.h+", "+e+", "+t+", "+this.color.alpha.toFixed(2)+")"},t}(c(r(7)).default);t.default=f},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.get=function(){return[this.h,this.s,this.v]},t.prototype.set=function(e){var t;return t=i(e,3),this.h=t[0],this.s=t[1],this.v=t[2],this},t.prototype.toCss=function(){return this.color.hsl.toCss()},t}(c(r(10)).default);t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.color=e}return Object.defineProperty(e.prototype,"h",{get:function(){return this.color.getHue()},set:function(e){this.color.setHue(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"s",{get:function(){return this.color.getSaturationV()},set:function(e){this.color.setSaturationV(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"v",{get:function(){return this.color.getValue()},set:function(e){this.color.setValue(e)},enumerable:!1,configurable:!0}),e}();t.default=n},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"a",{get:function(){return this.color.alpha},set:function(e){this.color.alpha=e},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.v,this.a]},t.prototype.set=function(e){var t;return t=i(e,4),this.h=t[0],this.s=t[1],this.v=t[2],this.a=t[3],this},t.prototype.toCss=function(){return this.color.hsla.toCss()},t}(c(r(10)).default);t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),o=r(0),i=function(){function e(e){this.color=e}return e.prototype.set=function(e){var t=n.RE_HEX_3.test(e)?n.RE_HEX_3:n.RE_HEX_6.test(e)?n.RE_HEX_6:null;if(!t)throw Error("Not valid hex color");return o.cssParsers.get(t)(e.match(t),this.color),this},e.prototype.get=function(){return this.color.rgb.get().map(o.toTwoHex).join("")},e.prototype.toCss=function(){var e=this.get();return e[0]===e[1]&&e[2]===e[3]&&e[4]===e[5]&&(e=""+e[0]+e[2]+e[4]),"#"+e},e}();t.default=i},function(e,t,r){"use strict";var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=r(0),c=function(){function e(e){this.color=e}return Object.defineProperty(e.prototype,"a",{get:function(){return this.color.alpha},set:function(e){this.color.alpha=e},enumerable:!1,configurable:!0}),e.prototype.set=function(e){if(!o.RE_HEX_4.test(e)&&!o.RE_HEX_8.test(e))throw Error("Not valid hexa color");o.RE_HEX_4.test(e)&&(e=Array.from(e).flatMap((function(e){return[e,e]})).join(""));var t=n(e.match(/../g).map((function(e){return Number.parseInt(e,16)})),4),r=t[0],i=t[1],c=t[2],u=t[3];return this.color.rgb.set([r,i,c]),this.a=0===u?0:u/255,this},e.prototype.get=function(){return this.color.rgba.get().map((function(e,t){return i.toTwoHex(3===t?Math.round(255*e):e)})).join("")},e.prototype.toCss=function(){var e=this.get();return e[0]===e[1]&&e[2]===e[3]&&e[4]===e[5]&&e[6]===e[7]&&(e=""+e[0]+e[2]+e[4]+e[6]),"#"+e},e}();t.default=c},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(2));t.default=o.default;var i=r(3);Object.defineProperty(t,"RGBInterface",{enumerable:!0,get:function(){return i.default}});var c=r(5);Object.defineProperty(t,"RGBAInterface",{enumerable:!0,get:function(){return c.default}});var u=r(6);Object.defineProperty(t,"HSLInterface",{enumerable:!0,get:function(){return u.default}});var f=r(8);Object.defineProperty(t,"HSLAInterface",{enumerable:!0,get:function(){return f.default}});var s=r(9);Object.defineProperty(t,"HSVInterface",{enumerable:!0,get:function(){return s.default}});var a=r(11);Object.defineProperty(t,"HSVAInterface",{enumerable:!0,get:function(){return a.default}});var l=r(12);Object.defineProperty(t,"HexInterface",{enumerable:!0,get:function(){return l.default}});var b=r(13);Object.defineProperty(t,"HexAInterface",{enumerable:!0,get:function(){return b.default}});var h=r(1);Object.defineProperty(t,"ColorType",{enumerable:!0,get:function(){return h.ColorType}});var p=r(0);Object.defineProperty(t,"parseCSSColor",{enumerable:!0,get:function(){return p.parseCSSColor}})}]); |
@@ -0,0 +0,0 @@ import { RGBAInterface as RGBAInterface_, RGBA } from './ColorInterface'; |
@@ -0,0 +0,0 @@ import { RGBInterface as RGBInterface_, RGB } from './ColorInterface'; |
import { RGB } from './ColorInterface'; | ||
import Color from './Color'; | ||
declare type ParseFromMatch = (match: RegExpMatchArray) => Color; | ||
export declare const cssParserTuples: [RegExp, ParseFromMatch][]; | ||
declare type ParseFromMatch = (match: RegExpMatchArray, color?: Color) => Color; | ||
export declare const cssParsers: Map<RegExp, ParseFromMatch>; | ||
export declare const parseCSSColor: (input: string) => Color; | ||
@@ -6,0 +6,0 @@ export declare const clamp: (val: number, min: number, max: number) => number; |
{ | ||
"name": "color-interfaces", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "interfaces for color spaces", | ||
@@ -26,3 +26,3 @@ "repository": "https://github.com/chriskr/color-interfaces", | ||
"build": "cross-env NODE_ENV=production webpack --mode production", | ||
"test": "jest --coverage" | ||
"test": "jest --config jest.config.js" | ||
}, | ||
@@ -34,3 +34,5 @@ "devDependencies": { | ||
"@babel/preset-typescript": "^7.6.0", | ||
"babel-jest": "^26.0.1", | ||
"babel-loader": "^8.1.0", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"cross-env": "^7.0.2", | ||
@@ -37,0 +39,0 @@ "jest": "^26.0.1", |
@@ -1,2 +0,2 @@ | ||
import { Color as Color_, RGB, HSV, HSL } from './ColorInterface'; | ||
import { Color as Color_, RGB, HSV, HSL, HSVA, HSLA } from './ColorInterface'; | ||
import RGBInterface from './RGBInterface'; | ||
@@ -60,5 +60,11 @@ import RGBAInterface from './RGBAInterface'; | ||
break; | ||
case ColorType.HSLA: | ||
this.hsla.set(value as HSVA); | ||
break; | ||
case ColorType.HSV: | ||
this.hsv.set(value as HSL); | ||
break; | ||
case ColorType.HSVA: | ||
this.hsva.set(value as HSLA); | ||
break; | ||
} | ||
@@ -65,0 +71,0 @@ } |
@@ -20,2 +20,3 @@ import { RGB } from './ColorInterface'; | ||
HSV, | ||
HSVA, | ||
} | ||
@@ -22,0 +23,0 @@ |
@@ -1,5 +0,9 @@ | ||
import { Color, HexAInterface as HexAInterface_, HEXA } from './ColorInterface'; | ||
import { HexAInterface as HexAInterface_, HEXA } from './ColorInterface'; | ||
import { RE_HEX_4, RE_HEX_8 } from './consts'; | ||
import { toTwoHex } from './utils'; | ||
import { toTwoHex, cssParsers } from './utils'; | ||
import Color from './Color'; | ||
const getRe = (input: string) => | ||
[RE_HEX_8, RE_HEX_4].find((re) => re.test(input)); | ||
class HexAInterface implements HexAInterface_ { | ||
@@ -20,13 +24,7 @@ private color: Color; | ||
set(hexa: HEXA) { | ||
if (!(RE_HEX_4.test(hexa) || RE_HEX_8.test(hexa))) { | ||
throw Error('Not valid hexa color'); | ||
const re = getRe(hexa); | ||
if (!re) { | ||
throw new Error('Not valid hex color'); | ||
} | ||
if (RE_HEX_4.test(hexa)) { | ||
hexa = Array.from(hexa) | ||
.flatMap((h) => [h, h]) | ||
.join(''); | ||
} | ||
const [r, g, b, a] = hexa.match(/../g)!.map((h) => Number.parseInt(h, 16)); | ||
this.color.rgb.set([r, g, b]); | ||
this.a = a === 0 ? 0 : a / 255; | ||
cssParsers.get(re)!(hexa.match(re)!, this.color); | ||
return this; | ||
@@ -33,0 +31,0 @@ } |
@@ -1,5 +0,9 @@ | ||
import { Color, HexInterface as HexInterface_, HEX } from './ColorInterface'; | ||
import { HexInterface as HexInterface_, HEX } from './ColorInterface'; | ||
import { RE_HEX_3, RE_HEX_6 } from './consts'; | ||
import { toTwoHex } from './utils'; | ||
import { toTwoHex, cssParsers } from './utils'; | ||
import Color from './Color'; | ||
const getRe = (input: string) => | ||
[RE_HEX_6, RE_HEX_3].find((re) => re.test(input)); | ||
class HexInterface implements HexInterface_ { | ||
@@ -12,10 +16,7 @@ private color: Color; | ||
set(hex: HEX) { | ||
if (!(RE_HEX_3.test(hex) || RE_HEX_6.test(hex))) { | ||
throw Error('Not valid hex color'); | ||
const re = getRe(hex); | ||
if (!re) { | ||
throw new Error('Not valid hex color'); | ||
} | ||
if (RE_HEX_3.test(hex)) { | ||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; | ||
} | ||
const temp = Number.parseInt(hex, 16); | ||
this.color.rgb.set([temp >> 16, (temp >> 8) & 0xff, temp & 0xff]); | ||
cssParsers.get(re)!(hex.match(re)!, this.color); | ||
return this; | ||
@@ -29,5 +30,5 @@ } | ||
toCss() { | ||
let hex = this.get(); | ||
const hex = this.get(); | ||
if (hex[0] === hex[1] && hex[2] === hex[3] && hex[4] === hex[5]) { | ||
hex = `${hex[0]}${hex[2]}${hex[4]}`; | ||
return `#${hex[0]}${hex[2]}${hex[4]}`; | ||
} | ||
@@ -34,0 +35,0 @@ return `#${hex}`; |
@@ -13,20 +13,24 @@ import { | ||
} from './consts'; | ||
import { RGB } from './ColorInterface'; | ||
import { Color as Color_, RGB } from './ColorInterface'; | ||
import Color from './Color'; | ||
type ParseFromMatch = (match: RegExpMatchArray) => Color; | ||
type ParseFromMatch = (match: RegExpMatchArray, color?: Color) => Color; | ||
const hex6ToColor: ParseFromMatch = (match) => { | ||
const rgb = match.slice(1).map((hex) => Number.parseInt(hex, 16)); | ||
return new Color(rgb, ColorType.RGB); | ||
const hex6ToColor: ParseFromMatch = (match, color = new Color()) => { | ||
const rgb = match.slice(1).map((hex) => Number.parseInt(hex, 16)) as RGB; | ||
color.rgb.set(rgb); | ||
return color; | ||
}; | ||
const hex3ToColor: ParseFromMatch = (match) => { | ||
const rgb = match.slice(1).map((hex) => Number.parseInt(hex.repeat(2), 16)); | ||
return new Color(rgb, ColorType.RGB); | ||
const hex3ToColor: ParseFromMatch = (match, color = new Color()) => { | ||
const rgb = match | ||
.slice(1) | ||
.map((hex) => Number.parseInt(hex.repeat(2), 16)) as RGB; | ||
color.rgb.set(rgb); | ||
return color; | ||
}; | ||
const hex8ToColor: ParseFromMatch = (match) => { | ||
const hex8ToColor: ParseFromMatch = (match, color = new Color()) => { | ||
const alpha = Number.parseInt(match.pop()!, 16); | ||
const color = hex6ToColor(match); | ||
hex6ToColor(match, color); | ||
color.alpha = alpha === 0 ? alpha : alpha / 255; | ||
@@ -36,5 +40,5 @@ return color; | ||
const hex4ToColor: ParseFromMatch = (match) => { | ||
const hex4ToColor: ParseFromMatch = (match, color = new Color()) => { | ||
const alpha = Number.parseInt(match.pop()!.repeat(2), 16); | ||
const color = hex3ToColor(match); | ||
hex3ToColor(match, color); | ||
color.alpha = alpha === 0 ? alpha : alpha / 255; | ||
@@ -68,3 +72,3 @@ return color; | ||
export const cssParserTuples: [RegExp, ParseFromMatch][] = [ | ||
const cssParserTuples: [RegExp, ParseFromMatch][] = [ | ||
[RE_HEX_6, hex6ToColor], | ||
@@ -80,2 +84,4 @@ [RE_HEX_3, hex3ToColor], | ||
export const cssParsers = new Map(cssParserTuples); | ||
export const parseCSSColor = (input: string) => { | ||
@@ -82,0 +88,0 @@ let tuple = cssParserTuples.find(([re]) => re.test(input)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
72
691653
13
3733
1