@cccsaurora/clue-ui 1.2.3 → 1.2.4-dev.278

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 (188) hide show
  1. package/ActionForm-BdW0Za1y.js +5956 -0
  2. package/AnnotationDetails-BHZFzyt-.js +175 -0
  3. package/AnnotationPreview-DGoyoxRb.js +188 -0
  4. package/ClueEnrichContext-CJEJxrgs.js +541 -0
  5. package/FlexOne-BSYAhhtG.js +9 -0
  6. package/_MapCache-WmuDdwuH.js +222 -0
  7. package/_Uint8Array-B7JqpgFX.js +128 -0
  8. package/_baseAssignValue-CGTuELqU.js +25 -0
  9. package/_baseClone-CkNrTyhm.js +283 -0
  10. package/_baseExtremum-kob8QXyt.js +18 -0
  11. package/_baseFlatten-jIR_sN_-.js +92 -0
  12. package/_baseGet-Bx3A4Qfp.js +108 -0
  13. package/_baseIsEqual-C5OTWzTk.js +208 -0
  14. package/_baseIteratee-avi7MX2o.js +126 -0
  15. package/_baseSlice-GAv_YFTT.js +20 -0
  16. package/_baseSum-D0WC1dN0.js +13 -0
  17. package/_baseUniq-BI9GIHMF.js +115 -0
  18. package/_commonjsHelpers-DWwsNxpa.js +8 -0
  19. package/_createAggregator-QD8MzKwe.js +63 -0
  20. package/_getPrototype-CU0j_POw.js +5 -0
  21. package/_getTag-Ckxxfr88.js +126 -0
  22. package/_isIterateeCall-Ds3sw2SF.js +17 -0
  23. package/_setToArray-CaPKQhcz.js +33 -0
  24. package/cloneDeep-DJrLSw8W.js +8 -0
  25. package/components/AnnotationBody.js +49 -35
  26. package/components/AnnotationDetailPopover.js +36 -30
  27. package/components/AnnotationDetails.js +7 -7
  28. package/components/AnnotationEntry.js +35 -35
  29. package/components/AnnotationPreview.js +5 -5
  30. package/components/ClassificationChip.js +44 -23
  31. package/components/CountBadge.js +31 -26
  32. package/components/EnrichedCard.js +110 -97
  33. package/components/EnrichedChip.js +130 -105
  34. package/components/EnrichedTypography.js +133 -107
  35. package/components/ErrorBoundary.js +28 -24
  36. package/components/RetryFailedEnrichments.js +10 -9
  37. package/components/SourcePicker.js +57 -49
  38. package/components/actions/ActionForm.js +4 -4
  39. package/components/actions/ExecutePopover.js +75 -59
  40. package/components/actions/ResultModal.js +4 -4
  41. package/components/actions/form/schemaAdapter.js +39 -23
  42. package/components/actions/formats/FileResult.js +86 -59
  43. package/components/actions/formats/index.js +21 -10
  44. package/components/display/graph/ExpandMoreButton.js +10 -10
  45. package/components/display/graph/elements/NodeCard.js +111 -91
  46. package/components/display/graph/elements/NodeTag.js +15 -13
  47. package/components/display/graph/index.js +261 -202
  48. package/components/display/graph/visualizations/Leaf.js +88 -69
  49. package/components/display/graph/visualizations/cloud/index.js +98 -81
  50. package/components/display/graph/visualizations/icons/BaseIcon.js +26 -21
  51. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  52. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  53. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  54. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  55. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  56. package/components/display/graph/visualizations/icons/index.js +14 -13
  57. package/components/display/graph/visualizations/panels/NodePanel.js +10 -8
  58. package/components/display/graph/visualizations/tree/BundleLine.js +108 -81
  59. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  60. package/components/display/graph/visualizations/tree/index.js +408 -306
  61. package/components/display/icons/Iconified.js +27 -12
  62. package/components/display/json/index.js +4 -4
  63. package/components/display/markdown/index.js +8678 -5770
  64. package/components/enrichment/EnrichPopover.js +54 -46
  65. package/components/fetchers/Fetcher.js +158 -119
  66. package/components/fetchers/PreviewModal.js +20 -17
  67. package/components/fetchers/StatusChip.js +21 -17
  68. package/components/group/Entry.js +13 -11
  69. package/components/group/Group.js +13 -10
  70. package/components/group/GroupControl.js +76 -65
  71. package/components/stats/QueryStatus.js +43 -33
  72. package/countBy-c6S3dvSW.js +14 -0
  73. package/data/event.js +6 -4
  74. package/database/index.js +2 -2
  75. package/debounce-bV0h5FC5.js +92 -0
  76. package/en/translation.json +1 -1
  77. package/fr/translation.json +1 -1
  78. package/get-DSsNkRQs.js +8 -0
  79. package/groupBy-xqz-n0Vd.js +14 -0
  80. package/hooks/ClueActionContext.js +6 -6
  81. package/hooks/ClueComponentContext.js +29 -23
  82. package/hooks/ClueConfigProvider.js +14 -12
  83. package/hooks/ClueDatabaseContext.js +19 -13
  84. package/hooks/ClueEnrichContext.js +8 -8
  85. package/hooks/ClueFetcherContext.js +83 -56
  86. package/hooks/ClueGroupContext.js +17 -14
  87. package/hooks/CluePopupContext.js +5 -5
  88. package/hooks/ClueProvider.js +12 -10
  89. package/hooks/selectors.js +7 -7
  90. package/hooks/useActionResult.d.ts +1 -0
  91. package/hooks/useActionResult.js +4 -2
  92. package/hooks/useAnnotations.js +47 -31
  93. package/hooks/useClue.js +6 -4
  94. package/hooks/useClueActions.js +3 -3
  95. package/hooks/useClueConfig.js +6 -4
  96. package/hooks/useClueTypeConfig.js +3 -3
  97. package/hooks/useComparator.js +722 -435
  98. package/hooks/useErrors.js +22 -18
  99. package/hooks/useFetcherResult.d.ts +1 -0
  100. package/hooks/useFetcherResult.js +33 -24
  101. package/hooks/useMyHighlights.js +66 -36
  102. package/hooks/useMyLocalStorage.js +66 -37
  103. package/iconify-CXMreGTg.js +1782 -0
  104. package/icons/Action.js +66 -49
  105. package/icons/Assessment.js +85 -69
  106. package/icons/Context.js +77 -63
  107. package/icons/Opinion.js +76 -60
  108. package/icons/iconMap.js +2 -2
  109. package/identity-CPGTqrE4.js +6 -0
  110. package/index-AMfoEg_6.js +696 -0
  111. package/index-B6C2a_Lg.js +1172 -0
  112. package/index-C12gPw2W.js +17698 -0
  113. package/index-DCKkHTvx.js +15750 -0
  114. package/index-JcKyZeoY.js +465 -0
  115. package/isNil-CIubwp4T.js +6 -0
  116. package/isObject-FTY-5JQX.js +7 -0
  117. package/isObjectLike-OAgjjZye.js +48 -0
  118. package/isSymbol-Xd2FsJyp.js +8 -0
  119. package/last-CUCl67Im.js +7 -0
  120. package/main.js +60 -60
  121. package/maxBy-IKHzFrCS.js +8 -0
  122. package/package.json +1 -1
  123. package/sortBy-DfSj8IoJ.js +96 -0
  124. package/sumBy-D-hb_NY-.js +8 -0
  125. package/text/Frequency.js +42 -23
  126. package/toFinite-Bc55msYj.js +16 -0
  127. package/toNumber-DPxy1FBy.js +39 -0
  128. package/types/WithActionData.d.ts +2 -1
  129. package/useClueTypeConfig-Z1LFp01b.js +3289 -0
  130. package/utils/chain.js +92 -65
  131. package/utils/classificationParser.js +519 -256
  132. package/utils/constants.js +35 -10
  133. package/utils/graph.js +72 -45
  134. package/utils/hashUtil.js +7 -7
  135. package/utils/line.js +131 -81
  136. package/utils/loggerUtil.js +5 -3
  137. package/utils/sessionStorage.js +41 -27
  138. package/utils/time.js +423 -423
  139. package/utils/utils.js +9 -9
  140. package/utils/window.js +21 -10
  141. package/utils-HmNPuoDB.js +199 -0
  142. package/ActionForm-DlOXqMUx.js +0 -4460
  143. package/AnnotationDetails-Bk-p0F6h.js +0 -160
  144. package/AnnotationPreview-jzZvkCxJ.js +0 -140
  145. package/ClueEnrichContext-KqRuuWNS.js +0 -418
  146. package/FlexOne-BXWFOd1T.js +0 -6
  147. package/_MapCache-BiTi0iqu.js +0 -180
  148. package/_Uint8Array-BQNOM9Rr.js +0 -101
  149. package/_baseAssignValue-CNMLQZco.js +0 -20
  150. package/_baseClone-BnT-6pyM.js +0 -207
  151. package/_baseExtremum-Ca2EHgy2.js +0 -16
  152. package/_baseFlatten-Bfr_Molw.js +0 -72
  153. package/_baseGet-DSZygzyq.js +0 -79
  154. package/_baseIsEqual-VgvaAFZG.js +0 -147
  155. package/_baseIteratee-Dbfsw5z8.js +0 -95
  156. package/_baseSlice-M5RKzt1A.js +0 -10
  157. package/_baseSum-wEbgNeUs.js +0 -10
  158. package/_baseUniq-BJcj69PL.js +0 -79
  159. package/_commonjsHelpers-DaMA6jEr.js +0 -8
  160. package/_createAggregator-k3TuAnxT.js +0 -53
  161. package/_getPrototype-Cr1Mk7BC.js +0 -5
  162. package/_getTag-CK2Sffaq.js +0 -90
  163. package/_isIterateeCall-DkJP7Rbx.js +0 -13
  164. package/_setToArray-C7yMOeww.js +0 -29
  165. package/cloneDeep-CF8TtLHr.js +0 -8
  166. package/countBy-CdYegFSu.js +0 -8
  167. package/debounce-DryYcbJ4.js +0 -56
  168. package/get-CH7kz5Ix.js +0 -8
  169. package/groupBy-br8xmD2R.js +0 -8
  170. package/iconify-BBckr5AQ.js +0 -1263
  171. package/identity-ByMq8VxU.js +0 -6
  172. package/index-BHAe_V9n.js +0 -12768
  173. package/index-BK-zfYhR.js +0 -358
  174. package/index-CA5CUNZO.js +0 -975
  175. package/index-Dj5C04IX.js +0 -568
  176. package/index-p5_wX7q1.js +0 -11729
  177. package/isNil-CjWwlQS3.js +0 -6
  178. package/isObject-B53jY8Qg.js +0 -7
  179. package/isObjectLike-BatpeCIi.js +0 -29
  180. package/isSymbol-C3_SC0Qp.js +0 -8
  181. package/last-7CdUxN0r.js +0 -7
  182. package/maxBy-Bc0dYHcO.js +0 -8
  183. package/sortBy-DY2JBf9n.js +0 -75
  184. package/sumBy-DuMASLPd.js +0 -8
  185. package/toFinite-BMy6GObD.js +0 -14
  186. package/toNumber-YVhnnJv4.js +0 -31
  187. package/useClueTypeConfig-Ct9Ygter.js +0 -2292
  188. package/utils-DmwSUrum.js +0 -129
