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