@dappworks/kit 0.4.200 → 0.4.202

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/dist/wallet.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AIem } from './chunk-3TBJNCTQ.mjs';
2
2
  import './chunk-7MDKCI65.mjs';
3
3
  import { StorageState, ObjectPool, PromiseHook } from './chunk-DRTTNPZI.mjs';
4
- import './chunk-OISBIKAQ.mjs';
4
+ import './chunk-4UFM3HVW.mjs';
5
5
  import { DialogStore } from './chunk-L6XS2K2K.mjs';
6
6
  import { ToastPlugin } from './chunk-IMOLRP7I.mjs';
7
7
  import './chunk-K73JTEJQ.mjs';
@@ -9,16 +9,16 @@ import { RootStore } from './chunk-XSGTWROT.mjs';
9
9
  import { helper } from './chunk-R4N52NI2.mjs';
10
10
  import './chunk-ONVPCAMQ.mjs';
11
11
  import './chunk-K7LFG5BA.mjs';
12
- import { __commonJS, __spreadValues, __spreadProps, __toESM } from './chunk-2EXDWOHY.mjs';
12
+ import { __commonJS, __toESM, __spreadValues, __spreadProps } from './chunk-2EXDWOHY.mjs';
13
13
  import { getDefaultConfig, useConnectModal, RainbowKitProvider, darkTheme, lightTheme } from '@rainbow-me/rainbowkit';
14
14
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
15
- import React5, { forwardRef, useEffect, useState, createElement } from 'react';
15
+ import React5, { useEffect, useState } from 'react';
16
16
  import { useWalletClient, useAccount, useSwitchChain, useConnect, useDisconnect, WagmiProvider } from 'wagmi';
17
17
  import EventEmitter from 'events';
18
+ import { Icon } from '@iconify/react';
18
19
  import { encodeFunctionData, hashMessage, hashTypedData } from 'viem';
19
20
  import { observer } from 'mobx-react-lite';
20
21
  import { iopayWallet, metaMaskWallet, walletConnectWallet, okxWallet, binanceWallet } from '@rainbow-me/rainbowkit/wallets';
21
- import { injected } from 'wagmi/connectors';
22
22
  import { reaction } from 'mobx';
23
23
  import { iotex as iotex$1, iotexTestnet as iotexTestnet$1 } from 'viem/chains';
24
24
  import { Checkbox, Tooltip, Button, Popover, PopoverTrigger, PopoverContent, Input, Table, TableHeader, TableColumn, TableBody, TableRow, TableCell } from '@nextui-org/react';
@@ -750,1753 +750,6 @@ var require_dist = __commonJS({
750
750
  exports.putAccountDataSettings = putAccountDataSettings;
751
751
  }
752
752
  });
