@cccsaurora/clue-ui 0.15.0 → 1.0.0-dev.49

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/ActionForm-c5hLIfQ-.js +436 -0
  2. package/AnnotationPreview-BvNpZOP0.js +188 -0
  3. package/ClueEnrichContext-m-4vn9rz.js +518 -0
  4. package/FlexOne-BSYAhhtG.js +9 -0
  5. package/_Map-kgDsDYxq.js +64 -0
  6. package/_MapCache-DabaaWfq.js +161 -0
  7. package/_Uint8Array-BlVVH1tp.js +129 -0
  8. package/_baseAssignValue-CNbcU6Nb.js +25 -0
  9. package/_baseClone-D3a8Pa4T.js +284 -0
  10. package/_baseExtremum-B1o1zHjR.js +33 -0
  11. package/_baseFlatten-D4huXoEI.js +92 -0
  12. package/_baseGet-BSK_nnoz.js +109 -0
  13. package/_baseIsEqual-B5xLoweL.js +238 -0
  14. package/_baseIteratee-p6Nj07-n.js +126 -0
  15. package/_baseSlice-GAv_YFTT.js +20 -0
  16. package/_baseSum-D0WC1dN0.js +13 -0
  17. package/_baseUniq-CpupKWcL.js +89 -0
  18. package/_commonjsHelpers-CUmg6egw.js +6 -0
  19. package/_createAggregator-BpVy5xMi.js +63 -0
  20. package/_getPrototype-D1LAdQKO.js +5 -0
  21. package/_getTag-D3ToyefI.js +126 -0
  22. package/api/lookup/enrich.d.ts +10 -0
  23. package/api/lookup/index.d.ts +5 -0
  24. package/api/lookup/types.d.ts +5 -0
  25. package/api/lookup/types_detection.d.ts +5 -0
  26. package/cloneDeep-CjP5k9zW.js +8 -0
  27. package/components/AnnotationBody.d.ts +6 -0
  28. package/components/AnnotationBody.js +56 -0
  29. package/components/AnnotationDetailPopover.d.ts +14 -0
  30. package/components/AnnotationDetailPopover.js +61 -0
  31. package/components/AnnotationDetails.d.ts +8 -0
  32. package/components/AnnotationDetails.js +172 -0
  33. package/components/AnnotationEntry.d.ts +6 -0
  34. package/components/AnnotationEntry.js +59 -0
  35. package/components/AnnotationPreview.d.ts +14 -0
  36. package/components/AnnotationPreview.js +11 -0
  37. package/components/ClassificationChip.d.ts +11 -0
  38. package/components/ClassificationChip.js +52 -0
  39. package/components/CountBadge.d.ts +8 -0
  40. package/components/CountBadge.js +34 -0
  41. package/components/EnrichedCard.d.ts +14 -0
  42. package/components/EnrichedCard.js +162 -0
  43. package/components/EnrichedChip.d.ts +9 -0
  44. package/components/EnrichedChip.js +176 -0
  45. package/components/EnrichedTypography.d.ts +16 -0
  46. package/components/EnrichedTypography.js +178 -0
  47. package/components/ErrorBoundary.d.ts +15 -0
  48. package/components/ErrorBoundary.js +36 -0
  49. package/components/RetryFailedEnrichments.d.ts +2 -0
  50. package/components/RetryFailedEnrichments.js +13 -0
  51. package/components/SourcePicker.d.ts +2 -0
  52. package/components/SourcePicker.js +98 -0
  53. package/components/actions/ActionForm.d.ts +6 -0
  54. package/components/actions/ActionForm.js +16 -0
  55. package/components/actions/ExecutePopover.d.ts +10 -0
  56. package/components/actions/ExecutePopover.js +93 -0
  57. package/components/actions/ResultModal.d.ts +9 -0
  58. package/components/actions/ResultModal.js +46 -0
  59. package/components/actions/form/schemaAdapter.d.ts +3 -0
  60. package/components/actions/form/schemaAdapter.js +47 -0
  61. package/components/display/graph/ExpandMoreButton.d.ts +7 -0
  62. package/components/display/graph/ExpandMoreButton.js +18 -0
  63. package/components/display/graph/elements/NodeCard.d.ts +10 -0
  64. package/components/display/graph/elements/NodeCard.js +146 -0
  65. package/components/display/graph/elements/NodeTag.d.ts +9 -0
  66. package/components/display/graph/elements/NodeTag.js +17 -0
  67. package/components/display/graph/index.d.ts +9 -0
  68. package/components/display/graph/index.js +438 -0
  69. package/components/display/graph/visualizations/Leaf.d.ts +25 -0
  70. package/components/display/graph/visualizations/Leaf.js +125 -0
  71. package/components/display/graph/visualizations/cloud/index.d.ts +24 -0
  72. package/components/display/graph/visualizations/cloud/index.js +141 -0
  73. package/components/display/graph/visualizations/icons/BaseIcon.d.ts +12 -0
  74. package/components/display/graph/visualizations/icons/BaseIcon.js +37 -0
  75. package/components/display/graph/visualizations/icons/BugIcon.d.ts +5 -0
  76. package/components/display/graph/visualizations/icons/BugIcon.js +18 -0
  77. package/components/display/graph/visualizations/icons/HostIcon.d.ts +5 -0
  78. package/components/display/graph/visualizations/icons/HostIcon.js +24 -0
  79. package/components/display/graph/visualizations/icons/NetworkIcon.d.ts +5 -0
  80. package/components/display/graph/visualizations/icons/NetworkIcon.js +24 -0
  81. package/components/display/graph/visualizations/icons/ProcessIcon.d.ts +5 -0
  82. package/components/display/graph/visualizations/icons/ProcessIcon.js +18 -0
  83. package/components/display/graph/visualizations/icons/TargetIcon.d.ts +5 -0
  84. package/components/display/graph/visualizations/icons/TargetIcon.js +19 -0
  85. package/components/display/graph/visualizations/icons/index.d.ts +2 -0
  86. package/components/display/graph/visualizations/icons/index.js +16 -0
  87. package/components/display/graph/visualizations/panels/NodePanel.d.ts +8 -0
  88. package/components/display/graph/visualizations/panels/NodePanel.js +12 -0
  89. package/components/display/graph/visualizations/tree/BundleLine.d.ts +29 -0
  90. package/components/display/graph/visualizations/tree/BundleLine.js +121 -0
  91. package/components/display/graph/visualizations/tree/Triangle.d.ts +9 -0
  92. package/components/display/graph/visualizations/tree/Triangle.js +26 -0
  93. package/components/display/graph/visualizations/tree/index.d.ts +36 -0
  94. package/components/display/graph/visualizations/tree/index.js +485 -0
  95. package/components/display/graph/visualizations/tree/types.d.ts +11 -0
  96. package/components/display/graph/visualizations/tree/types.js +1 -0
  97. package/components/display/icons/Iconified.d.ts +9 -0
  98. package/components/display/icons/Iconified.js +29 -0
  99. package/components/display/json/index.d.ts +14 -0
  100. package/components/display/json/index.js +12 -0
  101. package/components/display/markdown/DynamicTabs.d.ts +8 -0
  102. package/components/display/markdown/DynamicTabs.js +26 -0
  103. package/components/display/markdown/index.d.ts +9 -0
  104. package/components/display/markdown/index.js +13389 -0
  105. package/components/display/markdown/markdownPlugins/tabs.d.ts +3 -0
  106. package/components/display/markdown/markdownPlugins/tabs.js +4 -0
  107. package/components/enrichment/EnrichPopover.d.ts +10 -0
  108. package/components/enrichment/EnrichPopover.js +88 -0
  109. package/components/fetchers/Fetcher.d.ts +17 -0
  110. package/components/fetchers/Fetcher.js +188 -0
  111. package/components/fetchers/PreviewModal.d.ts +8 -0
  112. package/components/fetchers/PreviewModal.js +22 -0
  113. package/components/fetchers/StatusChip.d.ts +8 -0
  114. package/components/fetchers/StatusChip.js +30 -0
  115. package/components/group/Entry.d.ts +8 -0
  116. package/components/group/Entry.js +15 -0
  117. package/components/group/Group.d.ts +12 -0
  118. package/components/group/Group.js +15 -0
  119. package/components/group/GroupControl.d.ts +4 -0
  120. package/components/group/GroupControl.js +103 -0
  121. package/components/stats/QueryStatus.d.ts +4 -0
  122. package/components/stats/QueryStatus.js +61 -0
  123. package/countBy-C69WslUA.js +14 -0
  124. package/data/event.d.ts +12 -0
  125. package/data/event.js +8 -0
  126. package/database/index.d.ts +4 -0
  127. package/database/index.js +4 -0
  128. package/database/selector.schema.json.d.ts +119 -0
  129. package/database/status.schema.json.d.ts +38 -0
  130. package/database/types.d.ts +64 -0
  131. package/debounce-bV0h5FC5.js +92 -0
  132. package/en/translation.json +135 -0
  133. package/fr/translation.json +134 -0
  134. package/get-D3C3lEU3.js +8 -0
  135. package/groupBy-DC2oOuBN.js +14 -0
  136. package/hooks/ClueActionContext.d.ts +86 -0
  137. package/hooks/ClueActionContext.js +18 -0
  138. package/hooks/ClueComponentContext.d.ts +10 -0
  139. package/hooks/ClueComponentContext.js +40 -0
  140. package/hooks/ClueConfigProvider.d.ts +12 -0
  141. package/hooks/ClueConfigProvider.js +23 -0
  142. package/hooks/ClueDatabaseContext.d.ts +10 -0
  143. package/hooks/ClueDatabaseContext.js +23 -0
  144. package/hooks/ClueEnrichContext.d.ts +6 -0
  145. package/hooks/ClueEnrichContext.js +15 -0
  146. package/hooks/ClueEnrichContextType.d.ts +113 -0
  147. package/hooks/ClueEnrichProps.d.ts +81 -0
  148. package/hooks/ClueFetcherContext.d.ts +35 -0
  149. package/hooks/ClueFetcherContext.js +88 -0
  150. package/hooks/ClueGroupContext.d.ts +14 -0
  151. package/hooks/ClueGroupContext.js +23 -0
  152. package/hooks/CluePopupContext.d.ts +24 -0
  153. package/hooks/CluePopupContext.js +12 -0
  154. package/hooks/ClueProvider.d.ts +9 -0
  155. package/hooks/ClueProvider.js +14 -0
  156. package/hooks/selectors.d.ts +10 -0
  157. package/hooks/selectors.js +24 -0
  158. package/hooks/useAnnotations.d.ts +24 -0
  159. package/hooks/useAnnotations.js +69 -0
  160. package/hooks/useClue.d.ts +4 -0
  161. package/hooks/useClue.js +8 -0
  162. package/hooks/useClueActions.d.ts +4 -0
  163. package/hooks/useClueActions.js +5 -0
  164. package/hooks/useClueConfig.d.ts +1 -0
  165. package/hooks/useClueConfig.js +8 -0
  166. package/hooks/useClueTypeConfig.d.ts +17 -0
  167. package/hooks/useClueTypeConfig.js +7 -0
  168. package/hooks/useComparator.d.ts +16 -0
  169. package/hooks/useComparator.js +1060 -0
  170. package/hooks/useErrors.d.ts +17 -0
  171. package/hooks/useErrors.js +35 -0
  172. package/hooks/useMyHighlights.d.ts +11 -0
  173. package/hooks/useMyHighlights.js +74 -0
  174. package/hooks/useMyLocalStorage.d.ts +16 -0
  175. package/hooks/useMyLocalStorage.js +80 -0
  176. package/iconify-CXMreGTg.js +1782 -0
  177. package/icons/Action.d.ts +9 -0
  178. package/icons/Action.js +90 -0
  179. package/icons/Assessment.d.ts +11 -0
  180. package/icons/Assessment.js +123 -0
  181. package/icons/Context.d.ts +12 -0
  182. package/icons/Context.js +83 -0
  183. package/icons/Opinion.d.ts +11 -0
  184. package/icons/Opinion.js +125 -0
  185. package/icons/iconMap.d.ts +7 -0
  186. package/icons/iconMap.js +10 -0
  187. package/identity-CPGTqrE4.js +6 -0
  188. package/index-BDVjGvMI.js +696 -0
  189. package/index-BDrtH5ec.js +465 -0
  190. package/index-BbPn6-Mw.js +15750 -0
  191. package/index-C9lySIVX.js +1172 -0
  192. package/index-Dn2NHyXg.js +17654 -0
  193. package/index.css +21 -0
  194. package/isEmpty-BQkZubqU.js +29 -0
  195. package/isNil-CIubwp4T.js +6 -0
  196. package/isObject-FTY-5JQX.js +7 -0
  197. package/isObjectLike-OAgjjZye.js +48 -0
  198. package/isSymbol-Xd2FsJyp.js +8 -0
  199. package/isUndefined-CE8h73dH.js +10 -0
  200. package/last-CUCl67Im.js +7 -0
  201. package/main.d.ts +42 -0
  202. package/main.js +70 -0
  203. package/package.json +39 -143
  204. package/public/manifest.json +16 -0
  205. package/public/robots.txt +3 -0
  206. package/public/svg/dark/clue-h.svg +52 -0
  207. package/public/svg/dark/clue-icon1-simple.svg +33 -0
  208. package/public/svg/dark/clue-icon1.svg +44 -0
  209. package/public/svg/dark/clue-icon2-simple.svg +26 -0
  210. package/public/svg/dark/clue-icon2.svg +37 -0
  211. package/public/svg/dark/clue-name.svg +14 -0
  212. package/public/svg/dark/clue-v.svg +52 -0
  213. package/public/svg/light/clue-h.svg +60 -0
  214. package/public/svg/light/clue-icon1-simple.svg +37 -0
  215. package/public/svg/light/clue-icon1.svg +48 -0
  216. package/public/svg/light/clue-icon2-simple.svg +30 -0
  217. package/public/svg/light/clue-icon2.svg +41 -0
  218. package/public/svg/light/clue-name.svg +14 -0
  219. package/public/svg/light/clue-v.svg +60 -0
  220. package/sortBy-B-UKp4GT.js +100 -0
  221. package/sumBy-MYkDPHZL.js +8 -0
  222. package/tabs-xGuUGsJd.js +254 -0
  223. package/text/Frequency.d.ts +9 -0
  224. package/text/Frequency.js +49 -0
  225. package/toFinite-Bc55msYj.js +16 -0
  226. package/toNumber-DPxy1FBy.js +39 -0
  227. package/types/EnrichmentProps.d.ts +73 -0
  228. package/types/RunningActionData.d.ts +15 -0
  229. package/types/WithActionData.d.ts +9 -0
  230. package/types/action.d.ts +25 -0
  231. package/types/config.d.ts +16 -0
  232. package/types/fetcher.d.ts +60 -0
  233. package/types/graph.d.ts +101 -0
  234. package/types/lookup.d.ts +62 -0
  235. package/types/network.d.ts +9 -0
  236. package/useClueTypeConfig-D4zcy8Gr.js +3184 -0
  237. package/utils/chain.d.ts +14 -0
  238. package/utils/chain.js +106 -0
  239. package/utils/classificationParser.d.ts +195 -0
  240. package/utils/classificationParser.js +553 -0
  241. package/utils/constants.d.ts +27 -0
  242. package/utils/constants.js +37 -0
  243. package/utils/graph.d.ts +13 -0
  244. package/utils/graph.js +79 -0
  245. package/utils/hashUtil.d.ts +6 -0
  246. package/utils/hashUtil.js +11 -0
  247. package/utils/line.d.ts +28 -0
  248. package/utils/line.js +136 -0
  249. package/utils/loggerUtil.d.ts +6 -0
  250. package/utils/loggerUtil.js +8 -0
  251. package/utils/sessionStorage.d.ts +9 -0
  252. package/utils/sessionStorage.js +51 -0
  253. package/utils/utils.d.ts +13 -0
  254. package/utils/utils.js +11 -0
  255. package/utils/window.d.ts +3 -0
  256. package/utils/window.js +24 -0
  257. package/utils-CxIhC2xH.js +4182 -0
@@ -0,0 +1,1060 @@
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
+ };