favesalon-embed 0.0.4 → 0.1.0

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.
Files changed (241) hide show
  1. package/LICENSE +21 -0
  2. package/{cjs → dist/cjs}/_commonjsHelpers-5cfcba41.js +0 -0
  3. package/dist/cjs/colors-38421769.js +69 -0
  4. package/dist/cjs/favesalon-embed.cjs.js +20 -0
  5. package/{cjs → dist/cjs}/global-9073d10e.js +0 -0
  6. package/dist/cjs/google-map_5.cjs.entry.js +291 -0
  7. package/{cjs/index-48ac68d0.js → dist/cjs/index-7f190886.js} +1924 -0
  8. package/{cjs/index-d5de0b9d.js → dist/cjs/index-e6bea8f5.js} +10 -0
  9. package/{cjs → dist/cjs}/index.cjs.js +0 -0
  10. package/dist/cjs/loader.cjs.js +22 -0
  11. package/{cjs → dist/cjs}/salon-booking-modal.cjs.entry.js +5 -5
  12. package/{cjs → dist/cjs}/salon-booking.cjs.entry.js +6 -7
  13. package/dist/cjs/salon-gift-card-modal.cjs.entry.js +28 -0
  14. package/{cjs → dist/cjs}/salon-gift-card.cjs.entry.js +7 -7
  15. package/dist/cjs/salon-latest-reviews.cjs.entry.js +95 -0
  16. package/{cjs/salon-lookbook_2.cjs.entry.js → dist/cjs/salon-lookbook.cjs.entry.js} +23 -57
  17. package/{cjs → dist/cjs}/salon-ranking.cjs.entry.js +7 -7
  18. package/dist/cjs/salon-reviews.cjs.entry.js +186 -0
  19. package/dist/cjs/salon-services.cjs.entry.js +78 -0
  20. package/dist/cjs/salon-stylists.cjs.entry.js +112 -0
  21. package/{cjs/services-f1102d4a.js → dist/cjs/services-eee8f251.js} +265 -393
  22. package/dist/cjs/style-detail.cjs.entry.js +310 -0
  23. package/dist/cjs/user-avatar.cjs.entry.js +41 -0
  24. package/{cjs → dist/cjs}/utils-c5a33b3c.js +0 -0
  25. package/{collection → dist/collection}/collection-manifest.json +2 -3
  26. package/dist/collection/components/google-map/assets/map--placeholder.jpeg +0 -0
  27. package/{collection → dist/collection}/components/google-map/index.css +0 -1
  28. package/dist/collection/components/google-map/index.js +86 -0
  29. package/{collection → dist/collection}/components/salon-booking/index.css +10 -24
  30. package/{collection → dist/collection}/components/salon-booking/index.js +3 -3
  31. package/{collection → dist/collection}/components/salon-booking/salon-booking-modal.js +4 -4
  32. package/dist/collection/components/salon-gift-card/index.css +25 -0
  33. package/{collection → dist/collection}/components/salon-gift-card/index.js +4 -3
  34. package/{collection → dist/collection}/components/salon-gift-card/salon-gift-card-modal.js +24 -3
  35. package/{collection/components/salon-locations → dist/collection/components/salon-info}/index.css +0 -0
  36. package/{collection → dist/collection}/components/salon-info/index.js +6 -32
  37. package/{collection → dist/collection}/components/salon-latest-reviews/index.css +0 -3
  38. package/dist/collection/components/salon-latest-reviews/index.js +176 -0
  39. package/dist/collection/components/salon-latest-styles/index.css +10 -0
  40. package/dist/collection/components/salon-latest-styles/index.js +178 -0
  41. package/{collection/components/salon-contact → dist/collection/components/salon-locations}/index.css +6 -6
  42. package/dist/collection/components/salon-locations/index.js +151 -0
  43. package/{collection → dist/collection}/components/salon-lookbook/index.css +0 -9
  44. package/{collection → dist/collection}/components/salon-lookbook/index.js +19 -19
  45. package/{collection → dist/collection}/components/salon-ranking/index.css +0 -0
  46. package/{collection → dist/collection}/components/salon-ranking/index.js +5 -5
  47. package/{collection → dist/collection}/components/salon-reviews/index.css +0 -0
  48. package/dist/collection/components/salon-reviews/index.js +286 -0
  49. package/dist/collection/components/salon-schedules/index.css +15 -0
  50. package/dist/collection/components/salon-schedules/index.js +189 -0
  51. package/{collection → dist/collection}/components/salon-services/index.css +0 -0
  52. package/{collection → dist/collection}/components/salon-services/index.js +51 -8
  53. package/{collection → dist/collection}/components/salon-stylists/index.css +0 -8
  54. package/dist/collection/components/salon-stylists/index.js +183 -0
  55. package/dist/collection/components/style-detail/index.css +62 -0
  56. package/dist/collection/components/style-detail/index.js +461 -0
  57. package/{collection → dist/collection}/components/user-avatar/index.css +0 -0
  58. package/{collection → dist/collection}/components/user-avatar/index.js +2 -2
  59. package/dist/collection/constants/colors.js +65 -0
  60. package/{collection → dist/collection}/global/global.js +0 -0
  61. package/{collection → dist/collection}/index.js +0 -0
  62. package/dist/collection/services/services.js +174 -0
  63. package/dist/collection/types/common.js +11 -0
  64. package/{collection → dist/collection}/types/review.js +9 -5
  65. package/dist/collection/types/salon.js +58 -0
  66. package/{collection → dist/collection}/types/service.js +0 -0
  67. package/dist/collection/types/style.js +128 -0
  68. package/{collection → dist/collection}/types/stylist.js +12 -9
  69. package/{favesalon-embed/index.esm.js → dist/collection/types/tmp.js} +0 -0
  70. package/{collection → dist/collection}/types/user.js +2 -2
  71. package/{collection → dist/collection}/utils/utils.js +0 -0
  72. package/{custom-elements → dist/custom-elements}/index.d.ts +12 -18
  73. package/{custom-elements → dist/custom-elements}/index.js +1227 -1035
  74. package/{esm → dist/esm}/_commonjsHelpers-098d5b27.js +0 -0
  75. package/dist/esm/colors-ea36347a.js +67 -0
  76. package/dist/esm/favesalon-embed.js +18 -0
  77. package/{esm → dist/esm}/global-e1089ffd.js +0 -0
  78. package/dist/esm/google-map_5.entry.js +283 -0
  79. package/{esm/index-0f8eed73.js → dist/esm/index-6af0a03d.js} +10 -1
  80. package/{esm/index-67d677ba.js → dist/esm/index-80523fec.js} +1924 -1
  81. package/{esm → dist/esm}/index.js +0 -0
  82. package/dist/esm/loader.js +18 -0
  83. package/{esm → dist/esm}/polyfills/core-js.js +0 -0
  84. package/{esm → dist/esm}/polyfills/css-shim.js +0 -0
  85. package/{esm → dist/esm}/polyfills/dom.js +0 -0
  86. package/{esm → dist/esm}/polyfills/es5-html-element.js +0 -0
  87. package/{esm → dist/esm}/polyfills/index.js +0 -0
  88. package/{esm → dist/esm}/polyfills/system.js +0 -0
  89. package/{esm → dist/esm}/salon-booking-modal.entry.js +5 -5
  90. package/{esm → dist/esm}/salon-booking.entry.js +5 -6
  91. package/dist/esm/salon-gift-card-modal.entry.js +24 -0
  92. package/{esm → dist/esm}/salon-gift-card.entry.js +6 -6
  93. package/dist/esm/salon-latest-reviews.entry.js +91 -0
  94. package/{esm/salon-lookbook_2.entry.js → dist/esm/salon-lookbook.entry.js} +24 -57
  95. package/{esm → dist/esm}/salon-ranking.entry.js +7 -7
  96. package/dist/esm/salon-reviews.entry.js +182 -0
  97. package/dist/esm/salon-services.entry.js +74 -0
  98. package/dist/esm/salon-stylists.entry.js +108 -0
  99. package/{esm/services-74d84ca9.js → dist/esm/services-295247b1.js} +263 -392
  100. package/dist/esm/style-detail.entry.js +306 -0
  101. package/dist/esm/user-avatar.entry.js +37 -0
  102. package/{esm → dist/esm}/utils-e97485e0.js +0 -0
  103. package/dist/favesalon-embed/assets/map--placeholder.jpeg +0 -0
  104. package/{favesalon-embed → dist/favesalon-embed}/favesalon-embed.css +1 -1
  105. package/dist/favesalon-embed/favesalon-embed.esm.js +1 -0
  106. package/dist/favesalon-embed/index.esm.js +0 -0
  107. package/dist/favesalon-embed/p-292b97ba.entry.js +1 -0
  108. package/{favesalon-embed → dist/favesalon-embed}/p-47e646f8.js +0 -0
  109. package/dist/favesalon-embed/p-4869dfed.entry.js +1 -0
  110. package/{favesalon-embed → dist/favesalon-embed}/p-4a5eca9a.js +0 -0
  111. package/dist/favesalon-embed/p-4aee4fd9.entry.js +1 -0
  112. package/dist/favesalon-embed/p-5528c705.entry.js +1 -0
  113. package/dist/favesalon-embed/p-612ad685.entry.js +1 -0
  114. package/dist/favesalon-embed/p-75aef7e0.entry.js +1 -0
  115. package/dist/favesalon-embed/p-8c780874.entry.js +1 -0
  116. package/dist/favesalon-embed/p-8dbf04c5.js +1 -0
  117. package/dist/favesalon-embed/p-9f31061a.entry.js +1 -0
  118. package/dist/favesalon-embed/p-a33331cc.js +1 -0
  119. package/dist/favesalon-embed/p-a60d78e9.entry.js +1 -0
  120. package/dist/favesalon-embed/p-a6debdae.entry.js +1 -0
  121. package/dist/favesalon-embed/p-bad1e9a7.entry.js +1 -0
  122. package/dist/favesalon-embed/p-c2ecb365.js +1 -0
  123. package/dist/favesalon-embed/p-c7dea70c.entry.js +1 -0
  124. package/{favesalon-embed → dist/favesalon-embed}/p-d6083940.js +0 -0
  125. package/dist/favesalon-embed/p-f0e14641.entry.js +1 -0
  126. package/dist/favesalon-embed/p-fc9a5551.js +6 -0
  127. package/{index.cjs.js → dist/index.cjs.js} +0 -0
  128. package/{index.js → dist/index.js} +0 -0
  129. package/dist/types/components/google-map/index.d.ts +5 -0
  130. package/{types → dist/types}/components/salon-booking/index.d.ts +0 -0
  131. package/{types → dist/types}/components/salon-booking/salon-booking-modal.d.ts +0 -0
  132. package/{types → dist/types}/components/salon-gift-card/index.d.ts +0 -0
  133. package/{types → dist/types}/components/salon-gift-card/salon-gift-card-modal.d.ts +1 -0
  134. package/{types → dist/types}/components/salon-info/index.d.ts +0 -1
  135. package/{types → dist/types}/components/salon-latest-reviews/index.d.ts +2 -0
  136. package/dist/types/components/salon-latest-styles/index.d.ts +12 -0
  137. package/{types → dist/types}/components/salon-locations/index.d.ts +2 -0
  138. package/{types → dist/types}/components/salon-lookbook/index.d.ts +3 -3
  139. package/{types → dist/types}/components/salon-ranking/index.d.ts +0 -0
  140. package/dist/types/components/salon-reviews/index.d.ts +24 -0
  141. package/{types → dist/types}/components/salon-schedules/index.d.ts +2 -0
  142. package/{types → dist/types}/components/salon-services/index.d.ts +1 -0
  143. package/{types → dist/types}/components/salon-stylists/index.d.ts +6 -0
  144. package/dist/types/components/style-detail/index.d.ts +24 -0
  145. package/{types → dist/types}/components/user-avatar/index.d.ts +0 -0
  146. package/{types → dist/types}/components.d.ts +54 -59
  147. package/dist/types/constants/colors.d.ts +65 -0
  148. package/{types → dist/types}/index.d.ts +0 -0
  149. package/dist/types/services/services.d.ts +60 -0
  150. package/{types → dist/types}/stencil-public-runtime.d.ts +0 -0
  151. package/dist/types/types/common.d.ts +11 -0
  152. package/{types → dist/types}/types/review.d.ts +4 -0
  153. package/{types → dist/types}/types/salon.d.ts +3 -1
  154. package/{types → dist/types}/types/service.d.ts +0 -0
  155. package/dist/types/types/style.d.ts +88 -0
  156. package/{types → dist/types}/types/stylist.d.ts +1 -1
  157. package/dist/types/types/tmp.d.ts +0 -0
  158. package/{types → dist/types}/types/user.d.ts +2 -2
  159. package/{types → dist/types}/utils/utils.d.ts +0 -0
  160. package/loader/cdn.js +3 -0
  161. package/loader/index.cjs.js +3 -0
  162. package/loader/index.d.ts +12 -0
  163. package/loader/index.es2017.js +3 -0
  164. package/loader/index.js +4 -0
  165. package/loader/package.json +10 -0
  166. package/package.json +18 -13
  167. package/readme.md +24 -7
  168. package/cjs/colors-7f354880.js +0 -95
  169. package/cjs/favesalon-embed.cjs.js +0 -20
  170. package/cjs/google-map.cjs.entry.js +0 -47
  171. package/cjs/index-95daad08.js +0 -1928
  172. package/cjs/loader.cjs.js +0 -22
  173. package/cjs/salon-contact_4.cjs.entry.js +0 -155
  174. package/cjs/salon-gift-card-modal.cjs.entry.js +0 -25
  175. package/cjs/salon-info.cjs.entry.js +0 -35
  176. package/cjs/salon-latest-reviews.cjs.entry.js +0 -58
  177. package/cjs/salon-lookbook-modal.cjs.entry.js +0 -141
  178. package/cjs/salon-reviews.cjs.entry.js +0 -205
  179. package/cjs/salon-services.cjs.entry.js +0 -47
  180. package/cjs/salon-stylists.cjs.entry.js +0 -54
  181. package/collection/components/google-map/index.js +0 -97
  182. package/collection/components/salon-contact/index.js +0 -88
  183. package/collection/components/salon-gift-card/index.css +0 -25
  184. package/collection/components/salon-info/index.css +0 -3
  185. package/collection/components/salon-latest-reviews/index.js +0 -108
  186. package/collection/components/salon-locations/index.js +0 -80
  187. package/collection/components/salon-lookbook/lookbook-modal.css +0 -72
  188. package/collection/components/salon-lookbook/salon-lookbook-modal.js +0 -248
  189. package/collection/components/salon-reviews/index.js +0 -317
  190. package/collection/components/salon-schedules/index.css +0 -14
  191. package/collection/components/salon-schedules/index.js +0 -103
  192. package/collection/components/salon-styles/index.css +0 -23
  193. package/collection/components/salon-styles/index.js +0 -100
  194. package/collection/components/salon-stylists/index.js +0 -96
  195. package/collection/constants/colors.js +0 -91
  196. package/collection/services/services.js +0 -225
  197. package/collection/types/common.js +0 -2
  198. package/collection/types/salon.js +0 -52
  199. package/collection/types/style.js +0 -103
  200. package/esm/colors-1ec90c5f.js +0 -93
  201. package/esm/favesalon-embed.js +0 -18
  202. package/esm/google-map.entry.js +0 -43
  203. package/esm/index-09d43e3e.js +0 -1926
  204. package/esm/loader.js +0 -18
  205. package/esm/salon-contact_4.entry.js +0 -148
  206. package/esm/salon-gift-card-modal.entry.js +0 -21
  207. package/esm/salon-info.entry.js +0 -31
  208. package/esm/salon-latest-reviews.entry.js +0 -54
  209. package/esm/salon-lookbook-modal.entry.js +0 -137
  210. package/esm/salon-reviews.entry.js +0 -201
  211. package/esm/salon-services.entry.js +0 -43
  212. package/esm/salon-stylists.entry.js +0 -50
  213. package/favesalon-embed/favesalon-embed.esm.js +0 -1
  214. package/favesalon-embed/p-0188d4dc.entry.js +0 -1
  215. package/favesalon-embed/p-0318501e.js +0 -1
  216. package/favesalon-embed/p-078f242d.entry.js +0 -1
  217. package/favesalon-embed/p-13e23c61.entry.js +0 -1
  218. package/favesalon-embed/p-17df13ad.js +0 -1
  219. package/favesalon-embed/p-1a3179c8.entry.js +0 -1
  220. package/favesalon-embed/p-20aa75de.js +0 -6
  221. package/favesalon-embed/p-2901a6d6.entry.js +0 -1
  222. package/favesalon-embed/p-2b861430.entry.js +0 -1
  223. package/favesalon-embed/p-44d810a0.js +0 -1
  224. package/favesalon-embed/p-4c68700f.entry.js +0 -1
  225. package/favesalon-embed/p-4e2d7b29.js +0 -1
  226. package/favesalon-embed/p-6b845bf1.entry.js +0 -1
  227. package/favesalon-embed/p-7350f6b5.entry.js +0 -1
  228. package/favesalon-embed/p-897c2b1c.entry.js +0 -1
  229. package/favesalon-embed/p-8e60f56f.entry.js +0 -1
  230. package/favesalon-embed/p-a49afdc1.entry.js +0 -1
  231. package/favesalon-embed/p-c93867c4.entry.js +0 -1
  232. package/favesalon-embed/p-ea6a097f.entry.js +0 -1
  233. package/types/components/google-map/index.d.ts +0 -10
  234. package/types/components/salon-contact/index.d.ts +0 -9
  235. package/types/components/salon-lookbook/salon-lookbook-modal.d.ts +0 -13
  236. package/types/components/salon-reviews/index.d.ts +0 -24
  237. package/types/components/salon-styles/index.d.ts +0 -9
  238. package/types/constants/colors.d.ts +0 -88
  239. package/types/services/services.d.ts +0 -26
  240. package/types/types/common.d.ts +0 -2
  241. package/types/types/style.d.ts +0 -59
