@charcoal-ui/theme 2.0.0-alpha.4 → 2.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,868 @@
1
- var e=require("@charcoal-ui/foundation"),a=require("@charcoal-ui/utils");function r(){return r=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},r.apply(this,arguments)}function t(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function n(e,a){return n=Object.setPrototypeOf||function(e,a){return e.__proto__=a,e},n(e,a)}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function i(e,a,r){return i=s()?Reflect.construct:function(e,a,r){var t=[null];t.push.apply(t,a);var o=new(Function.bind.apply(e,t));return r&&n(o,r.prototype),o},i.apply(null,arguments)}function f(e){var a="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==a){if(a.has(e))return a.get(e);a.set(e,r)}function r(){return i(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),n(r,e)},f(e)}var l={1:"Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",2:"Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",3:"Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",4:"Couldn't generate valid rgb string from %s, it returned %s.\n\n",5:"Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",6:"Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",7:"Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",8:"Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",9:"Please provide a number of steps to the modularScale helper.\n\n",10:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",11:'Invalid value passed as base to modularScale, expected number or em string but got "%s"\n\n',12:'Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.\n\n',13:'Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.\n\n',14:'Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',15:'Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',16:"You must provide a template to this method.\n\n",17:"You passed an unsupported selector state to this method.\n\n",18:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",19:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",20:"expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:"fontFace expects a name of a font-family.\n\n",24:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",25:"fontFace expects localFonts to be an array.\n\n",26:"fontFace expects fileFormats to be an array.\n\n",27:"radialGradient requries at least 2 color-stops to properly render.\n\n",28:"Please supply a filename to retinaImage() as the first argument.\n\n",29:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",32:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",33:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",34:"borderRadius expects a radius value as a string or number as the second argument.\n\n",35:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',36:"Property must be a string value.\n\n",37:"Syntax Error at %s.\n\n",38:"Formula contains a function that needs parentheses at %s.\n\n",39:"Formula is missing closing parenthesis at %s.\n\n",40:"Formula has too many closing parentheses at %s.\n\n",41:"All values in a formula must have the same unit or be unitless.\n\n",42:"Please provide a number of steps to the modularScale helper.\n\n",43:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",44:"Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",45:"Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",46:"Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",47:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",48:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",49:"Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",50:"Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",51:"Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",52:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",53:"fontFace expects localFonts to be an array.\n\n",54:"fontFace expects fileFormats to be an array.\n\n",55:"fontFace expects a name of a font-family.\n\n",56:"linearGradient requries at least 2 color-stops to properly render.\n\n",57:"radialGradient requries at least 2 color-stops to properly render.\n\n",58:"Please supply a filename to retinaImage() as the first argument.\n\n",59:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:"Property must be a string value.\n\n",62:"borderRadius expects a radius value as a string or number as the second argument.\n\n",63:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',64:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",65:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",66:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",67:"You must provide a template to this method.\n\n",68:"You passed an unsupported selector state to this method.\n\n",69:'Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.\n\n',70:'Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.\n\n',71:'Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.\n\n',72:'Passed invalid base value %s to %s(), please pass a value like "12px" or 12.\n\n',73:"Please provide a valid CSS variable.\n\n",74:"CSS variable not found and no default was provided.\n\n",75:"important requires a valid style object, got a %s instead.\n\n",76:"fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",77:'remToPx expects a value in "rem" but you provided it in "%s".\n\n',78:'base must be set in "px" or "%" but you set it in "%s".\n'};function u(){for(var e=arguments.length,a=new Array(e),r=0;r<e;r++)a[r]=arguments[r];var t,n=a[0],o=[];for(t=1;t<a.length;t+=1)o.push(a[t]);return o.forEach(function(e){n=n.replace(/%[a-z]/,e)}),n}var d=/*#__PURE__*/function(e){var a,r;function o(a){var r;if("production"===process.env.NODE_ENV)r=e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+a+" for more information.")||this;else{for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];r=e.call(this,u.apply(void 0,[l[a]].concat(o)))||this}return t(r)}return r=e,(a=o).prototype=Object.create(r.prototype),a.prototype.constructor=a,n(a,r),o}(/*#__PURE__*/f(Error));function p(e){return Math.round(255*e)}function c(e,a,r){return p(e)+","+p(a)+","+p(r)}function b(e,a,r,t){if(void 0===t&&(t=c),0===a)return t(r,r,r);var n=(e%360+360)%360/60,o=(1-Math.abs(2*r-1))*a,s=o*(1-Math.abs(n%2-1)),i=0,f=0,l=0;n>=0&&n<1?(i=o,f=s):n>=1&&n<2?(i=s,f=o):n>=2&&n<3?(f=o,l=s):n>=3&&n<4?(f=s,l=o):n>=4&&n<5?(i=s,l=o):n>=5&&n<6&&(i=o,l=s);var u=r-o/2;return t(i+u,f+u,l+u)}var g={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},h=/^#[a-fA-F0-9]{6}$/,m=/^#[a-fA-F0-9]{8}$/,v=/^#[a-fA-F0-9]{3}$/,y=/^#[a-fA-F0-9]{4}$/,x=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i,w=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i,k=/^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,S=/^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i,I=function(e){return 7===e.length&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e};function P(e){var a=e.toString(16);return 1===a.length?"0"+a:a}function j(e,a,r){if("number"==typeof e&&"number"==typeof a&&"number"==typeof r)return I("#"+P(e)+P(a)+P(r));if("object"==typeof e&&void 0===a&&void 0===r)return I("#"+P(e.red)+P(e.green)+P(e.blue));throw new d(6)}function F(e,a,r,t){if("string"==typeof e&&"number"==typeof a){var n=function(e){if("string"!=typeof e)throw new d(3);var a=function(e){if("string"!=typeof e)return e;var a=e.toLowerCase();return g[a]?"#"+g[a]:e}(e);if(a.match(h))return{red:parseInt(""+a[1]+a[2],16),green:parseInt(""+a[3]+a[4],16),blue:parseInt(""+a[5]+a[6],16)};if(a.match(m)){var r=parseFloat((parseInt(""+a[7]+a[8],16)/255).toFixed(2));return{red:parseInt(""+a[1]+a[2],16),green:parseInt(""+a[3]+a[4],16),blue:parseInt(""+a[5]+a[6],16),alpha:r}}if(a.match(v))return{red:parseInt(""+a[1]+a[1],16),green:parseInt(""+a[2]+a[2],16),blue:parseInt(""+a[3]+a[3],16)};if(a.match(y)){var t=parseFloat((parseInt(""+a[4]+a[4],16)/255).toFixed(2));return{red:parseInt(""+a[1]+a[1],16),green:parseInt(""+a[2]+a[2],16),blue:parseInt(""+a[3]+a[3],16),alpha:t}}var n=x.exec(a);if(n)return{red:parseInt(""+n[1],10),green:parseInt(""+n[2],10),blue:parseInt(""+n[3],10)};var o=w.exec(a.substring(0,50));if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10),alpha:parseFloat(""+o[4])};var s=k.exec(a);if(s){var i="rgb("+b(parseInt(""+s[1],10),parseInt(""+s[2],10)/100,parseInt(""+s[3],10)/100)+")",f=x.exec(i);if(!f)throw new d(4,a,i);return{red:parseInt(""+f[1],10),green:parseInt(""+f[2],10),blue:parseInt(""+f[3],10)}}var l=S.exec(a.substring(0,50));if(l){var u="rgb("+b(parseInt(""+l[1],10),parseInt(""+l[2],10)/100,parseInt(""+l[3],10)/100)+")",p=x.exec(u);if(!p)throw new d(4,a,u);return{red:parseInt(""+p[1],10),green:parseInt(""+p[2],10),blue:parseInt(""+p[3],10),alpha:parseFloat(""+l[4])}}throw new d(5)}(e);return"rgba("+n.red+","+n.green+","+n.blue+","+a+")"}if("number"==typeof e&&"number"==typeof a&&"number"==typeof r&&"number"==typeof t)return t>=1?j(e,a,r):"rgba("+e+","+a+","+r+","+t+")";if("object"==typeof e&&void 0===a&&void 0===r&&void 0===t)return e.alpha>=1?j(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new d(7)}var E={type:"opacity",opacity:.32},R=F("#000000",.08),O=F("#ffffff",.12),T={typography:{size:e.TYPOGRAPHY_SIZE},spacing:e.SPACING,grid:{unit:{column:e.COLUMN_UNIT,gutter:e.GUTTER_UNIT}},borderRadius:e.BORDER_RADIUS,transition:{default:{duration:.2}},breakpoint:{screen1:e.BREAKPOINT[6],screen2:e.BREAKPOINT[8],screen3:e.BREAKPOINT[10],screen4:e.BREAKPOINT[12]},gradientColor:{surface5:[{color:F("#000000",.32),ratio:0},{color:F("#000000",0),ratio:100}],callToAction:[{color:"#d1ff1a",ratio:0},{color:"#1ad1ff",ratio:100}]},outline:{default:{color:a.applyEffect("#0096fa",E),weight:4},assertive:{color:a.applyEffect("#ff2b00",E),weight:4}},elementEffect:{disabled:{type:"opacity",opacity:.32}}},z=r({},T,{effect:{hover:{type:"alpha",color:F("#000000",.04)},press:{type:"alpha",color:F("#000000",.16)}},color:{transparent:F("#000000",0),background1:"#ffffff",background2:"#f5f5f5",icon6:F("#ffffff",.28),link1:"#3d7699",link2:F("#ffffff",.36),surface1:"#ffffff",surface2:F("#000000",.02),surface3:F("#000000",.04),surface4:F("#000000",.32),surface6:F("#000000",.88),surface7:F("#000000",.02),surface8:F("#000000",.88),surface9:"#ffffff",surface10:F("#000000",.16),text1:"#1f1f1f",text2:"#474747",text3:"#858585",text4:"#adadad",text5:"#ffffff",brand:"#0096fa",assertive:"#ff2b00",warning:"#ffaf0f",success:"#b1cc29",updatedItem:F(0,150,250,.04),border:R},border:{default:{color:R}}}),C=r({},T,{effect:{hover:{type:"alpha",color:F("#ffffff",.12)},press:{type:"alpha",color:F("#ffffff",.2)}},color:{transparent:F("#000000",0),background1:"#1f1f1f",background2:"#000000",icon6:z.color.icon6,link1:z.color.link1,link2:z.color.link2,surface1:"#1f1f1f",surface2:F("#000000",.16),surface3:F("#ffffff",.12),surface4:z.color.surface4,surface6:F("#ffffff",.12),surface7:z.color.surface7,surface8:z.color.surface8,surface9:"#333333",surface10:F("#ffffff",.2),text1:"#f5f5f5",text2:"#d6d6d6",text3:"#858585",text4:"#5c5c5c",text5:"#f5f5f5",brand:"#0096fa",assertive:"#ff2b00",warning:z.color.warning,success:z.color.success,updatedItem:F(0,150,250,.12),border:O},border:{default:{color:O}}});exports.dark=C,exports.light=z;
1
+ var foundation = require('@charcoal-ui/foundation');
2
+ var utils = require('@charcoal-ui/utils');
3
+
4
+ function _extends() {
5
+ _extends = Object.assign || function (target) {
6
+ for (var i = 1; i < arguments.length; i++) {
7
+ var source = arguments[i];
8
+
9
+ for (var key in source) {
10
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
11
+ target[key] = source[key];
12
+ }
13
+ }
14
+ }
15
+
16
+ return target;
17
+ };
18
+
19
+ return _extends.apply(this, arguments);
20
+ }
21
+
22
+ function _assertThisInitialized(self) {
23
+ if (self === void 0) {
24
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
25
+ }
26
+
27
+ return self;
28
+ }
29
+
30
+ function _setPrototypeOf(o, p) {
31
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
32
+ o.__proto__ = p;
33
+ return o;
34
+ };
35
+
36
+ return _setPrototypeOf(o, p);
37
+ }
38
+
39
+ function _inheritsLoose(subClass, superClass) {
40
+ subClass.prototype = Object.create(superClass.prototype);
41
+ subClass.prototype.constructor = subClass;
42
+ _setPrototypeOf(subClass, superClass);
43
+ }
44
+
45
+ function _getPrototypeOf(o) {
46
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
47
+ return o.__proto__ || Object.getPrototypeOf(o);
48
+ };
49
+ return _getPrototypeOf(o);
50
+ }
51
+
52
+ function _isNativeFunction(fn) {
53
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
54
+ }
55
+
56
+ function _isNativeReflectConstruct() {
57
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
58
+ if (Reflect.construct.sham) return false;
59
+ if (typeof Proxy === "function") return true;
60
+
61
+ try {
62
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
63
+ return true;
64
+ } catch (e) {
65
+ return false;
66
+ }
67
+ }
68
+
69
+ function _construct(Parent, args, Class) {
70
+ if (_isNativeReflectConstruct()) {
71
+ _construct = Reflect.construct;
72
+ } else {
73
+ _construct = function _construct(Parent, args, Class) {
74
+ var a = [null];
75
+ a.push.apply(a, args);
76
+ var Constructor = Function.bind.apply(Parent, a);
77
+ var instance = new Constructor();
78
+ if (Class) _setPrototypeOf(instance, Class.prototype);
79
+ return instance;
80
+ };
81
+ }
82
+
83
+ return _construct.apply(null, arguments);
84
+ }
85
+
86
+ function _wrapNativeSuper(Class) {
87
+ var _cache = typeof Map === "function" ? new Map() : undefined;
88
+
89
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
90
+ if (Class === null || !_isNativeFunction(Class)) return Class;
91
+
92
+ if (typeof Class !== "function") {
93
+ throw new TypeError("Super expression must either be null or a function");
94
+ }
95
+
96
+ if (typeof _cache !== "undefined") {
97
+ if (_cache.has(Class)) return _cache.get(Class);
98
+
99
+ _cache.set(Class, Wrapper);
100
+ }
101
+
102
+ function Wrapper() {
103
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
104
+ }
105
+
106
+ Wrapper.prototype = Object.create(Class.prototype, {
107
+ constructor: {
108
+ value: Wrapper,
109
+ enumerable: false,
110
+ writable: true,
111
+ configurable: true
112
+ }
113
+ });
114
+ return _setPrototypeOf(Wrapper, Class);
115
+ };
116
+
117
+ return _wrapNativeSuper(Class);
118
+ }
119
+
120
+ /**
121
+ * Parse errors.md and turn it into a simple hash of code: message
122
+ * @private
123
+ */
124
+
125
+ var ERRORS = {
126
+ "1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
127
+ "2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
128
+ "3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
129
+ "4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
130
+ "5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
131
+ "6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
132
+ "7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
133
+ "8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
134
+ "9": "Please provide a number of steps to the modularScale helper.\n\n",
135
+ "10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
136
+ "11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
137
+ "12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
138
+ "13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
139
+ "14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
140
+ "15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
141
+ "16": "You must provide a template to this method.\n\n",
142
+ "17": "You passed an unsupported selector state to this method.\n\n",
143
+ "18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
144
+ "19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
145
+ "20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
146
+ "21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
147
+ "22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
148
+ "23": "fontFace expects a name of a font-family.\n\n",
149
+ "24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
150
+ "25": "fontFace expects localFonts to be an array.\n\n",
151
+ "26": "fontFace expects fileFormats to be an array.\n\n",
152
+ "27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
153
+ "28": "Please supply a filename to retinaImage() as the first argument.\n\n",
154
+ "29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
155
+ "30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
156
+ "31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
157
+ "32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
158
+ "33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
159
+ "34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
160
+ "35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
161
+ "36": "Property must be a string value.\n\n",
162
+ "37": "Syntax Error at %s.\n\n",
163
+ "38": "Formula contains a function that needs parentheses at %s.\n\n",
164
+ "39": "Formula is missing closing parenthesis at %s.\n\n",
165
+ "40": "Formula has too many closing parentheses at %s.\n\n",
166
+ "41": "All values in a formula must have the same unit or be unitless.\n\n",
167
+ "42": "Please provide a number of steps to the modularScale helper.\n\n",
168
+ "43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
169
+ "44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
170
+ "45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
171
+ "46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
172
+ "47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
173
+ "48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
174
+ "49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
175
+ "50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
176
+ "51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
177
+ "52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
178
+ "53": "fontFace expects localFonts to be an array.\n\n",
179
+ "54": "fontFace expects fileFormats to be an array.\n\n",
180
+ "55": "fontFace expects a name of a font-family.\n\n",
181
+ "56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
182
+ "57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
183
+ "58": "Please supply a filename to retinaImage() as the first argument.\n\n",
184
+ "59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
185
+ "60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
186
+ "61": "Property must be a string value.\n\n",
187
+ "62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
188
+ "63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
189
+ "64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
190
+ "65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
191
+ "66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
192
+ "67": "You must provide a template to this method.\n\n",
193
+ "68": "You passed an unsupported selector state to this method.\n\n",
194
+ "69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
195
+ "70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
196
+ "71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
197
+ "72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
198
+ "73": "Please provide a valid CSS variable.\n\n",
199
+ "74": "CSS variable not found and no default was provided.\n\n",
200
+ "75": "important requires a valid style object, got a %s instead.\n\n",
201
+ "76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",
202
+ "77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
203
+ "78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
204
+ };
205
+ /**
206
+ * super basic version of sprintf
207
+ * @private
208
+ */
209
+
210
+ function format() {
211
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
212
+ args[_key] = arguments[_key];
213
+ }
214
+
215
+ var a = args[0];
216
+ var b = [];
217
+ var c;
218
+
219
+ for (c = 1; c < args.length; c += 1) {
220
+ b.push(args[c]);
221
+ }
222
+
223
+ b.forEach(function (d) {
224
+ a = a.replace(/%[a-z]/, d);
225
+ });
226
+ return a;
227
+ }
228
+ /**
229
+ * Create an error file out of errors.md for development and a simple web link to the full errors
230
+ * in production mode.
231
+ * @private
232
+ */
233
+
234
+
235
+ var PolishedError = /*#__PURE__*/function (_Error) {
236
+ _inheritsLoose(PolishedError, _Error);
237
+
238
+ function PolishedError(code) {
239
+ var _this;
240
+
241
+ if (process.env.NODE_ENV === 'production') {
242
+ _this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
243
+ } else {
244
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
245
+ args[_key2 - 1] = arguments[_key2];
246
+ }
247
+
248
+ _this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
249
+ }
250
+
251
+ return _assertThisInitialized(_this);
252
+ }
253
+
254
+ return PolishedError;
255
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
256
+
257
+ function colorToInt(color) {
258
+ return Math.round(color * 255);
259
+ }
260
+
261
+ function convertToInt(red, green, blue) {
262
+ return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
263
+ }
264
+
265
+ function hslToRgb(hue, saturation, lightness, convert) {
266
+ if (convert === void 0) {
267
+ convert = convertToInt;
268
+ }
269
+
270
+ if (saturation === 0) {
271
+ // achromatic
272
+ return convert(lightness, lightness, lightness);
273
+ } // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
274
+
275
+
276
+ var huePrime = (hue % 360 + 360) % 360 / 60;
277
+ var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
278
+ var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
279
+ var red = 0;
280
+ var green = 0;
281
+ var blue = 0;
282
+
283
+ if (huePrime >= 0 && huePrime < 1) {
284
+ red = chroma;
285
+ green = secondComponent;
286
+ } else if (huePrime >= 1 && huePrime < 2) {
287
+ red = secondComponent;
288
+ green = chroma;
289
+ } else if (huePrime >= 2 && huePrime < 3) {
290
+ green = chroma;
291
+ blue = secondComponent;
292
+ } else if (huePrime >= 3 && huePrime < 4) {
293
+ green = secondComponent;
294
+ blue = chroma;
295
+ } else if (huePrime >= 4 && huePrime < 5) {
296
+ red = secondComponent;
297
+ blue = chroma;
298
+ } else if (huePrime >= 5 && huePrime < 6) {
299
+ red = chroma;
300
+ blue = secondComponent;
301
+ }
302
+
303
+ var lightnessModification = lightness - chroma / 2;
304
+ var finalRed = red + lightnessModification;
305
+ var finalGreen = green + lightnessModification;
306
+ var finalBlue = blue + lightnessModification;
307
+ return convert(finalRed, finalGreen, finalBlue);
308
+ }
309
+
310
+ var namedColorMap = {
311
+ aliceblue: 'f0f8ff',
312
+ antiquewhite: 'faebd7',
313
+ aqua: '00ffff',
314
+ aquamarine: '7fffd4',
315
+ azure: 'f0ffff',
316
+ beige: 'f5f5dc',
317
+ bisque: 'ffe4c4',
318
+ black: '000',
319
+ blanchedalmond: 'ffebcd',
320
+ blue: '0000ff',
321
+ blueviolet: '8a2be2',
322
+ brown: 'a52a2a',
323
+ burlywood: 'deb887',
324
+ cadetblue: '5f9ea0',
325
+ chartreuse: '7fff00',
326
+ chocolate: 'd2691e',
327
+ coral: 'ff7f50',
328
+ cornflowerblue: '6495ed',
329
+ cornsilk: 'fff8dc',
330
+ crimson: 'dc143c',
331
+ cyan: '00ffff',
332
+ darkblue: '00008b',
333
+ darkcyan: '008b8b',
334
+ darkgoldenrod: 'b8860b',
335
+ darkgray: 'a9a9a9',
336
+ darkgreen: '006400',
337
+ darkgrey: 'a9a9a9',
338
+ darkkhaki: 'bdb76b',
339
+ darkmagenta: '8b008b',
340
+ darkolivegreen: '556b2f',
341
+ darkorange: 'ff8c00',
342
+ darkorchid: '9932cc',
343
+ darkred: '8b0000',
344
+ darksalmon: 'e9967a',
345
+ darkseagreen: '8fbc8f',
346
+ darkslateblue: '483d8b',
347
+ darkslategray: '2f4f4f',
348
+ darkslategrey: '2f4f4f',
349
+ darkturquoise: '00ced1',
350
+ darkviolet: '9400d3',
351
+ deeppink: 'ff1493',
352
+ deepskyblue: '00bfff',
353
+ dimgray: '696969',
354
+ dimgrey: '696969',
355
+ dodgerblue: '1e90ff',
356
+ firebrick: 'b22222',
357
+ floralwhite: 'fffaf0',
358
+ forestgreen: '228b22',
359
+ fuchsia: 'ff00ff',
360
+ gainsboro: 'dcdcdc',
361
+ ghostwhite: 'f8f8ff',
362
+ gold: 'ffd700',
363
+ goldenrod: 'daa520',
364
+ gray: '808080',
365
+ green: '008000',
366
+ greenyellow: 'adff2f',
367
+ grey: '808080',
368
+ honeydew: 'f0fff0',
369
+ hotpink: 'ff69b4',
370
+ indianred: 'cd5c5c',
371
+ indigo: '4b0082',
372
+ ivory: 'fffff0',
373
+ khaki: 'f0e68c',
374
+ lavender: 'e6e6fa',
375
+ lavenderblush: 'fff0f5',
376
+ lawngreen: '7cfc00',
377
+ lemonchiffon: 'fffacd',
378
+ lightblue: 'add8e6',
379
+ lightcoral: 'f08080',
380
+ lightcyan: 'e0ffff',
381
+ lightgoldenrodyellow: 'fafad2',
382
+ lightgray: 'd3d3d3',
383
+ lightgreen: '90ee90',
384
+ lightgrey: 'd3d3d3',
385
+ lightpink: 'ffb6c1',
386
+ lightsalmon: 'ffa07a',
387
+ lightseagreen: '20b2aa',
388
+ lightskyblue: '87cefa',
389
+ lightslategray: '789',
390
+ lightslategrey: '789',
391
+ lightsteelblue: 'b0c4de',
392
+ lightyellow: 'ffffe0',
393
+ lime: '0f0',
394
+ limegreen: '32cd32',
395
+ linen: 'faf0e6',
396
+ magenta: 'f0f',
397
+ maroon: '800000',
398
+ mediumaquamarine: '66cdaa',
399
+ mediumblue: '0000cd',
400
+ mediumorchid: 'ba55d3',
401
+ mediumpurple: '9370db',
402
+ mediumseagreen: '3cb371',
403
+ mediumslateblue: '7b68ee',
404
+ mediumspringgreen: '00fa9a',
405
+ mediumturquoise: '48d1cc',
406
+ mediumvioletred: 'c71585',
407
+ midnightblue: '191970',
408
+ mintcream: 'f5fffa',
409
+ mistyrose: 'ffe4e1',
410
+ moccasin: 'ffe4b5',
411
+ navajowhite: 'ffdead',
412
+ navy: '000080',
413
+ oldlace: 'fdf5e6',
414
+ olive: '808000',
415
+ olivedrab: '6b8e23',
416
+ orange: 'ffa500',
417
+ orangered: 'ff4500',
418
+ orchid: 'da70d6',
419
+ palegoldenrod: 'eee8aa',
420
+ palegreen: '98fb98',
421
+ paleturquoise: 'afeeee',
422
+ palevioletred: 'db7093',
423
+ papayawhip: 'ffefd5',
424
+ peachpuff: 'ffdab9',
425
+ peru: 'cd853f',
426
+ pink: 'ffc0cb',
427
+ plum: 'dda0dd',
428
+ powderblue: 'b0e0e6',
429
+ purple: '800080',
430
+ rebeccapurple: '639',
431
+ red: 'f00',
432
+ rosybrown: 'bc8f8f',
433
+ royalblue: '4169e1',
434
+ saddlebrown: '8b4513',
435
+ salmon: 'fa8072',
436
+ sandybrown: 'f4a460',
437
+ seagreen: '2e8b57',
438
+ seashell: 'fff5ee',
439
+ sienna: 'a0522d',
440
+ silver: 'c0c0c0',
441
+ skyblue: '87ceeb',
442
+ slateblue: '6a5acd',
443
+ slategray: '708090',
444
+ slategrey: '708090',
445
+ snow: 'fffafa',
446
+ springgreen: '00ff7f',
447
+ steelblue: '4682b4',
448
+ tan: 'd2b48c',
449
+ teal: '008080',
450
+ thistle: 'd8bfd8',
451
+ tomato: 'ff6347',
452
+ turquoise: '40e0d0',
453
+ violet: 'ee82ee',
454
+ wheat: 'f5deb3',
455
+ white: 'fff',
456
+ whitesmoke: 'f5f5f5',
457
+ yellow: 'ff0',
458
+ yellowgreen: '9acd32'
459
+ };
460
+ /**
461
+ * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
462
+ * @private
463
+ */
464
+
465
+ function nameToHex(color) {
466
+ if (typeof color !== 'string') return color;
467
+ var normalizedColorName = color.toLowerCase();
468
+ return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
469
+ }
470
+
471
+ var hexRegex = /^#[a-fA-F0-9]{6}$/;
472
+ var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
473
+ var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
474
+ var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
475
+ var rgbRegex = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
476
+ var rgbaRegex = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
477
+ var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
478
+ var hslaRegex = /^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
479
+ /**
480
+ * Returns an RgbColor or RgbaColor object. This utility function is only useful
481
+ * if want to extract a color component. With the color util `toColorString` you
482
+ * can convert a RgbColor or RgbaColor object back to a string.
483
+ *
484
+ * @example
485
+ * // Assigns `{ red: 255, green: 0, blue: 0 }` to color1
486
+ * const color1 = parseToRgb('rgb(255, 0, 0)');
487
+ * // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
488
+ * const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
489
+ */
490
+
491
+ function parseToRgb(color) {
492
+ if (typeof color !== 'string') {
493
+ throw new PolishedError(3);
494
+ }
495
+
496
+ var normalizedColor = nameToHex(color);
497
+
498
+ if (normalizedColor.match(hexRegex)) {
499
+ return {
500
+ red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
501
+ green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
502
+ blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
503
+ };
504
+ }
505
+
506
+ if (normalizedColor.match(hexRgbaRegex)) {
507
+ var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
508
+ return {
509
+ red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
510
+ green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
511
+ blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
512
+ alpha: alpha
513
+ };
514
+ }
515
+
516
+ if (normalizedColor.match(reducedHexRegex)) {
517
+ return {
518
+ red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
519
+ green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
520
+ blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
521
+ };
522
+ }
523
+
524
+ if (normalizedColor.match(reducedRgbaHexRegex)) {
525
+ var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
526
+
527
+ return {
528
+ red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
529
+ green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
530
+ blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
531
+ alpha: _alpha
532
+ };
533
+ }
534
+
535
+ var rgbMatched = rgbRegex.exec(normalizedColor);
536
+
537
+ if (rgbMatched) {
538
+ return {
539
+ red: parseInt("" + rgbMatched[1], 10),
540
+ green: parseInt("" + rgbMatched[2], 10),
541
+ blue: parseInt("" + rgbMatched[3], 10)
542
+ };
543
+ }
544
+
545
+ var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
546
+
547
+ if (rgbaMatched) {
548
+ return {
549
+ red: parseInt("" + rgbaMatched[1], 10),
550
+ green: parseInt("" + rgbaMatched[2], 10),
551
+ blue: parseInt("" + rgbaMatched[3], 10),
552
+ alpha: parseFloat("" + rgbaMatched[4])
553
+ };
554
+ }
555
+
556
+ var hslMatched = hslRegex.exec(normalizedColor);
557
+
558
+ if (hslMatched) {
559
+ var hue = parseInt("" + hslMatched[1], 10);
560
+ var saturation = parseInt("" + hslMatched[2], 10) / 100;
561
+ var lightness = parseInt("" + hslMatched[3], 10) / 100;
562
+ var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
563
+ var hslRgbMatched = rgbRegex.exec(rgbColorString);
564
+
565
+ if (!hslRgbMatched) {
566
+ throw new PolishedError(4, normalizedColor, rgbColorString);
567
+ }
568
+
569
+ return {
570
+ red: parseInt("" + hslRgbMatched[1], 10),
571
+ green: parseInt("" + hslRgbMatched[2], 10),
572
+ blue: parseInt("" + hslRgbMatched[3], 10)
573
+ };
574
+ }
575
+
576
+ var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
577
+
578
+ if (hslaMatched) {
579
+ var _hue = parseInt("" + hslaMatched[1], 10);
580
+
581
+ var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
582
+
583
+ var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
584
+
585
+ var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
586
+
587
+ var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
588
+
589
+ if (!_hslRgbMatched) {
590
+ throw new PolishedError(4, normalizedColor, _rgbColorString);
591
+ }
592
+
593
+ return {
594
+ red: parseInt("" + _hslRgbMatched[1], 10),
595
+ green: parseInt("" + _hslRgbMatched[2], 10),
596
+ blue: parseInt("" + _hslRgbMatched[3], 10),
597
+ alpha: parseFloat("" + hslaMatched[4])
598
+ };
599
+ }
600
+
601
+ throw new PolishedError(5);
602
+ }
603
+ /**
604
+ * Reduces hex values if possible e.g. #ff8866 to #f86
605
+ * @private
606
+ */
607
+
608
+
609
+ var reduceHexValue = function reduceHexValue(value) {
610
+ if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
611
+ return "#" + value[1] + value[3] + value[5];
612
+ }
613
+
614
+ return value;
615
+ };
616
+
617
+ var reduceHexValue$1 = reduceHexValue;
618
+
619
+ function numberToHex(value) {
620
+ var hex = value.toString(16);
621
+ return hex.length === 1 ? "0" + hex : hex;
622
+ }
623
+ /**
624
+ * Returns a string value for the color. The returned result is the smallest possible hex notation.
625
+ *
626
+ * @example
627
+ * // Styles as object usage
628
+ * const styles = {
629
+ * background: rgb(255, 205, 100),
630
+ * background: rgb({ red: 255, green: 205, blue: 100 }),
631
+ * }
632
+ *
633
+ * // styled-components usage
634
+ * const div = styled.div`
635
+ * background: ${rgb(255, 205, 100)};
636
+ * background: ${rgb({ red: 255, green: 205, blue: 100 })};
637
+ * `
638
+ *
639
+ * // CSS in JS Output
640
+ *
641
+ * element {
642
+ * background: "#ffcd64";
643
+ * background: "#ffcd64";
644
+ * }
645
+ */
646
+
647
+
648
+ function rgb(value, green, blue) {
649
+ if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
650
+ return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
651
+ } else if (typeof value === 'object' && green === undefined && blue === undefined) {
652
+ return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
653
+ }
654
+
655
+ throw new PolishedError(6);
656
+ }
657
+ /**
658
+ * Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
659
+ *
660
+ * Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
661
+ *
662
+ * @example
663
+ * // Styles as object usage
664
+ * const styles = {
665
+ * background: rgba(255, 205, 100, 0.7),
666
+ * background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
667
+ * background: rgba(255, 205, 100, 1),
668
+ * background: rgba('#ffffff', 0.4),
669
+ * background: rgba('black', 0.7),
670
+ * }
671
+ *
672
+ * // styled-components usage
673
+ * const div = styled.div`
674
+ * background: ${rgba(255, 205, 100, 0.7)};
675
+ * background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
676
+ * background: ${rgba(255, 205, 100, 1)};
677
+ * background: ${rgba('#ffffff', 0.4)};
678
+ * background: ${rgba('black', 0.7)};
679
+ * `
680
+ *
681
+ * // CSS in JS Output
682
+ *
683
+ * element {
684
+ * background: "rgba(255,205,100,0.7)";
685
+ * background: "rgba(255,205,100,0.7)";
686
+ * background: "#ffcd64";
687
+ * background: "rgba(255,255,255,0.4)";
688
+ * background: "rgba(0,0,0,0.7)";
689
+ * }
690
+ */
691
+
692
+
693
+ function rgba(firstValue, secondValue, thirdValue, fourthValue) {
694
+ if (typeof firstValue === 'string' && typeof secondValue === 'number') {
695
+ var rgbValue = parseToRgb(firstValue);
696
+ return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
697
+ } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
698
+ return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
699
+ } else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
700
+ return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
701
+ }
702
+
703
+ throw new PolishedError(7);
704
+ }
705
+
706
+ var outlineEffect = {
707
+ type: 'opacity',
708
+ opacity: 0.32
709
+ };
710
+ var assertive = '#ff2b00';
711
+ var brand = '#0096fa';
712
+ var borderForLight = rgba('#000000', 0.08);
713
+ var borderForDark = rgba('#ffffff', 0.12);
714
+ var common = {
715
+ typography: {
716
+ size: foundation.TYPOGRAPHY_SIZE
717
+ },
718
+ spacing: foundation.SPACING,
719
+ grid: {
720
+ unit: {
721
+ column: foundation.COLUMN_UNIT,
722
+ gutter: foundation.GUTTER_UNIT
723
+ }
724
+ },
725
+ borderRadius: foundation.BORDER_RADIUS,
726
+ transition: {
727
+ "default": {
728
+ duration: 0.2
729
+ }
730
+ },
731
+ breakpoint: {
732
+ screen1: foundation.BREAKPOINT[6],
733
+ screen2: foundation.BREAKPOINT[8],
734
+ screen3: foundation.BREAKPOINT[10],
735
+ screen4: foundation.BREAKPOINT[12]
736
+ },
737
+ gradientColor: {
738
+ surface5: [{
739
+ color: rgba('#000000', 0.32),
740
+ ratio: 0
741
+ }, {
742
+ color: rgba('#000000', 0),
743
+ ratio: 100
744
+ }],
745
+ callToAction: [{
746
+ color: '#d1ff1a',
747
+ ratio: 0
748
+ }, {
749
+ color: '#1ad1ff',
750
+ ratio: 100
751
+ }]
752
+ },
753
+ outline: {
754
+ "default": {
755
+ color: utils.applyEffect(brand, outlineEffect),
756
+ weight: 4
757
+ },
758
+ assertive: {
759
+ color: utils.applyEffect(assertive, outlineEffect),
760
+ weight: 4
761
+ }
762
+ },
763
+ elementEffect: {
764
+ disabled: {
765
+ type: 'opacity',
766
+ opacity: 0.32
767
+ }
768
+ }
769
+ };
770
+ var light = _extends({}, common, {
771
+ effect: {
772
+ hover: {
773
+ type: 'alpha',
774
+ color: rgba('#000000', 0.04) // surface3
775
+
776
+ },
777
+ press: {
778
+ type: 'alpha',
779
+ color: rgba('#000000', 0.16) // surface10
780
+
781
+ }
782
+ },
783
+ color: {
784
+ // TODO: colors should be picked from foundation color palette
785
+ transparent: rgba('#000000', 0),
786
+ background1: '#ffffff',
787
+ background2: '#f5f5f5',
788
+ icon6: rgba('#ffffff', 0.28),
789
+ link1: '#3d7699',
790
+ link2: rgba('#ffffff', 0.36),
791
+ surface1: '#ffffff',
792
+ surface2: rgba('#000000', 0.02),
793
+ surface3: rgba('#000000', 0.04),
794
+ surface4: rgba('#000000', 0.32),
795
+ surface6: rgba('#000000', 0.88),
796
+ surface7: rgba('#000000', 0.02),
797
+ surface8: rgba('#000000', 0.88),
798
+ surface9: '#ffffff',
799
+ surface10: rgba('#000000', 0.16),
800
+ text1: '#1f1f1f',
801
+ text2: '#474747',
802
+ text3: '#858585',
803
+ text4: '#adadad',
804
+ text5: '#ffffff',
805
+ brand: brand,
806
+ assertive: assertive,
807
+ warning: '#ffaf0f',
808
+ success: '#b1cc29',
809
+ updatedItem: rgba(0, 150, 250, 0.04),
810
+ border: borderForLight
811
+ },
812
+ border: {
813
+ "default": {
814
+ color: borderForLight
815
+ }
816
+ }
817
+ });
818
+ var dark = _extends({}, common, {
819
+ effect: {
820
+ hover: {
821
+ type: 'alpha',
822
+ color: rgba('#ffffff', 0.12) // surface3
823
+
824
+ },
825
+ press: {
826
+ type: 'alpha',
827
+ color: rgba('#ffffff', 0.2) // surface10
828
+
829
+ }
830
+ },
831
+ color: {
832
+ transparent: rgba('#000000', 0),
833
+ background1: '#1f1f1f',
834
+ background2: '#000000',
835
+ icon6: light.color.icon6,
836
+ link1: '#669FC2',
837
+ link2: light.color.link2,
838
+ surface1: '#1f1f1f',
839
+ surface2: rgba('#000000', 0.16),
840
+ surface3: rgba('#ffffff', 0.12),
841
+ surface4: light.color.surface4,
842
+ surface6: rgba('#ffffff', 0.12),
843
+ surface7: light.color.surface7,
844
+ surface8: light.color.surface8,
845
+ surface9: '#333333',
846
+ surface10: rgba('#ffffff', 0.2),
847
+ text1: '#f5f5f5',
848
+ text2: '#d6d6d6',
849
+ text3: '#858585',
850
+ text4: '#5c5c5c',
851
+ text5: '#f5f5f5',
852
+ brand: brand,
853
+ assertive: assertive,
854
+ warning: light.color.warning,
855
+ success: light.color.success,
856
+ updatedItem: rgba(0, 150, 250, 0.12),
857
+ border: borderForDark
858
+ },
859
+ border: {
860
+ "default": {
861
+ color: borderForDark
862
+ }
863
+ }
864
+ });
865
+
866
+ exports.dark = dark;
867
+ exports.light = light;
2
868
  //# sourceMappingURL=index.cjs.map