@cccsaurora/clue-ui 0.15.0-dev.31 → 0.15.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 (257) hide show
  1. package/package.json +143 -39
  2. package/ActionForm-DgfJwTzt.js +0 -436
  3. package/AnnotationPreview-BvNpZOP0.js +0 -188
  4. package/ClueEnrichContext-DXwLVp0M.js +0 -518
  5. package/FlexOne-BSYAhhtG.js +0 -9
  6. package/_Map-kgDsDYxq.js +0 -64
  7. package/_MapCache-DabaaWfq.js +0 -161
  8. package/_Uint8Array-BlVVH1tp.js +0 -129
  9. package/_baseAssignValue-CNbcU6Nb.js +0 -25
  10. package/_baseClone-D3a8Pa4T.js +0 -284
  11. package/_baseExtremum-B1o1zHjR.js +0 -33
  12. package/_baseFlatten-D4huXoEI.js +0 -92
  13. package/_baseGet-BSK_nnoz.js +0 -109
  14. package/_baseIsEqual-B5xLoweL.js +0 -238
  15. package/_baseIteratee-p6Nj07-n.js +0 -126
  16. package/_baseSlice-GAv_YFTT.js +0 -20
  17. package/_baseSum-D0WC1dN0.js +0 -13
  18. package/_baseUniq-CpupKWcL.js +0 -89
  19. package/_commonjsHelpers-CUmg6egw.js +0 -6
  20. package/_createAggregator-BpVy5xMi.js +0 -63
  21. package/_getPrototype-D1LAdQKO.js +0 -5
  22. package/_getTag-D3ToyefI.js +0 -126
  23. package/api/lookup/enrich.d.ts +0 -10
  24. package/api/lookup/index.d.ts +0 -5
  25. package/api/lookup/types.d.ts +0 -5
  26. package/api/lookup/types_detection.d.ts +0 -5
  27. package/cloneDeep-CjP5k9zW.js +0 -8
  28. package/components/AnnotationBody.d.ts +0 -6
  29. package/components/AnnotationBody.js +0 -56
  30. package/components/AnnotationDetailPopover.d.ts +0 -14
  31. package/components/AnnotationDetailPopover.js +0 -61
  32. package/components/AnnotationDetails.d.ts +0 -8
  33. package/components/AnnotationDetails.js +0 -172
  34. package/components/AnnotationEntry.d.ts +0 -6
  35. package/components/AnnotationEntry.js +0 -59
  36. package/components/AnnotationPreview.d.ts +0 -14
  37. package/components/AnnotationPreview.js +0 -11
  38. package/components/ClassificationChip.d.ts +0 -11
  39. package/components/ClassificationChip.js +0 -52
  40. package/components/CountBadge.d.ts +0 -8
  41. package/components/CountBadge.js +0 -34
  42. package/components/EnrichedCard.d.ts +0 -14
  43. package/components/EnrichedCard.js +0 -162
  44. package/components/EnrichedChip.d.ts +0 -9
  45. package/components/EnrichedChip.js +0 -176
  46. package/components/EnrichedTypography.d.ts +0 -16
  47. package/components/EnrichedTypography.js +0 -178
  48. package/components/ErrorBoundary.d.ts +0 -15
  49. package/components/ErrorBoundary.js +0 -36
  50. package/components/RetryFailedEnrichments.d.ts +0 -2
  51. package/components/RetryFailedEnrichments.js +0 -13
  52. package/components/SourcePicker.d.ts +0 -2
  53. package/components/SourcePicker.js +0 -98
  54. package/components/actions/ActionForm.d.ts +0 -6
  55. package/components/actions/ActionForm.js +0 -16
  56. package/components/actions/ExecutePopover.d.ts +0 -10
  57. package/components/actions/ExecutePopover.js +0 -93
  58. package/components/actions/ResultModal.d.ts +0 -9
  59. package/components/actions/ResultModal.js +0 -46
  60. package/components/actions/form/schemaAdapter.d.ts +0 -3
  61. package/components/actions/form/schemaAdapter.js +0 -47
  62. package/components/display/graph/ExpandMoreButton.d.ts +0 -7
  63. package/components/display/graph/ExpandMoreButton.js +0 -18
  64. package/components/display/graph/elements/NodeCard.d.ts +0 -10
  65. package/components/display/graph/elements/NodeCard.js +0 -146
  66. package/components/display/graph/elements/NodeTag.d.ts +0 -9
  67. package/components/display/graph/elements/NodeTag.js +0 -17
  68. package/components/display/graph/index.d.ts +0 -9
  69. package/components/display/graph/index.js +0 -438
  70. package/components/display/graph/visualizations/Leaf.d.ts +0 -25
  71. package/components/display/graph/visualizations/Leaf.js +0 -125
  72. package/components/display/graph/visualizations/cloud/index.d.ts +0 -24
  73. package/components/display/graph/visualizations/cloud/index.js +0 -141
  74. package/components/display/graph/visualizations/icons/BaseIcon.d.ts +0 -12
  75. package/components/display/graph/visualizations/icons/BaseIcon.js +0 -37
  76. package/components/display/graph/visualizations/icons/BugIcon.d.ts +0 -5
  77. package/components/display/graph/visualizations/icons/BugIcon.js +0 -18
  78. package/components/display/graph/visualizations/icons/HostIcon.d.ts +0 -5
  79. package/components/display/graph/visualizations/icons/HostIcon.js +0 -24
  80. package/components/display/graph/visualizations/icons/NetworkIcon.d.ts +0 -5
  81. package/components/display/graph/visualizations/icons/NetworkIcon.js +0 -24
  82. package/components/display/graph/visualizations/icons/ProcessIcon.d.ts +0 -5
  83. package/components/display/graph/visualizations/icons/ProcessIcon.js +0 -18
  84. package/components/display/graph/visualizations/icons/TargetIcon.d.ts +0 -5
  85. package/components/display/graph/visualizations/icons/TargetIcon.js +0 -19
  86. package/components/display/graph/visualizations/icons/index.d.ts +0 -2
  87. package/components/display/graph/visualizations/icons/index.js +0 -16
  88. package/components/display/graph/visualizations/panels/NodePanel.d.ts +0 -8
  89. package/components/display/graph/visualizations/panels/NodePanel.js +0 -12
  90. package/components/display/graph/visualizations/tree/BundleLine.d.ts +0 -29
  91. package/components/display/graph/visualizations/tree/BundleLine.js +0 -121
  92. package/components/display/graph/visualizations/tree/Triangle.d.ts +0 -9
  93. package/components/display/graph/visualizations/tree/Triangle.js +0 -26
  94. package/components/display/graph/visualizations/tree/index.d.ts +0 -36
  95. package/components/display/graph/visualizations/tree/index.js +0 -485
  96. package/components/display/graph/visualizations/tree/types.d.ts +0 -11
  97. package/components/display/graph/visualizations/tree/types.js +0 -1
  98. package/components/display/icons/Iconified.d.ts +0 -9
  99. package/components/display/icons/Iconified.js +0 -29
  100. package/components/display/json/index.d.ts +0 -14
  101. package/components/display/json/index.js +0 -12
  102. package/components/display/markdown/DynamicTabs.d.ts +0 -8
  103. package/components/display/markdown/DynamicTabs.js +0 -26
  104. package/components/display/markdown/index.d.ts +0 -9
  105. package/components/display/markdown/index.js +0 -13389
  106. package/components/display/markdown/markdownPlugins/tabs.d.ts +0 -3
  107. package/components/display/markdown/markdownPlugins/tabs.js +0 -4
  108. package/components/enrichment/EnrichPopover.d.ts +0 -10
  109. package/components/enrichment/EnrichPopover.js +0 -88
  110. package/components/fetchers/Fetcher.d.ts +0 -17
  111. package/components/fetchers/Fetcher.js +0 -188
  112. package/components/fetchers/PreviewModal.d.ts +0 -8
  113. package/components/fetchers/PreviewModal.js +0 -22
  114. package/components/fetchers/StatusChip.d.ts +0 -8
  115. package/components/fetchers/StatusChip.js +0 -30
  116. package/components/group/Entry.d.ts +0 -8
  117. package/components/group/Entry.js +0 -15
  118. package/components/group/Group.d.ts +0 -12
  119. package/components/group/Group.js +0 -15
  120. package/components/group/GroupControl.d.ts +0 -4
  121. package/components/group/GroupControl.js +0 -103
  122. package/components/stats/QueryStatus.d.ts +0 -4
  123. package/components/stats/QueryStatus.js +0 -61
  124. package/countBy-C69WslUA.js +0 -14
  125. package/data/event.d.ts +0 -12
  126. package/data/event.js +0 -8
  127. package/database/index.d.ts +0 -4
  128. package/database/index.js +0 -4
  129. package/database/selector.schema.json.d.ts +0 -119
  130. package/database/status.schema.json.d.ts +0 -38
  131. package/database/types.d.ts +0 -64
  132. package/debounce-bV0h5FC5.js +0 -92
  133. package/en/translation.json +0 -135
  134. package/fr/translation.json +0 -135
  135. package/get-D3C3lEU3.js +0 -8
  136. package/groupBy-DC2oOuBN.js +0 -14
  137. package/hooks/ClueActionContext.d.ts +0 -86
  138. package/hooks/ClueActionContext.js +0 -18
  139. package/hooks/ClueComponentContext.d.ts +0 -10
  140. package/hooks/ClueComponentContext.js +0 -40
  141. package/hooks/ClueConfigProvider.d.ts +0 -12
  142. package/hooks/ClueConfigProvider.js +0 -23
  143. package/hooks/ClueDatabaseContext.d.ts +0 -10
  144. package/hooks/ClueDatabaseContext.js +0 -23
  145. package/hooks/ClueEnrichContext.d.ts +0 -6
  146. package/hooks/ClueEnrichContext.js +0 -15
  147. package/hooks/ClueEnrichContextType.d.ts +0 -113
  148. package/hooks/ClueEnrichProps.d.ts +0 -81
  149. package/hooks/ClueFetcherContext.d.ts +0 -35
  150. package/hooks/ClueFetcherContext.js +0 -88
  151. package/hooks/ClueGroupContext.d.ts +0 -14
  152. package/hooks/ClueGroupContext.js +0 -23
  153. package/hooks/CluePopupContext.d.ts +0 -24
  154. package/hooks/CluePopupContext.js +0 -12
  155. package/hooks/ClueProvider.d.ts +0 -9
  156. package/hooks/ClueProvider.js +0 -14
  157. package/hooks/selectors.d.ts +0 -10
  158. package/hooks/selectors.js +0 -24
  159. package/hooks/useAnnotations.d.ts +0 -24
  160. package/hooks/useAnnotations.js +0 -69
  161. package/hooks/useClue.d.ts +0 -4
  162. package/hooks/useClue.js +0 -8
  163. package/hooks/useClueActions.d.ts +0 -4
  164. package/hooks/useClueActions.js +0 -5
  165. package/hooks/useClueConfig.d.ts +0 -1
  166. package/hooks/useClueConfig.js +0 -8
  167. package/hooks/useClueTypeConfig.d.ts +0 -17
  168. package/hooks/useClueTypeConfig.js +0 -7
  169. package/hooks/useComparator.d.ts +0 -16
  170. package/hooks/useComparator.js +0 -1060
  171. package/hooks/useErrors.d.ts +0 -17
  172. package/hooks/useErrors.js +0 -35
  173. package/hooks/useMyHighlights.d.ts +0 -11
  174. package/hooks/useMyHighlights.js +0 -74
  175. package/hooks/useMyLocalStorage.d.ts +0 -16
  176. package/hooks/useMyLocalStorage.js +0 -80
  177. package/iconify-CXMreGTg.js +0 -1782
  178. package/icons/Action.d.ts +0 -9
  179. package/icons/Action.js +0 -90
  180. package/icons/Assessment.d.ts +0 -11
  181. package/icons/Assessment.js +0 -123
  182. package/icons/Context.d.ts +0 -12
  183. package/icons/Context.js +0 -83
  184. package/icons/Opinion.d.ts +0 -11
  185. package/icons/Opinion.js +0 -125
  186. package/icons/iconMap.d.ts +0 -7
  187. package/icons/iconMap.js +0 -10
  188. package/identity-CPGTqrE4.js +0 -6
  189. package/index-BDVjGvMI.js +0 -696
  190. package/index-BDrtH5ec.js +0 -465
  191. package/index-C9lySIVX.js +0 -1172
  192. package/index-DJYqRcxJ.js +0 -15750
  193. package/index-Dn2NHyXg.js +0 -17654
  194. package/index.css +0 -21
  195. package/isEmpty-BQkZubqU.js +0 -29
  196. package/isNil-CIubwp4T.js +0 -6
  197. package/isObject-FTY-5JQX.js +0 -7
  198. package/isObjectLike-OAgjjZye.js +0 -48
  199. package/isSymbol-Xd2FsJyp.js +0 -8
  200. package/isUndefined-CE8h73dH.js +0 -10
  201. package/last-CUCl67Im.js +0 -7
  202. package/main.d.ts +0 -42
  203. package/main.js +0 -70
  204. package/public/manifest.json +0 -16
  205. package/public/robots.txt +0 -3
  206. package/public/svg/dark/clue-h.svg +0 -52
  207. package/public/svg/dark/clue-icon1-simple.svg +0 -33
  208. package/public/svg/dark/clue-icon1.svg +0 -44
  209. package/public/svg/dark/clue-icon2-simple.svg +0 -26
  210. package/public/svg/dark/clue-icon2.svg +0 -37
  211. package/public/svg/dark/clue-name.svg +0 -14
  212. package/public/svg/dark/clue-v.svg +0 -52
  213. package/public/svg/light/clue-h.svg +0 -60
  214. package/public/svg/light/clue-icon1-simple.svg +0 -37
  215. package/public/svg/light/clue-icon1.svg +0 -48
  216. package/public/svg/light/clue-icon2-simple.svg +0 -30
  217. package/public/svg/light/clue-icon2.svg +0 -41
  218. package/public/svg/light/clue-name.svg +0 -14
  219. package/public/svg/light/clue-v.svg +0 -60
  220. package/sortBy-B-UKp4GT.js +0 -100
  221. package/sumBy-MYkDPHZL.js +0 -8
  222. package/tabs-xGuUGsJd.js +0 -254
  223. package/text/Frequency.d.ts +0 -9
  224. package/text/Frequency.js +0 -49
  225. package/toFinite-CArjry_l.js +0 -16
  226. package/toNumber-DPxy1FBy.js +0 -39
  227. package/types/EnrichmentProps.d.ts +0 -73
  228. package/types/RunningActionData.d.ts +0 -15
  229. package/types/WithActionData.d.ts +0 -9
  230. package/types/action.d.ts +0 -25
  231. package/types/config.d.ts +0 -16
  232. package/types/fetcher.d.ts +0 -60
  233. package/types/graph.d.ts +0 -101
  234. package/types/lookup.d.ts +0 -62
  235. package/types/network.d.ts +0 -9
  236. package/useClueTypeConfig-D9ZSxa4F.js +0 -3096
  237. package/utils/chain.d.ts +0 -14
  238. package/utils/chain.js +0 -106
  239. package/utils/classificationParser.d.ts +0 -195
  240. package/utils/classificationParser.js +0 -553
  241. package/utils/constants.d.ts +0 -26
  242. package/utils/constants.js +0 -36
  243. package/utils/graph.d.ts +0 -13
  244. package/utils/graph.js +0 -79
  245. package/utils/hashUtil.d.ts +0 -6
  246. package/utils/hashUtil.js +0 -11
  247. package/utils/line.d.ts +0 -28
  248. package/utils/line.js +0 -136
  249. package/utils/loggerUtil.d.ts +0 -6
  250. package/utils/loggerUtil.js +0 -8
  251. package/utils/sessionStorage.d.ts +0 -9
  252. package/utils/sessionStorage.js +0 -51
  253. package/utils/utils.d.ts +0 -13
  254. package/utils/utils.js +0 -11
  255. package/utils/window.d.ts +0 -3
  256. package/utils/window.js +0 -24
  257. package/utils-CxIhC2xH.js +0 -4182
