@dappworks/kit 0.4.199 → 0.4.201

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