@bagelink/vue 1.2.143 → 1.2.145

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