753
- var defaultIconDimensions = Object.freeze(
754
- {
755
- left: 0,
756
- top: 0,
757
- width: 16,
758
- height: 16
759
- }
760
- );
761
- var defaultIconTransformations = Object.freeze({
762
- rotate: 0,
763
- vFlip: false,
764
- hFlip: false
765
- });
766
- var defaultIconProps = Object.freeze(__spreadValues(__spreadValues({}, defaultIconDimensions), defaultIconTransformations));
767
- var defaultExtendedIconProps = Object.freeze(__spreadProps(__spreadValues({}, defaultIconProps), {
768
- body: "",
769
- hidden: false
770
- }));
771
- function mergeIconTransformations(obj1, obj2) {
772
- const result = {};
773
- if (!obj1.hFlip !== !obj2.hFlip) {
774
- result.hFlip = true;
775
- }
776
- if (!obj1.vFlip !== !obj2.vFlip) {
777
- result.vFlip = true;
778
- }
779
- const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
780
- if (rotate) {
781
- result.rotate = rotate;
782
- }
783
- return result;
784
- }
785
- function mergeIconData(parent, child) {
786
- const result = mergeIconTransformations(parent, child);
787
- for (const key in defaultExtendedIconProps) {
788
- if (key in defaultIconTransformations) {
789
- if (key in parent && !(key in result)) {
790
- result[key] = defaultIconTransformations[key];
791
- }
792
- } else if (key in child) {
793
- result[key] = child[key];
794
- } else if (key in parent) {
795
- result[key] = parent[key];
796
- }
797
- }
798
- return result;
799
- }
800
- function getIconsTree(data, names) {
801
- const icons = data.icons;
802
- const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
803
- const resolved = /* @__PURE__ */ Object.create(null);
804
- function resolve(name) {
805
- if (icons[name]) {
806
- return resolved[name] = [];
807
- }
808
- if (!(name in resolved)) {
809
- resolved[name] = null;
810
- const parent = aliases[name] && aliases[name].parent;
811
- const value = parent && resolve(parent);
812
- if (value) {
813
- resolved[name] = [parent].concat(value);
814
- }
815
- }
816
- return resolved[name];
817
- }
818
- (Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
819
- return resolved;
820
- }
821
- function internalGetIconData(data, name, tree) {
822
- const icons = data.icons;
823
- const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
824
- let currentProps = {};
825
- function parse(name2) {
826
- currentProps = mergeIconData(
827
- icons[name2] || aliases[name2],
828
- currentProps
829
- );
830
- }
831
- parse(name);
832
- tree.forEach(parse);
833
- return mergeIconData(data, currentProps);
834
- }
835
- function parseIconSet(data, callback) {
836
- const names = [];
837
- if (typeof data !== "object" || typeof data.icons !== "object") {
838
- return names;
839
- }
840
- if (data.not_found instanceof Array) {
841
- data.not_found.forEach((name) => {
842
- callback(name, null);
843
- names.push(name);
844
- });
845
- }
846
- const tree = getIconsTree(data);
847
- for (const name in tree) {
848
- const item = tree[name];
849
- if (item) {
850
- callback(name, internalGetIconData(data, name, item));
851
- names.push(name);
852
- }
853
- }
854
- return names;
855
- }
856
- var matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
857
- var stringToIcon = (value, validate, allowSimpleName, provider = "") => {
858
- const colonSeparated = value.split(":");
859
- if (value.slice(0, 1) === "@") {
860
- if (colonSeparated.length < 2 || colonSeparated.length > 3) {
861
- return null;
862
- }
863
- provider = colonSeparated.shift().slice(1);
864
- }
865
- if (colonSeparated.length > 3 || !colonSeparated.length) {
866
- return null;
867
- }
868
- if (colonSeparated.length > 1) {
869
- const name2 = colonSeparated.pop();
870
- const prefix = colonSeparated.pop();
871
- const result = {
872
- // Allow provider without '@': "provider:prefix:name"
873
- provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
874
- prefix,
875
- name: name2
876
- };
877
- return validate && !validateIconName(result) ? null : result;
878
- }
879
- const name = colonSeparated[0];
880
- const dashSeparated = name.split("-");
881
- if (dashSeparated.length > 1) {
882
- const result = {
883
- provider,
884
- prefix: dashSeparated.shift(),
885
- name: dashSeparated.join("-")
886
- };
887
- return validate && !validateIconName(result) ? null : result;
888
- }
889
- if (allowSimpleName && provider === "") {
890
- const result = {
891
- provider,
892
- prefix: "",
893
- name
894
- };
895
- return validate && !validateIconName(result, allowSimpleName) ? null : result;
896
- }
897
- return null;
898
- };
899
- var validateIconName = (icon, allowSimpleName) => {
900
- if (!icon) {
901
- return false;
902
- }
903
- return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
904
- };
905
- var optionalPropertyDefaults = __spreadValues({
906
- provider: "",
907
- aliases: {},
908
- not_found: {}
909
- }, defaultIconDimensions);
910
- function checkOptionalProps(item, defaults) {
911
- for (const prop in defaults) {
912
- if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
913
- return false;
914
- }
915
- }
916
- return true;
917
- }
918
- function quicklyValidateIconSet(obj) {
919
- if (typeof obj !== "object" || obj === null) {
920
- return null;
921
- }
922
- const data = obj;
923
- if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
924
- return null;
925
- }
926
- if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
927
- return null;
928
- }
929
- const icons = data.icons;
930
- for (const name in icons) {
931
- const icon = icons[name];
932
- if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(
933
- icon,
934
- defaultExtendedIconProps
935
- )) {
936
- return null;
937
- }
938
- }
939
- const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
940
- for (const name in aliases) {
941
- const icon = aliases[name];
942
- const parent = icon.parent;
943
- if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(
944
- icon,
945
- defaultExtendedIconProps
946
- )) {
947
- return null;
948
- }
949
- }
950
- return data;
951
- }
952
- var dataStorage = /* @__PURE__ */ Object.create(null);
953
- function newStorage(provider, prefix) {
954
- return {
955
- provider,
956
- prefix,
957
- icons: /* @__PURE__ */ Object.create(null),
958
- missing: /* @__PURE__ */ new Set()
959
- };
960
- }
961
- function getStorage(provider, prefix) {
962
- const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
963
- return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
964
- }
965
- function addIconSet(storage2, data) {
966
- if (!quicklyValidateIconSet(data)) {
967
- return [];
968
- }
969
- return parseIconSet(data, (name, icon) => {
970
- if (icon) {
971
- storage2.icons[name] = icon;
972
- } else {
973
- storage2.missing.add(name);
974
- }
975
- });
976
- }
977
- function addIconToStorage(storage2, name, icon) {
978
- try {
979
- if (typeof icon.body === "string") {
980
- storage2.icons[name] = __spreadValues({}, icon);
981
- return true;
982
- }
983
- } catch (err) {
984
- }
985
- return false;
986
- }
987
- var simpleNames = false;
988
- function allowSimpleNames(allow) {
989
- if (typeof allow === "boolean") {
990
- simpleNames = allow;
991
- }
992
- return simpleNames;
993
- }
994
- function getIconData(name) {
995
- const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
996
- if (icon) {
997
- const storage2 = getStorage(icon.provider, icon.prefix);
998
- const iconName = icon.name;
999
- return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
1000
- }
1001
- }
1002
- function addIcon(name, data) {
1003
- const icon = stringToIcon(name, true, simpleNames);
1004
- if (!icon) {
1005
- return false;
1006
- }
1007
- const storage2 = getStorage(icon.provider, icon.prefix);
1008
- return addIconToStorage(storage2, icon.name, data);
1009
- }
1010
- function addCollection(data, provider) {
1011
- if (typeof data !== "object") {
1012
- return false;
1013
- }
1014
- if (typeof provider !== "string") {
1015
- provider = data.provider || "";
1016
- }
1017
- if (simpleNames && !provider && !data.prefix) {
1018
- let added = false;
1019
- if (quicklyValidateIconSet(data)) {
1020
- data.prefix = "";
1021
- parseIconSet(data, (name, icon) => {
1022
- if (icon && addIcon(name, icon)) {
1023
- added = true;
1024
- }
1025
- });
1026
- }
1027
- return added;
1028
- }
1029
- const prefix = data.prefix;
1030
- if (!validateIconName({
1031
- provider,
1032
- prefix,
1033
- name: "a"
1034
- })) {
1035
- return false;
1036
- }
1037
- const storage2 = getStorage(provider, prefix);
1038
- return !!addIconSet(storage2, data);
1039
- }
1040
- var defaultIconSizeCustomisations = Object.freeze({
1041
- width: null,
1042
- height: null
1043
- });
1044
- var defaultIconCustomisations = Object.freeze(__spreadValues(__spreadValues({}, defaultIconSizeCustomisations), defaultIconTransformations));
1045
- var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
1046
- var unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
1047
- function calculateSize(size, ratio, precision) {
1048
- if (ratio === 1) {
1049
- return size;
1050
- }
1051
- precision = precision || 100;
1052
- if (typeof size === "number") {
1053
- return Math.ceil(size * ratio * precision) / precision;
1054
- }
1055
- if (typeof size !== "string") {
1056
- return size;
1057
- }
1058
- const oldParts = size.split(unitsSplit);
1059
- if (oldParts === null || !oldParts.length) {
1060
- return size;
1061
- }
1062
- const newParts = [];
1063
- let code = oldParts.shift();
1064
- let isNumber = unitsTest.test(code);
1065
- while (true) {
1066
- if (isNumber) {
1067
- const num = parseFloat(code);
1068
- if (isNaN(num)) {
1069
- newParts.push(code);
1070
- } else {
1071
- newParts.push(Math.ceil(num * ratio * precision) / precision);
1072
- }
1073
- } else {
1074
- newParts.push(code);
1075
- }
1076
- code = oldParts.shift();
1077
- if (code === void 0) {
1078
- return newParts.join("");
1079
- }
1080
- isNumber = !isNumber;
1081
- }
1082
- }
1083
- function splitSVGDefs(content, tag = "defs") {
1084
- let defs = "";
1085
- const index = content.indexOf("<" + tag);
1086
- while (index >= 0) {
1087
- const start = content.indexOf(">", index);
1088
- const end = content.indexOf("</" + tag);
1089
- if (start === -1 || end === -1) {
1090
- break;
1091
- }
1092
- const endEnd = content.indexOf(">", end);
1093
- if (endEnd === -1) {
1094
- break;
1095
- }
1096
- defs += content.slice(start + 1, end).trim();
1097
- content = content.slice(0, index).trim() + content.slice(endEnd + 1);
1098
- }
1099
- return {
1100
- defs,
1101
- content
1102
- };
1103
- }
1104
- function mergeDefsAndContent(defs, content) {
1105
- return defs ? "<defs>" + defs + "</defs>" + content : content;
1106
- }
1107
- function wrapSVGContent(body, start, end) {
1108
- const split = splitSVGDefs(body);
1109
- return mergeDefsAndContent(split.defs, start + split.content + end);
1110
- }
1111
- var isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
1112
- function iconToSVG(icon, customisations) {
1113
- const fullIcon = __spreadValues(__spreadValues({}, defaultIconProps), icon);
1114
- const fullCustomisations = __spreadValues(__spreadValues({}, defaultIconCustomisations), customisations);
1115
- const box = {
1116
- left: fullIcon.left,
1117
- top: fullIcon.top,
1118
- width: fullIcon.width,
1119
- height: fullIcon.height
1120
- };
1121
- let body = fullIcon.body;
1122
- [fullIcon, fullCustomisations].forEach((props) => {
1123
- const transformations = [];
1124
- const hFlip = props.hFlip;
1125
- const vFlip = props.vFlip;
1126
- let rotation = props.rotate;
1127
- if (hFlip) {
1128
- if (vFlip) {
1129
- rotation += 2;
1130
- } else {
1131
- transformations.push(
1132
- "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
1133
- );
1134
- transformations.push("scale(-1 1)");
1135
- box.top = box.left = 0;
1136
- }
1137
- } else if (vFlip) {
1138
- transformations.push(
1139
- "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
1140
- );
1141
- transformations.push("scale(1 -1)");
1142
- box.top = box.left = 0;
1143
- }
1144
- let tempValue;
1145
- if (rotation < 0) {
1146
- rotation -= Math.floor(rotation / 4) * 4;
1147
- }
1148
- rotation = rotation % 4;
1149
- switch (rotation) {
1150
- case 1:
1151
- tempValue = box.height / 2 + box.top;
1152
- transformations.unshift(
1153
- "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
1154
- );
1155
- break;
1156
- case 2:
1157
- transformations.unshift(
1158
- "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
1159
- );
1160
- break;
1161
- case 3:
1162
- tempValue = box.width / 2 + box.left;
1163
- transformations.unshift(
1164
- "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
1165
- );
1166
- break;
1167
- }
1168
- if (rotation % 2 === 1) {
1169
- if (box.left !== box.top) {
1170
- tempValue = box.left;
1171
- box.left = box.top;
1172
- box.top = tempValue;
1173
- }
1174
- if (box.width !== box.height) {
1175
- tempValue = box.width;
1176
- box.width = box.height;
1177
- box.height = tempValue;
1178
- }
1179
- }
1180
- if (transformations.length) {
1181
- body = wrapSVGContent(
1182
- body,
1183
- '<g transform="' + transformations.join(" ") + '">',
1184
- "</g>"
1185
- );
1186
- }
1187
- });
1188
- const customisationsWidth = fullCustomisations.width;
1189
- const customisationsHeight = fullCustomisations.height;
1190
- const boxWidth = box.width;
1191
- const boxHeight = box.height;
1192
- let width;
1193
- let height;
1194
- if (customisationsWidth === null) {
1195
- height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
1196
- width = calculateSize(height, boxWidth / boxHeight);
1197
- } else {
1198
- width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
1199
- height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
1200
- }
1201
- const attributes = {};
1202
- const setAttr = (prop, value) => {
1203
- if (!isUnsetKeyword(value)) {
1204
- attributes[prop] = value.toString();
1205
- }
1206
- };
1207
- setAttr("width", width);
1208
- setAttr("height", height);
1209
- const viewBox = [box.left, box.top, boxWidth, boxHeight];
1210
- attributes.viewBox = viewBox.join(" ");
1211
- return {
1212
- attributes,
1213
- viewBox,
1214
- body
1215
- };
1216
- }
1217
- var regex = /\sid="(\S+)"/g;
1218
- var randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
1219
- var counter = 0;
1220
- function replaceIDs(body, prefix = randomPrefix) {
1221
- const ids = [];
1222
- let match;
1223
- while (match = regex.exec(body)) {
1224
- ids.push(match[1]);
1225
- }
1226
- if (!ids.length) {
1227
- return body;
1228
- }
1229
- const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
1230
- ids.forEach((id) => {
1231
- const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
1232
- const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1233
- body = body.replace(
1234
- // Allowed characters before id: [#;"]
1235
- // Allowed characters after id: [)"], .[a-z]
1236
- new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"),
1237
- "$1" + newID + suffix + "$3"
1238
- );
1239
- });
1240
- body = body.replace(new RegExp(suffix, "g"), "");
1241
- return body;
1242
- }
1243
- var storage = /* @__PURE__ */ Object.create(null);
1244
- function setAPIModule(provider, item) {
1245
- storage[provider] = item;
1246
- }
1247
- function getAPIModule(provider) {
1248
- return storage[provider] || storage[""];
1249
- }
1250
- function createAPIConfig(source) {
1251
- let resources;
1252
- if (typeof source.resources === "string") {
1253
- resources = [source.resources];
1254
- } else {
1255
- resources = source.resources;
1256
- if (!(resources instanceof Array) || !resources.length) {
1257
- return null;
1258
- }
1259
- }
1260
- const result = {
1261
- // API hosts
1262
- resources,
1263
- // Root path
1264
- path: source.path || "/",
1265
- // URL length limit
1266
- maxURL: source.maxURL || 500,
1267
- // Timeout before next host is used.
1268
- rotate: source.rotate || 750,
1269
- // Timeout before failing query.
1270
- timeout: source.timeout || 5e3,
1271
- // Randomise default API end point.
1272
- random: source.random === true,
1273
- // Start index
1274
- index: source.index || 0,
1275
- // Receive data after time out (used if time out kicks in first, then API module sends data anyway).
1276
- dataAfterTimeout: source.dataAfterTimeout !== false
1277
- };
1278
- return result;
1279
- }
1280
- var configStorage = /* @__PURE__ */ Object.create(null);
1281
- var fallBackAPISources = [
1282
- "https://api.simplesvg.com",
1283
- "https://api.unisvg.com"
1284
- ];
1285
- var fallBackAPI = [];
1286
- while (fallBackAPISources.length > 0) {
1287
- if (fallBackAPISources.length === 1) {
1288
- fallBackAPI.push(fallBackAPISources.shift());
1289
- } else {
1290
- if (Math.random() > 0.5) {
1291
- fallBackAPI.push(fallBackAPISources.shift());
1292
- } else {
1293
- fallBackAPI.push(fallBackAPISources.pop());
1294
- }
1295
- }
1296
- }
1297
- configStorage[""] = createAPIConfig({
1298
- resources: ["https://api.iconify.design"].concat(fallBackAPI)
1299
- });
1300
- function addAPIProvider(provider, customConfig) {
1301
- const config = createAPIConfig(customConfig);
1302
- if (config === null) {
1303
- return false;
1304
- }
1305
- configStorage[provider] = config;
1306
- return true;
1307
- }
1308
- function getAPIConfig(provider) {
1309
- return configStorage[provider];
1310
- }
1311
- var detectFetch = () => {
1312
- let callback;
1313
- try {
1314
- callback = fetch;
1315
- if (typeof callback === "function") {
1316
- return callback;
1317
- }
1318
- } catch (err) {
1319
- }
1320
- };
1321
- var fetchModule = detectFetch();
1322
- function calculateMaxLength(provider, prefix) {
1323
- const config = getAPIConfig(provider);
1324
- if (!config) {
1325
- return 0;
1326
- }
1327
- let result;
1328
- if (!config.maxURL) {
1329
- result = 0;
1330
- } else {
1331
- let maxHostLength = 0;
1332
- config.resources.forEach((item) => {
1333
- const host = item;
1334
- maxHostLength = Math.max(maxHostLength, host.length);
1335
- });
1336
- const url = prefix + ".json?icons=";
1337
- result = config.maxURL - maxHostLength - config.path.length - url.length;
1338
- }
1339
- return result;
1340
- }
1341
- function shouldAbort(status) {
1342
- return status === 404;
1343
- }
1344
- var prepare = (provider, prefix, icons) => {
1345
- const results = [];
1346
- const maxLength = calculateMaxLength(provider, prefix);
1347
- const type = "icons";
1348
- let item = {
1349
- type,
1350
- provider,
1351
- prefix,
1352
- icons: []
1353
- };
1354
- let length = 0;
1355
- icons.forEach((name, index) => {
1356
- length += name.length + 1;
1357
- if (length >= maxLength && index > 0) {
1358
- results.push(item);
1359
- item = {
1360
- type,
1361
- provider,
1362
- prefix,
1363
- icons: []
1364
- };
1365
- length = name.length;
1366
- }
1367
- item.icons.push(name);
1368
- });
1369
- results.push(item);
1370
- return results;
1371
- };
1372
- function getPath(provider) {
1373
- if (typeof provider === "string") {
1374
- const config = getAPIConfig(provider);
1375
- if (config) {
1376
- return config.path;
1377
- }
1378
- }
1379
- return "/";
1380
- }
1381
- var send = (host, params, callback) => {
1382
- if (!fetchModule) {
1383
- callback("abort", 424);
1384
- return;
1385
- }
1386
- let path = getPath(params.provider);
1387
- switch (params.type) {
1388
- case "icons": {
1389
- const prefix = params.prefix;
1390
- const icons = params.icons;
1391
- const iconsList = icons.join(",");
1392
- const urlParams = new URLSearchParams({
1393
- icons: iconsList
1394
- });
1395
- path += prefix + ".json?" + urlParams.toString();
1396
- break;
1397
- }
1398
- case "custom": {
1399
- const uri = params.uri;
1400
- path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
1401
- break;
1402
- }
1403
- default:
1404
- callback("abort", 400);
1405
- return;
1406
- }
1407
- let defaultError = 503;
1408
- fetchModule(host + path).then((response) => {
1409
- const status = response.status;
1410
- if (status !== 200) {
1411
- setTimeout(() => {
1412
- callback(shouldAbort(status) ? "abort" : "next", status);
1413
- });
1414
- return;
1415
- }
1416
- defaultError = 501;
1417
- return response.json();
1418
- }).then((data) => {
1419
- if (typeof data !== "object" || data === null) {
1420
- setTimeout(() => {
1421
- if (data === 404) {
1422
- callback("abort", data);
1423
- } else {
1424
- callback("next", defaultError);
1425
- }
1426
- });
1427
- return;
1428
- }
1429
- setTimeout(() => {
1430
- callback("success", data);
1431
- });
1432
- }).catch(() => {
1433
- callback("next", defaultError);
1434
- });
1435
- };
1436
- var fetchAPIModule = {
1437
- prepare,
1438
- send
1439
- };
1440
- function sortIcons(icons) {
1441
- const result = {
1442
- loaded: [],
1443
- missing: [],
1444
- pending: []
1445
- };
1446
- const storage2 = /* @__PURE__ */ Object.create(null);
1447
- icons.sort((a, b) => {
1448
- if (a.provider !== b.provider) {
1449
- return a.provider.localeCompare(b.provider);
1450
- }
1451
- if (a.prefix !== b.prefix) {
1452
- return a.prefix.localeCompare(b.prefix);
1453
- }
1454
- return a.name.localeCompare(b.name);
1455
- });
1456
- let lastIcon = {
1457
- provider: "",
1458
- prefix: "",
1459
- name: ""
1460
- };
1461
- icons.forEach((icon) => {
1462
- if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
1463
- return;
1464
- }
1465
- lastIcon = icon;
1466
- const provider = icon.provider;
1467
- const prefix = icon.prefix;
1468
- const name = icon.name;
1469
- const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
1470
- const localStorage2 = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
1471
- let list;
1472
- if (name in localStorage2.icons) {
1473
- list = result.loaded;
1474
- } else if (prefix === "" || localStorage2.missing.has(name)) {
1475
- list = result.missing;
1476
- } else {
1477
- list = result.pending;
1478
- }
1479
- const item = {
1480
- provider,
1481
- prefix,
1482
- name
1483
- };
1484
- list.push(item);
1485
- });
1486
- return result;
1487
- }
1488
- function removeCallback(storages, id) {
1489
- storages.forEach((storage2) => {
1490
- const items = storage2.loaderCallbacks;
1491
- if (items) {
1492
- storage2.loaderCallbacks = items.filter((row) => row.id !== id);
1493
- }
1494
- });
1495
- }
1496
- function updateCallbacks(storage2) {
1497
- if (!storage2.pendingCallbacksFlag) {
1498
- storage2.pendingCallbacksFlag = true;
1499
- setTimeout(() => {
1500
- storage2.pendingCallbacksFlag = false;
1501
- const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
1502
- if (!items.length) {
1503
- return;
1504
- }
1505
- let hasPending = false;
1506
- const provider = storage2.provider;
1507
- const prefix = storage2.prefix;
1508
- items.forEach((item) => {
1509
- const icons = item.icons;
1510
- const oldLength = icons.pending.length;
1511
- icons.pending = icons.pending.filter((icon) => {
1512
- if (icon.prefix !== prefix) {
1513
- return true;
1514
- }
1515
- const name = icon.name;
1516
- if (storage2.icons[name]) {
1517
- icons.loaded.push({
1518
- provider,
1519
- prefix,
1520
- name
1521
- });
1522
- } else if (storage2.missing.has(name)) {
1523
- icons.missing.push({
1524
- provider,
1525
- prefix,
1526
- name
1527
- });
1528
- } else {
1529
- hasPending = true;
1530
- return true;
1531
- }
1532
- return false;
1533
- });
1534
- if (icons.pending.length !== oldLength) {
1535
- if (!hasPending) {
1536
- removeCallback([storage2], item.id);
1537
- }
1538
- item.callback(
1539
- icons.loaded.slice(0),
1540
- icons.missing.slice(0),
1541
- icons.pending.slice(0),
1542
- item.abort
1543
- );
1544
- }
1545
- });
1546
- });
1547
- }
1548
- }
1549
- var idCounter = 0;
1550
- function storeCallback(callback, icons, pendingSources) {
1551
- const id = idCounter++;
1552
- const abort = removeCallback.bind(null, pendingSources, id);
1553
- if (!icons.pending.length) {
1554
- return abort;
1555
- }
1556
- const item = {
1557
- id,
1558
- icons,
1559
- callback,
1560
- abort
1561
- };
1562
- pendingSources.forEach((storage2) => {
1563
- (storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
1564
- });
1565
- return abort;
1566
- }
1567
- function listToIcons(list, validate = true, simpleNames2 = false) {
1568
- const result = [];
1569
- list.forEach((item) => {
1570
- const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
1571
- if (icon) {
1572
- result.push(icon);
1573
- }
1574
- });
1575
- return result;
1576
- }
1577
- var defaultConfig = {
1578
- resources: [],
1579
- index: 0,
1580
- timeout: 2e3,
1581
- rotate: 750,
1582
- random: false,
1583
- dataAfterTimeout: false
1584
- };
1585
- function sendQuery(config, payload, query, done) {
1586
- const resourcesCount = config.resources.length;
1587
- const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
1588
- let resources;
1589
- if (config.random) {
1590
- let list = config.resources.slice(0);
1591
- resources = [];
1592
- while (list.length > 1) {
1593
- const nextIndex = Math.floor(Math.random() * list.length);
1594
- resources.push(list[nextIndex]);
1595
- list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
1596
- }
1597
- resources = resources.concat(list);
1598
- } else {
1599
- resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
1600
- }
1601
- const startTime = Date.now();
1602
- let status = "pending";
1603
- let queriesSent = 0;
1604
- let lastError;
1605
- let timer = null;
1606
- let queue = [];
1607
- let doneCallbacks = [];
1608
- if (typeof done === "function") {
1609
- doneCallbacks.push(done);
1610
- }
1611
- function resetTimer() {
1612
- if (timer) {
1613
- clearTimeout(timer);
1614
- timer = null;
1615
- }
1616
- }
1617
- function abort() {
1618
- if (status === "pending") {
1619
- status = "aborted";
1620
- }
1621
- resetTimer();
1622
- queue.forEach((item) => {
1623
- if (item.status === "pending") {
1624
- item.status = "aborted";
1625
- }
1626
- });
1627
- queue = [];
1628
- }
1629
- function subscribe(callback, overwrite) {
1630
- if (overwrite) {
1631
- doneCallbacks = [];
1632
- }
1633
- if (typeof callback === "function") {
1634
- doneCallbacks.push(callback);
1635
- }
1636
- }
1637
- function getQueryStatus() {
1638
- return {
1639
- startTime,
1640
- payload,
1641
- status,
1642
- queriesSent,
1643
- queriesPending: queue.length,
1644
- subscribe,
1645
- abort
1646
- };
1647
- }
1648
- function failQuery() {
1649
- status = "failed";
1650
- doneCallbacks.forEach((callback) => {
1651
- callback(void 0, lastError);
1652
- });
1653
- }
1654
- function clearQueue() {
1655
- queue.forEach((item) => {
1656
- if (item.status === "pending") {
1657
- item.status = "aborted";
1658
- }
1659
- });
1660
- queue = [];
1661
- }
1662
- function moduleResponse(item, response, data) {
1663
- const isError = response !== "success";
1664
- queue = queue.filter((queued) => queued !== item);
1665
- switch (status) {
1666
- case "pending":
1667
- break;
1668
- case "failed":
1669
- if (isError || !config.dataAfterTimeout) {
1670
- return;
1671
- }
1672
- break;
1673
- default:
1674
- return;
1675
- }
1676
- if (response === "abort") {
1677
- lastError = data;
1678
- failQuery();
1679
- return;
1680
- }
1681
- if (isError) {
1682
- lastError = data;
1683
- if (!queue.length) {
1684
- if (!resources.length) {
1685
- failQuery();
1686
- } else {
1687
- execNext();
1688
- }
1689
- }
1690
- return;
1691
- }
1692
- resetTimer();
1693
- clearQueue();
1694
- if (!config.random) {
1695
- const index = config.resources.indexOf(item.resource);
1696
- if (index !== -1 && index !== config.index) {
1697
- config.index = index;
1698
- }
1699
- }
1700
- status = "completed";
1701
- doneCallbacks.forEach((callback) => {
1702
- callback(data);
1703
- });
1704
- }
1705
- function execNext() {
1706
- if (status !== "pending") {
1707
- return;
1708
- }
1709
- resetTimer();
1710
- const resource = resources.shift();
1711
- if (resource === void 0) {
1712
- if (queue.length) {
1713
- timer = setTimeout(() => {
1714
- resetTimer();
1715
- if (status === "pending") {
1716
- clearQueue();
1717
- failQuery();
1718
- }
1719
- }, config.timeout);
1720
- return;
1721
- }
1722
- failQuery();
1723
- return;
1724
- }
1725
- const item = {
1726
- status: "pending",
1727
- resource,
1728
- callback: (status2, data) => {
1729
- moduleResponse(item, status2, data);
1730
- }
1731
- };
1732
- queue.push(item);
1733
- queriesSent++;
1734
- timer = setTimeout(execNext, config.rotate);
1735
- query(resource, payload, item.callback);
1736
- }
1737
- setTimeout(execNext);
1738
- return getQueryStatus;
1739
- }
1740
- function initRedundancy(cfg) {
1741
- const config = __spreadValues(__spreadValues({}, defaultConfig), cfg);
1742
- let queries = [];
1743
- function cleanup() {
1744
- queries = queries.filter((item) => item().status === "pending");
1745
- }
1746
- function query(payload, queryCallback, doneCallback) {
1747
- const query2 = sendQuery(
1748
- config,
1749
- payload,
1750
- queryCallback,
1751
- (data, error) => {
1752
- cleanup();
1753
- if (doneCallback) {
1754
- doneCallback(data, error);
1755
- }
1756
- }
1757
- );
1758
- queries.push(query2);
1759
- return query2;
1760
- }
1761
- function find(callback) {
1762
- return queries.find((value) => {
1763
- return callback(value);
1764
- }) || null;
1765
- }
1766
- const instance = {
1767
- query,
1768
- find,
1769
- setIndex: (index) => {
1770
- config.index = index;
1771
- },
1772
- getIndex: () => config.index,
1773
- cleanup
1774
- };
1775
- return instance;
1776
- }
1777
- function emptyCallback$1() {
1778
- }
1779
- var redundancyCache = /* @__PURE__ */ Object.create(null);
1780
- function getRedundancyCache(provider) {
1781
- if (!redundancyCache[provider]) {
1782
- const config = getAPIConfig(provider);
1783
- if (!config) {
1784
- return;
1785
- }
1786
- const redundancy = initRedundancy(config);
1787
- const cachedReundancy = {
1788
- config,
1789
- redundancy
1790
- };
1791
- redundancyCache[provider] = cachedReundancy;
1792
- }
1793
- return redundancyCache[provider];
1794
- }
1795
- function sendAPIQuery(target, query, callback) {
1796
- let redundancy;
1797
- let send2;
1798
- if (typeof target === "string") {
1799
- const api = getAPIModule(target);
1800
- if (!api) {
1801
- callback(void 0, 424);
1802
- return emptyCallback$1;
1803
- }
1804
- send2 = api.send;
1805
- const cached = getRedundancyCache(target);
1806
- if (cached) {
1807
- redundancy = cached.redundancy;
1808
- }
1809
- } else {
1810
- const config = createAPIConfig(target);
1811
- if (config) {
1812
- redundancy = initRedundancy(config);
1813
- const moduleKey = target.resources ? target.resources[0] : "";
1814
- const api = getAPIModule(moduleKey);
1815
- if (api) {
1816
- send2 = api.send;
1817
- }
1818
- }
1819
- }
1820
- if (!redundancy || !send2) {
1821
- callback(void 0, 424);
1822
- return emptyCallback$1;
1823
- }
1824
- return redundancy.query(query, send2, callback)().abort;
1825
- }
1826
- var browserCacheVersion = "iconify2";
1827
- var browserCachePrefix = "iconify";
1828
- var browserCacheCountKey = browserCachePrefix + "-count";
1829
- var browserCacheVersionKey = browserCachePrefix + "-version";
1830
- var browserStorageHour = 36e5;
1831
- var browserStorageCacheExpiration = 168;
1832
- var browserStorageLimit = 50;
1833
- function getStoredItem(func, key) {
1834
- try {
1835
- return func.getItem(key);
1836
- } catch (err) {
1837
- }
1838
- }
1839
- function setStoredItem(func, key, value) {
1840
- try {
1841
- func.setItem(key, value);
1842
- return true;
1843
- } catch (err) {
1844
- }
1845
- }
1846
- function removeStoredItem(func, key) {
1847
- try {
1848
- func.removeItem(key);
1849
- } catch (err) {
1850
- }
1851
- }
1852
- function setBrowserStorageItemsCount(storage2, value) {
1853
- return setStoredItem(storage2, browserCacheCountKey, value.toString());
1854
- }
1855
- function getBrowserStorageItemsCount(storage2) {
1856
- return parseInt(getStoredItem(storage2, browserCacheCountKey)) || 0;
1857
- }
1858
- var browserStorageConfig = {
1859
- local: true,
1860
- session: true
1861
- };
1862
- var browserStorageEmptyItems = {
1863
- local: /* @__PURE__ */ new Set(),
1864
- session: /* @__PURE__ */ new Set()
1865
- };
1866
- var browserStorageStatus = false;
1867
- function setBrowserStorageStatus(status) {
1868
- browserStorageStatus = status;
1869
- }
1870
- var _window = typeof window === "undefined" ? {} : window;
1871
- function getBrowserStorage(key) {
1872
- const attr = key + "Storage";
1873
- try {
1874
- if (_window && _window[attr] && typeof _window[attr].length === "number") {
1875
- return _window[attr];
1876
- }
1877
- } catch (err) {
1878
- }
1879
- browserStorageConfig[key] = false;
1880
- }
1881
- function iterateBrowserStorage(key, callback) {
1882
- const func = getBrowserStorage(key);
1883
- if (!func) {
1884
- return;
1885
- }
1886
- const version = getStoredItem(func, browserCacheVersionKey);
1887
- if (version !== browserCacheVersion) {
1888
- if (version) {
1889
- const total2 = getBrowserStorageItemsCount(func);
1890
- for (let i = 0; i < total2; i++) {
1891
- removeStoredItem(func, browserCachePrefix + i.toString());
1892
- }
1893
- }
1894
- setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
1895
- setBrowserStorageItemsCount(func, 0);
1896
- return;
1897
- }
1898
- const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
1899
- const parseItem = (index) => {
1900
- const name = browserCachePrefix + index.toString();
1901
- const item = getStoredItem(func, name);
1902
- if (typeof item !== "string") {
1903
- return;
1904
- }
1905
- try {
1906
- const data = JSON.parse(item);
1907
- if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" && // Valid item: run callback
1908
- callback(data, index)) {
1909
- return true;
1910
- }
1911
- } catch (err) {
1912
- }
1913
- removeStoredItem(func, name);
1914
- };
1915
- let total = getBrowserStorageItemsCount(func);
1916
- for (let i = total - 1; i >= 0; i--) {
1917
- if (!parseItem(i)) {
1918
- if (i === total - 1) {
1919
- total--;
1920
- setBrowserStorageItemsCount(func, total);
1921
- } else {
1922
- browserStorageEmptyItems[key].add(i);
1923
- }
1924
- }
1925
- }
1926
- }
1927
- function initBrowserStorage() {
1928
- if (browserStorageStatus) {
1929
- return;
1930
- }
1931
- setBrowserStorageStatus(true);
1932
- for (const key in browserStorageConfig) {
1933
- iterateBrowserStorage(key, (item) => {
1934
- const iconSet = item.data;
1935
- const provider = item.provider;
1936
- const prefix = iconSet.prefix;
1937
- const storage2 = getStorage(
1938
- provider,
1939
- prefix
1940
- );
1941
- if (!addIconSet(storage2, iconSet).length) {
1942
- return false;
1943
- }
1944
- const lastModified = iconSet.lastModified || -1;
1945
- storage2.lastModifiedCached = storage2.lastModifiedCached ? Math.min(storage2.lastModifiedCached, lastModified) : lastModified;
1946
- return true;
1947
- });
1948
- }
1949
- }
1950
- function updateLastModified(storage2, lastModified) {
1951
- const lastValue = storage2.lastModifiedCached;
1952
- if (
1953
- // Matches or newer
1954
- lastValue && lastValue >= lastModified
1955
- ) {
1956
- return lastValue === lastModified;
1957
- }
1958
- storage2.lastModifiedCached = lastModified;
1959
- if (lastValue) {
1960
- for (const key in browserStorageConfig) {
1961
- iterateBrowserStorage(key, (item) => {
1962
- const iconSet = item.data;
1963
- return item.provider !== storage2.provider || iconSet.prefix !== storage2.prefix || iconSet.lastModified === lastModified;
1964
- });
1965
- }
1966
- }
1967
- return true;
1968
- }
1969
- function storeInBrowserStorage(storage2, data) {
1970
- if (!browserStorageStatus) {
1971
- initBrowserStorage();
1972
- }
1973
- function store(key) {
1974
- let func;
1975
- if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
1976
- return;
1977
- }
1978
- const set = browserStorageEmptyItems[key];
1979
- let index;
1980
- if (set.size) {
1981
- set.delete(index = Array.from(set).shift());
1982
- } else {
1983
- index = getBrowserStorageItemsCount(func);
1984
- if (index >= browserStorageLimit || !setBrowserStorageItemsCount(func, index + 1)) {
1985
- return;
1986
- }
1987
- }
1988
- const item = {
1989
- cached: Math.floor(Date.now() / browserStorageHour),
1990
- provider: storage2.provider,
1991
- data
1992
- };
1993
- return setStoredItem(
1994
- func,
1995
- browserCachePrefix + index.toString(),
1996
- JSON.stringify(item)
1997
- );
1998
- }
1999
- if (data.lastModified && !updateLastModified(storage2, data.lastModified)) {
2000
- return;
2001
- }
2002
- if (!Object.keys(data.icons).length) {
2003
- return;
2004
- }
2005
- if (data.not_found) {
2006
- data = Object.assign({}, data);
2007
- delete data.not_found;
2008
- }
2009
- if (!store("local")) {
2010
- store("session");
2011
- }
2012
- }
2013
- function emptyCallback() {
2014
- }
2015
- function loadedNewIcons(storage2) {
2016
- if (!storage2.iconsLoaderFlag) {
2017
- storage2.iconsLoaderFlag = true;
2018
- setTimeout(() => {
2019
- storage2.iconsLoaderFlag = false;
2020
- updateCallbacks(storage2);
2021
- });
2022
- }
2023
- }
2024
- function loadNewIcons(storage2, icons) {
2025
- if (!storage2.iconsToLoad) {
2026
- storage2.iconsToLoad = icons;
2027
- } else {
2028
- storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
2029
- }
2030
- if (!storage2.iconsQueueFlag) {
2031
- storage2.iconsQueueFlag = true;
2032
- setTimeout(() => {
2033
- storage2.iconsQueueFlag = false;
2034
- const { provider, prefix } = storage2;
2035
- const icons2 = storage2.iconsToLoad;
2036
- delete storage2.iconsToLoad;
2037
- let api;
2038
- if (!icons2 || !(api = getAPIModule(provider))) {
2039
- return;
2040
- }
2041
- const params = api.prepare(provider, prefix, icons2);
2042
- params.forEach((item) => {
2043
- sendAPIQuery(provider, item, (data) => {
2044
- if (typeof data !== "object") {
2045
- item.icons.forEach((name) => {
2046
- storage2.missing.add(name);
2047
- });
2048
- } else {
2049
- try {
2050
- const parsed = addIconSet(
2051
- storage2,
2052
- data
2053
- );
2054
- if (!parsed.length) {
2055
- return;
2056
- }
2057
- const pending = storage2.pendingIcons;
2058
- if (pending) {
2059
- parsed.forEach((name) => {
2060
- pending.delete(name);
2061
- });
2062
- }
2063
- storeInBrowserStorage(storage2, data);
2064
- } catch (err) {
2065
- console.error(err);
2066
- }
2067
- }
2068
- loadedNewIcons(storage2);
2069
- });
2070
- });
2071
- });
2072
- }
2073
- }
2074
- var loadIcons = (icons, callback) => {
2075
- const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
2076
- const sortedIcons = sortIcons(cleanedIcons);
2077
- if (!sortedIcons.pending.length) {
2078
- let callCallback = true;
2079
- if (callback) {
2080
- setTimeout(() => {
2081
- if (callCallback) {
2082
- callback(
2083
- sortedIcons.loaded,
2084
- sortedIcons.missing,
2085
- sortedIcons.pending,
2086
- emptyCallback
2087
- );
2088
- }
2089
- });
2090
- }
2091
- return () => {
2092
- callCallback = false;
2093
- };
2094
- }
2095
- const newIcons = /* @__PURE__ */ Object.create(null);
2096
- const sources = [];
2097
- let lastProvider, lastPrefix;
2098
- sortedIcons.pending.forEach((icon) => {
2099
- const { provider, prefix } = icon;
2100
- if (prefix === lastPrefix && provider === lastProvider) {
2101
- return;
2102
- }
2103
- lastProvider = provider;
2104
- lastPrefix = prefix;
2105
- sources.push(getStorage(provider, prefix));
2106
- const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
2107
- if (!providerNewIcons[prefix]) {
2108
- providerNewIcons[prefix] = [];
2109
- }
2110
- });
2111
- sortedIcons.pending.forEach((icon) => {
2112
- const { provider, prefix, name } = icon;
2113
- const storage2 = getStorage(provider, prefix);
2114
- const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
2115
- if (!pendingQueue.has(name)) {
2116
- pendingQueue.add(name);
2117
- newIcons[provider][prefix].push(name);
2118
- }
2119
- });
2120
- sources.forEach((storage2) => {
2121
- const { provider, prefix } = storage2;
2122
- if (newIcons[provider][prefix].length) {
2123
- loadNewIcons(storage2, newIcons[provider][prefix]);
2124
- }
2125
- });
2126
- return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
2127
- };
2128
- function mergeCustomisations(defaults, item) {
2129
- const result = __spreadValues({}, defaults);
2130
- for (const key in item) {
2131
- const value = item[key];
2132
- const valueType = typeof value;
2133
- if (key in defaultIconSizeCustomisations) {
2134
- if (value === null || value && (valueType === "string" || valueType === "number")) {
2135
- result[key] = value;
2136
- }
2137
- } else if (valueType === typeof result[key]) {
2138
- result[key] = key === "rotate" ? value % 4 : value;
2139
- }
2140
- }
2141
- return result;
2142
- }
2143
- var separator = /[\s,]+/;
2144
- function flipFromString(custom, flip) {
2145
- flip.split(separator).forEach((str) => {
2146
- const value = str.trim();
2147
- switch (value) {
2148
- case "horizontal":
2149
- custom.hFlip = true;
2150
- break;
2151
- case "vertical":
2152
- custom.vFlip = true;
2153
- break;
2154
- }
2155
- });
2156
- }
2157
- function rotateFromString(value, defaultValue = 0) {
2158
- const units = value.replace(/^-?[0-9.]*/, "");
2159
- function cleanup(value2) {
2160
- while (value2 < 0) {
2161
- value2 += 4;
2162
- }
2163
- return value2 % 4;
2164
- }
2165
- if (units === "") {
2166
- const num = parseInt(value);
2167
- return isNaN(num) ? 0 : cleanup(num);
2168
- } else if (units !== value) {
2169
- let split = 0;
2170
- switch (units) {
2171
- case "%":
2172
- split = 25;
2173
- break;
2174
- case "deg":
2175
- split = 90;
2176
- }
2177
- if (split) {
2178
- let num = parseFloat(value.slice(0, value.length - units.length));
2179
- if (isNaN(num)) {
2180
- return 0;
2181
- }
2182
- num = num / split;
2183
- return num % 1 === 0 ? cleanup(num) : 0;
2184
- }
2185
- }
2186
- return defaultValue;
2187
- }
2188
- function iconToHTML(body, attributes) {
2189
- let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
2190
- for (const attr in attributes) {
2191
- renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
2192
- }
2193
- return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
2194
- }
2195
- function encodeSVGforURL(svg) {
2196
- return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
2197
- }
2198
- function svgToData(svg) {
2199
- return "data:image/svg+xml," + encodeSVGforURL(svg);
2200
- }
2201
- function svgToURL(svg) {
2202
- return 'url("' + svgToData(svg) + '")';
2203
- }
2204
- var policy;
2205
- function createPolicy() {
2206
- try {
2207
- policy = window.trustedTypes.createPolicy("iconify", {
2208
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
2209
- createHTML: (s) => s
2210
- });
2211
- } catch (err) {
2212
- policy = null;
2213
- }
2214
- }
2215
- function cleanUpInnerHTML(html) {
2216
- if (policy === void 0) {
2217
- createPolicy();
2218
- }
2219
- return policy ? policy.createHTML(html) : html;
2220
- }
2221
- var defaultExtendedIconCustomisations = __spreadProps(__spreadValues({}, defaultIconCustomisations), {
2222
- inline: false
2223
- });
2224
- var svgDefaults = {
2225
- "xmlns": "http://www.w3.org/2000/svg",
2226
- "xmlnsXlink": "http://www.w3.org/1999/xlink",
2227
- "aria-hidden": true,
2228
- "role": "img"
2229
- };
2230
- var commonProps = {
2231
- display: "inline-block"
2232
- };
2233
- var monotoneProps = {
2234
- backgroundColor: "currentColor"
2235
- };
2236
- var coloredProps = {
2237
- backgroundColor: "transparent"
2238
- };
2239
- var propsToAdd = {
2240
- Image: "var(--svg)",
2241
- Repeat: "no-repeat",
2242
- Size: "100% 100%"
2243
- };
2244
- var propsToAddTo = {
2245
- WebkitMask: monotoneProps,
2246
- mask: monotoneProps,
2247
- background: coloredProps
2248
- };
2249
- for (const prefix in propsToAddTo) {
2250
- const list = propsToAddTo[prefix];
2251
- for (const prop in propsToAdd) {
2252
- list[prefix + prop] = propsToAdd[prop];
2253
- }
2254
- }
2255
- var inlineDefaults = __spreadProps(__spreadValues({}, defaultExtendedIconCustomisations), {
2256
- inline: true
2257
- });
2258
- function fixSize(value) {
2259
- return value + (value.match(/^[-0-9.]+$/) ? "px" : "");
2260
- }
2261
- var render = (icon, props, name) => {
2262
- const defaultProps = props.inline ? inlineDefaults : defaultExtendedIconCustomisations;
2263
- const customisations = mergeCustomisations(defaultProps, props);
2264
- const mode = props.mode || "svg";
2265
- const style = {};
2266
- const customStyle = props.style || {};
2267
- const componentProps = __spreadValues({}, mode === "svg" ? svgDefaults : {});
2268
- if (name) {
2269
- const iconName = stringToIcon(name, false, true);
2270
- if (iconName) {
2271
- const classNames = ["iconify"];
2272
- const props2 = [
2273
- "provider",
2274
- "prefix"
2275
- ];
2276
- for (const prop of props2) {
2277
- if (iconName[prop]) {
2278
- classNames.push("iconify--" + iconName[prop]);
2279
- }
2280
- }
2281
- componentProps.className = classNames.join(" ");
2282
- }
2283
- }
2284
- for (let key in props) {
2285
- const value = props[key];
2286
- if (value === void 0) {
2287
- continue;
2288
- }
2289
- switch (key) {
2290
- case "icon":
2291
- case "style":
2292
- case "children":
2293
- case "onLoad":
2294
- case "mode":
2295
- case "ssr":
2296
- break;
2297
- case "_ref":
2298
- componentProps.ref = value;
2299
- break;
2300
- case "className":
2301
- componentProps[key] = (componentProps[key] ? componentProps[key] + " " : "") + value;
2302
- break;
2303
- case "inline":
2304
- case "hFlip":
2305
- case "vFlip":
2306
- customisations[key] = value === true || value === "true" || value === 1;
2307
- break;
2308
- case "flip":
2309
- if (typeof value === "string") {
2310
- flipFromString(customisations, value);
2311
- }
2312
- break;
2313
- case "color":
2314
- style.color = value;
2315
- break;
2316
- case "rotate":
2317
- if (typeof value === "string") {
2318
- customisations[key] = rotateFromString(value);
2319
- } else if (typeof value === "number") {
2320
- customisations[key] = value;
2321
- }
2322
- break;
2323
- case "ariaHidden":
2324
- case "aria-hidden":
2325
- if (value !== true && value !== "true") {
2326
- delete componentProps["aria-hidden"];
2327
- }
2328
- break;
2329
- default:
2330
- if (defaultProps[key] === void 0) {
2331
- componentProps[key] = value;
2332
- }
2333
- }
2334
- }
2335
- const item = iconToSVG(icon, customisations);
2336
- const renderAttribs = item.attributes;
2337
- if (customisations.inline) {
2338
- style.verticalAlign = "-0.125em";
2339
- }
2340
- if (mode === "svg") {
2341
- componentProps.style = __spreadValues(__spreadValues({}, style), customStyle);
2342
- Object.assign(componentProps, renderAttribs);
2343
- let localCounter = 0;
2344
- let id = props.id;
2345
- if (typeof id === "string") {
2346
- id = id.replace(/-/g, "_");
2347
- }
2348
- componentProps.dangerouslySetInnerHTML = {
2349
- __html: cleanUpInnerHTML(replaceIDs(item.body, id ? () => id + "ID" + localCounter++ : "iconifyReact"))
2350
- };
2351
- return createElement("svg", componentProps);
2352
- }
2353
- const { body, width, height } = icon;
2354
- const useMask = mode === "mask" || (mode === "bg" ? false : body.indexOf("currentColor") !== -1);
2355
- const html = iconToHTML(body, __spreadProps(__spreadValues({}, renderAttribs), {
2356
- width: width + "",
2357
- height: height + ""
2358
- }));
2359
- componentProps.style = __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, style), {
2360
- "--svg": svgToURL(html),
2361
- "width": fixSize(renderAttribs.width),
2362
- "height": fixSize(renderAttribs.height)
2363
- }), commonProps), useMask ? monotoneProps : coloredProps), customStyle);
2364
- return createElement("span", componentProps);
2365
- };
2366
- allowSimpleNames(true);
2367
- setAPIModule("", fetchAPIModule);
2368
- if (typeof document !== "undefined" && typeof window !== "undefined") {
2369
- initBrowserStorage();
2370
- const _window2 = window;
2371
- if (_window2.IconifyPreload !== void 0) {
2372
- const preload = _window2.IconifyPreload;
2373
- const err = "Invalid IconifyPreload syntax.";
2374
- if (typeof preload === "object" && preload !== null) {
2375
- (preload instanceof Array ? preload : [preload]).forEach((item) => {
2376
- try {
2377
- if (
2378
- // Check if item is an object and not null/array
2379
- typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
2380
- typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
2381
- !addCollection(item)
2382
- ) {
2383
- console.error(err);
2384
- }
2385
- } catch (e) {
2386
- console.error(err);
2387
- }
2388
- });
2389
- }
2390
- }
2391
- if (_window2.IconifyProviders !== void 0) {
2392
- const providers = _window2.IconifyProviders;
2393
- if (typeof providers === "object" && providers !== null) {
2394
- for (let key in providers) {
2395
- const err = "IconifyProviders[" + key + "] is invalid.";
2396
- try {
2397
- const value = providers[key];
2398
- if (typeof value !== "object" || !value || value.resources === void 0) {
2399
- continue;
2400
- }
2401
- if (!addAPIProvider(key, value)) {
2402
- console.error(err);
2403
- }
2404
- } catch (e) {
2405
- console.error(err);
2406
- }
2407
- }
2408
- }
2409
- }
2410
- }
2411
- function IconComponent(props) {
2412
- const [mounted, setMounted] = useState(!!props.ssr);
2413
- const [abort, setAbort] = useState({});
2414
- function getInitialState(mounted2) {
2415
- if (mounted2) {
2416
- const name2 = props.icon;
2417
- if (typeof name2 === "object") {
2418
- return {
2419
- name: "",
2420
- data: name2
2421
- };
2422
- }
2423
- const data2 = getIconData(name2);
2424
- if (data2) {
2425
- return {
2426
- name: name2,
2427
- data: data2
2428
- };
2429
- }
2430
- }
2431
- return {
2432
- name: ""
2433
- };
2434
- }
2435
- const [state, setState] = useState(getInitialState(!!props.ssr));
2436
- function cleanup() {
2437
- const callback = abort.callback;
2438
- if (callback) {
2439
- callback();
2440
- setAbort({});
2441
- }
2442
- }
2443
- function changeState(newState) {
2444
- if (JSON.stringify(state) !== JSON.stringify(newState)) {
2445
- cleanup();
2446
- setState(newState);
2447
- return true;
2448
- }
2449
- }
2450
- function updateState() {
2451
- var _a;
2452
- const name2 = props.icon;
2453
- if (typeof name2 === "object") {
2454
- changeState({
2455
- name: "",
2456
- data: name2
2457
- });
2458
- return;
2459
- }
2460
- const data2 = getIconData(name2);
2461
- if (changeState({
2462
- name: name2,
2463
- data: data2
2464
- })) {
2465
- if (data2 === void 0) {
2466
- const callback = loadIcons([name2], updateState);
2467
- setAbort({
2468
- callback
2469
- });
2470
- } else if (data2) {
2471
- (_a = props.onLoad) === null || _a === void 0 ? void 0 : _a.call(props, name2);
2472
- }
2473
- }
2474
- }
2475
- useEffect(() => {
2476
- setMounted(true);
2477
- return cleanup;
2478
- }, []);
2479
- useEffect(() => {
2480
- if (mounted) {
2481
- updateState();
2482
- }
2483
- }, [props.icon, mounted]);
2484
- const { name, data } = state;
2485
- if (!data) {
2486
- return props.children ? props.children : createElement("span", {});
2487
- }
2488
- return render(__spreadValues(__spreadValues({}, defaultIconProps), data), props, name);
2489
- }
2490
- var Icon = forwardRef((props, ref) => IconComponent(__spreadProps(__spreadValues({}, props), {
2491
- _ref: ref
2492
- })));
2493
- forwardRef((props, ref) => IconComponent(__spreadProps(__spreadValues({
2494
- inline: true
2495
- }, props), {
2496
- _ref: ref
2497
- })));
2498
-
2499
- // module/Wallet/walletPluginStore.tsx
2500
753
  var defaultRPCList = [
2501
754
  { name: "https://babel-api.fastblocks.io", latency: 0, height: 0, custom: false },
2502
755
  { name: "https://babel-api.mainnet.iotex.one", latency: 0, height: 0 },
@@ -3315,6 +1568,8 @@ var WalletConfigStore = class {
3315
1568
  });
