favesalon-embed 0.0.4 → 0.0.5

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