@@ -1,1060 +0,0 @@
1
- import { useTheme } from "@mui/material";
2
- import { g as get } from "../get-D3C3lEU3.js";
3
- import { i as isNil } from "../isNil-CIubwp4T.js";
4
- function _typeof(obj) {
5
- "@babel/helpers - typeof";
6
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
7
- return typeof obj2;
8
- } : function(obj2) {
9
- return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
10
- }, _typeof(obj);
11
- }
12
- var trimLeft = /^\s+/;
13
- var trimRight = /\s+$/;
14
- function tinycolor(color, opts) {
15
- color = color ? color : "";
16
- opts = opts || {};
17
- if (color instanceof tinycolor) {
18
- return color;
19
- }
20
- if (!(this instanceof tinycolor)) {
21
- return new tinycolor(color, opts);
22
- }
23
- var rgb = inputToRGB(color);
24
- this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format;
25
- this._gradientType = opts.gradientType;
26
- if (this._r < 1) this._r = Math.round(this._r);
27
- if (this._g < 1) this._g = Math.round(this._g);
28
- if (this._b < 1) this._b = Math.round(this._b);
29
- this._ok = rgb.ok;
30
- }
31
- tinycolor.prototype = {
32
- isDark: function isDark() {
33
- return this.getBrightness() < 128;
34
- },
35
- isLight: function isLight() {
36
- return !this.isDark();
37
- },
38
- isValid: function isValid() {
39
- return this._ok;
40
- },
41
- getOriginalInput: function getOriginalInput() {
42
- return this._originalInput;
43
- },
44
- getFormat: function getFormat() {
45
- return this._format;
46
- },
47
- getAlpha: function getAlpha() {
48
- return this._a;
49
- },
50
- getBrightness: function getBrightness() {
51
- var rgb = this.toRgb();
52
- return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
53
- },
54
- getLuminance: function getLuminance() {
55
- var rgb = this.toRgb();
56
- var RsRGB, GsRGB, BsRGB, R, G, B;
57
- RsRGB = rgb.r / 255;
58
- GsRGB = rgb.g / 255;
59
- BsRGB = rgb.b / 255;
60
- if (RsRGB <= 0.03928) R = RsRGB / 12.92;
61
- else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
62
- if (GsRGB <= 0.03928) G = GsRGB / 12.92;
63
- else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
64
- if (BsRGB <= 0.03928) B = BsRGB / 12.92;
65
- else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
66
- return 0.2126 * R + 0.7152 * G + 0.0722 * B;
67
- },
68
- setAlpha: function setAlpha(value) {
69
- this._a = boundAlpha(value);
70
- this._roundA = Math.round(100 * this._a) / 100;
71
- return this;
72
- },
73
- toHsv: function toHsv() {
74
- var hsv = rgbToHsv(this._r, this._g, this._b);
75
- return {
76
- h: hsv.h * 360,
77
- s: hsv.s,
78
- v: hsv.v,
79
- a: this._a
80
- };
81
- },
82
- toHsvString: function toHsvString() {
83
- var hsv = rgbToHsv(this._r, this._g, this._b);
84
- var h = Math.round(hsv.h * 360), s = Math.round(hsv.s * 100), v = Math.round(hsv.v * 100);
85
- return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
86
- },
87
- toHsl: function toHsl() {
88
- var hsl = rgbToHsl(this._r, this._g, this._b);
89
- return {
90
- h: hsl.h * 360,
91
- s: hsl.s,
92
- l: hsl.l,
93
- a: this._a
94
- };
95
- },
96
- toHslString: function toHslString() {
97
- var hsl = rgbToHsl(this._r, this._g, this._b);
98
- var h = Math.round(hsl.h * 360), s = Math.round(hsl.s * 100), l = Math.round(hsl.l * 100);
99
- return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
100
- },
101
- toHex: function toHex(allow3Char) {
102
- return rgbToHex(this._r, this._g, this._b, allow3Char);
103
- },
104
- toHexString: function toHexString(allow3Char) {
105
- return "#" + this.toHex(allow3Char);
106
- },
107
- toHex8: function toHex8(allow4Char) {
108
- return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
109
- },
110
- toHex8String: function toHex8String(allow4Char) {
111
- return "#" + this.toHex8(allow4Char);
112
- },
113
- toRgb: function toRgb() {
114
- return {
115
- r: Math.round(this._r),
116
- g: Math.round(this._g),
117
- b: Math.round(this._b),
118
- a: this._a
119
- };
120
- },
121
- toRgbString: function toRgbString() {
122
- return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
123
- },
124
- toPercentageRgb: function toPercentageRgb() {
125
- return {
126
- r: Math.round(bound01(this._r, 255) * 100) + "%",
127
- g: Math.round(bound01(this._g, 255) * 100) + "%",
128
- b: Math.round(bound01(this._b, 255) * 100) + "%",
129
- a: this._a
130
- };
131
- },
132
- toPercentageRgbString: function toPercentageRgbString() {
133
- return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
134
- },
135
- toName: function toName() {
136
- if (this._a === 0) {
137
- return "transparent";
138
- }
139
- if (this._a < 1) {
140
- return false;
141
- }
142
- return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
143
- },
144
- toFilter: function toFilter(secondColor) {
145
- var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
146
- var secondHex8String = hex8String;
147
- var gradientType = this._gradientType ? "GradientType = 1, " : "";
148
- if (secondColor) {
149
- var s = tinycolor(secondColor);
150
- secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
151
- }
152
- return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
153
- },
154
- toString: function toString(format) {
155
- var formatSet = !!format;
156
- format = format || this._format;
157
- var formattedString = false;
158
- var hasAlpha = this._a < 1 && this._a >= 0;
159
- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
160
- if (needsAlphaFormat) {
161
- if (format === "name" && this._a === 0) {
162
- return this.toName();
163
- }
164
- return this.toRgbString();
165
- }
166
- if (format === "rgb") {
167
- formattedString = this.toRgbString();
168
- }
169
- if (format === "prgb") {
170
- formattedString = this.toPercentageRgbString();
171
- }
172
- if (format === "hex" || format === "hex6") {
173
- formattedString = this.toHexString();
174
- }
175
- if (format === "hex3") {
176
- formattedString = this.toHexString(true);
177
- }
178
- if (format === "hex4") {
179
- formattedString = this.toHex8String(true);
180
- }
181
- if (format === "hex8") {
182
- formattedString = this.toHex8String();
183
- }
184
- if (format === "name") {
185
- formattedString = this.toName();
186
- }
187
- if (format === "hsl") {
188
- formattedString = this.toHslString();
189
- }
190
- if (format === "hsv") {
191
- formattedString = this.toHsvString();
192
- }
193
- return formattedString || this.toHexString();
194
- },
195
- clone: function clone() {
196
- return tinycolor(this.toString());
197
- },
198
- _applyModification: function _applyModification(fn, args) {
199
- var color = fn.apply(null, [this].concat([].slice.call(args)));
200
- this._r = color._r;
201
- this._g = color._g;
202
- this._b = color._b;
203
- this.setAlpha(color._a);
204
- return this;
205
- },
206
- lighten: function lighten() {
207
- return this._applyModification(_lighten, arguments);
208
- },
209
- brighten: function brighten() {
210
- return this._applyModification(_brighten, arguments);
211
- },
212
- darken: function darken() {
213
- return this._applyModification(_darken, arguments);
214
- },
215
- desaturate: function desaturate() {
216
- return this._applyModification(_desaturate, arguments);
217
- },
218
- saturate: function saturate() {
219
- return this._applyModification(_saturate, arguments);
220
- },
221
- greyscale: function greyscale() {
222
- return this._applyModification(_greyscale, arguments);
223
- },
224
- spin: function spin() {
225
- return this._applyModification(_spin, arguments);
226
- },
227
- _applyCombination: function _applyCombination(fn, args) {
228
- return fn.apply(null, [this].concat([].slice.call(args)));
229
- },
230
- analogous: function analogous() {
231
- return this._applyCombination(_analogous, arguments);
232
- },
233
- complement: function complement() {
234
- return this._applyCombination(_complement, arguments);
235
- },
236
- monochromatic: function monochromatic() {
237
- return this._applyCombination(_monochromatic, arguments);
238
- },
239
- splitcomplement: function splitcomplement() {
240
- return this._applyCombination(_splitcomplement, arguments);
241
- },
242
- // Disabled until https://github.com/bgrins/TinyColor/issues/254
243
- // polyad: function (number) {
244
- // return this._applyCombination(polyad, [number]);
245
- // },
246
- triad: function triad() {
247
- return this._applyCombination(polyad, [3]);
248
- },
249
- tetrad: function tetrad() {
250
- return this._applyCombination(polyad, [4]);
251
- }
252
- };
253
- tinycolor.fromRatio = function(color, opts) {
254
- if (_typeof(color) == "object") {
255
- var newColor = {};
256
- for (var i in color) {
257
- if (color.hasOwnProperty(i)) {
258
- if (i === "a") {
259
- newColor[i] = color[i];
260
- } else {
261
- newColor[i] = convertToPercentage(color[i]);
262
- }
263
- }
264
- }
265
- color = newColor;
266
- }
267
- return tinycolor(color, opts);
268
- };
269
- function inputToRGB(color) {
270
- var rgb = {
271
- r: 0,
272
- g: 0,
273
- b: 0
274
- };
275
- var a = 1;
276
- var s = null;
277
- var v = null;
278
- var l = null;
279
- var ok = false;
280
- var format = false;
281
- if (typeof color == "string") {
282
- color = stringInputToObject(color);
283
- }
284
- if (_typeof(color) == "object") {
285
- if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
286
- rgb = rgbToRgb(color.r, color.g, color.b);
287
- ok = true;
288
- format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
289
- } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
290
- s = convertToPercentage(color.s);
291
- v = convertToPercentage(color.v);
292
- rgb = hsvToRgb(color.h, s, v);
293
- ok = true;
294
- format = "hsv";
295
- } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
296
- s = convertToPercentage(color.s);
297
- l = convertToPercentage(color.l);
298
- rgb = hslToRgb(color.h, s, l);
299
- ok = true;
300
- format = "hsl";
301
- }
302
- if (color.hasOwnProperty("a")) {
303
- a = color.a;
304
- }
305
- }
306
- a = boundAlpha(a);
307
- return {
308
- ok,
309
- format: color.format || format,
310
- r: Math.min(255, Math.max(rgb.r, 0)),
311
- g: Math.min(255, Math.max(rgb.g, 0)),
312
- b: Math.min(255, Math.max(rgb.b, 0)),
313
- a
314
- };
315
- }
316
- function rgbToRgb(r, g, b) {
317
- return {
318
- r: bound01(r, 255) * 255,
319
- g: bound01(g, 255) * 255,
320
- b: bound01(b, 255) * 255
321
- };
322
- }
323
- function rgbToHsl(r, g, b) {
324
- r = bound01(r, 255);
325
- g = bound01(g, 255);
326
- b = bound01(b, 255);
327
- var max = Math.max(r, g, b), min = Math.min(r, g, b);
328
- var h, s, l = (max + min) / 2;
329
- if (max == min) {
330
- h = s = 0;
331
- } else {
332
- var d = max - min;
333
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
334
- switch (max) {
335
- case r:
336
- h = (g - b) / d + (g < b ? 6 : 0);
337
- break;
338
- case g:
339
- h = (b - r) / d + 2;
340
- break;
341
- case b:
342
- h = (r - g) / d + 4;
343
- break;
344
- }
345
- h /= 6;
346
- }
347
- return {
348
- h,
349
- s,
350
- l
351
- };
352
- }
353
- function hslToRgb(h, s, l) {
354
- var r, g, b;
355
- h = bound01(h, 360);
356
- s = bound01(s, 100);
357
- l = bound01(l, 100);
358
- function hue2rgb(p2, q2, t) {
359
- if (t < 0) t += 1;
360
- if (t > 1) t -= 1;
361
- if (t < 1 / 6) return p2 + (q2 - p2) * 6 * t;
362
- if (t < 1 / 2) return q2;
363
- if (t < 2 / 3) return p2 + (q2 - p2) * (2 / 3 - t) * 6;
364
- return p2;
365
- }
366
- if (s === 0) {
367
- r = g = b = l;
368
- } else {
369
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
370
- var p = 2 * l - q;
371
- r = hue2rgb(p, q, h + 1 / 3);
372
- g = hue2rgb(p, q, h);
373
- b = hue2rgb(p, q, h - 1 / 3);
374
- }
375
- return {
376
- r: r * 255,
377
- g: g * 255,
378
- b: b * 255
379
- };
380
- }
381
- function rgbToHsv(r, g, b) {
382
- r = bound01(r, 255);
383
- g = bound01(g, 255);
384
- b = bound01(b, 255);
385
- var max = Math.max(r, g, b), min = Math.min(r, g, b);
386
- var h, s, v = max;
387
- var d = max - min;
388
- s = max === 0 ? 0 : d / max;
389
- if (max == min) {
390
- h = 0;
391
- } else {
392
- switch (max) {
393
- case r:
394
- h = (g - b) / d + (g < b ? 6 : 0);
395
- break;
396
- case g:
397
- h = (b - r) / d + 2;
398
- break;
399
- case b:
400
- h = (r - g) / d + 4;
401
- break;
402
- }
403
- h /= 6;
404
- }
405
- return {
406
- h,
407
- s,
408
- v
409
- };
410
- }
411
- function hsvToRgb(h, s, v) {
412
- h = bound01(h, 360) * 6;
413
- s = bound01(s, 100);
414
- v = bound01(v, 100);
415
- var i = Math.floor(h), f = h - i, p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s), mod = i % 6, r = [v, q, p, p, t, v][mod], g = [t, v, v, q, p, p][mod], b = [p, p, t, v, v, q][mod];
416
- return {
417
- r: r * 255,
418
- g: g * 255,
419
- b: b * 255
420
- };
421
- }
422
- function rgbToHex(r, g, b, allow3Char) {
423
- var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
424
- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
425
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
426
- }
427
- return hex.join("");
428
- }
429
- function rgbaToHex(r, g, b, a, allow4Char) {
430
- var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
431
- if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
432
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
433
- }
434
- return hex.join("");
435
- }
436
- function rgbaToArgbHex(r, g, b, a) {
437
- var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
438
- return hex.join("");
439
- }
440
- tinycolor.equals = function(color1, color2) {
441
- if (!color1 || !color2) return false;
442
- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
443
- };
444
- tinycolor.random = function() {
445
- return tinycolor.fromRatio({
446
- r: Math.random(),
447
- g: Math.random(),
448
- b: Math.random()
449
- });
450
- };
451
- function _desaturate(color, amount) {
452
- amount = amount === 0 ? 0 : amount || 10;
453
- var hsl = tinycolor(color).toHsl();
454
- hsl.s -= amount / 100;
455
- hsl.s = clamp01(hsl.s);
456
- return tinycolor(hsl);
457
- }
458
- function _saturate(color, amount) {
459
- amount = amount === 0 ? 0 : amount || 10;
460
- var hsl = tinycolor(color).toHsl();
461
- hsl.s += amount / 100;
462
- hsl.s = clamp01(hsl.s);
463
- return tinycolor(hsl);
464
- }
465
- function _greyscale(color) {
466
- return tinycolor(color).desaturate(100);
467
- }
468
- function _lighten(color, amount) {
469
- amount = amount === 0 ? 0 : amount || 10;
470
- var hsl = tinycolor(color).toHsl();
471
- hsl.l += amount / 100;
472
- hsl.l = clamp01(hsl.l);
473
- return tinycolor(hsl);
474
- }
475
- function _brighten(color, amount) {
476
- amount = amount === 0 ? 0 : amount || 10;
477
- var rgb = tinycolor(color).toRgb();
478
- rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
479
- rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
480
- rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
481
- return tinycolor(rgb);
482
- }
483
- function _darken(color, amount) {
484
- amount = amount === 0 ? 0 : amount || 10;
485
- var hsl = tinycolor(color).toHsl();
486
- hsl.l -= amount / 100;
487
- hsl.l = clamp01(hsl.l);
488
- return tinycolor(hsl);
489
- }
490
- function _spin(color, amount) {
491
- var hsl = tinycolor(color).toHsl();
492
- var hue = (hsl.h + amount) % 360;
493
- hsl.h = hue < 0 ? 360 + hue : hue;
494
- return tinycolor(hsl);
495
- }
496
- function _complement(color) {
497
- var hsl = tinycolor(color).toHsl();
498
- hsl.h = (hsl.h + 180) % 360;
499
- return tinycolor(hsl);
500
- }
501
- function polyad(color, number) {
502
- if (isNaN(number) || number <= 0) {
503
- throw new Error("Argument to polyad must be a positive number");
504
- }
505
- var hsl = tinycolor(color).toHsl();
506
- var result = [tinycolor(color)];
507
- var step = 360 / number;
508
- for (var i = 1; i < number; i++) {
509
- result.push(tinycolor({
510
- h: (hsl.h + i * step) % 360,
511
- s: hsl.s,
512
- l: hsl.l
513
- }));
514
- }
515
- return result;
516
- }
517
- function _splitcomplement(color) {
518
- var hsl = tinycolor(color).toHsl();
519
- var h = hsl.h;
520
- return [tinycolor(color), tinycolor({
521
- h: (h + 72) % 360,
522
- s: hsl.s,
523
- l: hsl.l
524
- }), tinycolor({
525
- h: (h + 216) % 360,
526
- s: hsl.s,
527
- l: hsl.l
528
- })];
529
- }
530
- function _analogous(color, results, slices) {
531
- results = results || 6;
532
- slices = slices || 30;
533
- var hsl = tinycolor(color).toHsl();
534
- var part = 360 / slices;
535
- var ret = [tinycolor(color)];
536
- for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
537
- hsl.h = (hsl.h + part) % 360;
538
- ret.push(tinycolor(hsl));
539
- }
540
- return ret;
541
- }
542
- function _monochromatic(color, results) {
543
- results = results || 6;
544
- var hsv = tinycolor(color).toHsv();
545
- var h = hsv.h, s = hsv.s, v = hsv.v;
546
- var ret = [];
547
- var modification = 1 / results;
548
- while (results--) {
549
- ret.push(tinycolor({
550
- h,
551
- s,
552
- v
553
- }));
554
- v = (v + modification) % 1;
555
- }
556
- return ret;
557
- }
558
- tinycolor.mix = function(color1, color2, amount) {
559
- amount = amount === 0 ? 0 : amount || 50;
560
- var rgb1 = tinycolor(color1).toRgb();
561
- var rgb2 = tinycolor(color2).toRgb();
562
- var p = amount / 100;
563
- var rgba = {
564
- r: (rgb2.r - rgb1.r) * p + rgb1.r,
565
- g: (rgb2.g - rgb1.g) * p + rgb1.g,
566
- b: (rgb2.b - rgb1.b) * p + rgb1.b,
567
- a: (rgb2.a - rgb1.a) * p + rgb1.a
568
- };
569
- return tinycolor(rgba);
570
- };
571
- tinycolor.readability = function(color1, color2) {
572
- var c1 = tinycolor(color1);
573
- var c2 = tinycolor(color2);
574
- return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
575
- };
576
- tinycolor.isReadable = function(color1, color2, wcag2) {
577
- var readability = tinycolor.readability(color1, color2);
578
- var wcag2Parms, out;
579
- out = false;
580
- wcag2Parms = validateWCAG2Parms(wcag2);
581
- switch (wcag2Parms.level + wcag2Parms.size) {
582
- case "AAsmall":
583
- case "AAAlarge":
584
- out = readability >= 4.5;
585
- break;
586
- case "AAlarge":
587
- out = readability >= 3;
588
- break;
589
- case "AAAsmall":
590
- out = readability >= 7;
591
- break;
592
- }
593
- return out;
594
- };
595
- tinycolor.mostReadable = function(baseColor, colorList, args) {
596
- var bestColor = null;
597
- var bestScore = 0;
598
- var readability;
599
- var includeFallbackColors, level, size;
600
- args = args || {};
601
- includeFallbackColors = args.includeFallbackColors;
602
- level = args.level;
603
- size = args.size;
604
- for (var i = 0; i < colorList.length; i++) {
605
- readability = tinycolor.readability(baseColor, colorList[i]);
606
- if (readability > bestScore) {
607
- bestScore = readability;
608
- bestColor = tinycolor(colorList[i]);
609
- }
610
- }
611
- if (tinycolor.isReadable(baseColor, bestColor, {
612
- level,
613
- size
614
- }) || !includeFallbackColors) {
615
- return bestColor;
616
- } else {
617
- args.includeFallbackColors = false;
618
- return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
619
- }
620
- };
621
- var names = tinycolor.names = {
622
- aliceblue: "f0f8ff",
623
- antiquewhite: "faebd7",
624
- aqua: "0ff",
625
- aquamarine: "7fffd4",
626
- azure: "f0ffff",
627
- beige: "f5f5dc",
628
- bisque: "ffe4c4",
629
- black: "000",
630
- blanchedalmond: "ffebcd",
631
- blue: "00f",
632
- blueviolet: "8a2be2",
633
- brown: "a52a2a",
634
- burlywood: "deb887",
635
- burntsienna: "ea7e5d",
636
- cadetblue: "5f9ea0",
637
- chartreuse: "7fff00",
638
- chocolate: "d2691e",
639
- coral: "ff7f50",
640
- cornflowerblue: "6495ed",
641
- cornsilk: "fff8dc",
642
- crimson: "dc143c",
643
- cyan: "0ff",
644
- darkblue: "00008b",
645
- darkcyan: "008b8b",
646
- darkgoldenrod: "b8860b",
647
- darkgray: "a9a9a9",
648
- darkgreen: "006400",
649
- darkgrey: "a9a9a9",
650
- darkkhaki: "bdb76b",
651
- darkmagenta: "8b008b",
652
- darkolivegreen: "556b2f",
653
- darkorange: "ff8c00",
654
- darkorchid: "9932cc",
655
- darkred: "8b0000",
656
- darksalmon: "e9967a",
657
- darkseagreen: "8fbc8f",
658
- darkslateblue: "483d8b",
659
- darkslategray: "2f4f4f",
660
- darkslategrey: "2f4f4f",
661
- darkturquoise: "00ced1",
662
- darkviolet: "9400d3",
663
- deeppink: "ff1493",
664
- deepskyblue: "00bfff",
665
- dimgray: "696969",
666
- dimgrey: "696969",
667
- dodgerblue: "1e90ff",
668
- firebrick: "b22222",
669
- floralwhite: "fffaf0",
670
- forestgreen: "228b22",
671
- fuchsia: "f0f",
672
- gainsboro: "dcdcdc",
673
- ghostwhite: "f8f8ff",
674
- gold: "ffd700",
675
- goldenrod: "daa520",
676
- gray: "808080",
677
- green: "008000",
678
- greenyellow: "adff2f",
679
- grey: "808080",
680
- honeydew: "f0fff0",
681
- hotpink: "ff69b4",
682
- indianred: "cd5c5c",
683
- indigo: "4b0082",
684
- ivory: "fffff0",
685
- khaki: "f0e68c",
686
- lavender: "e6e6fa",
687
- lavenderblush: "fff0f5",
688
- lawngreen: "7cfc00",
689
- lemonchiffon: "fffacd",
690
- lightblue: "add8e6",
691
- lightcoral: "f08080",
692
- lightcyan: "e0ffff",
693
- lightgoldenrodyellow: "fafad2",
694
- lightgray: "d3d3d3",
695
- lightgreen: "90ee90",
696
- lightgrey: "d3d3d3",
697
- lightpink: "ffb6c1",
698
- lightsalmon: "ffa07a",
699
- lightseagreen: "20b2aa",
700
- lightskyblue: "87cefa",
701
- lightslategray: "789",
702
- lightslategrey: "789",
703
- lightsteelblue: "b0c4de",
704
- lightyellow: "ffffe0",
705
- lime: "0f0",
706
- limegreen: "32cd32",
707
- linen: "faf0e6",
708
- magenta: "f0f",
709
- maroon: "800000",
710
- mediumaquamarine: "66cdaa",
711
- mediumblue: "0000cd",
712
- mediumorchid: "ba55d3",
713
- mediumpurple: "9370db",
714
- mediumseagreen: "3cb371",
715
- mediumslateblue: "7b68ee",
716
- mediumspringgreen: "00fa9a",
717
- mediumturquoise: "48d1cc",
718
- mediumvioletred: "c71585",
719
- midnightblue: "191970",
720
- mintcream: "f5fffa",
721
- mistyrose: "ffe4e1",
722
- moccasin: "ffe4b5",
723
- navajowhite: "ffdead",
724
- navy: "000080",
725
- oldlace: "fdf5e6",
726
- olive: "808000",
727
- olivedrab: "6b8e23",
728
- orange: "ffa500",
729
- orangered: "ff4500",
730
- orchid: "da70d6",
731
- palegoldenrod: "eee8aa",
732
- palegreen: "98fb98",
733
- paleturquoise: "afeeee",
734
- palevioletred: "db7093",
735
- papayawhip: "ffefd5",
736
- peachpuff: "ffdab9",
737
- peru: "cd853f",
738
- pink: "ffc0cb",
739
- plum: "dda0dd",
740
- powderblue: "b0e0e6",
741
- purple: "800080",
742
- rebeccapurple: "663399",
743
- red: "f00",
744
- rosybrown: "bc8f8f",
745
- royalblue: "4169e1",
746
- saddlebrown: "8b4513",
747
- salmon: "fa8072",
748
- sandybrown: "f4a460",
749
- seagreen: "2e8b57",
750
- seashell: "fff5ee",
751
- sienna: "a0522d",
752
- silver: "c0c0c0",
753
- skyblue: "87ceeb",
754
- slateblue: "6a5acd",
755
- slategray: "708090",
756
- slategrey: "708090",
757
- snow: "fffafa",
758
- springgreen: "00ff7f",
759
- steelblue: "4682b4",
760
- tan: "d2b48c",
761
- teal: "008080",
762
- thistle: "d8bfd8",
763
- tomato: "ff6347",
764
- turquoise: "40e0d0",
765
- violet: "ee82ee",
766
- wheat: "f5deb3",
767
- white: "fff",
768
- whitesmoke: "f5f5f5",
769
- yellow: "ff0",
770
- yellowgreen: "9acd32"
771
- };
772
- var hexNames = tinycolor.hexNames = flip(names);
773
- function flip(o) {
774
- var flipped = {};
775
- for (var i in o) {
776
- if (o.hasOwnProperty(i)) {
777
- flipped[o[i]] = i;
778
- }
779
- }
780
- return flipped;
781
- }
782
- function boundAlpha(a) {
783
- a = parseFloat(a);
784
- if (isNaN(a) || a < 0 || a > 1) {
785
- a = 1;
786
- }
787
- return a;
788
- }
789
- function bound01(n, max) {
790
- if (isOnePointZero(n)) n = "100%";
791
- var processPercent = isPercentage(n);
792
- n = Math.min(max, Math.max(0, parseFloat(n)));
793
- if (processPercent) {
794
- n = parseInt(n * max, 10) / 100;
795
- }
796
- if (Math.abs(n - max) < 1e-6) {
797
- return 1;
798
- }
799
- return n % max / parseFloat(max);
800
- }
801
- function clamp01(val) {
802
- return Math.min(1, Math.max(0, val));
803
- }
804
- function parseIntFromHex(val) {
805
- return parseInt(val, 16);
806
- }
807
- function isOnePointZero(n) {
808
- return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
809
- }
810
- function isPercentage(n) {
811
- return typeof n === "string" && n.indexOf("%") != -1;
812
- }
813
- function pad2(c) {
814
- return c.length == 1 ? "0" + c : "" + c;
815
- }
816
- function convertToPercentage(n) {
817
- if (n <= 1) {
818
- n = n * 100 + "%";
819
- }
820
- return n;
821
- }
822
- function convertDecimalToHex(d) {
823
- return Math.round(parseFloat(d) * 255).toString(16);
824
- }
825
- function convertHexToDecimal(h) {
826
- return parseIntFromHex(h) / 255;
827
- }
828
- var matchers = function() {
829
- var CSS_INTEGER = "[-\\+]?\\d+%?";
830
- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
831
- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
832
- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
833
- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
834
- return {
835
- CSS_UNIT: new RegExp(CSS_UNIT),
836
- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
837
- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
838
- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
839
- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
840
- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
841
- hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
842
- hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
843
- hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
844
- hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
845
- hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
846
- };
847
- }();
848
- function isValidCSSUnit(color) {
849
- return !!matchers.CSS_UNIT.exec(color);
850
- }
851
- function stringInputToObject(color) {
852
- color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
853
- var named = false;
854
- if (names[color]) {
855
- color = names[color];
856
- named = true;
857
- } else if (color == "transparent") {
858
- return {
859
- r: 0,
860
- g: 0,
861
- b: 0,
862
- a: 0,
863
- format: "name"
864
- };
865
- }
866
- var match;
867
- if (match = matchers.rgb.exec(color)) {
868
- return {
869
- r: match[1],
870
- g: match[2],
871
- b: match[3]
872
- };
873
- }
874
- if (match = matchers.rgba.exec(color)) {
875
- return {
876
- r: match[1],
877
- g: match[2],
878
- b: match[3],
879
- a: match[4]
880
- };
881
- }
882
- if (match = matchers.hsl.exec(color)) {
883
- return {
884
- h: match[1],
885
- s: match[2],
886
- l: match[3]
887
- };
888
- }
889
- if (match = matchers.hsla.exec(color)) {
890
- return {
891
- h: match[1],
892
- s: match[2],
893
- l: match[3],
894
- a: match[4]
895
- };
896
- }
897
- if (match = matchers.hsv.exec(color)) {
898
- return {
899
- h: match[1],
900
- s: match[2],
901
- v: match[3]
902
- };
903
- }
904
- if (match = matchers.hsva.exec(color)) {
905
- return {
906
- h: match[1],
907
- s: match[2],
908
- v: match[3],
909
- a: match[4]
910
- };
911
- }
912
- if (match = matchers.hex8.exec(color)) {
913
- return {
914
- r: parseIntFromHex(match[1]),
915
- g: parseIntFromHex(match[2]),
916
- b: parseIntFromHex(match[3]),
917
- a: convertHexToDecimal(match[4]),
918
- format: named ? "name" : "hex8"
919
- };
920
- }
921
- if (match = matchers.hex6.exec(color)) {
922
- return {
923
- r: parseIntFromHex(match[1]),
924
- g: parseIntFromHex(match[2]),
925
- b: parseIntFromHex(match[3]),
926
- format: named ? "name" : "hex"
927
- };
928
- }
929
- if (match = matchers.hex4.exec(color)) {
930
- return {
931
- r: parseIntFromHex(match[1] + "" + match[1]),
932
- g: parseIntFromHex(match[2] + "" + match[2]),
933
- b: parseIntFromHex(match[3] + "" + match[3]),
934
- a: convertHexToDecimal(match[4] + "" + match[4]),
935
- format: named ? "name" : "hex8"
936
- };
937
- }
938
- if (match = matchers.hex3.exec(color)) {
939
- return {
940
- r: parseIntFromHex(match[1] + "" + match[1]),
941
- g: parseIntFromHex(match[2] + "" + match[2]),
942
- b: parseIntFromHex(match[3] + "" + match[3]),
943
- format: named ? "name" : "hex"
944
- };
945
- }
946
- return false;
947
- }
948
- function validateWCAG2Parms(parms) {
949
- var level, size;
950
- parms = parms || {
951
- level: "AA",
952
- size: "small"
953
- };
954
- level = (parms.level || "AA").toUpperCase();
955
- size = (parms.size || "small").toLowerCase();
956
- if (level !== "AA" && level !== "AAA") {
957
- level = "AA";
958
- }
959
- if (size !== "small" && size !== "large") {
960
- size = "small";
961
- }
962
- return {
963
- level,
964
- size
965
- };
966
- }
967
- const useComparator = () => {
968
- const theme = useTheme();
969
- const isBaseComparator = (comparator) => {
970
- return !comparator.type;
971
- };
972
- const isNodeStyler = (comparator) => {
973
- return comparator.type === "node";
974
- };
975
- const runOperator = (value1, operator, value2) => {
976
- var _a, _b;
977
- if (!operator || !value2) {
978
- return true;
979
- }
980
- let result;
981
- switch (operator) {
982
- case "=": {
983
- result = (isNil(value1) ? "" : value1).toString() == (value2 == null ? void 0 : value2.toString());
984
- break;
985
- }
986
- case "<": {
987
- result = parseFloat(value1) < parseFloat(value2);
988
- break;
989
- }
990
- case ">": {
991
- result = parseFloat(value1) > parseFloat(value2);
992
- break;
993
- }
994
- case "!=": {
995
- result = (value1 == null ? void 0 : value1.toString()) != (value2 == null ? void 0 : value2.toString());
996
- break;
997
- }
998
- case "<=": {
999
- result = parseInt(value1) <= parseInt(value2);
1000
- break;
1001
- }
1002
- case ">=": {
1003
- result = parseInt(value1) >= parseInt(value2);
1004
- break;
1005
- }
1006
- case "~": {
1007
- const strValue1 = ((_a = value1 == null ? void 0 : value1.toString) == null ? void 0 : _a.call(value1)) ?? "";
1008
- const strValue2 = ((_b = value2.toString) == null ? void 0 : _b.call(value2)) ?? "";
1009
- result = !!strValue1 && strValue1.toLowerCase().includes(strValue2.toLowerCase());
1010
- break;
1011
- }
1012
- default: {
1013
- result = false;
1014
- }
1015
- }
1016
- return result;
1017
- };
1018
- const runBaseComparator = (comparator, node) => runOperator(get(node, comparator.field), comparator.operator, comparator.value);
1019
- const runNodeComparator = (comparator, node) => {
1020
- var _a;
1021
- const nodeValue = get(node, comparator.field);
1022
- if (!runOperator(nodeValue, comparator.operator, comparator.value)) {
1023
- return {};
1024
- }
1025
- const styles = {};
1026
- if (comparator.color) {
1027
- const color = ((_a = theme.palette[comparator.color]) == null ? void 0 : _a.main) ?? comparator.color;
1028
- styles.fill = color;
1029
- try {
1030
- styles.stroke = tinycolor(color).darken(10).toString();
1031
- } catch {
1032
- styles.stroke = color;
1033
- }
1034
- }
1035
- if (comparator.size) {
1036
- styles.strokeWidth = comparator.size;
1037
- styles.fontSize = comparator.size;
1038
- }
1039
- return styles;
1040
- };
1041
- const runEdgeComparator = (_comparator, _source, _target) => {
1042
- return {};
1043
- };
1044
- const runComparator = (comparator, nodeOrSource, target) => {
1045
- if (isBaseComparator(comparator)) {
1046
- return runBaseComparator(comparator, nodeOrSource);
1047
- }
1048
- if (isNodeStyler(comparator)) {
1049
- return runNodeComparator(comparator, nodeOrSource);
1050
- }
1051
- return runEdgeComparator();
1052
- };
1053
- const runComparators = (comparators, nodeOrSource, target) => {
1054
- return (comparators ?? []).map((comparator) => runComparator(comparator, nodeOrSource)).reduce((acc, val) => ({ ...acc, ...val }), {});
1055
- };
1056
- return { runComparators, runComparator };
1057
- };
1058
- export {
1059
- useComparator as default
1060
- };