3316
1569
  }
3317
1570
  };
1571
+
1572
+ // module/Wallet/index.tsx
3318
1573
  var WalletStore = class _WalletStore {
3319
1574
  constructor(args) {
3320
1575
  this.sid = "wallet";
@@ -3385,6 +1640,7 @@ var WalletStore = class _WalletStore {
3385
1640
  this.set({
3386
1641
  isConnect: isConnected,
3387
1642
  account: address,
1643
+ // @ts-ignore
3388
1644
  chain
3389
1645
  });
3390
1646
  walletConfigStore.set({
@@ -3402,7 +1658,6 @@ var WalletStore = class _WalletStore {
3402
1658
  if (!address) {
3403
1659
  if (walletConfigStore.compatibleMode) {
3404
1660
  console.log("%c[walletStore]: walletStore plugin is running in compatible mode", "color: yellow; font-weight: bold;");
3405
- connect(walletConfigStore.rainbowKitConfig, { connector: injected() });
3406
1661
  }
3407
1662
  }
3408
1663
  }, []);
@@ -3672,7 +1927,8 @@ var WalletProvider = ({
3672
1927
  theme,
3673
1928
  appName,
3674
1929
  supportedChains,
3675
- compatibleMode = true
1930
+ compatibleMode = true,
1931
+ reconnectOnMount = true
3676
1932
  }) => {
3677
1933
  const walletConfig = RootStore.Get(WalletConfigStore, { args: { supportedChains: supportedChains != null ? supportedChains : [iotex] } });
3678
1934
  const [config, setConfig] = useState(walletConfig.rainbowKitConfig);
@@ -3692,7 +1948,7 @@ var WalletProvider = ({
3692
1948
  }, [appName, compatibleMode]);
3693
1949
  return (
3694
1950
  //@ts-ignore
3695
- /* @__PURE__ */ React5.createElement(WagmiProvider, { config, reconnectOnMount: walletConfig.reconnectOnMount }, /* @__PURE__ */ React5.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React5.createElement(RainbowKitProvider, { locale: "en", theme: theme == "dark" ? darkTheme() : lightTheme() }, children, /* @__PURE__ */ React5.createElement(WalletConnect, null))))
1951
+ /* @__PURE__ */ React5.createElement(WagmiProvider, { config, reconnectOnMount }, /* @__PURE__ */ React5.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React5.createElement(RainbowKitProvider, { locale: "en", theme: theme == "dark" ? darkTheme() : lightTheme() }, children, /* @__PURE__ */ React5.createElement(WalletConnect, null))))
3696
1952
  );
3697
1953
  };
3698
1954
  var WalletConnect = () => {