Skip to content
Snippets Groups Projects
index.js 8.22 MiB
Newer Older
  • Learn to ignore specific revisions
  • 	var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
    	var b = (rem % 6) / 5 * 255;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return [r, g, b];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.rgb.hex = function (args) {
    	var integer = ((Math.round(args[0]) & 0xFF) << 16)
    		+ ((Math.round(args[1]) & 0xFF) << 8)
    		+ (Math.round(args[2]) & 0xFF);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	var string = integer.toString(16).toUpperCase();
    	return '000000'.substring(string.length) + string;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.hex.rgb = function (args) {
    	var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
    	if (!match) {
    		return [0, 0, 0];
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	var colorString = match[0];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (match[0].length === 3) {
    		colorString = colorString.split('').map(function (char) {
    			return char + char;
    		}).join('');
    	}
    
    	var integer = parseInt(colorString, 16);
    	var r = (integer >> 16) & 0xFF;
    	var g = (integer >> 8) & 0xFF;
    	var b = integer & 0xFF;
    
    	return [r, g, b];
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    convert.rgb.hcg = function (rgb) {
    	var r = rgb[0] / 255;
    	var g = rgb[1] / 255;
    	var b = rgb[2] / 255;
    	var max = Math.max(Math.max(r, g), b);
    	var min = Math.min(Math.min(r, g), b);
    	var chroma = (max - min);
    	var grayscale;
    	var hue;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (chroma < 1) {
    		grayscale = min / (1 - chroma);
    	} else {
    		grayscale = 0;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (chroma <= 0) {
    		hue = 0;
    	} else
    	if (max === r) {
    		hue = ((g - b) / chroma) % 6;
    	} else
    	if (max === g) {
    		hue = 2 + (b - r) / chroma;
    	} else {
    		hue = 4 + (r - g) / chroma + 4;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	hue /= 6;
    	hue %= 1;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return [hue * 360, chroma * 100, grayscale * 100];
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.hsl.hcg = function (hsl) {
    	var s = hsl[1] / 100;
    	var l = hsl[2] / 100;
    	var c = 1;
    	var f = 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (l < 0.5) {
    		c = 2.0 * s * l;
    	} else {
    		c = 2.0 * s * (1.0 - l);
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (c < 1.0) {
    		f = (l - 0.5 * c) / (1.0 - c);
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return [hsl[0], c * 100, f * 100];
    
    convert.hsv.hcg = function (hsv) {
    	var s = hsv[1] / 100;
    	var v = hsv[2] / 100;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	var c = s * v;
    	var f = 0;
    
    	if (c < 1.0) {
    		f = (v - c) / (1 - c);
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return [hsv[0], c * 100, f * 100];
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.hcg.rgb = function (hcg) {
    	var h = hcg[0] / 360;
    	var c = hcg[1] / 100;
    	var g = hcg[2] / 100;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (c === 0.0) {
    		return [g * 255, g * 255, g * 255];
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	var pure = [0, 0, 0];
    	var hi = (h % 1) * 6;
    	var v = hi % 1;
    	var w = 1 - v;
    	var mg = 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	switch (Math.floor(hi)) {
    		case 0:
    			pure[0] = 1; pure[1] = v; pure[2] = 0; break;
    		case 1:
    			pure[0] = w; pure[1] = 1; pure[2] = 0; break;
    		case 2:
    			pure[0] = 0; pure[1] = 1; pure[2] = v; break;
    		case 3:
    			pure[0] = 0; pure[1] = w; pure[2] = 1; break;
    		case 4:
    			pure[0] = v; pure[1] = 0; pure[2] = 1; break;
    		default:
    			pure[0] = 1; pure[1] = 0; pure[2] = w;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	mg = (1.0 - c) * g;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return [
    		(c * pure[0] + mg) * 255,
    		(c * pure[1] + mg) * 255,
    		(c * pure[2] + mg) * 255
    	];
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.hcg.hsv = function (hcg) {
    	var c = hcg[1] / 100;
    	var g = hcg[2] / 100;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	var v = c + g * (1.0 - c);
    	var f = 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (v > 0.0) {
    		f = c / v;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return [hcg[0], f * 100, v * 100];
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.hcg.hsl = function (hcg) {
    	var c = hcg[1] / 100;
    	var g = hcg[2] / 100;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	var l = g * (1.0 - c) + 0.5 * c;
    	var s = 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (l > 0.0 && l < 0.5) {
    		s = c / (2 * l);
    	} else
    	if (l >= 0.5 && l < 1.0) {
    		s = c / (2 * (1 - l));
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return [hcg[0], s * 100, l * 100];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.hcg.hwb = function (hcg) {
    	var c = hcg[1] / 100;
    	var g = hcg[2] / 100;
    	var v = c + g * (1.0 - c);
    	return [hcg[0], (v - c) * 100, (1 - v) * 100];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.hwb.hcg = function (hwb) {
    	var w = hwb[1] / 100;
    	var b = hwb[2] / 100;
    	var v = 1 - b;
    	var c = v - w;
    	var g = 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (c < 1) {
    		g = (v - c) / (1 - c);
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return [hwb[0], c * 100, g * 100];
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    convert.apple.rgb = function (apple) {
    	return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    convert.rgb.apple = function (rgb) {
    	return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    convert.gray.rgb = function (args) {
    	return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    convert.gray.hsl = convert.gray.hsv = function (args) {
    	return [0, 0, args[0]];
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    convert.gray.hwb = function (gray) {
    	return [0, 100, gray[0]];
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    convert.gray.cmyk = function (gray) {
    	return [0, 0, 0, gray[0]];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.gray.lab = function (gray) {
    	return [gray[0], 0, 0];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.gray.hex = function (gray) {
    	var val = Math.round(gray[0] / 100 * 255) & 0xFF;
    	var integer = (val << 16) + (val << 8) + val;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	var string = integer.toString(16).toUpperCase();
    	return '000000'.substring(string.length) + string;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    convert.rgb.gray = function (rgb) {
    	var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
    	return [val / 255 * 100];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    
    /***/ }),
    /* 16 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    "use strict";
    
    
    module.exports = {
    	"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]
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    
    /***/ }),
    /* 17 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var conversions = __webpack_require__(15);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /*
    	this function routes a model to all other models.
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	all functions that are routed have a property `.conversion` attached
    	to the returned synthetic function. This property is an array
    	of strings, each with the steps in between the 'from' and 'to'
    	color models (inclusive).
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	conversions that are not possible simply are not included.
    */
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function buildGraph() {
    	var graph = {};
    	// https://jsperf.com/object-keys-vs-for-in-with-closure/3
    	var models = Object.keys(conversions);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	for (var len = models.length, i = 0; i < len; i++) {
    		graph[models[i]] = {
    			// http://jsperf.com/1-vs-infinity
    			// micro-opt, but this is simple.
    			distance: -1,
    			parent: null
    		};
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return graph;
    }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    // https://en.wikipedia.org/wiki/Breadth-first_search
    function deriveBFS(fromModel) {
    	var graph = buildGraph();
    	var queue = [fromModel]; // unshift -> queue -> pop
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	graph[fromModel].distance = 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	while (queue.length) {
    		var current = queue.pop();
    		var adjacents = Object.keys(conversions[current]);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    		for (var len = adjacents.length, i = 0; i < len; i++) {
    			var adjacent = adjacents[i];
    			var node = graph[adjacent];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    			if (node.distance === -1) {
    				node.distance = graph[current].distance + 1;
    				node.parent = current;
    				queue.unshift(adjacent);
    			}
    		}
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return graph;
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    
    function link(from, to) {
    	return function (args) {
    		return to(from(args));
    	};
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function wrapConversion(toModel, graph) {
    	var path = [graph[toModel].parent, toModel];
    	var fn = conversions[graph[toModel].parent][toModel];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	var cur = graph[toModel].parent;
    	while (graph[cur].parent) {
    		path.unshift(graph[cur].parent);
    		fn = link(conversions[graph[cur].parent][cur], fn);
    		cur = graph[cur].parent;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	fn.conversion = path;
    	return fn;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = function (fromModel) {
    	var graph = deriveBFS(fromModel);
    	var conversion = {};
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	var models = Object.keys(graph);
    	for (var len = models.length, i = 0; i < len; i++) {
    		var toModel = models[i];
    		var node = graph[toModel];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    		if (node.parent === null) {
    			// no possible conversion, or this node is the source model.
    			continue;
    		}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    		conversion[toModel] = wrapConversion(toModel, graph);
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return conversion;
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 18 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    "use strict";
    
    const os = __webpack_require__(19);
    const hasFlag = __webpack_require__(20);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const env = process.env;
    
    let forceColor;
    if (hasFlag('no-color') ||
    	hasFlag('no-colors') ||
    	hasFlag('color=false')) {
    	forceColor = false;
    } else if (hasFlag('color') ||
    	hasFlag('colors') ||
    	hasFlag('color=true') ||
    	hasFlag('color=always')) {
    	forceColor = true;
    
    if ('FORCE_COLOR' in env) {
    	forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function translateLevel(level) {
    	if (level === 0) {
    		return false;
    	}
    
    	return {
    		level,
    		hasBasic: true,
    		has256: level >= 2,
    		has16m: level >= 3
    	};
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function supportsColor(stream) {
    	if (forceColor === false) {
    		return 0;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (hasFlag('color=16m') ||
    		hasFlag('color=full') ||
    		hasFlag('color=truecolor')) {
    		return 3;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (hasFlag('color=256')) {
    		return 2;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (stream && !stream.isTTY && forceColor !== true) {
    		return 0;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	const min = forceColor ? 1 : 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (process.platform === 'win32') {
    		// Node.js 7.5.0 is the first version of Node.js to include a patch to
    		// libuv that enables 256 color output on Windows. Anything earlier and it
    		// won't work. However, here we target Node.js 8 at minimum as it is an LTS
    		// release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
    		// release that supports 256 colors. Windows 10 build 14931 is the first release
    		// that supports 16m/TrueColor.
    		const osRelease = os.release().split('.');
    		if (
    			Number(process.versions.node.split('.')[0]) >= 8 &&
    			Number(osRelease[0]) >= 10 &&
    			Number(osRelease[2]) >= 10586
    		) {
    			return Number(osRelease[2]) >= 14931 ? 3 : 2;
    		}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if ('CI' in env) {
    		if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
    			return 1;
    		}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    		return min;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if ('TEAMCITY_VERSION' in env) {
    		return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (env.COLORTERM === 'truecolor') {
    		return 3;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if ('TERM_PROGRAM' in env) {
    		const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
    
    		switch (env.TERM_PROGRAM) {
    			case 'iTerm.app':
    				return version >= 3 ? 3 : 2;
    			case 'Apple_Terminal':
    				return 2;
    			// No default
    		}
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (/-256(color)?$/i.test(env.TERM)) {
    		return 2;
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
    		return 1;
    	}
    
    	if ('COLORTERM' in env) {
    		return 1;
    	}
    
    	if (env.TERM === 'dumb') {
    		return min;
    	}
    
    	return min;
    }
    
    function getSupportLevel(stream) {
    	const level = supportsColor(stream);
    	return translateLevel(level);
    }
    
    module.exports = {
    	supportsColor: getSupportLevel,
    	stdout: getSupportLevel(process.stdout),
    	stderr: getSupportLevel(process.stderr)
    
    /***/ }),
    /* 19 */
    /***/ (function(module, exports) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = require("os");
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 20 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    "use strict";
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = (flag, argv) => {
    	argv = argv || process.argv;
    	const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
    	const pos = argv.indexOf(prefix + flag);
    	const terminatorPos = argv.indexOf('--');
    	return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    
    /***/ }),
    /* 21 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    "use strict";
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
    const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
    const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
    const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const ESCAPES = new Map([
    	['n', '\n'],
    	['r', '\r'],
    	['t', '\t'],
    	['b', '\b'],
    	['f', '\f'],
    	['v', '\v'],
    	['0', '\0'],
    	['\\', '\\'],
    	['e', '\u001B'],
    	['a', '\u0007']
    ]);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function unescape(c) {
    	if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
    		return String.fromCharCode(parseInt(c.slice(1), 16));
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return ESCAPES.get(c) || c;
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    
    function parseArguments(name, args) {
    	const results = [];
    	const chunks = args.trim().split(/\s*,\s*/g);
    	let matches;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	for (const chunk of chunks) {
    		if (!isNaN(chunk)) {
    			results.push(Number(chunk));
    		} else if ((matches = chunk.match(STRING_REGEX))) {
    			results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
    		} else {
    			throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
    		}
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return results;
    }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function parseStyle(style) {
    	STYLE_REGEX.lastIndex = 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	const results = [];
    	let matches;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	while ((matches = STYLE_REGEX.exec(style)) !== null) {
    		const name = matches[1];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    		if (matches[2]) {
    			const args = parseArguments(name, matches[2]);
    			results.push([name].concat(args));
    		} else {
    			results.push([name]);
    		}
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return results;
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    
    function buildStyle(chalk, styles) {
    	const enabled = {};
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	for (const layer of styles) {
    		for (const style of layer.styles) {
    			enabled[style[0]] = layer.inverse ? null : style.slice(1);
    		}
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	let current = chalk;
    	for (const styleName of Object.keys(enabled)) {
    		if (Array.isArray(enabled[styleName])) {
    			if (!(styleName in current)) {
    				throw new Error(`Unknown Chalk style: ${styleName}`);
    			}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    			if (enabled[styleName].length > 0) {
    				current = current[styleName].apply(current, enabled[styleName]);
    			} else {
    				current = current[styleName];
    			}
    		}
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return current;
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    
    module.exports = (chalk, tmp) => {
    	const styles = [];
    	const chunks = [];
    	let chunk = [];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	// eslint-disable-next-line max-params
    	tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
    		if (escapeChar) {
    			chunk.push(unescape(escapeChar));
    		} else if (style) {
    			const str = chunk.join('');
    			chunk = [];
    			chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
    			styles.push({inverse, styles: parseStyle(style)});
    		} else if (close) {
    			if (styles.length === 0) {
    				throw new Error('Found extraneous } in Chalk template literal');
    			}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    			chunks.push(buildStyle(chalk, styles)(chunk.join('')));
    			chunk = [];
    			styles.pop();
    		} else {
    			chunk.push(chr);
    		}
    	});
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	chunks.push(chunk.join(''));
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	if (styles.length > 0) {
    		const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
    		throw new Error(errMsg);
    	}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    	return chunks.join('');
    
    /***/ }),
    /* 22 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = __webpack_require__(23).default;
    
    Romain CREY's avatar
    Romain CREY committed
    
    /***/ }),
    
    /* 23 */
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    
    /**
     * This is a function which returns an instance of
     * [request-promise](https://www.npmjs.com/package/request-promise) initialized with
     * defaults often used in connector development.
     *
     * ```js
     * // Showing defaults
     * req = requestFactory({
     *   cheerio: false,
     *   jar: true,
     *   json: true
     * })
     * ```
     *
     * Options :
     *
     * - `cheerio`:  will parse automatically the `response.body` in a cheerio instance
     *
     * ```javascript
     * req = requestFactory({ cheerio: true })
     * req('http://github.com', $ => {
     *   const repos = $('#repo_listing .repo')
     * })
     * ```
     *
     * - `jar`: is passed to `request` options. Remembers cookies for future use.
     * - `json`: will parse the `response.body` as JSON
     * - `resolveWithFullResponse`: The full response will be return in the promise. It is compatible
     *   with cheerio and json options.
     *
     * ```javascript
     * req = requestFactory({
     *    resolveWithFullResponse: true,
     *    cheerio: true
     * })
     * req('http://github.com', response => {
     *   console.log(response.statusCode)
     *   const $ = response.body
     *   const repos = $('#repo_listing .repo')
     * })
     * ```
     * - `debug`: will display request and responses details in error output. Possible values :
     *   true : display request and response in normal request-debug json format
     *   'json' : display request and response in full json format
     *   'simple' : display main information about each request and response
     *   ```
     *   GET -> http://books.toscrape.com/media/cache/26/0c/260c6ae16bce31c8f8c95daddd9f4a1c.jpg
     *   <- 200  Content-Length: 7095
     *   ```
     *   'full' : display comple information about each request and response
     *   ```
     *   GET -> http://quotes.toscrape.com/login
     *
     *   BEGIN HEADERS
     *   host: quotes.toscrape.com
     *   END HEADERS
     *
     *   <- 200  Content-Length: 1869
     *
     *   BEGIN HEADERS
     *   server: nginx/1.12.1
     *   ...
     *   END HEADERS
     *
     *   BEGIN BODY
     *   <html>....
     *   END BODY
     *   ```
     *
     * You can find the full list of available options in [request-promise](https://github.com/request/request-promise) and [request](https://github.com/request/request) documentations.
     *
     * @module requestFactory
     */
    let request = __webpack_require__(24);
    
    const requestdebug = __webpack_require__(273); // Quickly found more UserAgent here
    // https://www.whatismybrowser.com/guides/the-latest-user-agent/
    
    const AGENTS_LIST = ['Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11.1; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (X11; Linux i686; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75'];
    const DEFAULT_USER_AGENT = AGENTS_LIST[Math.floor(Math.random() * AGENTS_LIST.length)];
    exports = module.exports = {
      default: requestFactory,
      mergeDefaultOptions,
      transformWithCheerio,
      getRequestOptions,
      DEFAULT_USER_AGENT
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    function requestFactory({
      debug,
      ...options
    } = {
      debug: false
    }) {
      const logFn = setDebugFunction(debug);
      debug && requestdebug(request, logFn);
      return request.defaults(getRequestOptions(mergeDefaultOptions(options)));
    }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function setDebugFunction(debug) {
      /* eslint no-console: off */
      if (debug === 'simple') {
        return (type, data) => console.error(requestToStrings(type, data).oneline);
      } else if (debug === 'json') {
        return (type, data) => console.error(JSON.stringify({
          type,
          data
        }));
      } else if (debug === 'full') {
        return (type, data) => {
          const {
            oneline,
            headers,
            body
          } = requestToStrings(type, data);
          console.error(`${oneline}
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    BEGIN HEADERS
    ${headers}
    END HEADERS
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    ` + (body ? `BEGIN BODY
    ${body}
    END BODY
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    ` : ''));
        };
      } else if (typeof debug === 'function') {
        return (type, data, resp) => debug({
          strings: requestToStrings(type, data),
          type,
          data,
          resp
        });
      }
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    
    function requestToStrings(type, data) {
      const result = {};
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      if (type === 'request') {
        result.oneline = `${data.method} -> ${data.uri} ${data.headers['content-length'] ? 'Content-Length: ' + data.headers['content-length'] : ''}`;
      } else if (type === 'response') {
        result.oneline = `<- ${data.statusCode}  ${data.headers['content-length'] ? 'Content-Length: ' + data.headers['content-length'] : ''}`;
      } else {
        result.oneline = `<- ${data.statusCode} ${data.uri}`;
      }
    
      result.headers = Object.keys(data.headers).map(key => `${key}: ${data.headers[key]}`).join('\n');
      result.body = data.body;
      return result;
    }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function mergeDefaultOptions(options = {}) {
      const defaultOptions = {
        debug: false,
        json: true,
        cheerio: false,
        headers: {},
        followAllRedirects: true
      };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      if (options.cheerio === true) {
        options.json = false;
      }
    
      return { ...defaultOptions,
        ...options
      };
    }
    
    function transformWithCheerio(body, response, resolveWithFullResponse) {
      const result = __webpack_require__(275).load(body);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      if (resolveWithFullResponse) {
        return { ...response,
          body: result
    
      return result;
    }
    
    function getRequestOptions({
      cheerio,
      userAgent,
      ...options
    }) {
      const userAgentOption = options.headers['User-Agent'];
      return cheerio ? { ...options,
        transform: transformWithCheerio,
        headers: { ...options.headers,
          'User-Agent': userAgentOption ? userAgentOption : userAgent === false ? undefined : DEFAULT_USER_AGENT
    
      } : { ...options,
        headers: { ...options.headers,