@@ -0,0 +1,1782 @@
1
+ import React__default from "react";
2
+ const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
3
+ const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
4
+ const colonSeparated = value.split(":");
5
+ if (value.slice(0, 1) === "@") {
6
+ if (colonSeparated.length < 2 || colonSeparated.length > 3) {
7
+ return null;
8
+ }
9
+ provider = colonSeparated.shift().slice(1);
10
+ }
11
+ if (colonSeparated.length > 3 || !colonSeparated.length) {
12
+ return null;
13
+ }
14
+ if (colonSeparated.length > 1) {
15
+ const name2 = colonSeparated.pop();
16
+ const prefix = colonSeparated.pop();
17
+ const result = {
18
+ // Allow provider without '@': "provider:prefix:name"
19
+ provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
20
+ prefix,
21
+ name: name2
22
+ };
23
+ return validate && !validateIconName(result) ? null : result;
24
+ }
25
+ const name = colonSeparated[0];
26
+ const dashSeparated = name.split("-");
27
+ if (dashSeparated.length > 1) {
28
+ const result = {
29
+ provider,
30
+ prefix: dashSeparated.shift(),
31
+ name: dashSeparated.join("-")
32
+ };
33
+ return validate && !validateIconName(result) ? null : result;
34
+ }
35
+ if (allowSimpleName && provider === "") {
36
+ const result = {
37
+ provider,
38
+ prefix: "",
39
+ name
40
+ };
41
+ return validate && !validateIconName(result, allowSimpleName) ? null : result;
42
+ }
43
+ return null;
44
+ };
45
+ const validateIconName = (icon, allowSimpleName) => {
46
+ if (!icon) {
47
+ return false;
48
+ }
49
+ return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
50
+ };
51
+ const defaultIconDimensions = Object.freeze(
52
+ {
53
+ left: 0,
54
+ top: 0,
55
+ width: 16,
56
+ height: 16
57
+ }
58
+ );
59
+ const defaultIconTransformations = Object.freeze({
60
+ rotate: 0,
61
+ vFlip: false,
62
+ hFlip: false
63
+ });
64
+ const defaultIconProps = Object.freeze({
65
+ ...defaultIconDimensions,
66
+ ...defaultIconTransformations
67
+ });
68
+ const defaultExtendedIconProps = Object.freeze({
69
+ ...defaultIconProps,
70
+ body: "",
71
+ hidden: false
72
+ });
73
+ function mergeIconTransformations(obj1, obj2) {
74
+ const result = {};
75
+ if (!obj1.hFlip !== !obj2.hFlip) {
76
+ result.hFlip = true;
77
+ }
78
+ if (!obj1.vFlip !== !obj2.vFlip) {
79
+ result.vFlip = true;
80
+ }
81
+ const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
82
+ if (rotate) {
83
+ result.rotate = rotate;
84
+ }
85
+ return result;
86
+ }
87
+ function mergeIconData(parent, child) {
88
+ const result = mergeIconTransformations(parent, child);
89
+ for (const key in defaultExtendedIconProps) {
90
+ if (key in defaultIconTransformations) {
91
+ if (key in parent && !(key in result)) {
92
+ result[key] = defaultIconTransformations[key];
93
+ }
94
+ } else if (key in child) {
95
+ result[key] = child[key];
96
+ } else if (key in parent) {
97
+ result[key] = parent[key];
98
+ }
99
+ }
100
+ return result;
101
+ }
102
+ function getIconsTree(data, names) {
103
+ const icons = data.icons;
104
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
105
+ const resolved = /* @__PURE__ */ Object.create(null);
106
+ function resolve(name) {
107
+ if (icons[name]) {
108
+ return resolved[name] = [];
109
+ }
110
+ if (!(name in resolved)) {
111
+ resolved[name] = null;
112
+ const parent = aliases[name] && aliases[name].parent;
113
+ const value = parent && resolve(parent);
114
+ if (value) {
115
+ resolved[name] = [parent].concat(value);
116
+ }
117
+ }
118
+ return resolved[name];
119
+ }
120
+ Object.keys(icons).concat(Object.keys(aliases)).forEach(resolve);
121
+ return resolved;
122
+ }
123
+ function internalGetIconData(data, name, tree) {
124
+ const icons = data.icons;
125
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
126
+ let currentProps = {};
127
+ function parse(name2) {
128
+ currentProps = mergeIconData(
129
+ icons[name2] || aliases[name2],
130
+ currentProps
131
+ );
132
+ }
133
+ parse(name);
134
+ tree.forEach(parse);
135
+ return mergeIconData(data, currentProps);
136
+ }
137
+ function parseIconSet(data, callback) {
138
+ const names = [];
139
+ if (typeof data !== "object" || typeof data.icons !== "object") {
140
+ return names;
141
+ }
142
+ if (data.not_found instanceof Array) {
143
+ data.not_found.forEach((name) => {
144
+ callback(name, null);
145
+ names.push(name);
146
+ });
147
+ }
148
+ const tree = getIconsTree(data);
149
+ for (const name in tree) {
150
+ const item = tree[name];
151
+ if (item) {
152
+ callback(name, internalGetIconData(data, name, item));
153
+ names.push(name);
154
+ }
155
+ }
156
+ return names;
157
+ }
158
+ const optionalPropertyDefaults = {
159
+ provider: "",
160
+ aliases: {},
161
+ not_found: {},
162
+ ...defaultIconDimensions
163
+ };
164
+ function checkOptionalProps(item, defaults) {
165
+ for (const prop in defaults) {
166
+ if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
167
+ return false;
168
+ }
169
+ }
170
+ return true;
171
+ }
172
+ function quicklyValidateIconSet(obj) {
173
+ if (typeof obj !== "object" || obj === null) {
174
+ return null;
175
+ }
176
+ const data = obj;
177
+ if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
178
+ return null;
179
+ }
180
+ if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
181
+ return null;
182
+ }
183
+ const icons = data.icons;
184
+ for (const name in icons) {
185
+ const icon = icons[name];
186
+ if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(
187
+ icon,
188
+ defaultExtendedIconProps
189
+ )) {
190
+ return null;
191
+ }
192
+ }
193
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
194
+ for (const name in aliases) {
195
+ const icon = aliases[name];
196
+ const parent = icon.parent;
197
+ if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(
198
+ icon,
199
+ defaultExtendedIconProps
200
+ )) {
201
+ return null;
202
+ }
203
+ }
204
+ return data;
205
+ }
206
+ const dataStorage = /* @__PURE__ */ Object.create(null);
207
+ function newStorage(provider, prefix) {
208
+ return {
209
+ provider,
210
+ prefix,
211
+ icons: /* @__PURE__ */ Object.create(null),
212
+ missing: /* @__PURE__ */ new Set()
213
+ };
214
+ }
215
+ function getStorage(provider, prefix) {
216
+ const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
217
+ return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
218
+ }
219
+ function addIconSet(storage2, data) {
220
+ if (!quicklyValidateIconSet(data)) {
221
+ return [];
222
+ }
223
+ return parseIconSet(data, (name, icon) => {
224
+ if (icon) {
225
+ storage2.icons[name] = icon;
226
+ } else {
227
+ storage2.missing.add(name);
228
+ }
229
+ });
230
+ }
231
+ function addIconToStorage(storage2, name, icon) {
232
+ try {
233
+ if (typeof icon.body === "string") {
234
+ storage2.icons[name] = { ...icon };
235
+ return true;
236
+ }
237
+ } catch (err) {
238
+ }
239
+ return false;
240
+ }
241
+ let simpleNames = false;
242
+ function allowSimpleNames(allow) {
243
+ if (typeof allow === "boolean") {
244
+ simpleNames = allow;
245
+ }
246
+ return simpleNames;
247
+ }
248
+ function getIconData(name) {
249
+ const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
250
+ if (icon) {
251
+ const storage2 = getStorage(icon.provider, icon.prefix);
252
+ const iconName = icon.name;
253
+ return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
254
+ }
255
+ }
256
+ function addIcon(name, data) {
257
+ const icon = stringToIcon(name, true, simpleNames);
258
+ if (!icon) {
259
+ return false;
260
+ }
261
+ const storage2 = getStorage(icon.provider, icon.prefix);
262
+ return addIconToStorage(storage2, icon.name, data);
263
+ }
264
+ function addCollection(data, provider) {
265
+ if (typeof data !== "object") {
266
+ return false;
267
+ }
268
+ if (typeof provider !== "string") {
269
+ provider = data.provider || "";
270
+ }
271
+ if (simpleNames && !provider && !data.prefix) {
272
+ let added = false;
273
+ if (quicklyValidateIconSet(data)) {
274
+ data.prefix = "";
275
+ parseIconSet(data, (name, icon) => {
276
+ if (icon && addIcon(name, icon)) {
277
+ added = true;
278
+ }
279
+ });
280
+ }
281
+ return added;
282
+ }
283
+ const prefix = data.prefix;
284
+ if (!validateIconName({
285
+ provider,
286
+ prefix,
287
+ name: "a"
288
+ })) {
289
+ return false;
290
+ }
291
+ const storage2 = getStorage(provider, prefix);
292
+ return !!addIconSet(storage2, data);
293
+ }
294
+ const defaultIconSizeCustomisations = Object.freeze({
295
+ width: null,
296
+ height: null
297
+ });
298
+ const defaultIconCustomisations = Object.freeze({
299
+ // Dimensions
300
+ ...defaultIconSizeCustomisations,
301
+ // Transformations
302
+ ...defaultIconTransformations
303
+ });
304
+ const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
305
+ const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
306
+ function calculateSize(size, ratio, precision) {
307
+ if (ratio === 1) {
308
+ return size;
309
+ }
310
+ precision = precision || 100;
311
+ if (typeof size === "number") {
312
+ return Math.ceil(size * ratio * precision) / precision;
313
+ }
314
+ if (typeof size !== "string") {
315
+ return size;
316
+ }
317
+ const oldParts = size.split(unitsSplit);
318
+ if (oldParts === null || !oldParts.length) {
319
+ return size;
320
+ }
321
+ const newParts = [];
322
+ let code = oldParts.shift();
323
+ let isNumber = unitsTest.test(code);
324
+ while (true) {
325
+ if (isNumber) {
326
+ const num = parseFloat(code);
327
+ if (isNaN(num)) {
328
+ newParts.push(code);
329
+ } else {
330
+ newParts.push(Math.ceil(num * ratio * precision) / precision);
331
+ }
332
+ } else {
333
+ newParts.push(code);
334
+ }
335
+ code = oldParts.shift();
336
+ if (code === void 0) {
337
+ return newParts.join("");
338
+ }
339
+ isNumber = !isNumber;
340
+ }
341
+ }
342
+ const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
343
+ function iconToSVG(icon, customisations) {
344
+ const fullIcon = {
345
+ ...defaultIconProps,
346
+ ...icon
347
+ };
348
+ const fullCustomisations = {
349
+ ...defaultIconCustomisations,
350
+ ...customisations
351
+ };
352
+ const box = {
353
+ left: fullIcon.left,
354
+ top: fullIcon.top,
355
+ width: fullIcon.width,
356
+ height: fullIcon.height
357
+ };
358
+ let body = fullIcon.body;
359
+ [fullIcon, fullCustomisations].forEach((props) => {
360
+ const transformations = [];
361
+ const hFlip = props.hFlip;
362
+ const vFlip = props.vFlip;
363
+ let rotation = props.rotate;
364
+ if (hFlip) {
365
+ if (vFlip) {
366
+ rotation += 2;
367
+ } else {
368
+ transformations.push(
369
+ "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
370
+ );
371
+ transformations.push("scale(-1 1)");
372
+ box.top = box.left = 0;
373
+ }
374
+ } else if (vFlip) {
375
+ transformations.push(
376
+ "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
377
+ );
378
+ transformations.push("scale(1 -1)");
379
+ box.top = box.left = 0;
380
+ }
381
+ let tempValue;
382
+ if (rotation < 0) {
383
+ rotation -= Math.floor(rotation / 4) * 4;
384
+ }
385
+ rotation = rotation % 4;
386
+ switch (rotation) {
387
+ case 1:
388
+ tempValue = box.height / 2 + box.top;
389
+ transformations.unshift(
390
+ "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
391
+ );
392
+ break;
393
+ case 2:
394
+ transformations.unshift(
395
+ "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
396
+ );
397
+ break;
398
+ case 3:
399
+ tempValue = box.width / 2 + box.left;
400
+ transformations.unshift(
401
+ "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
402
+ );
403
+ break;
404
+ }
405
+ if (rotation % 2 === 1) {
406
+ if (box.left !== box.top) {
407
+ tempValue = box.left;
408
+ box.left = box.top;
409
+ box.top = tempValue;
410
+ }
411
+ if (box.width !== box.height) {
412
+ tempValue = box.width;
413
+ box.width = box.height;
414
+ box.height = tempValue;
415
+ }
416
+ }
417
+ if (transformations.length) {
418
+ body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
419
+ }
420
+ });
421
+ const customisationsWidth = fullCustomisations.width;
422
+ const customisationsHeight = fullCustomisations.height;
423
+ const boxWidth = box.width;
424
+ const boxHeight = box.height;
425
+ let width;
426
+ let height;
427
+ if (customisationsWidth === null) {
428
+ height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
429
+ width = calculateSize(height, boxWidth / boxHeight);
430
+ } else {
431
+ width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
432
+ height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
433
+ }
434
+ const attributes = {};
435
+ const setAttr = (prop, value) => {
436
+ if (!isUnsetKeyword(value)) {
437
+ attributes[prop] = value.toString();
438
+ }
439
+ };
440
+ setAttr("width", width);
441
+ setAttr("height", height);
442
+ attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
443
+ return {
444
+ attributes,
445
+ body
446
+ };
447
+ }
448
+ const regex = /\sid="(\S+)"/g;
449
+ const randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
450
+ let counter = 0;
451
+ function replaceIDs(body, prefix = randomPrefix) {
452
+ const ids = [];
453
+ let match;
454
+ while (match = regex.exec(body)) {
455
+ ids.push(match[1]);
456
+ }
457
+ if (!ids.length) {
458
+ return body;
459
+ }
460
+ const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
461
+ ids.forEach((id) => {
462
+ const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
463
+ const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
464
+ body = body.replace(
465
+ // Allowed characters before id: [#;"]
466
+ // Allowed characters after id: [)"], .[a-z]
467
+ new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"),
468
+ "$1" + newID + suffix + "$3"
469
+ );
470
+ });
471
+ body = body.replace(new RegExp(suffix, "g"), "");
472
+ return body;
473
+ }
474
+ const storage = /* @__PURE__ */ Object.create(null);
475
+ function setAPIModule(provider, item) {
476
+ storage[provider] = item;
477
+ }
478
+ function getAPIModule(provider) {
479
+ return storage[provider] || storage[""];
480
+ }
481
+ function createAPIConfig(source) {
482
+ let resources;
483
+ if (typeof source.resources === "string") {
484
+ resources = [source.resources];
485
+ } else {
486
+ resources = source.resources;
487
+ if (!(resources instanceof Array) || !resources.length) {
488
+ return null;
489
+ }
490
+ }
491
+ const result = {
492
+ // API hosts
493
+ resources,
494
+ // Root path
495
+ path: source.path || "/",
496
+ // URL length limit
497
+ maxURL: source.maxURL || 500,
498
+ // Timeout before next host is used.
499
+ rotate: source.rotate || 750,
500
+ // Timeout before failing query.
501
+ timeout: source.timeout || 5e3,
502
+ // Randomise default API end point.
503
+ random: source.random === true,
504
+ // Start index
505
+ index: source.index || 0,
506
+ // Receive data after time out (used if time out kicks in first, then API module sends data anyway).
507
+ dataAfterTimeout: source.dataAfterTimeout !== false
508
+ };
509
+ return result;
510
+ }
511
+ const configStorage = /* @__PURE__ */ Object.create(null);
512
+ const fallBackAPISources = [
513
+ "https://api.simplesvg.com",
514
+ "https://api.unisvg.com"
515
+ ];
516
+ const fallBackAPI = [];
517
+ while (fallBackAPISources.length > 0) {
518
+ if (fallBackAPISources.length === 1) {
519
+ fallBackAPI.push(fallBackAPISources.shift());
520
+ } else {
521
+ if (Math.random() > 0.5) {
522
+ fallBackAPI.push(fallBackAPISources.shift());
523
+ } else {
524
+ fallBackAPI.push(fallBackAPISources.pop());
525
+ }
526
+ }
527
+ }
528
+ configStorage[""] = createAPIConfig({
529
+ resources: ["https://api.iconify.design"].concat(fallBackAPI)
530
+ });
531
+ function addAPIProvider(provider, customConfig) {
532
+ const config = createAPIConfig(customConfig);
533
+ if (config === null) {
534
+ return false;
535
+ }
536
+ configStorage[provider] = config;
537
+ return true;
538
+ }
539
+ function getAPIConfig(provider) {
540
+ return configStorage[provider];
541
+ }
542
+ const detectFetch = () => {
543
+ let callback;
544
+ try {
545
+ callback = fetch;
546
+ if (typeof callback === "function") {
547
+ return callback;
548
+ }
549
+ } catch (err) {
550
+ }
551
+ };
552
+ let fetchModule = detectFetch();
553
+ function calculateMaxLength(provider, prefix) {
554
+ const config = getAPIConfig(provider);
555
+ if (!config) {
556
+ return 0;
557
+ }
558
+ let result;
559
+ if (!config.maxURL) {
560
+ result = 0;
561
+ } else {
562
+ let maxHostLength = 0;
563
+ config.resources.forEach((item) => {
564
+ const host = item;
565
+ maxHostLength = Math.max(maxHostLength, host.length);
566
+ });
567
+ const url = prefix + ".json?icons=";
568
+ result = config.maxURL - maxHostLength - config.path.length - url.length;
569
+ }
570
+ return result;
571
+ }
572
+ function shouldAbort(status) {
573
+ return status === 404;
574
+ }
575
+ const prepare = (provider, prefix, icons) => {
576
+ const results = [];
577
+ const maxLength = calculateMaxLength(provider, prefix);
578
+ const type = "icons";
579
+ let item = {
580
+ type,
581
+ provider,
582
+ prefix,
583
+ icons: []
584
+ };
585
+ let length = 0;
586
+ icons.forEach((name, index) => {
587
+ length += name.length + 1;
588
+ if (length >= maxLength && index > 0) {
589
+ results.push(item);
590
+ item = {
591
+ type,
592
+ provider,
593
+ prefix,
594
+ icons: []
595
+ };
596
+ length = name.length;
597
+ }
598
+ item.icons.push(name);
599
+ });
600
+ results.push(item);
601
+ return results;
602
+ };
603
+ function getPath(provider) {
604
+ if (typeof provider === "string") {
605
+ const config = getAPIConfig(provider);
606
+ if (config) {
607
+ return config.path;
608
+ }
609
+ }
610
+ return "/";
611
+ }
612
+ const send = (host, params, callback) => {
613
+ if (!fetchModule) {
614
+ callback("abort", 424);
615
+ return;
616
+ }
617
+ let path = getPath(params.provider);
618
+ switch (params.type) {
619
+ case "icons": {
620
+ const prefix = params.prefix;
621
+ const icons = params.icons;
622
+ const iconsList = icons.join(",");
623
+ const urlParams = new URLSearchParams({
624
+ icons: iconsList
625
+ });
626
+ path += prefix + ".json?" + urlParams.toString();
627
+ break;
628
+ }
629
+ case "custom": {
630
+ const uri = params.uri;
631
+ path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
632
+ break;
633
+ }
634
+ default:
635
+ callback("abort", 400);
636
+ return;
637
+ }
638
+ let defaultError = 503;
639
+ fetchModule(host + path).then((response) => {
640
+ const status = response.status;
641
+ if (status !== 200) {
642
+ setTimeout(() => {
643
+ callback(shouldAbort(status) ? "abort" : "next", status);
644
+ });
645
+ return;
646
+ }
647
+ defaultError = 501;
648
+ return response.json();
649
+ }).then((data) => {
650
+ if (typeof data !== "object" || data === null) {
651
+ setTimeout(() => {
652
+ if (data === 404) {
653
+ callback("abort", data);
654
+ } else {
655
+ callback("next", defaultError);
656
+ }
657
+ });
658
+ return;
659
+ }
660
+ setTimeout(() => {
661
+ callback("success", data);
662
+ });
663
+ }).catch(() => {
664
+ callback("next", defaultError);
665
+ });
666
+ };
667
+ const fetchAPIModule = {
668
+ prepare,
669
+ send
670
+ };
671
+ function sortIcons(icons) {
672
+ const result = {
673
+ loaded: [],
674
+ missing: [],
675
+ pending: []
676
+ };
677
+ const storage2 = /* @__PURE__ */ Object.create(null);
678
+ icons.sort((a, b) => {
679
+ if (a.provider !== b.provider) {
680
+ return a.provider.localeCompare(b.provider);
681
+ }
682
+ if (a.prefix !== b.prefix) {
683
+ return a.prefix.localeCompare(b.prefix);
684
+ }
685
+ return a.name.localeCompare(b.name);
686
+ });
687
+ let lastIcon = {
688
+ provider: "",
689
+ prefix: "",
690
+ name: ""
691
+ };
692
+ icons.forEach((icon) => {
693
+ if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
694
+ return;
695
+ }
696
+ lastIcon = icon;
697
+ const provider = icon.provider;
698
+ const prefix = icon.prefix;
699
+ const name = icon.name;
700
+ const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
701
+ const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
702
+ let list;
703
+ if (name in localStorage.icons) {
704
+ list = result.loaded;
705
+ } else if (prefix === "" || localStorage.missing.has(name)) {
706
+ list = result.missing;
707
+ } else {
708
+ list = result.pending;
709
+ }
710
+ const item = {
711
+ provider,
712
+ prefix,
713
+ name
714
+ };
715
+ list.push(item);
716
+ });
717
+ return result;
718
+ }
719
+ function removeCallback(storages, id) {
720
+ storages.forEach((storage2) => {
721
+ const items = storage2.loaderCallbacks;
722
+ if (items) {
723
+ storage2.loaderCallbacks = items.filter((row) => row.id !== id);
724
+ }
725
+ });
726
+ }
727
+ function updateCallbacks(storage2) {
728
+ if (!storage2.pendingCallbacksFlag) {
729
+ storage2.pendingCallbacksFlag = true;
730
+ setTimeout(() => {
731
+ storage2.pendingCallbacksFlag = false;
732
+ const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
733
+ if (!items.length) {
734
+ return;
735
+ }
736
+ let hasPending = false;
737
+ const provider = storage2.provider;
738
+ const prefix = storage2.prefix;
739
+ items.forEach((item) => {
740
+ const icons = item.icons;
741
+ const oldLength = icons.pending.length;
742
+ icons.pending = icons.pending.filter((icon) => {
743
+ if (icon.prefix !== prefix) {
744
+ return true;
745
+ }
746
+ const name = icon.name;
747
+ if (storage2.icons[name]) {
748
+ icons.loaded.push({
749
+ provider,
750
+ prefix,
751
+ name
752
+ });
753
+ } else if (storage2.missing.has(name)) {
754
+ icons.missing.push({
755
+ provider,
756
+ prefix,
757
+ name
758
+ });
759
+ } else {
760
+ hasPending = true;
761
+ return true;
762
+ }
763
+ return false;
764
+ });
765
+ if (icons.pending.length !== oldLength) {
766
+ if (!hasPending) {
767
+ removeCallback([storage2], item.id);
768
+ }
769
+ item.callback(
770
+ icons.loaded.slice(0),
771
+ icons.missing.slice(0),
772
+ icons.pending.slice(0),
773
+ item.abort
774
+ );
775
+ }
776
+ });
777
+ });
778
+ }
779
+ }
780
+ let idCounter = 0;
781
+ function storeCallback(callback, icons, pendingSources) {
782
+ const id = idCounter++;
783
+ const abort = removeCallback.bind(null, pendingSources, id);
784
+ if (!icons.pending.length) {
785
+ return abort;
786
+ }
787
+ const item = {
788
+ id,
789
+ icons,
790
+ callback,
791
+ abort
792
+ };
793
+ pendingSources.forEach((storage2) => {
794
+ (storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
795
+ });
796
+ return abort;
797
+ }
798
+ function listToIcons(list, validate = true, simpleNames2 = false) {
799
+ const result = [];
800
+ list.forEach((item) => {
801
+ const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
802
+ if (icon) {
803
+ result.push(icon);
804
+ }
805
+ });
806
+ return result;
807
+ }
808
+ var defaultConfig = {
809
+ resources: [],
810
+ index: 0,
811
+ timeout: 2e3,
812
+ rotate: 750,
813
+ random: false,
814
+ dataAfterTimeout: false
815
+ };
816
+ function sendQuery(config, payload, query, done) {
817
+ const resourcesCount = config.resources.length;
818
+ const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
819
+ let resources;
820
+ if (config.random) {
821
+ let list = config.resources.slice(0);
822
+ resources = [];
823
+ while (list.length > 1) {
824
+ const nextIndex = Math.floor(Math.random() * list.length);
825
+ resources.push(list[nextIndex]);
826
+ list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
827
+ }
828
+ resources = resources.concat(list);
829
+ } else {
830
+ resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
831
+ }
832
+ const startTime = Date.now();
833
+ let status = "pending";
834
+ let queriesSent = 0;
835
+ let lastError;
836
+ let timer = null;
837
+ let queue = [];
838
+ let doneCallbacks = [];
839
+ if (typeof done === "function") {
840
+ doneCallbacks.push(done);
841
+ }
842
+ function resetTimer() {
843
+ if (timer) {
844
+ clearTimeout(timer);
845
+ timer = null;
846
+ }
847
+ }
848
+ function abort() {
849
+ if (status === "pending") {
850
+ status = "aborted";
851
+ }
852
+ resetTimer();
853
+ queue.forEach((item) => {
854
+ if (item.status === "pending") {
855
+ item.status = "aborted";
856
+ }
857
+ });
858
+ queue = [];
859
+ }
860
+ function subscribe(callback, overwrite) {
861
+ if (overwrite) {
862
+ doneCallbacks = [];
863
+ }
864
+ if (typeof callback === "function") {
865
+ doneCallbacks.push(callback);
866
+ }
867
+ }
868
+ function getQueryStatus() {
869
+ return {
870
+ startTime,
871
+ payload,
872
+ status,
873
+ queriesSent,
874
+ queriesPending: queue.length,
875
+ subscribe,
876
+ abort
877
+ };
878
+ }
879
+ function failQuery() {
880
+ status = "failed";
881
+ doneCallbacks.forEach((callback) => {
882
+ callback(void 0, lastError);
883
+ });
884
+ }
885
+ function clearQueue() {
886
+ queue.forEach((item) => {
887
+ if (item.status === "pending") {
888
+ item.status = "aborted";
889
+ }
890
+ });
891
+ queue = [];
892
+ }
893
+ function moduleResponse(item, response, data) {
894
+ const isError = response !== "success";
895
+ queue = queue.filter((queued) => queued !== item);
896
+ switch (status) {
897
+ case "pending":
898
+ break;
899
+ case "failed":
900
+ if (isError || !config.dataAfterTimeout) {
901
+ return;
902
+ }
903
+ break;
904
+ default:
905
+ return;
906
+ }
907
+ if (response === "abort") {
908
+ lastError = data;
909
+ failQuery();
910
+ return;
911
+ }
912
+ if (isError) {
913
+ lastError = data;
914
+ if (!queue.length) {
915
+ if (!resources.length) {
916
+ failQuery();
917
+ } else {
918
+ execNext();
919
+ }
920
+ }
921
+ return;
922
+ }
923
+ resetTimer();
924
+ clearQueue();
925
+ if (!config.random) {
926
+ const index = config.resources.indexOf(item.resource);
927
+ if (index !== -1 && index !== config.index) {
928
+ config.index = index;
929
+ }
930
+ }
931
+ status = "completed";
932
+ doneCallbacks.forEach((callback) => {
933
+ callback(data);
934
+ });
935
+ }
936
+ function execNext() {
937
+ if (status !== "pending") {
938
+ return;
939
+ }
940
+ resetTimer();
941
+ const resource = resources.shift();
942
+ if (resource === void 0) {
943
+ if (queue.length) {
944
+ timer = setTimeout(() => {
945
+ resetTimer();
946
+ if (status === "pending") {
947
+ clearQueue();
948
+ failQuery();
949
+ }
950
+ }, config.timeout);
951
+ return;
952
+ }
953
+ failQuery();
954
+ return;
955
+ }
956
+ const item = {
957
+ status: "pending",
958
+ resource,
959
+ callback: (status2, data) => {
960
+ moduleResponse(item, status2, data);
961
+ }
962
+ };
963
+ queue.push(item);
964
+ queriesSent++;
965
+ timer = setTimeout(execNext, config.rotate);
966
+ query(resource, payload, item.callback);
967
+ }
968
+ setTimeout(execNext);
969
+ return getQueryStatus;
970
+ }
971
+ function initRedundancy(cfg) {
972
+ const config = {
973
+ ...defaultConfig,
974
+ ...cfg
975
+ };
976
+ let queries = [];
977
+ function cleanup() {
978
+ queries = queries.filter((item) => item().status === "pending");
979
+ }
980
+ function query(payload, queryCallback, doneCallback) {
981
+ const query2 = sendQuery(
982
+ config,
983
+ payload,
984
+ queryCallback,
985
+ (data, error) => {
986
+ cleanup();
987
+ if (doneCallback) {
988
+ doneCallback(data, error);
989
+ }
990
+ }
991
+ );
992
+ queries.push(query2);
993
+ return query2;
994
+ }
995
+ function find(callback) {
996
+ return queries.find((value) => {
997
+ return callback(value);
998
+ }) || null;
999
+ }
1000
+ const instance = {
1001
+ query,
1002
+ find,
1003
+ setIndex: (index) => {
1004
+ config.index = index;
1005
+ },
1006
+ getIndex: () => config.index,
1007
+ cleanup
1008
+ };
1009
+ return instance;
1010
+ }
1011
+ function emptyCallback$1() {
1012
+ }
1013
+ const redundancyCache = /* @__PURE__ */ Object.create(null);
1014
+ function getRedundancyCache(provider) {
1015
+ if (!redundancyCache[provider]) {
1016
+ const config = getAPIConfig(provider);
1017
+ if (!config) {
1018
+ return;
1019
+ }
1020
+ const redundancy = initRedundancy(config);
1021
+ const cachedReundancy = {
1022
+ config,
1023
+ redundancy
1024
+ };
1025
+ redundancyCache[provider] = cachedReundancy;
1026
+ }
1027
+ return redundancyCache[provider];
1028
+ }
1029
+ function sendAPIQuery(target, query, callback) {
1030
+ let redundancy;
1031
+ let send2;
1032
+ if (typeof target === "string") {
1033
+ const api = getAPIModule(target);
1034
+ if (!api) {
1035
+ callback(void 0, 424);
1036
+ return emptyCallback$1;
1037
+ }
1038
+ send2 = api.send;
1039
+ const cached = getRedundancyCache(target);
1040
+ if (cached) {
1041
+ redundancy = cached.redundancy;
1042
+ }
1043
+ } else {
1044
+ const config = createAPIConfig(target);
1045
+ if (config) {
1046
+ redundancy = initRedundancy(config);
1047
+ const moduleKey = target.resources ? target.resources[0] : "";
1048
+ const api = getAPIModule(moduleKey);
1049
+ if (api) {
1050
+ send2 = api.send;
1051
+ }
1052
+ }
1053
+ }
1054
+ if (!redundancy || !send2) {
1055
+ callback(void 0, 424);
1056
+ return emptyCallback$1;
1057
+ }
1058
+ return redundancy.query(query, send2, callback)().abort;
1059
+ }
1060
+ const browserCacheVersion = "iconify2";
1061
+ const browserCachePrefix = "iconify";
1062
+ const browserCacheCountKey = browserCachePrefix + "-count";
1063
+ const browserCacheVersionKey = browserCachePrefix + "-version";
1064
+ const browserStorageHour = 36e5;
1065
+ const browserStorageCacheExpiration = 168;
1066
+ function getStoredItem(func, key) {
1067
+ try {
1068
+ return func.getItem(key);
1069
+ } catch (err) {
1070
+ }
1071
+ }
1072
+ function setStoredItem(func, key, value) {
1073
+ try {
1074
+ func.setItem(key, value);
1075
+ return true;
1076
+ } catch (err) {
1077
+ }
1078
+ }
1079
+ function removeStoredItem(func, key) {
1080
+ try {
1081
+ func.removeItem(key);
1082
+ } catch (err) {
1083
+ }
1084
+ }
1085
+ function setBrowserStorageItemsCount(storage2, value) {
1086
+ return setStoredItem(storage2, browserCacheCountKey, value.toString());
1087
+ }
1088
+ function getBrowserStorageItemsCount(storage2) {
1089
+ return parseInt(getStoredItem(storage2, browserCacheCountKey)) || 0;
1090
+ }
1091
+ const browserStorageConfig = {
1092
+ local: true,
1093
+ session: true
1094
+ };
1095
+ const browserStorageEmptyItems = {
1096
+ local: /* @__PURE__ */ new Set(),
1097
+ session: /* @__PURE__ */ new Set()
1098
+ };
1099
+ let browserStorageStatus = false;
1100
+ function setBrowserStorageStatus(status) {
1101
+ browserStorageStatus = status;
1102
+ }
1103
+ let _window = typeof window === "undefined" ? {} : window;
1104
+ function getBrowserStorage(key) {
1105
+ const attr = key + "Storage";
1106
+ try {
1107
+ if (_window && _window[attr] && typeof _window[attr].length === "number") {
1108
+ return _window[attr];
1109
+ }
1110
+ } catch (err) {
1111
+ }
1112
+ browserStorageConfig[key] = false;
1113
+ }
1114
+ function iterateBrowserStorage(key, callback) {
1115
+ const func = getBrowserStorage(key);
1116
+ if (!func) {
1117
+ return;
1118
+ }
1119
+ const version = getStoredItem(func, browserCacheVersionKey);
1120
+ if (version !== browserCacheVersion) {
1121
+ if (version) {
1122
+ const total2 = getBrowserStorageItemsCount(func);
1123
+ for (let i = 0; i < total2; i++) {
1124
+ removeStoredItem(func, browserCachePrefix + i.toString());
1125
+ }
1126
+ }
1127
+ setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
1128
+ setBrowserStorageItemsCount(func, 0);
1129
+ return;
1130
+ }
1131
+ const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
1132
+ const parseItem = (index) => {
1133
+ const name = browserCachePrefix + index.toString();
1134
+ const item = getStoredItem(func, name);
1135
+ if (typeof item !== "string") {
1136
+ return;
1137
+ }
1138
+ try {
1139
+ const data = JSON.parse(item);
1140
+ if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" && // Valid item: run callback
1141
+ callback(data, index)) {
1142
+ return true;
1143
+ }
1144
+ } catch (err) {
1145
+ }
1146
+ removeStoredItem(func, name);
1147
+ };
1148
+ let total = getBrowserStorageItemsCount(func);
1149
+ for (let i = total - 1; i >= 0; i--) {
1150
+ if (!parseItem(i)) {
1151
+ if (i === total - 1) {
1152
+ total--;
1153
+ setBrowserStorageItemsCount(func, total);
1154
+ } else {
1155
+ browserStorageEmptyItems[key].add(i);
1156
+ }
1157
+ }
1158
+ }
1159
+ }
1160
+ function initBrowserStorage() {
1161
+ if (browserStorageStatus) {
1162
+ return;
1163
+ }
1164
+ setBrowserStorageStatus(true);
1165
+ for (const key in browserStorageConfig) {
1166
+ iterateBrowserStorage(key, (item) => {
1167
+ const iconSet = item.data;
1168
+ const provider = item.provider;
1169
+ const prefix = iconSet.prefix;
1170
+ const storage2 = getStorage(
1171
+ provider,
1172
+ prefix
1173
+ );
1174
+ if (!addIconSet(storage2, iconSet).length) {
1175
+ return false;
1176
+ }
1177
+ const lastModified = iconSet.lastModified || -1;
1178
+ storage2.lastModifiedCached = storage2.lastModifiedCached ? Math.min(storage2.lastModifiedCached, lastModified) : lastModified;
1179
+ return true;
1180
+ });
1181
+ }
1182
+ }
1183
+ function updateLastModified(storage2, lastModified) {
1184
+ const lastValue = storage2.lastModifiedCached;
1185
+ if (
1186
+ // Matches or newer
1187
+ lastValue && lastValue >= lastModified
1188
+ ) {
1189
+ return lastValue === lastModified;
1190
+ }
1191
+ storage2.lastModifiedCached = lastModified;
1192
+ if (lastValue) {
1193
+ for (const key in browserStorageConfig) {
1194
+ iterateBrowserStorage(key, (item) => {
1195
+ const iconSet = item.data;
1196
+ return item.provider !== storage2.provider || iconSet.prefix !== storage2.prefix || iconSet.lastModified === lastModified;
1197
+ });
1198
+ }
1199
+ }
1200
+ return true;
1201
+ }
1202
+ function storeInBrowserStorage(storage2, data) {
1203
+ if (!browserStorageStatus) {
1204
+ initBrowserStorage();
1205
+ }
1206
+ function store(key) {
1207
+ let func;
1208
+ if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
1209
+ return;
1210
+ }
1211
+ const set = browserStorageEmptyItems[key];
1212
+ let index;
1213
+ if (set.size) {
1214
+ set.delete(index = Array.from(set).shift());
1215
+ } else {
1216
+ index = getBrowserStorageItemsCount(func);
1217
+ if (!setBrowserStorageItemsCount(func, index + 1)) {
1218
+ return;
1219
+ }
1220
+ }
1221
+ const item = {
1222
+ cached: Math.floor(Date.now() / browserStorageHour),
1223
+ provider: storage2.provider,
1224
+ data
1225
+ };
1226
+ return setStoredItem(
1227
+ func,
1228
+ browserCachePrefix + index.toString(),
1229
+ JSON.stringify(item)
1230
+ );
1231
+ }
1232
+ if (data.lastModified && !updateLastModified(storage2, data.lastModified)) {
1233
+ return;
1234
+ }
1235
+ if (!Object.keys(data.icons).length) {
1236
+ return;
1237
+ }
1238
+ if (data.not_found) {
1239
+ data = Object.assign({}, data);
1240
+ delete data.not_found;
1241
+ }
1242
+ if (!store("local")) {
1243
+ store("session");
1244
+ }
1245
+ }
1246
+ function emptyCallback() {
1247
+ }
1248
+ function loadedNewIcons(storage2) {
1249
+ if (!storage2.iconsLoaderFlag) {
1250
+ storage2.iconsLoaderFlag = true;
1251
+ setTimeout(() => {
1252
+ storage2.iconsLoaderFlag = false;
1253
+ updateCallbacks(storage2);
1254
+ });
1255
+ }
1256
+ }
1257
+ function loadNewIcons(storage2, icons) {
1258
+ if (!storage2.iconsToLoad) {
1259
+ storage2.iconsToLoad = icons;
1260
+ } else {
1261
+ storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
1262
+ }
1263
+ if (!storage2.iconsQueueFlag) {
1264
+ storage2.iconsQueueFlag = true;
1265
+ setTimeout(() => {
1266
+ storage2.iconsQueueFlag = false;
1267
+ const { provider, prefix } = storage2;
1268
+ const icons2 = storage2.iconsToLoad;
1269
+ delete storage2.iconsToLoad;
1270
+ let api;
1271
+ if (!icons2 || !(api = getAPIModule(provider))) {
1272
+ return;
1273
+ }
1274
+ const params = api.prepare(provider, prefix, icons2);
1275
+ params.forEach((item) => {
1276
+ sendAPIQuery(provider, item, (data) => {
1277
+ if (typeof data !== "object") {
1278
+ item.icons.forEach((name) => {
1279
+ storage2.missing.add(name);
1280
+ });
1281
+ } else {
1282
+ try {
1283
+ const parsed = addIconSet(
1284
+ storage2,
1285
+ data
1286
+ );
1287
+ if (!parsed.length) {
1288
+ return;
1289
+ }
1290
+ const pending = storage2.pendingIcons;
1291
+ if (pending) {
1292
+ parsed.forEach((name) => {
1293
+ pending.delete(name);
1294
+ });
1295
+ }
1296
+ storeInBrowserStorage(storage2, data);
1297
+ } catch (err) {
1298
+ console.error(err);
1299
+ }
1300
+ }
1301
+ loadedNewIcons(storage2);
1302
+ });
1303
+ });
1304
+ });
1305
+ }
1306
+ }
1307
+ const loadIcons = (icons, callback) => {
1308
+ const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
1309
+ const sortedIcons = sortIcons(cleanedIcons);
1310
+ if (!sortedIcons.pending.length) {
1311
+ let callCallback = true;
1312
+ if (callback) {
1313
+ setTimeout(() => {
1314
+ if (callCallback) {
1315
+ callback(
1316
+ sortedIcons.loaded,
1317
+ sortedIcons.missing,
1318
+ sortedIcons.pending,
1319
+ emptyCallback
1320
+ );
1321
+ }
1322
+ });
1323
+ }
1324
+ return () => {
1325
+ callCallback = false;
1326
+ };
1327
+ }
1328
+ const newIcons = /* @__PURE__ */ Object.create(null);
1329
+ const sources = [];
1330
+ let lastProvider, lastPrefix;
1331
+ sortedIcons.pending.forEach((icon) => {
1332
+ const { provider, prefix } = icon;
1333
+ if (prefix === lastPrefix && provider === lastProvider) {
1334
+ return;
1335
+ }
1336
+ lastProvider = provider;
1337
+ lastPrefix = prefix;
1338
+ sources.push(getStorage(provider, prefix));
1339
+ const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
1340
+ if (!providerNewIcons[prefix]) {
1341
+ providerNewIcons[prefix] = [];
1342
+ }
1343
+ });
1344
+ sortedIcons.pending.forEach((icon) => {
1345
+ const { provider, prefix, name } = icon;
1346
+ const storage2 = getStorage(provider, prefix);
1347
+ const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
1348
+ if (!pendingQueue.has(name)) {
1349
+ pendingQueue.add(name);
1350
+ newIcons[provider][prefix].push(name);
1351
+ }
1352
+ });
1353
+ sources.forEach((storage2) => {
1354
+ const { provider, prefix } = storage2;
1355
+ if (newIcons[provider][prefix].length) {
1356
+ loadNewIcons(storage2, newIcons[provider][prefix]);
1357
+ }
1358
+ });
1359
+ return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
1360
+ };
1361
+ function mergeCustomisations(defaults, item) {
1362
+ const result = {
1363
+ ...defaults
1364
+ };
1365
+ for (const key in item) {
1366
+ const value = item[key];
1367
+ const valueType = typeof value;
1368
+ if (key in defaultIconSizeCustomisations) {
1369
+ if (value === null || value && (valueType === "string" || valueType === "number")) {
1370
+ result[key] = value;
1371
+ }
1372
+ } else if (valueType === typeof result[key]) {
1373
+ result[key] = key === "rotate" ? value % 4 : value;
1374
+ }
1375
+ }
1376
+ return result;
1377
+ }
1378
+ const separator = /[\s,]+/;
1379
+ function flipFromString(custom, flip) {
1380
+ flip.split(separator).forEach((str) => {
1381
+ const value = str.trim();
1382
+ switch (value) {
1383
+ case "horizontal":
1384
+ custom.hFlip = true;
1385
+ break;
1386
+ case "vertical":
1387
+ custom.vFlip = true;
1388
+ break;
1389
+ }
1390
+ });
1391
+ }
1392
+ function rotateFromString(value, defaultValue = 0) {
1393
+ const units = value.replace(/^-?[0-9.]*/, "");
1394
+ function cleanup(value2) {
1395
+ while (value2 < 0) {
1396
+ value2 += 4;
1397
+ }
1398
+ return value2 % 4;
1399
+ }
1400
+ if (units === "") {
1401
+ const num = parseInt(value);
1402
+ return isNaN(num) ? 0 : cleanup(num);
1403
+ } else if (units !== value) {
1404
+ let split = 0;
1405
+ switch (units) {
1406
+ case "%":
1407
+ split = 25;
1408
+ break;
1409
+ case "deg":
1410
+ split = 90;
1411
+ }
1412
+ if (split) {
1413
+ let num = parseFloat(value.slice(0, value.length - units.length));
1414
+ if (isNaN(num)) {
1415
+ return 0;
1416
+ }
1417
+ num = num / split;
1418
+ return num % 1 === 0 ? cleanup(num) : 0;
1419
+ }
1420
+ }
1421
+ return defaultValue;
1422
+ }
1423
+ function iconToHTML(body, attributes) {
1424
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1425
+ for (const attr in attributes) {
1426
+ renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
1427
+ }
1428
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1429
+ }
1430
+ function encodeSVGforURL(svg) {
1431
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1432
+ }
1433
+ function svgToData(svg) {
1434
+ return "data:image/svg+xml," + encodeSVGforURL(svg);
1435
+ }
1436
+ function svgToURL(svg) {
1437
+ return 'url("' + svgToData(svg) + '")';
1438
+ }
1439
+ let policy;
1440
+ function createPolicy() {
1441
+ try {
1442
+ policy = window.trustedTypes.createPolicy("iconify", {
1443
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
1444
+ createHTML: (s) => s
1445
+ });
1446
+ } catch (err) {
1447
+ policy = null;
1448
+ }
1449
+ }
1450
+ function cleanUpInnerHTML(html) {
1451
+ if (policy === void 0) {
1452
+ createPolicy();
1453
+ }
1454
+ return policy ? policy.createHTML(html) : html;
1455
+ }
1456
+ const defaultExtendedIconCustomisations = {
1457
+ ...defaultIconCustomisations,
1458
+ inline: false
1459
+ };
1460
+ const svgDefaults = {
1461
+ "xmlns": "http://www.w3.org/2000/svg",
1462
+ "xmlnsXlink": "http://www.w3.org/1999/xlink",
1463
+ "aria-hidden": true,
1464
+ "role": "img"
1465
+ };
1466
+ const commonProps = {
1467
+ display: "inline-block"
1468
+ };
1469
+ const monotoneProps = {
1470
+ backgroundColor: "currentColor"
1471
+ };
1472
+ const coloredProps = {
1473
+ backgroundColor: "transparent"
1474
+ };
1475
+ const propsToAdd = {
1476
+ Image: "var(--svg)",
1477
+ Repeat: "no-repeat",
1478
+ Size: "100% 100%"
1479
+ };
1480
+ const propsToAddTo = {
1481
+ WebkitMask: monotoneProps,
1482
+ mask: monotoneProps,
1483
+ background: coloredProps
1484
+ };
1485
+ for (const prefix in propsToAddTo) {
1486
+ const list = propsToAddTo[prefix];
1487
+ for (const prop in propsToAdd) {
1488
+ list[prefix + prop] = propsToAdd[prop];
1489
+ }
1490
+ }
1491
+ const inlineDefaults = {
1492
+ ...defaultExtendedIconCustomisations,
1493
+ inline: true
1494
+ };
1495
+ function fixSize(value) {
1496
+ return value + (value.match(/^[-0-9.]+$/) ? "px" : "");
1497
+ }
1498
+ const render = (icon, props, inline, ref) => {
1499
+ const defaultProps = inline ? inlineDefaults : defaultExtendedIconCustomisations;
1500
+ const customisations = mergeCustomisations(defaultProps, props);
1501
+ const mode = props.mode || "svg";
1502
+ const style = {};
1503
+ const customStyle = props.style || {};
1504
+ const componentProps = {
1505
+ ...mode === "svg" ? svgDefaults : {},
1506
+ ref
1507
+ };
1508
+ for (let key in props) {
1509
+ const value = props[key];
1510
+ if (value === void 0) {
1511
+ continue;
1512
+ }
1513
+ switch (key) {
1514
+ case "icon":
1515
+ case "style":
1516
+ case "children":
1517
+ case "onLoad":
1518
+ case "mode":
1519
+ case "_ref":
1520
+ case "_inline":
1521
+ break;
1522
+ case "inline":
1523
+ case "hFlip":
1524
+ case "vFlip":
1525
+ customisations[key] = value === true || value === "true" || value === 1;
1526
+ break;
1527
+ case "flip":
1528
+ if (typeof value === "string") {
1529
+ flipFromString(customisations, value);
1530
+ }
1531
+ break;
1532
+ case "color":
1533
+ style.color = value;
1534
+ break;
1535
+ case "rotate":
1536
+ if (typeof value === "string") {
1537
+ customisations[key] = rotateFromString(value);
1538
+ } else if (typeof value === "number") {
1539
+ customisations[key] = value;
1540
+ }
1541
+ break;
1542
+ case "ariaHidden":
1543
+ case "aria-hidden":
1544
+ if (value !== true && value !== "true") {
1545
+ delete componentProps["aria-hidden"];
1546
+ }
1547
+ break;
1548
+ default:
1549
+ if (defaultProps[key] === void 0) {
1550
+ componentProps[key] = value;
1551
+ }
1552
+ }
1553
+ }
1554
+ const item = iconToSVG(icon, customisations);
1555
+ const renderAttribs = item.attributes;
1556
+ if (customisations.inline) {
1557
+ style.verticalAlign = "-0.125em";
1558
+ }
1559
+ if (mode === "svg") {
1560
+ componentProps.style = {
1561
+ ...style,
1562
+ ...customStyle
1563
+ };
1564
+ Object.assign(componentProps, renderAttribs);
1565
+ let localCounter = 0;
1566
+ let id = props.id;
1567
+ if (typeof id === "string") {
1568
+ id = id.replace(/-/g, "_");
1569
+ }
1570
+ componentProps.dangerouslySetInnerHTML = {
1571
+ __html: cleanUpInnerHTML(replaceIDs(item.body, id ? () => id + "ID" + localCounter++ : "iconifyReact"))
1572
+ };
1573
+ return React__default.createElement("svg", componentProps);
1574
+ }
1575
+ const { body, width, height } = icon;
1576
+ const useMask = mode === "mask" || (mode === "bg" ? false : body.indexOf("currentColor") !== -1);
1577
+ const html = iconToHTML(body, {
1578
+ ...renderAttribs,
1579
+ width: width + "",
1580
+ height: height + ""
1581
+ });
1582
+ componentProps.style = {
1583
+ ...style,
1584
+ "--svg": svgToURL(html),
1585
+ "width": fixSize(renderAttribs.width),
1586
+ "height": fixSize(renderAttribs.height),
1587
+ ...commonProps,
1588
+ ...useMask ? monotoneProps : coloredProps,
1589
+ ...customStyle
1590
+ };
1591
+ return React__default.createElement("span", componentProps);
1592
+ };
1593
+ allowSimpleNames(true);
1594
+ setAPIModule("", fetchAPIModule);
1595
+ if (typeof document !== "undefined" && typeof window !== "undefined") {
1596
+ initBrowserStorage();
1597
+ const _window2 = window;
1598
+ if (_window2.IconifyPreload !== void 0) {
1599
+ const preload = _window2.IconifyPreload;
1600
+ const err = "Invalid IconifyPreload syntax.";
1601
+ if (typeof preload === "object" && preload !== null) {
1602
+ (preload instanceof Array ? preload : [preload]).forEach((item) => {
1603
+ try {
1604
+ if (
1605
+ // Check if item is an object and not null/array
1606
+ typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
1607
+ typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
1608
+ !addCollection(item)
1609
+ ) {
1610
+ console.error(err);
1611
+ }
1612
+ } catch (e) {
1613
+ console.error(err);
1614
+ }
1615
+ });
1616
+ }
1617
+ }
1618
+ if (_window2.IconifyProviders !== void 0) {
1619
+ const providers = _window2.IconifyProviders;
1620
+ if (typeof providers === "object" && providers !== null) {
1621
+ for (let key in providers) {
1622
+ const err = "IconifyProviders[" + key + "] is invalid.";
1623
+ try {
1624
+ const value = providers[key];
1625
+ if (typeof value !== "object" || !value || value.resources === void 0) {
1626
+ continue;
1627
+ }
1628
+ if (!addAPIProvider(key, value)) {
1629
+ console.error(err);
1630
+ }
1631
+ } catch (e) {
1632
+ console.error(err);
1633
+ }
1634
+ }
1635
+ }
1636
+ }
1637
+ }
1638
+ class IconComponent extends React__default.Component {
1639
+ constructor(props) {
1640
+ super(props);
1641
+ this.state = {
1642
+ // Render placeholder before component is mounted
1643
+ icon: null
1644
+ };
1645
+ }
1646
+ /**
1647
+ * Abort loading icon
1648
+ */
1649
+ _abortLoading() {
1650
+ if (this._loading) {
1651
+ this._loading.abort();
1652
+ this._loading = null;
1653
+ }
1654
+ }
1655
+ /**
1656
+ * Update state
1657
+ */
1658
+ _setData(icon) {
1659
+ if (this.state.icon !== icon) {
1660
+ this.setState({
1661
+ icon
1662
+ });
1663
+ }
1664
+ }
1665
+ /**
1666
+ * Check if icon should be loaded
1667
+ */
1668
+ _checkIcon(changed) {
1669
+ const state = this.state;
1670
+ const icon = this.props.icon;
1671
+ if (typeof icon === "object" && icon !== null && typeof icon.body === "string") {
1672
+ this._icon = "";
1673
+ this._abortLoading();
1674
+ if (changed || state.icon === null) {
1675
+ this._setData({
1676
+ data: icon
1677
+ });
1678
+ }
1679
+ return;
1680
+ }
1681
+ let iconName;
1682
+ if (typeof icon !== "string" || (iconName = stringToIcon(icon, false, true)) === null) {
1683
+ this._abortLoading();
1684
+ this._setData(null);
1685
+ return;
1686
+ }
1687
+ const data = getIconData(iconName);
1688
+ if (!data) {
1689
+ if (!this._loading || this._loading.name !== icon) {
1690
+ this._abortLoading();
1691
+ this._icon = "";
1692
+ this._setData(null);
1693
+ if (data !== null) {
1694
+ this._loading = {
1695
+ name: icon,
1696
+ abort: loadIcons([iconName], this._checkIcon.bind(this, false))
1697
+ };
1698
+ }
1699
+ }
1700
+ return;
1701
+ }
1702
+ if (this._icon !== icon || state.icon === null) {
1703
+ this._abortLoading();
1704
+ this._icon = icon;
1705
+ const classes = ["iconify"];
1706
+ if (iconName.prefix !== "") {
1707
+ classes.push("iconify--" + iconName.prefix);
1708
+ }
1709
+ if (iconName.provider !== "") {
1710
+ classes.push("iconify--" + iconName.provider);
1711
+ }
1712
+ this._setData({
1713
+ data,
1714
+ classes
1715
+ });
1716
+ if (this.props.onLoad) {
1717
+ this.props.onLoad(icon);
1718
+ }
1719
+ }
1720
+ }
1721
+ /**
1722
+ * Component mounted
1723
+ */
1724
+ componentDidMount() {
1725
+ this._checkIcon(false);
1726
+ }
1727
+ /**
1728
+ * Component updated
1729
+ */
1730
+ componentDidUpdate(oldProps) {
1731
+ if (oldProps.icon !== this.props.icon) {
1732
+ this._checkIcon(true);
1733
+ }
1734
+ }
1735
+ /**
1736
+ * Abort loading
1737
+ */
1738
+ componentWillUnmount() {
1739
+ this._abortLoading();
1740
+ }
1741
+ /**
1742
+ * Render
1743
+ */
1744
+ render() {
1745
+ const props = this.props;
1746
+ const icon = this.state.icon;
1747
+ if (icon === null) {
1748
+ return props.children ? props.children : React__default.createElement("span", {});
1749
+ }
1750
+ let newProps = props;
1751
+ if (icon.classes) {
1752
+ newProps = {
1753
+ ...props,
1754
+ className: (typeof props.className === "string" ? props.className + " " : "") + icon.classes.join(" ")
1755
+ };
1756
+ }
1757
+ return render({
1758
+ ...defaultIconProps,
1759
+ ...icon.data
1760
+ }, newProps, props._inline, props._ref);
1761
+ }
1762
+ }
1763
+ const Icon = React__default.forwardRef(function Icon2(props, ref) {
1764
+ const newProps = {
1765
+ ...props,
1766
+ _ref: ref,
1767
+ _inline: false
1768
+ };
1769
+ return React__default.createElement(IconComponent, newProps);
1770
+ });
1771
+ React__default.forwardRef(function InlineIcon(props, ref) {
1772
+ const newProps = {
1773
+ ...props,
1774
+ _ref: ref,
1775
+ _inline: true
1776
+ };
1777
+ return React__default.createElement(IconComponent, newProps);
1778
+ });
1779
+ export {
1780
+ Icon as I,
1781
+ addAPIProvider as a
1782
+ };