@@ -1,5 +1,1928 @@
1
1
  import { a as createCommonjsModule, g as getAugmentedNamespace } from './_commonjsHelpers-098d5b27.js';
2
2
 
3
+ var colorName = {
4
+ "aliceblue": [240, 248, 255],
5
+ "antiquewhite": [250, 235, 215],
6
+ "aqua": [0, 255, 255],
7
+ "aquamarine": [127, 255, 212],
8
+ "azure": [240, 255, 255],
9
+ "beige": [245, 245, 220],
10
+ "bisque": [255, 228, 196],
11
+ "black": [0, 0, 0],
12
+ "blanchedalmond": [255, 235, 205],
13
+ "blue": [0, 0, 255],
14
+ "blueviolet": [138, 43, 226],
15
+ "brown": [165, 42, 42],
16
+ "burlywood": [222, 184, 135],
17
+ "cadetblue": [95, 158, 160],
18
+ "chartreuse": [127, 255, 0],
19
+ "chocolate": [210, 105, 30],
20
+ "coral": [255, 127, 80],
21
+ "cornflowerblue": [100, 149, 237],
22
+ "cornsilk": [255, 248, 220],
23
+ "crimson": [220, 20, 60],
24
+ "cyan": [0, 255, 255],
25
+ "darkblue": [0, 0, 139],
26
+ "darkcyan": [0, 139, 139],
27
+ "darkgoldenrod": [184, 134, 11],
28
+ "darkgray": [169, 169, 169],
29
+ "darkgreen": [0, 100, 0],
30
+ "darkgrey": [169, 169, 169],
31
+ "darkkhaki": [189, 183, 107],
32
+ "darkmagenta": [139, 0, 139],
33
+ "darkolivegreen": [85, 107, 47],
34
+ "darkorange": [255, 140, 0],
35
+ "darkorchid": [153, 50, 204],
36
+ "darkred": [139, 0, 0],
37
+ "darksalmon": [233, 150, 122],
38
+ "darkseagreen": [143, 188, 143],
39
+ "darkslateblue": [72, 61, 139],
40
+ "darkslategray": [47, 79, 79],
41
+ "darkslategrey": [47, 79, 79],
42
+ "darkturquoise": [0, 206, 209],
43
+ "darkviolet": [148, 0, 211],
44
+ "deeppink": [255, 20, 147],
45
+ "deepskyblue": [0, 191, 255],
46
+ "dimgray": [105, 105, 105],
47
+ "dimgrey": [105, 105, 105],
48
+ "dodgerblue": [30, 144, 255],
49
+ "firebrick": [178, 34, 34],
50
+ "floralwhite": [255, 250, 240],
51
+ "forestgreen": [34, 139, 34],
52
+ "fuchsia": [255, 0, 255],
53
+ "gainsboro": [220, 220, 220],
54
+ "ghostwhite": [248, 248, 255],
55
+ "gold": [255, 215, 0],
56
+ "goldenrod": [218, 165, 32],
57
+ "gray": [128, 128, 128],
58
+ "green": [0, 128, 0],
59
+ "greenyellow": [173, 255, 47],
60
+ "grey": [128, 128, 128],
61
+ "honeydew": [240, 255, 240],
62
+ "hotpink": [255, 105, 180],
63
+ "indianred": [205, 92, 92],
64
+ "indigo": [75, 0, 130],
65
+ "ivory": [255, 255, 240],
66
+ "khaki": [240, 230, 140],
67
+ "lavender": [230, 230, 250],
68
+ "lavenderblush": [255, 240, 245],
69
+ "lawngreen": [124, 252, 0],
70
+ "lemonchiffon": [255, 250, 205],
71
+ "lightblue": [173, 216, 230],
72
+ "lightcoral": [240, 128, 128],
73
+ "lightcyan": [224, 255, 255],
74
+ "lightgoldenrodyellow": [250, 250, 210],
75
+ "lightgray": [211, 211, 211],
76
+ "lightgreen": [144, 238, 144],
77
+ "lightgrey": [211, 211, 211],
78
+ "lightpink": [255, 182, 193],
79
+ "lightsalmon": [255, 160, 122],
80
+ "lightseagreen": [32, 178, 170],
81
+ "lightskyblue": [135, 206, 250],
82
+ "lightslategray": [119, 136, 153],
83
+ "lightslategrey": [119, 136, 153],
84
+ "lightsteelblue": [176, 196, 222],
85
+ "lightyellow": [255, 255, 224],
86
+ "lime": [0, 255, 0],
87
+ "limegreen": [50, 205, 50],
88
+ "linen": [250, 240, 230],
89
+ "magenta": [255, 0, 255],
90
+ "maroon": [128, 0, 0],
91
+ "mediumaquamarine": [102, 205, 170],
92
+ "mediumblue": [0, 0, 205],
93
+ "mediumorchid": [186, 85, 211],
94
+ "mediumpurple": [147, 112, 219],
95
+ "mediumseagreen": [60, 179, 113],
96
+ "mediumslateblue": [123, 104, 238],
97
+ "mediumspringgreen": [0, 250, 154],
98
+ "mediumturquoise": [72, 209, 204],
99
+ "mediumvioletred": [199, 21, 133],
100
+ "midnightblue": [25, 25, 112],
101
+ "mintcream": [245, 255, 250],
102
+ "mistyrose": [255, 228, 225],
103
+ "moccasin": [255, 228, 181],
104
+ "navajowhite": [255, 222, 173],
105
+ "navy": [0, 0, 128],
106
+ "oldlace": [253, 245, 230],
107
+ "olive": [128, 128, 0],
108
+ "olivedrab": [107, 142, 35],
109
+ "orange": [255, 165, 0],
110
+ "orangered": [255, 69, 0],
111
+ "orchid": [218, 112, 214],
112
+ "palegoldenrod": [238, 232, 170],
113
+ "palegreen": [152, 251, 152],
114
+ "paleturquoise": [175, 238, 238],
115
+ "palevioletred": [219, 112, 147],
116
+ "papayawhip": [255, 239, 213],
117
+ "peachpuff": [255, 218, 185],
118
+ "peru": [205, 133, 63],
119
+ "pink": [255, 192, 203],
120
+ "plum": [221, 160, 221],
121
+ "powderblue": [176, 224, 230],
122
+ "purple": [128, 0, 128],
123
+ "rebeccapurple": [102, 51, 153],
124
+ "red": [255, 0, 0],
125
+ "rosybrown": [188, 143, 143],
126
+ "royalblue": [65, 105, 225],
127
+ "saddlebrown": [139, 69, 19],
128
+ "salmon": [250, 128, 114],
129
+ "sandybrown": [244, 164, 96],
130
+ "seagreen": [46, 139, 87],
131
+ "seashell": [255, 245, 238],
132
+ "sienna": [160, 82, 45],
133
+ "silver": [192, 192, 192],
134
+ "skyblue": [135, 206, 235],
135
+ "slateblue": [106, 90, 205],
136
+ "slategray": [112, 128, 144],
137
+ "slategrey": [112, 128, 144],
138
+ "snow": [255, 250, 250],
139
+ "springgreen": [0, 255, 127],
140
+ "steelblue": [70, 130, 180],
141
+ "tan": [210, 180, 140],
142
+ "teal": [0, 128, 128],
143
+ "thistle": [216, 191, 216],
144
+ "tomato": [255, 99, 71],
145
+ "turquoise": [64, 224, 208],
146
+ "violet": [238, 130, 238],
147
+ "wheat": [245, 222, 179],
148
+ "white": [255, 255, 255],
149
+ "whitesmoke": [245, 245, 245],
150
+ "yellow": [255, 255, 0],
151
+ "yellowgreen": [154, 205, 50]
152
+ };
153
+
154
+ var isArrayish = function isArrayish(obj) {
155
+ if (!obj || typeof obj === 'string') {
156
+ return false;
157
+ }
158
+
159
+ return obj instanceof Array || Array.isArray(obj) ||
160
+ (obj.length >= 0 && (obj.splice instanceof Function ||
161
+ (Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));
162
+ };
163
+
164
+ var simpleSwizzle = createCommonjsModule(function (module) {
165
+
166
+
167
+
168
+ var concat = Array.prototype.concat;
169
+ var slice = Array.prototype.slice;
170
+
171
+ var swizzle = module.exports = function swizzle(args) {
172
+ var results = [];
173
+
174
+ for (var i = 0, len = args.length; i < len; i++) {
175
+ var arg = args[i];
176
+
177
+ if (isArrayish(arg)) {
178
+ // http://jsperf.com/javascript-array-concat-vs-push/98
179
+ results = concat.call(results, slice.call(arg));
180
+ } else {
181
+ results.push(arg);
182
+ }
183
+ }
184
+
185
+ return results;
186
+ };
187
+
188
+ swizzle.wrap = function (fn) {
189
+ return function () {
190
+ return fn(swizzle(arguments));
191
+ };
192
+ };
193
+ });
194
+
195
+ var colorString = createCommonjsModule(function (module) {
196
+ /* MIT license */
197
+
198
+
199
+
200
+ var reverseNames = {};
201
+
202
+ // create a list of reverse color names
203
+ for (var name in colorName) {
204
+ if (colorName.hasOwnProperty(name)) {
205
+ reverseNames[colorName[name]] = name;
206
+ }
207
+ }
208
+
209
+ var cs = module.exports = {
210
+ to: {},
211
+ get: {}
212
+ };
213
+
214
+ cs.get = function (string) {
215
+ var prefix = string.substring(0, 3).toLowerCase();
216
+ var val;
217
+ var model;
218
+ switch (prefix) {
219
+ case 'hsl':
220
+ val = cs.get.hsl(string);
221
+ model = 'hsl';
222
+ break;
223
+ case 'hwb':
224
+ val = cs.get.hwb(string);
225
+ model = 'hwb';
226
+ break;
227
+ default:
228
+ val = cs.get.rgb(string);
229
+ model = 'rgb';
230
+ break;
231
+ }
232
+
233
+ if (!val) {
234
+ return null;
235
+ }
236
+
237
+ return {model: model, value: val};
238
+ };
239
+
240
+ cs.get.rgb = function (string) {
241
+ if (!string) {
242
+ return null;
243
+ }
244
+
245
+ var abbr = /^#([a-f0-9]{3,4})$/i;
246
+ var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
247
+ var rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
248
+ var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
249
+ var keyword = /(\D+)/;
250
+
251
+ var rgb = [0, 0, 0, 1];
252
+ var match;
253
+ var i;
254
+ var hexAlpha;
255
+
256
+ if (match = string.match(hex)) {
257
+ hexAlpha = match[2];
258
+ match = match[1];
259
+
260
+ for (i = 0; i < 3; i++) {
261
+ // https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
262
+ var i2 = i * 2;
263
+ rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
264
+ }
265
+
266
+ if (hexAlpha) {
267
+ rgb[3] = parseInt(hexAlpha, 16) / 255;
268
+ }
269
+ } else if (match = string.match(abbr)) {
270
+ match = match[1];
271
+ hexAlpha = match[3];
272
+
273
+ for (i = 0; i < 3; i++) {
274
+ rgb[i] = parseInt(match[i] + match[i], 16);
275
+ }
276
+
277
+ if (hexAlpha) {
278
+ rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
279
+ }
280
+ } else if (match = string.match(rgba)) {
281
+ for (i = 0; i < 3; i++) {
282
+ rgb[i] = parseInt(match[i + 1], 0);
283
+ }
284
+
285
+ if (match[4]) {
286
+ rgb[3] = parseFloat(match[4]);
287
+ }
288
+ } else if (match = string.match(per)) {
289
+ for (i = 0; i < 3; i++) {
290
+ rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
291
+ }
292
+
293
+ if (match[4]) {
294
+ rgb[3] = parseFloat(match[4]);
295
+ }
296
+ } else if (match = string.match(keyword)) {
297
+ if (match[1] === 'transparent') {
298
+ return [0, 0, 0, 0];
299
+ }
300
+
301
+ rgb = colorName[match[1]];
302
+
303
+ if (!rgb) {
304
+ return null;
305
+ }
306
+
307
+ rgb[3] = 1;
308
+
309
+ return rgb;
310
+ } else {
311
+ return null;
312
+ }
313
+
314
+ for (i = 0; i < 3; i++) {
315
+ rgb[i] = clamp(rgb[i], 0, 255);
316
+ }
317
+ rgb[3] = clamp(rgb[3], 0, 1);
318
+
319
+ return rgb;
320
+ };
321
+
322
+ cs.get.hsl = function (string) {
323
+ if (!string) {
324
+ return null;
325
+ }
326
+
327
+ var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?[\d\.]+)\s*)?\)$/;
328
+ var match = string.match(hsl);
329
+
330
+ if (match) {
331
+ var alpha = parseFloat(match[4]);
332
+ var h = (parseFloat(match[1]) + 360) % 360;
333
+ var s = clamp(parseFloat(match[2]), 0, 100);
334
+ var l = clamp(parseFloat(match[3]), 0, 100);
335
+ var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
336
+
337
+ return [h, s, l, a];
338
+ }
339
+
340
+ return null;
341
+ };
342
+
343
+ cs.get.hwb = function (string) {
344
+ if (!string) {
345
+ return null;
346
+ }
347
+
348
+ var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
349
+ var match = string.match(hwb);
350
+
351
+ if (match) {
352
+ var alpha = parseFloat(match[4]);
353
+ var h = ((parseFloat(match[1]) % 360) + 360) % 360;
354
+ var w = clamp(parseFloat(match[2]), 0, 100);
355
+ var b = clamp(parseFloat(match[3]), 0, 100);
356
+ var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
357
+ return [h, w, b, a];
358
+ }
359
+
360
+ return null;
361
+ };
362
+
363
+ cs.to.hex = function () {
364
+ var rgba = simpleSwizzle(arguments);
365
+
366
+ return (
367
+ '#' +
368
+ hexDouble(rgba[0]) +
369
+ hexDouble(rgba[1]) +
370
+ hexDouble(rgba[2]) +
371
+ (rgba[3] < 1
372
+ ? (hexDouble(Math.round(rgba[3] * 255)))
373
+ : '')
374
+ );
375
+ };
376
+
377
+ cs.to.rgb = function () {
378
+ var rgba = simpleSwizzle(arguments);
379
+
380
+ return rgba.length < 4 || rgba[3] === 1
381
+ ? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
382
+ : 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
383
+ };
384
+
385
+ cs.to.rgb.percent = function () {
386
+ var rgba = simpleSwizzle(arguments);
387
+
388
+ var r = Math.round(rgba[0] / 255 * 100);
389
+ var g = Math.round(rgba[1] / 255 * 100);
390
+ var b = Math.round(rgba[2] / 255 * 100);
391
+
392
+ return rgba.length < 4 || rgba[3] === 1
393
+ ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
394
+ : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
395
+ };
396
+
397
+ cs.to.hsl = function () {
398
+ var hsla = simpleSwizzle(arguments);
399
+ return hsla.length < 4 || hsla[3] === 1
400
+ ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
401
+ : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
402
+ };
403
+
404
+ // hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
405
+ // (hwb have alpha optional & 1 is default value)
406
+ cs.to.hwb = function () {
407
+ var hwba = simpleSwizzle(arguments);
408
+
409
+ var a = '';
410
+ if (hwba.length >= 4 && hwba[3] !== 1) {
411
+ a = ', ' + hwba[3];
412
+ }
413
+
414
+ return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
415
+ };
416
+
417
+ cs.to.keyword = function (rgb) {
418
+ return reverseNames[rgb.slice(0, 3)];
419
+ };
420
+
421
+ // helpers
422
+ function clamp(num, min, max) {
423
+ return Math.min(Math.max(min, num), max);
424
+ }
425
+
426
+ function hexDouble(num) {
427
+ var str = num.toString(16).toUpperCase();
428
+ return (str.length < 2) ? '0' + str : str;
429
+ }
430
+ });
431
+
432
+ /* MIT license */
433
+ /* eslint-disable no-mixed-operators */
434
+
435
+
436
+ // NOTE: conversions should only return primitive values (i.e. arrays, or
437
+ // values that give correct `typeof` results).
438
+ // do not use box values types (i.e. Number(), String(), etc.)
439
+
440
+ const reverseKeywords = {};
441
+ for (const key of Object.keys(colorName)) {
442
+ reverseKeywords[colorName[key]] = key;
443
+ }
444
+
445
+ const convert$1 = {
446
+ rgb: {channels: 3, labels: 'rgb'},
447
+ hsl: {channels: 3, labels: 'hsl'},
448
+ hsv: {channels: 3, labels: 'hsv'},
449
+ hwb: {channels: 3, labels: 'hwb'},
450
+ cmyk: {channels: 4, labels: 'cmyk'},
451
+ xyz: {channels: 3, labels: 'xyz'},
452
+ lab: {channels: 3, labels: 'lab'},
453
+ lch: {channels: 3, labels: 'lch'},
454
+ hex: {channels: 1, labels: ['hex']},
455
+ keyword: {channels: 1, labels: ['keyword']},
456
+ ansi16: {channels: 1, labels: ['ansi16']},
457
+ ansi256: {channels: 1, labels: ['ansi256']},
458
+ hcg: {channels: 3, labels: ['h', 'c', 'g']},
459
+ apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
460
+ gray: {channels: 1, labels: ['gray']}
461
+ };
462
+
463
+ var conversions = convert$1;
464
+
465
+ // Hide .channels and .labels properties
466
+ for (const model of Object.keys(convert$1)) {
467
+ if (!('channels' in convert$1[model])) {
468
+ throw new Error('missing channels property: ' + model);
469
+ }
470
+
471
+ if (!('labels' in convert$1[model])) {
472
+ throw new Error('missing channel labels property: ' + model);
473
+ }
474
+
475
+ if (convert$1[model].labels.length !== convert$1[model].channels) {
476
+ throw new Error('channel and label counts mismatch: ' + model);
477
+ }
478
+
479
+ const {channels, labels} = convert$1[model];
480
+ delete convert$1[model].channels;
481
+ delete convert$1[model].labels;
482
+ Object.defineProperty(convert$1[model], 'channels', {value: channels});
483
+ Object.defineProperty(convert$1[model], 'labels', {value: labels});
484
+ }
485
+
486
+ convert$1.rgb.hsl = function (rgb) {
487
+ const r = rgb[0] / 255;
488
+ const g = rgb[1] / 255;
489
+ const b = rgb[2] / 255;
490
+ const min = Math.min(r, g, b);
491
+ const max = Math.max(r, g, b);
492
+ const delta = max - min;
493
+ let h;
494
+ let s;
495
+
496
+ if (max === min) {
497
+ h = 0;
498
+ } else if (r === max) {
499
+ h = (g - b) / delta;
500
+ } else if (g === max) {
501
+ h = 2 + (b - r) / delta;
502
+ } else if (b === max) {
503
+ h = 4 + (r - g) / delta;
504
+ }
505
+
506
+ h = Math.min(h * 60, 360);
507
+
508
+ if (h < 0) {
509
+ h += 360;
510
+ }
511
+
512
+ const l = (min + max) / 2;
513
+
514
+ if (max === min) {
515
+ s = 0;
516
+ } else if (l <= 0.5) {
517
+ s = delta / (max + min);
518
+ } else {
519
+ s = delta / (2 - max - min);
520
+ }
521
+
522
+ return [h, s * 100, l * 100];
523
+ };
524
+
525
+ convert$1.rgb.hsv = function (rgb) {
526
+ let rdif;
527
+ let gdif;
528
+ let bdif;
529
+ let h;
530
+ let s;
531
+
532
+ const r = rgb[0] / 255;
533
+ const g = rgb[1] / 255;
534
+ const b = rgb[2] / 255;
535
+ const v = Math.max(r, g, b);
536
+ const diff = v - Math.min(r, g, b);
537
+ const diffc = function (c) {
538
+ return (v - c) / 6 / diff + 1 / 2;
539
+ };
540
+
541
+ if (diff === 0) {
542
+ h = 0;
543
+ s = 0;
544
+ } else {
545
+ s = diff / v;
546
+ rdif = diffc(r);
547
+ gdif = diffc(g);
548
+ bdif = diffc(b);
549
+
550
+ if (r === v) {
551
+ h = bdif - gdif;
552
+ } else if (g === v) {
553
+ h = (1 / 3) + rdif - bdif;
554
+ } else if (b === v) {
555
+ h = (2 / 3) + gdif - rdif;
556
+ }
557
+
558
+ if (h < 0) {
559
+ h += 1;
560
+ } else if (h > 1) {
561
+ h -= 1;
562
+ }
563
+ }
564
+
565
+ return [
566
+ h * 360,
567
+ s * 100,
568
+ v * 100
569
+ ];
570
+ };
571
+
572
+ convert$1.rgb.hwb = function (rgb) {
573
+ const r = rgb[0];
574
+ const g = rgb[1];
575
+ let b = rgb[2];
576
+ const h = convert$1.rgb.hsl(rgb)[0];
577
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
578
+
579
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
580
+
581
+ return [h, w * 100, b * 100];
582
+ };
583
+
584
+ convert$1.rgb.cmyk = function (rgb) {
585
+ const r = rgb[0] / 255;
586
+ const g = rgb[1] / 255;
587
+ const b = rgb[2] / 255;
588
+
589
+ const k = Math.min(1 - r, 1 - g, 1 - b);
590
+ const c = (1 - r - k) / (1 - k) || 0;
591
+ const m = (1 - g - k) / (1 - k) || 0;
592
+ const y = (1 - b - k) / (1 - k) || 0;
593
+
594
+ return [c * 100, m * 100, y * 100, k * 100];
595
+ };
596
+
597
+ function comparativeDistance(x, y) {
598
+ /*
599
+ See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
600
+ */
601
+ return (
602
+ ((x[0] - y[0]) ** 2) +
603
+ ((x[1] - y[1]) ** 2) +
604
+ ((x[2] - y[2]) ** 2)
605
+ );
606
+ }
607
+
608
+ convert$1.rgb.keyword = function (rgb) {
609
+ const reversed = reverseKeywords[rgb];
610
+ if (reversed) {
611
+ return reversed;
612
+ }
613
+
614
+ let currentClosestDistance = Infinity;
615
+ let currentClosestKeyword;
616
+
617
+ for (const keyword of Object.keys(colorName)) {
618
+ const value = colorName[keyword];
619
+
620
+ // Compute comparative distance
621
+ const distance = comparativeDistance(rgb, value);
622
+
623
+ // Check if its less, if so set as closest
624
+ if (distance < currentClosestDistance) {
625
+ currentClosestDistance = distance;
626
+ currentClosestKeyword = keyword;
627
+ }
628
+ }
629
+
630
+ return currentClosestKeyword;
631
+ };
632
+
633
+ convert$1.keyword.rgb = function (keyword) {
634
+ return colorName[keyword];
635
+ };
636
+
637
+ convert$1.rgb.xyz = function (rgb) {
638
+ let r = rgb[0] / 255;
639
+ let g = rgb[1] / 255;
640
+ let b = rgb[2] / 255;
641
+
642
+ // Assume sRGB
643
+ r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
644
+ g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
645
+ b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
646
+
647
+ const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
648
+ const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
649
+ const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
650
+
651
+ return [x * 100, y * 100, z * 100];
652
+ };
653
+
654
+ convert$1.rgb.lab = function (rgb) {
655
+ const xyz = convert$1.rgb.xyz(rgb);
656
+ let x = xyz[0];
657
+ let y = xyz[1];
658
+ let z = xyz[2];
659
+
660
+ x /= 95.047;
661
+ y /= 100;
662
+ z /= 108.883;
663
+
664
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
665
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
666
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
667
+
668
+ const l = (116 * y) - 16;
669
+ const a = 500 * (x - y);
670
+ const b = 200 * (y - z);
671
+
672
+ return [l, a, b];
673
+ };
674
+
675
+ convert$1.hsl.rgb = function (hsl) {
676
+ const h = hsl[0] / 360;
677
+ const s = hsl[1] / 100;
678
+ const l = hsl[2] / 100;
679
+ let t2;
680
+ let t3;
681
+ let val;
682
+
683
+ if (s === 0) {
684
+ val = l * 255;
685
+ return [val, val, val];
686
+ }
687
+
688
+ if (l < 0.5) {
689
+ t2 = l * (1 + s);
690
+ } else {
691
+ t2 = l + s - l * s;
692
+ }
693
+
694
+ const t1 = 2 * l - t2;
695
+
696
+ const rgb = [0, 0, 0];
697
+ for (let i = 0; i < 3; i++) {
698
+ t3 = h + 1 / 3 * -(i - 1);
699
+ if (t3 < 0) {
700
+ t3++;
701
+ }
702
+
703
+ if (t3 > 1) {
704
+ t3--;
705
+ }
706
+
707
+ if (6 * t3 < 1) {
708
+ val = t1 + (t2 - t1) * 6 * t3;
709
+ } else if (2 * t3 < 1) {
710
+ val = t2;
711
+ } else if (3 * t3 < 2) {
712
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
713
+ } else {
714
+ val = t1;
715
+ }
716
+
717
+ rgb[i] = val * 255;
718
+ }
719
+
720
+ return rgb;
721
+ };
722
+
723
+ convert$1.hsl.hsv = function (hsl) {
724
+ const h = hsl[0];
725
+ let s = hsl[1] / 100;
726
+ let l = hsl[2] / 100;
727
+ let smin = s;
728
+ const lmin = Math.max(l, 0.01);
729
+
730
+ l *= 2;
731
+ s *= (l <= 1) ? l : 2 - l;
732
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
733
+ const v = (l + s) / 2;
734
+ const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
735
+
736
+ return [h, sv * 100, v * 100];
737
+ };
738
+
739
+ convert$1.hsv.rgb = function (hsv) {
740
+ const h = hsv[0] / 60;
741
+ const s = hsv[1] / 100;
742
+ let v = hsv[2] / 100;
743
+ const hi = Math.floor(h) % 6;
744
+
745
+ const f = h - Math.floor(h);
746
+ const p = 255 * v * (1 - s);
747
+ const q = 255 * v * (1 - (s * f));
748
+ const t = 255 * v * (1 - (s * (1 - f)));
749
+ v *= 255;
750
+
751
+ switch (hi) {
752
+ case 0:
753
+ return [v, t, p];
754
+ case 1:
755
+ return [q, v, p];
756
+ case 2:
757
+ return [p, v, t];
758
+ case 3:
759
+ return [p, q, v];
760
+ case 4:
761
+ return [t, p, v];
762
+ case 5:
763
+ return [v, p, q];
764
+ }
765
+ };
766
+
767
+ convert$1.hsv.hsl = function (hsv) {
768
+ const h = hsv[0];
769
+ const s = hsv[1] / 100;
770
+ const v = hsv[2] / 100;
771
+ const vmin = Math.max(v, 0.01);
772
+ let sl;
773
+ let l;
774
+
775
+ l = (2 - s) * v;
776
+ const lmin = (2 - s) * vmin;
777
+ sl = s * vmin;
778
+ sl /= (lmin <= 1) ? lmin : 2 - lmin;
779
+ sl = sl || 0;
780
+ l /= 2;
781
+
782
+ return [h, sl * 100, l * 100];
783
+ };
784
+
785
+ // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
786
+ convert$1.hwb.rgb = function (hwb) {
787
+ const h = hwb[0] / 360;
788
+ let wh = hwb[1] / 100;
789
+ let bl = hwb[2] / 100;
790
+ const ratio = wh + bl;
791
+ let f;
792
+
793
+ // Wh + bl cant be > 1
794
+ if (ratio > 1) {
795
+ wh /= ratio;
796
+ bl /= ratio;
797
+ }
798
+
799
+ const i = Math.floor(6 * h);
800
+ const v = 1 - bl;
801
+ f = 6 * h - i;
802
+
803
+ if ((i & 0x01) !== 0) {
804
+ f = 1 - f;
805
+ }
806
+
807
+ const n = wh + f * (v - wh); // Linear interpolation
808
+
809
+ let r;
810
+ let g;
811
+ let b;
812
+ /* eslint-disable max-statements-per-line,no-multi-spaces */
813
+ switch (i) {
814
+ default:
815
+ case 6:
816
+ case 0: r = v; g = n; b = wh; break;
817
+ case 1: r = n; g = v; b = wh; break;
818
+ case 2: r = wh; g = v; b = n; break;
819
+ case 3: r = wh; g = n; b = v; break;
820
+ case 4: r = n; g = wh; b = v; break;
821
+ case 5: r = v; g = wh; b = n; break;
822
+ }
823
+ /* eslint-enable max-statements-per-line,no-multi-spaces */
824
+
825
+ return [r * 255, g * 255, b * 255];
826
+ };
827
+
828
+ convert$1.cmyk.rgb = function (cmyk) {
829
+ const c = cmyk[0] / 100;
830
+ const m = cmyk[1] / 100;
831
+ const y = cmyk[2] / 100;
832
+ const k = cmyk[3] / 100;
833
+
834
+ const r = 1 - Math.min(1, c * (1 - k) + k);
835
+ const g = 1 - Math.min(1, m * (1 - k) + k);
836
+ const b = 1 - Math.min(1, y * (1 - k) + k);
837
+
838
+ return [r * 255, g * 255, b * 255];
839
+ };
840
+
841
+ convert$1.xyz.rgb = function (xyz) {
842
+ const x = xyz[0] / 100;
843
+ const y = xyz[1] / 100;
844
+ const z = xyz[2] / 100;
845
+ let r;
846
+ let g;
847
+ let b;
848
+
849
+ r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
850
+ g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
851
+ b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
852
+
853
+ // Assume sRGB
854
+ r = r > 0.0031308
855
+ ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
856
+ : r * 12.92;
857
+
858
+ g = g > 0.0031308
859
+ ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
860
+ : g * 12.92;
861
+
862
+ b = b > 0.0031308
863
+ ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
864
+ : b * 12.92;
865
+
866
+ r = Math.min(Math.max(0, r), 1);
867
+ g = Math.min(Math.max(0, g), 1);
868
+ b = Math.min(Math.max(0, b), 1);
869
+
870
+ return [r * 255, g * 255, b * 255];
871
+ };
872
+
873
+ convert$1.xyz.lab = function (xyz) {
874
+ let x = xyz[0];
875
+ let y = xyz[1];
876
+ let z = xyz[2];
877
+
878
+ x /= 95.047;
879
+ y /= 100;
880
+ z /= 108.883;
881
+
882
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
883
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
884
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
885
+
886
+ const l = (116 * y) - 16;
887
+ const a = 500 * (x - y);
888
+ const b = 200 * (y - z);
889
+
890
+ return [l, a, b];
891
+ };
892
+
893
+ convert$1.lab.xyz = function (lab) {
894
+ const l = lab[0];
895
+ const a = lab[1];
896
+ const b = lab[2];
897
+ let x;
898
+ let y;
899
+ let z;
900
+
901
+ y = (l + 16) / 116;
902
+ x = a / 500 + y;
903
+ z = y - b / 200;
904
+
905
+ const y2 = y ** 3;
906
+ const x2 = x ** 3;
907
+ const z2 = z ** 3;
908
+ y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
909
+ x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
910
+ z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
911
+
912
+ x *= 95.047;
913
+ y *= 100;
914
+ z *= 108.883;
915
+
916
+ return [x, y, z];
917
+ };
918
+
919
+ convert$1.lab.lch = function (lab) {
920
+ const l = lab[0];
921
+ const a = lab[1];
922
+ const b = lab[2];
923
+ let h;
924
+
925
+ const hr = Math.atan2(b, a);
926
+ h = hr * 360 / 2 / Math.PI;
927
+
928
+ if (h < 0) {
929
+ h += 360;
930
+ }
931
+
932
+ const c = Math.sqrt(a * a + b * b);
933
+
934
+ return [l, c, h];
935
+ };
936
+
937
+ convert$1.lch.lab = function (lch) {
938
+ const l = lch[0];
939
+ const c = lch[1];
940
+ const h = lch[2];
941
+
942
+ const hr = h / 360 * 2 * Math.PI;
943
+ const a = c * Math.cos(hr);
944
+ const b = c * Math.sin(hr);
945
+
946
+ return [l, a, b];
947
+ };
948
+
949
+ convert$1.rgb.ansi16 = function (args, saturation = null) {
950
+ const [r, g, b] = args;
951
+ let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
952
+
953
+ value = Math.round(value / 50);
954
+
955
+ if (value === 0) {
956
+ return 30;
957
+ }
958
+
959
+ let ansi = 30
960
+ + ((Math.round(b / 255) << 2)
961
+ | (Math.round(g / 255) << 1)
962
+ | Math.round(r / 255));
963
+
964
+ if (value === 2) {
965
+ ansi += 60;
966
+ }
967
+
968
+ return ansi;
969
+ };
970
+
971
+ convert$1.hsv.ansi16 = function (args) {
972
+ // Optimization here; we already know the value and don't need to get
973
+ // it converted for us.
974
+ return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
975
+ };
976
+
977
+ convert$1.rgb.ansi256 = function (args) {
978
+ const r = args[0];
979
+ const g = args[1];
980
+ const b = args[2];
981
+
982
+ // We use the extended greyscale palette here, with the exception of
983
+ // black and white. normal palette only has 4 greyscale shades.
984
+ if (r === g && g === b) {
985
+ if (r < 8) {
986
+ return 16;
987
+ }
988
+
989
+ if (r > 248) {
990
+ return 231;
991
+ }
992
+
993
+ return Math.round(((r - 8) / 247) * 24) + 232;
994
+ }
995
+
996
+ const ansi = 16
997
+ + (36 * Math.round(r / 255 * 5))
998
+ + (6 * Math.round(g / 255 * 5))
999
+ + Math.round(b / 255 * 5);
1000
+
1001
+ return ansi;
1002
+ };
1003
+
1004
+ convert$1.ansi16.rgb = function (args) {
1005
+ let color = args % 10;
1006
+
1007
+ // Handle greyscale
1008
+ if (color === 0 || color === 7) {
1009
+ if (args > 50) {
1010
+ color += 3.5;
1011
+ }
1012
+
1013
+ color = color / 10.5 * 255;
1014
+
1015
+ return [color, color, color];
1016
+ }
1017
+
1018
+ const mult = (~~(args > 50) + 1) * 0.5;
1019
+ const r = ((color & 1) * mult) * 255;
1020
+ const g = (((color >> 1) & 1) * mult) * 255;
1021
+ const b = (((color >> 2) & 1) * mult) * 255;
1022
+
1023
+ return [r, g, b];
1024
+ };
1025
+
1026
+ convert$1.ansi256.rgb = function (args) {
1027
+ // Handle greyscale
1028
+ if (args >= 232) {
1029
+ const c = (args - 232) * 10 + 8;
1030
+ return [c, c, c];
1031
+ }
1032
+
1033
+ args -= 16;
1034
+
1035
+ let rem;
1036
+ const r = Math.floor(args / 36) / 5 * 255;
1037
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1038
+ const b = (rem % 6) / 5 * 255;
1039
+
1040
+ return [r, g, b];
1041
+ };
1042
+
1043
+ convert$1.rgb.hex = function (args) {
1044
+ const integer = ((Math.round(args[0]) & 0xFF) << 16)
1045
+ + ((Math.round(args[1]) & 0xFF) << 8)
1046
+ + (Math.round(args[2]) & 0xFF);
1047
+
1048
+ const string = integer.toString(16).toUpperCase();
1049
+ return '000000'.substring(string.length) + string;
1050
+ };
1051
+
1052
+ convert$1.hex.rgb = function (args) {
1053
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1054
+ if (!match) {
1055
+ return [0, 0, 0];
1056
+ }
1057
+
1058
+ let colorString = match[0];
1059
+
1060
+ if (match[0].length === 3) {
1061
+ colorString = colorString.split('').map(char => {
1062
+ return char + char;
1063
+ }).join('');
1064
+ }
1065
+
1066
+ const integer = parseInt(colorString, 16);
1067
+ const r = (integer >> 16) & 0xFF;
1068
+ const g = (integer >> 8) & 0xFF;
1069
+ const b = integer & 0xFF;
1070
+
1071
+ return [r, g, b];
1072
+ };
1073
+
1074
+ convert$1.rgb.hcg = function (rgb) {
1075
+ const r = rgb[0] / 255;
1076
+ const g = rgb[1] / 255;
1077
+ const b = rgb[2] / 255;
1078
+ const max = Math.max(Math.max(r, g), b);
1079
+ const min = Math.min(Math.min(r, g), b);
1080
+ const chroma = (max - min);
1081
+ let grayscale;
1082
+ let hue;
1083
+
1084
+ if (chroma < 1) {
1085
+ grayscale = min / (1 - chroma);
1086
+ } else {
1087
+ grayscale = 0;
1088
+ }
1089
+
1090
+ if (chroma <= 0) {
1091
+ hue = 0;
1092
+ } else
1093
+ if (max === r) {
1094
+ hue = ((g - b) / chroma) % 6;
1095
+ } else
1096
+ if (max === g) {
1097
+ hue = 2 + (b - r) / chroma;
1098
+ } else {
1099
+ hue = 4 + (r - g) / chroma;
1100
+ }
1101
+
1102
+ hue /= 6;
1103
+ hue %= 1;
1104
+
1105
+ return [hue * 360, chroma * 100, grayscale * 100];
1106
+ };
1107
+
1108
+ convert$1.hsl.hcg = function (hsl) {
1109
+ const s = hsl[1] / 100;
1110
+ const l = hsl[2] / 100;
1111
+
1112
+ const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
1113
+
1114
+ let f = 0;
1115
+ if (c < 1.0) {
1116
+ f = (l - 0.5 * c) / (1.0 - c);
1117
+ }
1118
+
1119
+ return [hsl[0], c * 100, f * 100];
1120
+ };
1121
+
1122
+ convert$1.hsv.hcg = function (hsv) {
1123
+ const s = hsv[1] / 100;
1124
+ const v = hsv[2] / 100;
1125
+
1126
+ const c = s * v;
1127
+ let f = 0;
1128
+
1129
+ if (c < 1.0) {
1130
+ f = (v - c) / (1 - c);
1131
+ }
1132
+
1133
+ return [hsv[0], c * 100, f * 100];
1134
+ };
1135
+
1136
+ convert$1.hcg.rgb = function (hcg) {
1137
+ const h = hcg[0] / 360;
1138
+ const c = hcg[1] / 100;
1139
+ const g = hcg[2] / 100;
1140
+
1141
+ if (c === 0.0) {
1142
+ return [g * 255, g * 255, g * 255];
1143
+ }
1144
+
1145
+ const pure = [0, 0, 0];
1146
+ const hi = (h % 1) * 6;
1147
+ const v = hi % 1;
1148
+ const w = 1 - v;
1149
+ let mg = 0;
1150
+
1151
+ /* eslint-disable max-statements-per-line */
1152
+ switch (Math.floor(hi)) {
1153
+ case 0:
1154
+ pure[0] = 1; pure[1] = v; pure[2] = 0; break;
1155
+ case 1:
1156
+ pure[0] = w; pure[1] = 1; pure[2] = 0; break;
1157
+ case 2:
1158
+ pure[0] = 0; pure[1] = 1; pure[2] = v; break;
1159
+ case 3:
1160
+ pure[0] = 0; pure[1] = w; pure[2] = 1; break;
1161
+ case 4:
1162
+ pure[0] = v; pure[1] = 0; pure[2] = 1; break;
1163
+ default:
1164
+ pure[0] = 1; pure[1] = 0; pure[2] = w;
1165
+ }
1166
+ /* eslint-enable max-statements-per-line */
1167
+
1168
+ mg = (1.0 - c) * g;
1169
+
1170
+ return [
1171
+ (c * pure[0] + mg) * 255,
1172
+ (c * pure[1] + mg) * 255,
1173
+ (c * pure[2] + mg) * 255
1174
+ ];
1175
+ };
1176
+
1177
+ convert$1.hcg.hsv = function (hcg) {
1178
+ const c = hcg[1] / 100;
1179
+ const g = hcg[2] / 100;
1180
+
1181
+ const v = c + g * (1.0 - c);
1182
+ let f = 0;
1183
+
1184
+ if (v > 0.0) {
1185
+ f = c / v;
1186
+ }
1187
+
1188
+ return [hcg[0], f * 100, v * 100];
1189
+ };
1190
+
1191
+ convert$1.hcg.hsl = function (hcg) {
1192
+ const c = hcg[1] / 100;
1193
+ const g = hcg[2] / 100;
1194
+
1195
+ const l = g * (1.0 - c) + 0.5 * c;
1196
+ let s = 0;
1197
+
1198
+ if (l > 0.0 && l < 0.5) {
1199
+ s = c / (2 * l);
1200
+ } else
1201
+ if (l >= 0.5 && l < 1.0) {
1202
+ s = c / (2 * (1 - l));
1203
+ }
1204
+
1205
+ return [hcg[0], s * 100, l * 100];
1206
+ };
1207
+
1208
+ convert$1.hcg.hwb = function (hcg) {
1209
+ const c = hcg[1] / 100;
1210
+ const g = hcg[2] / 100;
1211
+ const v = c + g * (1.0 - c);
1212
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
1213
+ };
1214
+
1215
+ convert$1.hwb.hcg = function (hwb) {
1216
+ const w = hwb[1] / 100;
1217
+ const b = hwb[2] / 100;
1218
+ const v = 1 - b;
1219
+ const c = v - w;
1220
+ let g = 0;
1221
+
1222
+ if (c < 1) {
1223
+ g = (v - c) / (1 - c);
1224
+ }
1225
+
1226
+ return [hwb[0], c * 100, g * 100];
1227
+ };
1228
+
1229
+ convert$1.apple.rgb = function (apple) {
1230
+ return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
1231
+ };
1232
+
1233
+ convert$1.rgb.apple = function (rgb) {
1234
+ return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
1235
+ };
1236
+
1237
+ convert$1.gray.rgb = function (args) {
1238
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1239
+ };
1240
+
1241
+ convert$1.gray.hsl = function (args) {
1242
+ return [0, 0, args[0]];
1243
+ };
1244
+
1245
+ convert$1.gray.hsv = convert$1.gray.hsl;
1246
+
1247
+ convert$1.gray.hwb = function (gray) {
1248
+ return [0, 100, gray[0]];
1249
+ };
1250
+
1251
+ convert$1.gray.cmyk = function (gray) {
1252
+ return [0, 0, 0, gray[0]];
1253
+ };
1254
+
1255
+ convert$1.gray.lab = function (gray) {
1256
+ return [gray[0], 0, 0];
1257
+ };
1258
+
1259
+ convert$1.gray.hex = function (gray) {
1260
+ const val = Math.round(gray[0] / 100 * 255) & 0xFF;
1261
+ const integer = (val << 16) + (val << 8) + val;
1262
+
1263
+ const string = integer.toString(16).toUpperCase();
1264
+ return '000000'.substring(string.length) + string;
1265
+ };
1266
+
1267
+ convert$1.rgb.gray = function (rgb) {
1268
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1269
+ return [val / 255 * 100];
1270
+ };
1271
+
1272
+ /*
1273
+ This function routes a model to all other models.
1274
+
1275
+ all functions that are routed have a property `.conversion` attached
1276
+ to the returned synthetic function. This property is an array
1277
+ of strings, each with the steps in between the 'from' and 'to'
1278
+ color models (inclusive).
1279
+
1280
+ conversions that are not possible simply are not included.
1281
+ */
1282
+
1283
+ function buildGraph() {
1284
+ const graph = {};
1285
+ // https://jsperf.com/object-keys-vs-for-in-with-closure/3
1286
+ const models = Object.keys(conversions);
1287
+
1288
+ for (let len = models.length, i = 0; i < len; i++) {
1289
+ graph[models[i]] = {
1290
+ // http://jsperf.com/1-vs-infinity
1291
+ // micro-opt, but this is simple.
1292
+ distance: -1,
1293
+ parent: null
1294
+ };
1295
+ }
1296
+
1297
+ return graph;
1298
+ }
1299
+
1300
+ // https://en.wikipedia.org/wiki/Breadth-first_search
1301
+ function deriveBFS(fromModel) {
1302
+ const graph = buildGraph();
1303
+ const queue = [fromModel]; // Unshift -> queue -> pop
1304
+
1305
+ graph[fromModel].distance = 0;
1306
+
1307
+ while (queue.length) {
1308
+ const current = queue.pop();
1309
+ const adjacents = Object.keys(conversions[current]);
1310
+
1311
+ for (let len = adjacents.length, i = 0; i < len; i++) {
1312
+ const adjacent = adjacents[i];
1313
+ const node = graph[adjacent];
1314
+
1315
+ if (node.distance === -1) {
1316
+ node.distance = graph[current].distance + 1;
1317
+ node.parent = current;
1318
+ queue.unshift(adjacent);
1319
+ }
1320
+ }
1321
+ }
1322
+
1323
+ return graph;
1324
+ }
1325
+
1326
+ function link(from, to) {
1327
+ return function (args) {
1328
+ return to(from(args));
1329
+ };
1330
+ }
1331
+
1332
+ function wrapConversion(toModel, graph) {
1333
+ const path = [graph[toModel].parent, toModel];
1334
+ let fn = conversions[graph[toModel].parent][toModel];
1335
+
1336
+ let cur = graph[toModel].parent;
1337
+ while (graph[cur].parent) {
1338
+ path.unshift(graph[cur].parent);
1339
+ fn = link(conversions[graph[cur].parent][cur], fn);
1340
+ cur = graph[cur].parent;
1341
+ }
1342
+
1343
+ fn.conversion = path;
1344
+ return fn;
1345
+ }
1346
+
1347
+ var route = function (fromModel) {
1348
+ const graph = deriveBFS(fromModel);
1349
+ const conversion = {};
1350
+
1351
+ const models = Object.keys(graph);
1352
+ for (let len = models.length, i = 0; i < len; i++) {
1353
+ const toModel = models[i];
1354
+ const node = graph[toModel];
1355
+
1356
+ if (node.parent === null) {
1357
+ // No possible conversion, or this node is the source model.
1358
+ continue;
1359
+ }
1360
+
1361
+ conversion[toModel] = wrapConversion(toModel, graph);
1362
+ }
1363
+
1364
+ return conversion;
1365
+ };
1366
+
1367
+ const convert = {};
1368
+
1369
+ const models = Object.keys(conversions);
1370
+
1371
+ function wrapRaw(fn) {
1372
+ const wrappedFn = function (...args) {
1373
+ const arg0 = args[0];
1374
+ if (arg0 === undefined || arg0 === null) {
1375
+ return arg0;
1376
+ }
1377
+
1378
+ if (arg0.length > 1) {
1379
+ args = arg0;
1380
+ }
1381
+
1382
+ return fn(args);
1383
+ };
1384
+
1385
+ // Preserve .conversion property if there is one
1386
+ if ('conversion' in fn) {
1387
+ wrappedFn.conversion = fn.conversion;
1388
+ }
1389
+
1390
+ return wrappedFn;
1391
+ }
1392
+
1393
+ function wrapRounded(fn) {
1394
+ const wrappedFn = function (...args) {
1395
+ const arg0 = args[0];
1396
+
1397
+ if (arg0 === undefined || arg0 === null) {
1398
+ return arg0;
1399
+ }
1400
+
1401
+ if (arg0.length > 1) {
1402
+ args = arg0;
1403
+ }
1404
+
1405
+ const result = fn(args);
1406
+
1407
+ // We're assuming the result is an array here.
1408
+ // see notice in conversions.js; don't use box types
1409
+ // in conversion functions.
1410
+ if (typeof result === 'object') {
1411
+ for (let len = result.length, i = 0; i < len; i++) {
1412
+ result[i] = Math.round(result[i]);
1413
+ }
1414
+ }
1415
+
1416
+ return result;
1417
+ };
1418
+
1419
+ // Preserve .conversion property if there is one
1420
+ if ('conversion' in fn) {
1421
+ wrappedFn.conversion = fn.conversion;
1422
+ }
1423
+
1424
+ return wrappedFn;
1425
+ }
1426
+
1427
+ models.forEach(fromModel => {
1428
+ convert[fromModel] = {};
1429
+
1430
+ Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
1431
+ Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
1432
+
1433
+ const routes = route(fromModel);
1434
+ const routeModels = Object.keys(routes);
1435
+
1436
+ routeModels.forEach(toModel => {
1437
+ const fn = routes[toModel];
1438
+
1439
+ convert[fromModel][toModel] = wrapRounded(fn);
1440
+ convert[fromModel][toModel].raw = wrapRaw(fn);
1441
+ });
1442
+ });
1443
+
1444
+ var colorConvert = convert;
1445
+
1446
+ const _slice = [].slice;
1447
+
1448
+ const skippedModels = [
1449
+ // To be honest, I don't really feel like keyword belongs in color convert, but eh.
1450
+ 'keyword',
1451
+
1452
+ // Gray conflicts with some method names, and has its own method defined.
1453
+ 'gray',
1454
+
1455
+ // Shouldn't really be in color-convert either...
1456
+ 'hex',
1457
+ ];
1458
+
1459
+ const hashedModelKeys = {};
1460
+ for (const model of Object.keys(colorConvert)) {
1461
+ hashedModelKeys[_slice.call(colorConvert[model].labels).sort().join('')] = model;
1462
+ }
1463
+
1464
+ const limiters = {};
1465
+
1466
+ function Color(object, model) {
1467
+ if (!(this instanceof Color)) {
1468
+ return new Color(object, model);
1469
+ }
1470
+
1471
+ if (model && model in skippedModels) {
1472
+ model = null;
1473
+ }
1474
+
1475
+ if (model && !(model in colorConvert)) {
1476
+ throw new Error('Unknown model: ' + model);
1477
+ }
1478
+
1479
+ let i;
1480
+ let channels;
1481
+
1482
+ if (object == null) { // eslint-disable-line no-eq-null,eqeqeq
1483
+ this.model = 'rgb';
1484
+ this.color = [0, 0, 0];
1485
+ this.valpha = 1;
1486
+ } else if (object instanceof Color) {
1487
+ this.model = object.model;
1488
+ this.color = object.color.slice();
1489
+ this.valpha = object.valpha;
1490
+ } else if (typeof object === 'string') {
1491
+ const result = colorString.get(object);
1492
+ if (result === null) {
1493
+ throw new Error('Unable to parse color from string: ' + object);
1494
+ }
1495
+
1496
+ this.model = result.model;
1497
+ channels = colorConvert[this.model].channels;
1498
+ this.color = result.value.slice(0, channels);
1499
+ this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
1500
+ } else if (object.length > 0) {
1501
+ this.model = model || 'rgb';
1502
+ channels = colorConvert[this.model].channels;
1503
+ const newArray = _slice.call(object, 0, channels);
1504
+ this.color = zeroArray(newArray, channels);
1505
+ this.valpha = typeof object[channels] === 'number' ? object[channels] : 1;
1506
+ } else if (typeof object === 'number') {
1507
+ // This is always RGB - can be converted later on.
1508
+ this.model = 'rgb';
1509
+ this.color = [
1510
+ (object >> 16) & 0xFF,
1511
+ (object >> 8) & 0xFF,
1512
+ object & 0xFF,
1513
+ ];
1514
+ this.valpha = 1;
1515
+ } else {
1516
+ this.valpha = 1;
1517
+
1518
+ const keys = Object.keys(object);
1519
+ if ('alpha' in object) {
1520
+ keys.splice(keys.indexOf('alpha'), 1);
1521
+ this.valpha = typeof object.alpha === 'number' ? object.alpha : 0;
1522
+ }
1523
+
1524
+ const hashedKeys = keys.sort().join('');
1525
+ if (!(hashedKeys in hashedModelKeys)) {
1526
+ throw new Error('Unable to parse color from object: ' + JSON.stringify(object));
1527
+ }
1528
+
1529
+ this.model = hashedModelKeys[hashedKeys];
1530
+
1531
+ const labels = colorConvert[this.model].labels;
1532
+ const color = [];
1533
+ for (i = 0; i < labels.length; i++) {
1534
+ color.push(object[labels[i]]);
1535
+ }
1536
+
1537
+ this.color = zeroArray(color);
1538
+ }
1539
+
1540
+ // Perform limitations (clamping, etc.)
1541
+ if (limiters[this.model]) {
1542
+ channels = colorConvert[this.model].channels;
1543
+ for (i = 0; i < channels; i++) {
1544
+ const limit = limiters[this.model][i];
1545
+ if (limit) {
1546
+ this.color[i] = limit(this.color[i]);
1547
+ }
1548
+ }
1549
+ }
1550
+
1551
+ this.valpha = Math.max(0, Math.min(1, this.valpha));
1552
+
1553
+ if (Object.freeze) {
1554
+ Object.freeze(this);
1555
+ }
1556
+ }
1557
+
1558
+ Color.prototype = {
1559
+ toString() {
1560
+ return this.string();
1561
+ },
1562
+
1563
+ toJSON() {
1564
+ return this[this.model]();
1565
+ },
1566
+
1567
+ string(places) {
1568
+ let self = this.model in colorString.to ? this : this.rgb();
1569
+ self = self.round(typeof places === 'number' ? places : 1);
1570
+ const args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
1571
+ return colorString.to[self.model](args);
1572
+ },
1573
+
1574
+ percentString(places) {
1575
+ const self = this.rgb().round(typeof places === 'number' ? places : 1);
1576
+ const args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
1577
+ return colorString.to.rgb.percent(args);
1578
+ },
1579
+
1580
+ array() {
1581
+ return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);
1582
+ },
1583
+
1584
+ object() {
1585
+ const result = {};
1586
+ const channels = colorConvert[this.model].channels;
1587
+ const labels = colorConvert[this.model].labels;
1588
+
1589
+ for (let i = 0; i < channels; i++) {
1590
+ result[labels[i]] = this.color[i];
1591
+ }
1592
+
1593
+ if (this.valpha !== 1) {
1594
+ result.alpha = this.valpha;
1595
+ }
1596
+
1597
+ return result;
1598
+ },
1599
+
1600
+ unitArray() {
1601
+ const rgb = this.rgb().color;
1602
+ rgb[0] /= 255;
1603
+ rgb[1] /= 255;
1604
+ rgb[2] /= 255;
1605
+
1606
+ if (this.valpha !== 1) {
1607
+ rgb.push(this.valpha);
1608
+ }
1609
+
1610
+ return rgb;
1611
+ },
1612
+
1613
+ unitObject() {
1614
+ const rgb = this.rgb().object();
1615
+ rgb.r /= 255;
1616
+ rgb.g /= 255;
1617
+ rgb.b /= 255;
1618
+
1619
+ if (this.valpha !== 1) {
1620
+ rgb.alpha = this.valpha;
1621
+ }
1622
+
1623
+ return rgb;
1624
+ },
1625
+
1626
+ round(places) {
1627
+ places = Math.max(places || 0, 0);
1628
+ return new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);
1629
+ },
1630
+
1631
+ alpha(value) {
1632
+ if (arguments.length > 0) {
1633
+ return new Color(this.color.concat(Math.max(0, Math.min(1, value))), this.model);
1634
+ }
1635
+
1636
+ return this.valpha;
1637
+ },
1638
+
1639
+ // Rgb
1640
+ red: getset('rgb', 0, maxfn(255)),
1641
+ green: getset('rgb', 1, maxfn(255)),
1642
+ blue: getset('rgb', 2, maxfn(255)),
1643
+
1644
+ hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, value => ((value % 360) + 360) % 360),
1645
+
1646
+ saturationl: getset('hsl', 1, maxfn(100)),
1647
+ lightness: getset('hsl', 2, maxfn(100)),
1648
+
1649
+ saturationv: getset('hsv', 1, maxfn(100)),
1650
+ value: getset('hsv', 2, maxfn(100)),
1651
+
1652
+ chroma: getset('hcg', 1, maxfn(100)),
1653
+ gray: getset('hcg', 2, maxfn(100)),
1654
+
1655
+ white: getset('hwb', 1, maxfn(100)),
1656
+ wblack: getset('hwb', 2, maxfn(100)),
1657
+
1658
+ cyan: getset('cmyk', 0, maxfn(100)),
1659
+ magenta: getset('cmyk', 1, maxfn(100)),
1660
+ yellow: getset('cmyk', 2, maxfn(100)),
1661
+ black: getset('cmyk', 3, maxfn(100)),
1662
+
1663
+ x: getset('xyz', 0, maxfn(100)),
1664
+ y: getset('xyz', 1, maxfn(100)),
1665
+ z: getset('xyz', 2, maxfn(100)),
1666
+
1667
+ l: getset('lab', 0, maxfn(100)),
1668
+ a: getset('lab', 1),
1669
+ b: getset('lab', 2),
1670
+
1671
+ keyword(value) {
1672
+ if (arguments.length > 0) {
1673
+ return new Color(value);
1674
+ }
1675
+
1676
+ return colorConvert[this.model].keyword(this.color);
1677
+ },
1678
+
1679
+ hex(value) {
1680
+ if (arguments.length > 0) {
1681
+ return new Color(value);
1682
+ }
1683
+
1684
+ return colorString.to.hex(this.rgb().round().color);
1685
+ },
1686
+
1687
+ rgbNumber() {
1688
+ const rgb = this.rgb().color;
1689
+ return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
1690
+ },
1691
+
1692
+ luminosity() {
1693
+ // http://www.w3.org/TR/WCAG20/#relativeluminancedef
1694
+ const rgb = this.rgb().color;
1695
+
1696
+ const lum = [];
1697
+ for (const [i, element] of rgb.entries()) {
1698
+ const chan = element / 255;
1699
+ lum[i] = (chan <= 0.039_28) ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
1700
+ }
1701
+
1702
+ return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
1703
+ },
1704
+
1705
+ contrast(color2) {
1706
+ // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
1707
+ const lum1 = this.luminosity();
1708
+ const lum2 = color2.luminosity();
1709
+
1710
+ if (lum1 > lum2) {
1711
+ return (lum1 + 0.05) / (lum2 + 0.05);
1712
+ }
1713
+
1714
+ return (lum2 + 0.05) / (lum1 + 0.05);
1715
+ },
1716
+
1717
+ level(color2) {
1718
+ const contrastRatio = this.contrast(color2);
1719
+ if (contrastRatio >= 7.1) {
1720
+ return 'AAA';
1721
+ }
1722
+
1723
+ return (contrastRatio >= 4.5) ? 'AA' : '';
1724
+ },
1725
+
1726
+ isDark() {
1727
+ // YIQ equation from http://24ways.org/2010/calculating-color-contrast
1728
+ const rgb = this.rgb().color;
1729
+ const yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
1730
+ return yiq < 128;
1731
+ },
1732
+
1733
+ isLight() {
1734
+ return !this.isDark();
1735
+ },
1736
+
1737
+ negate() {
1738
+ const rgb = this.rgb();
1739
+ for (let i = 0; i < 3; i++) {
1740
+ rgb.color[i] = 255 - rgb.color[i];
1741
+ }
1742
+
1743
+ return rgb;
1744
+ },
1745
+
1746
+ lighten(ratio) {
1747
+ const hsl = this.hsl();
1748
+ hsl.color[2] += hsl.color[2] * ratio;
1749
+ return hsl;
1750
+ },
1751
+
1752
+ darken(ratio) {
1753
+ const hsl = this.hsl();
1754
+ hsl.color[2] -= hsl.color[2] * ratio;
1755
+ return hsl;
1756
+ },
1757
+
1758
+ saturate(ratio) {
1759
+ const hsl = this.hsl();
1760
+ hsl.color[1] += hsl.color[1] * ratio;
1761
+ return hsl;
1762
+ },
1763
+
1764
+ desaturate(ratio) {
1765
+ const hsl = this.hsl();
1766
+ hsl.color[1] -= hsl.color[1] * ratio;
1767
+ return hsl;
1768
+ },
1769
+
1770
+ whiten(ratio) {
1771
+ const hwb = this.hwb();
1772
+ hwb.color[1] += hwb.color[1] * ratio;
1773
+ return hwb;
1774
+ },
1775
+
1776
+ blacken(ratio) {
1777
+ const hwb = this.hwb();
1778
+ hwb.color[2] += hwb.color[2] * ratio;
1779
+ return hwb;
1780
+ },
1781
+
1782
+ grayscale() {
1783
+ // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
1784
+ const rgb = this.rgb().color;
1785
+ const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
1786
+ return Color.rgb(value, value, value);
1787
+ },
1788
+
1789
+ fade(ratio) {
1790
+ return this.alpha(this.valpha - (this.valpha * ratio));
1791
+ },
1792
+
1793
+ opaquer(ratio) {
1794
+ return this.alpha(this.valpha + (this.valpha * ratio));
1795
+ },
1796
+
1797
+ rotate(degrees) {
1798
+ const hsl = this.hsl();
1799
+ let hue = hsl.color[0];
1800
+ hue = (hue + degrees) % 360;
1801
+ hue = hue < 0 ? 360 + hue : hue;
1802
+ hsl.color[0] = hue;
1803
+ return hsl;
1804
+ },
1805
+
1806
+ mix(mixinColor, weight) {
1807
+ // Ported from sass implementation in C
1808
+ // https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
1809
+ if (!mixinColor || !mixinColor.rgb) {
1810
+ throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
1811
+ }
1812
+
1813
+ const color1 = mixinColor.rgb();
1814
+ const color2 = this.rgb();
1815
+ const p = weight === undefined ? 0.5 : weight;
1816
+
1817
+ const w = 2 * p - 1;
1818
+ const a = color1.alpha() - color2.alpha();
1819
+
1820
+ const w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2;
1821
+ const w2 = 1 - w1;
1822
+
1823
+ return Color.rgb(
1824
+ w1 * color1.red() + w2 * color2.red(),
1825
+ w1 * color1.green() + w2 * color2.green(),
1826
+ w1 * color1.blue() + w2 * color2.blue(),
1827
+ color1.alpha() * p + color2.alpha() * (1 - p));
1828
+ },
1829
+ };
1830
+
1831
+ // Model conversion methods and static constructors
1832
+ for (const model of Object.keys(colorConvert)) {
1833
+ if (skippedModels.includes(model)) {
1834
+ continue;
1835
+ }
1836
+
1837
+ const channels = colorConvert[model].channels;
1838
+
1839
+ // Conversion methods
1840
+ Color.prototype[model] = function () {
1841
+ if (this.model === model) {
1842
+ return new Color(this);
1843
+ }
1844
+
1845
+ if (arguments.length > 0) {
1846
+ return new Color(arguments, model);
1847
+ }
1848
+
1849
+ const newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;
1850
+ return new Color(assertArray(colorConvert[this.model][model].raw(this.color)).concat(newAlpha), model);
1851
+ };
1852
+
1853
+ // 'static' construction methods
1854
+ Color[model] = function (color) {
1855
+ if (typeof color === 'number') {
1856
+ color = zeroArray(_slice.call(arguments), channels);
1857
+ }
1858
+
1859
+ return new Color(color, model);
1860
+ };
1861
+ }
1862
+
1863
+ function roundTo(number, places) {
1864
+ return Number(number.toFixed(places));
1865
+ }
1866
+
1867
+ function roundToPlace(places) {
1868
+ return function (number) {
1869
+ return roundTo(number, places);
1870
+ };
1871
+ }
1872
+
1873
+ function getset(model, channel, modifier) {
1874
+ model = Array.isArray(model) ? model : [model];
1875
+
1876
+ for (const m of model) {
1877
+ (limiters[m] || (limiters[m] = []))[channel] = modifier;
1878
+ }
1879
+
1880
+ model = model[0];
1881
+
1882
+ return function (value) {
1883
+ let result;
1884
+
1885
+ if (arguments.length > 0) {
1886
+ if (modifier) {
1887
+ value = modifier(value);
1888
+ }
1889
+
1890
+ result = this[model]();
1891
+ result.color[channel] = value;
1892
+ return result;
1893
+ }
1894
+
1895
+ result = this[model]().color[channel];
1896
+ if (modifier) {
1897
+ result = modifier(result);
1898
+ }
1899
+
1900
+ return result;
1901
+ };
1902
+ }
1903
+
1904
+ function maxfn(max) {
1905
+ return function (v) {
1906
+ return Math.max(0, Math.min(max, v));
1907
+ };
1908
+ }
1909
+
1910
+ function assertArray(value) {
1911
+ return Array.isArray(value) ? value : [value];
1912
+ }
1913
+
1914
+ function zeroArray(array, length) {
1915
+ for (let i = 0; i < length; i++) {
1916
+ if (typeof array[i] !== 'number') {
1917
+ array[i] = 0;
1918
+ }
1919
+ }
1920
+
1921
+ return array;
1922
+ }
1923
+
1924
+ var color = Color;
1925
+
3
1926
  /*
4
1927
  object-assign
5
1928
  (c) Sindre Sorhus
@@ -2467,4 +4390,4 @@ function attribsFor() {
2467
4390
  }
2468
4391
  });
2469
4392
 
2470
- export { lib as l };
4393
+ export { color as c, lib as l };