@xyo-network/react-connected-accounts 2.77.0-rc.1 → 2.77.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/dist/browser/classes/EnabledWallets.d.cts +0 -9
  2. package/dist/browser/classes/EnabledWallets.d.cts.map +1 -1
  3. package/dist/browser/classes/EnabledWallets.d.mts +0 -9
  4. package/dist/browser/classes/EnabledWallets.d.mts.map +1 -1
  5. package/dist/browser/classes/EnabledWallets.d.ts +0 -9
  6. package/dist/browser/classes/EnabledWallets.d.ts.map +1 -1
  7. package/dist/browser/hooks/useEnabledWallets.d.cts +0 -6
  8. package/dist/browser/hooks/useEnabledWallets.d.cts.map +1 -1
  9. package/dist/browser/hooks/useEnabledWallets.d.mts +0 -6
  10. package/dist/browser/hooks/useEnabledWallets.d.mts.map +1 -1
  11. package/dist/browser/hooks/useEnabledWallets.d.ts +0 -6
  12. package/dist/browser/hooks/useEnabledWallets.d.ts.map +1 -1
  13. package/dist/browser/index.cjs +1 -577
  14. package/dist/browser/index.cjs.map +1 -1
  15. package/dist/browser/index.js +1 -544
  16. package/dist/browser/index.js.map +1 -1
  17. package/dist/neutral/classes/EnabledWallets.d.cts +0 -9
  18. package/dist/neutral/classes/EnabledWallets.d.cts.map +1 -1
  19. package/dist/neutral/classes/EnabledWallets.d.mts +0 -9
  20. package/dist/neutral/classes/EnabledWallets.d.mts.map +1 -1
  21. package/dist/neutral/classes/EnabledWallets.d.ts +0 -9
  22. package/dist/neutral/classes/EnabledWallets.d.ts.map +1 -1
  23. package/dist/neutral/hooks/useEnabledWallets.d.cts +0 -6
  24. package/dist/neutral/hooks/useEnabledWallets.d.cts.map +1 -1
  25. package/dist/neutral/hooks/useEnabledWallets.d.mts +0 -6
  26. package/dist/neutral/hooks/useEnabledWallets.d.mts.map +1 -1
  27. package/dist/neutral/hooks/useEnabledWallets.d.ts +0 -6
  28. package/dist/neutral/hooks/useEnabledWallets.d.ts.map +1 -1
  29. package/dist/neutral/index.cjs +1 -577
  30. package/dist/neutral/index.cjs.map +1 -1
  31. package/dist/neutral/index.js +1 -544
  32. package/dist/neutral/index.js.map +1 -1
  33. package/dist/node/classes/EnabledWallets.d.cts +0 -9
  34. package/dist/node/classes/EnabledWallets.d.cts.map +1 -1
  35. package/dist/node/classes/EnabledWallets.d.mts +0 -9
  36. package/dist/node/classes/EnabledWallets.d.mts.map +1 -1
  37. package/dist/node/classes/EnabledWallets.d.ts +0 -9
  38. package/dist/node/classes/EnabledWallets.d.ts.map +1 -1
  39. package/dist/node/hooks/useEnabledWallets.d.cts +0 -6
  40. package/dist/node/hooks/useEnabledWallets.d.cts.map +1 -1
  41. package/dist/node/hooks/useEnabledWallets.d.mts +0 -6
  42. package/dist/node/hooks/useEnabledWallets.d.mts.map +1 -1
  43. package/dist/node/hooks/useEnabledWallets.d.ts +0 -6
  44. package/dist/node/hooks/useEnabledWallets.d.ts.map +1 -1
  45. package/dist/node/index.cjs +1 -608
  46. package/dist/node/index.cjs.map +1 -1
  47. package/dist/node/index.js +1 -555
  48. package/dist/node/index.js.map +1 -1
  49. package/package.json +5 -6
@@ -1,609 +1,2 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- CheckboxFormControl: () => CheckboxFormControl,
34
- ConnectWalletDialog: () => ConnectWalletDialog,
35
- ConnectedAccountsFlexbox: () => ConnectedAccountsFlexbox,
36
- ConnectedWalletState: () => ConnectedWalletState,
37
- ConnectedWalletTableCells: () => ConnectedWalletTableCells,
38
- ConnectedWalletsAccountsTableCell: () => ConnectedWalletsAccountsTableCell,
39
- ConnectedWalletsActionsTableCell: () => ConnectedWalletsActionsTableCell,
40
- ConnectedWalletsChainNameTableCell: () => ConnectedWalletsChainNameTableCell,
41
- ConnectedWalletsTable: () => ConnectedWalletsTable,
42
- ConnectedWalletsWalletTableCell: () => ConnectedWalletsWalletTableCell,
43
- EnabledEthWalletConnections: () => EnabledEthWalletConnections,
44
- RevokeWalletConnectionDialog: () => RevokeWalletConnectionDialog,
45
- WalletConnectionsTableRow: () => WalletConnectionsTableRow,
46
- useActiveProviderDialogState: () => useActiveProviderDialogState,
47
- useDetectedWallets: () => useDetectedWallets,
48
- useEnabledWallets: () => useEnabledWallets,
49
- useEnabledWalletsInner: () => useEnabledWalletsInner
50
- });
51
- module.exports = __toCommonJS(src_exports);
52
-
53
- // src/classes/EnabledWallets.ts
54
- var DEFAULT_LOCAL_STORAGE_KEY = "XYO|EnabledWallets";
55
- var EnabledEthWalletConnections = class {
56
- // control whether or not enabled/disabled preferences are persisted (i.e. in localStorage)
57
- persistPreferences = true;
58
- // Map of wallet names and their enabled/disabled state
59
- enabledWallets = {};
60
- // Map of wallet names, their enabled/disabled state, and their wallet class
61
- ethWalletsState = {};
62
- // list of listeners that want to be notified on wallet changes
63
- listeners = [];
64
- // key to use in localStorage when persisting preferences
65
- localStorageKey = DEFAULT_LOCAL_STORAGE_KEY;
66
- constructor(localStorageKey = DEFAULT_LOCAL_STORAGE_KEY) {
67
- this.localStorageKey = localStorageKey;
68
- this.reviveSettings();
69
- }
70
- get wallets() {
71
- return this.ethWalletsState;
72
- }
73
- disableWallet(rdns) {
74
- this.toggleEnabledWallet(rdns, false);
75
- }
76
- enableWallet(rdns) {
77
- this.toggleEnabledWallet(rdns, true);
78
- }
79
- /**
80
- * Given a new set of wallets, set their enabled state based off previous preferences
81
- */
82
- resetWallets(wallets) {
83
- const newWallets = {};
84
- const addWallet = ([walletName, wallet]) => {
85
- newWallets[walletName] = {
86
- // preserve the existing enabled state
87
- enabled: walletName in this.enabledWallets ? this.enabledWallets[walletName] : true,
88
- wallet
89
- };
90
- };
91
- Object.entries(wallets).forEach(addWallet.bind(this));
92
- this.ethWalletsState = newWallets;
93
- this.emitChange();
94
- }
95
- subscribe(listener) {
96
- this.listeners = [...this.listeners, listener];
97
- return () => {
98
- this.listeners = this.listeners.filter((existingListener) => existingListener !== listener);
99
- };
100
- }
101
- toggleEnabledWallet(rdns, enabled) {
102
- if (rdns && this.ethWalletsState[rdns]) {
103
- this.ethWalletsState[rdns].enabled = enabled;
104
- this.ethWalletsState = { ...this.ethWalletsState };
105
- this.emitChange();
106
- }
107
- }
108
- emitChange() {
109
- for (const listener of this.listeners) {
110
- listener();
111
- }
112
- this.persistSettings();
113
- }
114
- isPersistance(method) {
115
- if (this.persistPreferences) {
116
- method();
117
- }
118
- }
119
- persistSettings() {
120
- this.isPersistance(() => {
121
- const enabledWallets = Object.entries(this.ethWalletsState).reduce((acc, [rdns, { enabled }]) => {
122
- acc[rdns] = enabled;
123
- return acc;
124
- }, {});
125
- localStorage.setItem(this.localStorageKey, JSON.stringify(enabledWallets));
126
- });
127
- }
128
- reviveSettings() {
129
- this.isPersistance(() => {
130
- const existingEntries = localStorage.getItem(this.localStorageKey);
131
- try {
132
- const entries = existingEntries ? JSON.parse(existingEntries) : {};
133
- this.enabledWallets = entries;
134
- } catch (e) {
135
- console.warn(`Error parsing saved enabled wallet entries: ${e.message}`);
136
- }
137
- });
138
- }
139
- };
140
-
141
- // src/components/ConnectedAccountsFlexbox.tsx
142
- var import_material13 = require("@mui/material");
143
- var import_react_flexbox6 = require("@xylabs/react-flexbox");
144
- var import_react7 = require("react");
145
-
146
- // src/hooks/useDetectWallets.tsx
147
- var import_react_crypto = require("@xylabs/react-crypto");
148
- var import_react = require("react");
149
- var sortWallets = (wallets) => (
150
- // eslint-disable-next-line unicorn/no-array-reduce
151
- Object.values(wallets).reduce((acc, wallet) => {
152
- wallet.allowedAccounts.length > 0 ? acc.unshift(wallet) : acc.push(wallet);
153
- return acc;
154
- }, [])
155
- );
156
- var useDetectedWallets = () => {
157
- const wallets = (0, import_react_crypto.useWalletDiscovery)();
158
- const [refresh, setRefresh] = (0, import_react.useState)(0);
159
- const [sortedWallets, setSortedWallets] = (0, import_react.useState)([]);
160
- (0, import_react.useEffect)(() => {
161
- setSortedWallets(sortWallets(wallets));
162
- }, [wallets, refresh]);
163
- (0, import_react.useEffect)(() => {
164
- const listener = () => {
165
- setRefresh((refresh2) => refresh2 + 1);
166
- };
167
- window.addEventListener(import_react_crypto.AccountsChangedEventName, listener);
168
- return () => {
169
- window.removeEventListener(import_react_crypto.AccountsChangedEventName, listener);
170
- };
171
- }, [wallets]);
172
- const totalConnectedAccounts = (0, import_react.useMemo)(
173
- () => Object.values(sortedWallets).reduce((acc, wallet) => acc + wallet.allowedAccounts.length, 0),
174
- [sortedWallets]
175
- );
176
- return { sortedWallets, totalConnectedAccounts };
177
- };
178
-
179
- // src/hooks/useEnabledWallets.tsx
180
- var import_react_crypto2 = require("@xylabs/react-crypto");
181
- var import_react2 = require("react");
182
- var enabledEthWallets;
183
- var useEnabledWalletsInner = (enabledWalletsRdns) => {
184
- const discoveredWallets = (0, import_react_crypto2.useWalletDiscovery)();
185
- const wallets = (0, import_react2.useMemo)(() => {
186
- if (enabledEthWallets === void 0)
187
- enabledEthWallets = new EnabledEthWalletConnections();
188
- enabledEthWallets.resetWallets(discoveredWallets);
189
- for (const [rdns, enabled] of Object.entries(enabledWalletsRdns ?? {}))
190
- enabledEthWallets == null ? void 0 : enabledEthWallets.toggleEnabledWallet(rdns, enabled);
191
- return enabledEthWallets;
192
- }, [discoveredWallets, enabledWalletsRdns]);
193
- return (0, import_react2.useSyncExternalStore)(wallets.subscribe.bind(wallets), () => wallets.wallets);
194
- };
195
- var useEnabledWallets = (enabledWalletsRdns) => {
196
- const wallets = useEnabledWalletsInner(enabledWalletsRdns);
197
- const enabledWallets = (0, import_react2.useMemo)(
198
- () => (
199
- // eslint-disable-next-line unicorn/no-array-reduce
200
- Object.entries(wallets).reduce((acc, [walletName, wallet]) => {
201
- if (wallet.enabled)
202
- acc[walletName] = wallet;
203
- return acc;
204
- }, {})
205
- ),
206
- [wallets]
207
- );
208
- return {
209
- disableWallet: enabledEthWallets == null ? void 0 : enabledEthWallets.disableWallet.bind(enabledEthWallets),
210
- enableWallet: enabledEthWallets == null ? void 0 : enabledEthWallets.enableWallet.bind(enabledEthWallets),
211
- enabledWallets,
212
- wallets
213
- };
214
- };
215
-
216
- // src/components/wallet/dialogs/connect/CheckboxFormControl.tsx
217
- var import_material = require("@mui/material");
218
- var import_jsx_runtime = require("react/jsx-runtime");
219
- var CheckboxFormControl = ({ onCheckChanged, ...props }) => {
220
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.FormControl, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.FormLabel, { children: [
221
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Checkbox, { onChange: (_, checked) => onCheckChanged == null ? void 0 : onCheckChanged(checked) }),
222
- "Do not show this again."
223
- ] }) });
224
- };
225
-
226
- // src/components/wallet/dialogs/connect/Dialog.tsx
227
- var import_material4 = require("@mui/material");
228
-
229
- // src/components/wallet/dialogs/connect/LinkedProvidersFlexbox.tsx
230
- var import_icons_material = require("@mui/icons-material");
231
- var import_material2 = require("@mui/material");
232
- var import_react_crypto3 = require("@xylabs/react-crypto");
233
- var import_react_flexbox = require("@xylabs/react-flexbox");
234
-
235
- // src/img/index.ts
236
- var import_xyo_color_logo = __toESM(require("./xyo-color-logo-LHR2SMEM.svg"), 1);
237
- var import_xyo_color_logo_text_only = __toESM(require("./xyo-color-logo-text-only-QPAW5BSQ.svg"), 1);
238
-
239
- // src/components/wallet/dialogs/connect/LinkedProvidersFlexbox.tsx
240
- var import_jsx_runtime2 = require("react/jsx-runtime");
241
- var LinkedProvidersFlexbox = ({ icon, providerName, ...props }) => {
242
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_flexbox.FlexRow, { gap: 4, justifyContent: "space-evenly", ...props, children: [
243
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_flexbox.FlexCol, { gap: 0.5, children: [
244
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { alt: "XYO Logo", src: import_xyo_color_logo.default, style: { height: "48px" } }),
245
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.Typography, { variant: "subtitle1", children: "XYO App" })
246
- ] }),
247
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SyncAlt, { fontSize: "large" }),
248
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_flexbox.FlexCol, { gap: 0.5, children: [
249
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_crypto3.ConstrainedImage, { constrainedValue: "48px", src: icon, alt: providerName, style: { height: "48px", maxWidth: "48px" } }),
250
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.Typography, { variant: "subtitle1", children: providerName })
251
- ] })
252
- ] });
253
- };
254
-
255
- // src/components/wallet/dialogs/connect/Permissions.tsx
256
- var import_material3 = require("@mui/material");
257
- var import_react_flexbox2 = require("@xylabs/react-flexbox");
258
- var import_jsx_runtime3 = require("react/jsx-runtime");
259
- var WalletPermissionsFlexbox = (props) => {
260
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_flexbox2.FlexCol, { gap: 4, ...props, children: [
261
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Typography, { fontWeight: "bold", sx: { textAlign: "center" }, children: "This will allow XYO to:" }),
262
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("ul", { children: [
263
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("li", { children: "View your wallet account(s) and address(es)" }),
264
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("li", { children: "Read-only access to browse the public blockchain(s) you select" })
265
- ] }),
266
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_material3.Typography, { variant: "subtitle1", sx: { textAlign: "center" }, children: [
267
- "You control what accounts to share and what blockchains to view. You can see or revoke access via your wallet's settings at anytime. View more on XYO's sovereign data philosophy",
268
- " ",
269
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
270
- import_material3.Link,
271
- {
272
- href: "https://cointelegraph.com/innovation-circle/decentralization-and-sovereignty-debunking-our-approach-to-digital-sovereignty",
273
- sx: { fontWeight: "bold" },
274
- target: "_blank",
275
- children: "here"
276
- }
277
- ),
278
- "."
279
- ] })
280
- ] });
281
- };
282
-
283
- // src/components/wallet/dialogs/connect/Dialog.tsx
284
- var import_jsx_runtime4 = require("react/jsx-runtime");
285
- var ConnectWalletDialog = ({ activeProvider, onIgnoreConnectDialog, ...props }) => {
286
- const { icon, providerName } = activeProvider ?? {};
287
- const onConnect = async () => {
288
- var _a, _b;
289
- try {
290
- await ((_a = activeProvider == null ? void 0 : activeProvider.connectWallet) == null ? void 0 : _a.call(activeProvider));
291
- (_b = props.onClose) == null ? void 0 : _b.call(props, {}, "escapeKeyDown");
292
- } catch (e) {
293
- console.warn(`Error connecting to wallet: ${e.message}`);
294
- }
295
- };
296
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material4.Dialog, { PaperProps: { sx: { display: "flex", gap: 4 } }, ...props, children: [
297
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material4.DialogTitle, { sx: { textAlign: "center" }, children: "XYO Wants To Access The Blockchain on Your Behalf" }),
298
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material4.DialogContent, { sx: { display: "flex", flexDirection: "column", gap: 4 }, children: [
299
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LinkedProvidersFlexbox, { icon, providerName }),
300
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WalletPermissionsFlexbox, {}),
301
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckboxFormControl, { onCheckChanged: onIgnoreConnectDialog })
302
- ] }),
303
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material4.DialogActions, { children: [
304
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material4.Button, { variant: "outlined", onClick: () => {
305
- var _a;
306
- return (_a = props.onClose) == null ? void 0 : _a.call(props, {}, "escapeKeyDown");
307
- }, children: "Close" }),
308
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material4.Button, { variant: "contained", onClick: onConnect, children: "Connect" })
309
- ] })
310
- ] });
311
- };
312
-
313
- // src/components/wallet/dialogs/revoke/Dialog.tsx
314
- var import_material5 = require("@mui/material");
315
- var import_react_crypto4 = require("@xylabs/react-crypto");
316
- var import_react_flexbox3 = require("@xylabs/react-flexbox");
317
- var import_jsx_runtime5 = require("react/jsx-runtime");
318
- var RevokeWalletConnectionDialog = ({ activeProvider, ...props }) => {
319
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_material5.Dialog, { ...props, children: [
320
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_flexbox3.FlexRow, { gap: 2, justifyContent: "start", pl: 2, children: [
321
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_crypto4.ConstrainedImage, { src: activeProvider == null ? void 0 : activeProvider.icon, constrainedValue: "24px" }),
322
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_material5.DialogTitle, { sx: { pl: 0 }, children: [
323
- "Revoke ",
324
- activeProvider == null ? void 0 : activeProvider.providerName,
325
- " Access"
326
- ] })
327
- ] }),
328
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_material5.DialogContent, { children: [
329
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_material5.Typography, { children: [
330
- "Revoking access to your wallet must be done from the wallet's browser extension. Wallets grant access to specific domains please consult ",
331
- activeProvider == null ? void 0 : activeProvider.providerName,
332
- "'s documentation on how to revoke access to this website:"
333
- ] }),
334
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.Typography, { children: window.location.origin })
335
- ] }),
336
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.DialogActions, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.Button, { variant: "contained", onClick: () => {
337
- var _a;
338
- return (_a = props.onClose) == null ? void 0 : _a.call(props, {}, "escapeKeyDown");
339
- }, children: "Close" }) })
340
- ] });
341
- };
342
-
343
- // src/components/wallet/table/cells/Accounts.tsx
344
- var import_material6 = require("@mui/material");
345
- var import_jsx_runtime6 = require("react/jsx-runtime");
346
- var ConnectedWalletsAccountsTableCell = ({
347
- additionalAccounts,
348
- currentAccount,
349
- totalAccounts,
350
- tableCellProps
351
- }) => {
352
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material6.TableCell, { ...tableCellProps, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
353
- import_material6.Tooltip,
354
- {
355
- sx: { cursor: totalAccounts > 0 ? "pointer" : "auto" },
356
- title: [...currentAccount ?? [], ...additionalAccounts ?? []].map((address, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: address }, index)),
357
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material6.Typography, { children: totalAccounts })
358
- }
359
- ) });
360
- };
361
-
362
- // src/components/wallet/table/cells/Actions.tsx
363
- var import_icons_material2 = require("@mui/icons-material");
364
- var import_material7 = require("@mui/material");
365
- var import_react_flexbox4 = require("@xylabs/react-flexbox");
366
- var import_jsx_runtime7 = require("react/jsx-runtime");
367
- var ConnectedWalletsActionsTableCell = ({ connected, onConnect, onRevoke, tableCellProps }) => {
368
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material7.TableCell, { ...tableCellProps, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_flexbox4.FlexRow, { gap: 2, justifyContent: "start", children: [
369
- connected ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_material7.Typography, { sx: { display: "inline-flex", gap: 0.5 }, children: [
370
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons_material2.Check, {}),
371
- "Connected"
372
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material7.Button, { variant: "contained", onClick: onConnect, children: "Connect" }),
373
- connected ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material7.IconButton, { onClick: onRevoke, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons_material2.InfoOutlined, {}) }) : null
374
- ] }) });
375
- };
376
-
377
- // src/components/wallet/table/cells/ChainName.tsx
378
- var import_material8 = require("@mui/material");
379
- var import_jsx_runtime8 = require("react/jsx-runtime");
380
- var ConnectedWalletsChainNameTableCell = ({ chainName, tableCellProps }) => {
381
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material8.TableCell, { ...tableCellProps, children: chainName });
382
- };
383
-
384
- // src/components/wallet/table/cells/State.tsx
385
- var import_material9 = require("@mui/material");
386
- var import_react3 = require("react");
387
- var import_jsx_runtime9 = require("react/jsx-runtime");
388
- var ConnectedWalletState = ({ connected, walletRdns, tableCellProps }) => {
389
- const { disableWallet, enableWallet, wallets } = useEnabledWallets();
390
- const enabled = (0, import_react3.useMemo)(() => walletRdns ? wallets[walletRdns].enabled : false, [wallets, walletRdns]);
391
- const handleClick = (event) => {
392
- var _a;
393
- const checked = (_a = event.target) == null ? void 0 : _a.checked;
394
- if (walletRdns) {
395
- checked ? enableWallet == null ? void 0 : enableWallet(walletRdns) : disableWallet == null ? void 0 : disableWallet(walletRdns);
396
- }
397
- };
398
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_material9.TableCell, { ...tableCellProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_material9.Switch, { disabled: !connected, checked: connected && enabled, onChange: handleClick }) });
399
- };
400
-
401
- // src/components/wallet/table/cells/Wallet.tsx
402
- var import_material10 = require("@mui/material");
403
- var import_react_crypto5 = require("@xylabs/react-crypto");
404
- var import_react_flexbox5 = require("@xylabs/react-flexbox");
405
- var import_jsx_runtime10 = require("react/jsx-runtime");
406
- var ConnectedWalletsWalletTableCell = ({ icon, walletName, tableCellProps }) => {
407
- const theme = (0, import_material10.useTheme)();
408
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material10.TableCell, { ...tableCellProps, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_flexbox5.FlexRow, { gap: 2, justifyContent: "start", children: [
409
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_crypto5.ConstrainedImage, { constrainedValue: theme.spacing(4), src: icon }),
410
- walletName
411
- ] }) });
412
- };
413
-
414
- // src/components/wallet/table/cells/Cells.tsx
415
- var ConnectedWalletTableCells = [
416
- ConnectedWalletsWalletTableCell,
417
- ConnectedWalletsChainNameTableCell,
418
- ConnectedWalletsAccountsTableCell,
419
- ConnectedWalletsActionsTableCell,
420
- ConnectedWalletState
421
- ];
422
-
423
- // src/components/wallet/table/ConnectedWalletsTable.tsx
424
- var import_material12 = require("@mui/material");
425
- var import_react6 = require("react");
426
-
427
- // src/components/wallet/lib/TableHeadData.ts
428
- var WalletsTableHeadCells = [
429
- {
430
- disablePadding: false,
431
- id: "wallet",
432
- label: "Wallet",
433
- numeric: false,
434
- showOnMobile: true
435
- },
436
- {
437
- disablePadding: false,
438
- id: "chain",
439
- label: "Chain",
440
- numeric: false,
441
- showOnMobile: true
442
- },
443
- {
444
- disablePadding: false,
445
- id: "accounts",
446
- label: "Accounts",
447
- numeric: true,
448
- showOnMobile: true
449
- },
450
- {
451
- disablePadding: false,
452
- id: "actions",
453
- label: "Actions",
454
- numeric: false,
455
- showOnMobile: true
456
- },
457
- {
458
- disablePadding: false,
459
- id: "enabled",
460
- label: "Enabled",
461
- numeric: false,
462
- showOnMobile: true
463
- }
464
- ];
465
-
466
- // src/components/wallet/table/ConnectedWalletsTableRow.tsx
467
- var import_material11 = require("@mui/material");
468
- var import_react_crypto6 = require("@xylabs/react-crypto");
469
- var import_react4 = require("react");
470
- var import_jsx_runtime11 = require("react/jsx-runtime");
471
- var WalletConnectionsTableRow = ({
472
- ignoreConnectDialog,
473
- onConnectClick,
474
- onRevoke,
475
- wallet,
476
- ...props
477
- }) => {
478
- const { currentAccount: currentAccountFromWallet, additionalAccounts, chainName, connectWallet, providerInfo } = (0, import_react_crypto6.useEthWallet)(wallet);
479
- const currentAccount = (currentAccountFromWallet == null ? void 0 : currentAccountFromWallet.toString()) ? [currentAccountFromWallet.toString()] : [];
480
- const totalAccounts = ((additionalAccounts == null ? void 0 : additionalAccounts.length) ?? 0) + ((currentAccount == null ? void 0 : currentAccount.length) ?? 0);
481
- const connected = !!((currentAccount == null ? void 0 : currentAccount.length) ?? 0 > 0);
482
- const { icon, name, rdns } = (0, import_react4.useMemo)(() => providerInfo ?? { icon: void 0, name: void 0, rdns: void 0 }, [providerInfo]);
483
- const activeProvider = (0, import_react4.useMemo)(
484
- () => ({
485
- connectWallet,
486
- icon,
487
- providerName: name
488
- }),
489
- [connectWallet, icon, name]
490
- );
491
- const onRevokeLocal = (0, import_react4.useCallback)(() => {
492
- onRevoke == null ? void 0 : onRevoke(activeProvider);
493
- }, [activeProvider, onRevoke]);
494
- const onConnectLocal = (0, import_react4.useCallback)(async () => {
495
- if (ignoreConnectDialog) {
496
- await (connectWallet == null ? void 0 : connectWallet());
497
- } else {
498
- onConnectClick == null ? void 0 : onConnectClick(activeProvider);
499
- }
500
- }, [activeProvider, connectWallet, ignoreConnectDialog, onConnectClick]);
501
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_material11.TableRow, { ...props, children: Object.values(ConnectedWalletTableCells).map((Cell, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
502
- Cell,
503
- {
504
- additionalAccounts,
505
- chainName,
506
- connected,
507
- currentAccount,
508
- icon,
509
- onConnect: onConnectLocal,
510
- onRevoke: onRevokeLocal,
511
- totalAccounts,
512
- walletName: name,
513
- walletRdns: rdns
514
- },
515
- index
516
- )) });
517
- };
518
-
519
- // src/components/wallet/table/hooks/useActiveProviderDialogState.tsx
520
- var import_react5 = require("react");
521
- var useActiveProviderDialogState = (setActiveProvider) => {
522
- const [show, setShow] = (0, import_react5.useState)(false);
523
- const onSetActiveProvider = (activeProvider) => {
524
- setShow(true);
525
- setActiveProvider(activeProvider);
526
- };
527
- const onClose = () => {
528
- setShow(false);
529
- setActiveProvider({});
530
- };
531
- return [show, onSetActiveProvider, onClose];
532
- };
533
-
534
- // src/components/wallet/table/ConnectedWalletsTable.tsx
535
- var import_jsx_runtime12 = require("react/jsx-runtime");
536
- var ConnectedWalletsTable = ({ ignoreConnectDialog, onIgnoreConnectDialog, wallets, ...props }) => {
537
- const [activeProvider, setActiveProvider] = (0, import_react6.useState)();
538
- const [showConnect, onSetActiveProviderConnect, onConnectClose] = useActiveProviderDialogState(setActiveProvider);
539
- const [showRevoke, onSetActiveProviderRevoke, onRevokeClose] = useActiveProviderDialogState(setActiveProvider);
540
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
541
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_material12.Table, { ...props, children: [
542
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material12.TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material12.TableRow, { children: WalletsTableHeadCells.map(({ disablePadding, id, label, align, width }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material12.TableCell, { align, padding: disablePadding ? "none" : "normal", width: width ?? "auto", children: label }, id)) }) }),
543
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material12.TableBody, { children: (wallets ?? []).map((wallet) => {
544
- var _a;
545
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
546
- WalletConnectionsTableRow,
547
- {
548
- ignoreConnectDialog,
549
- onConnectClick: onSetActiveProviderConnect,
550
- onRevoke: onSetActiveProviderRevoke,
551
- wallet
552
- },
553
- (_a = wallet.providerInfo) == null ? void 0 : _a.rdns
554
- );
555
- }) })
556
- ] }),
557
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RevokeWalletConnectionDialog, { open: showRevoke, onClose: onRevokeClose, activeProvider }),
558
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
559
- ConnectWalletDialog,
560
- {
561
- activeProvider,
562
- onClose: onConnectClose,
563
- open: showConnect,
564
- onIgnoreConnectDialog
565
- }
566
- )
567
- ] });
568
- };
569
-
570
- // src/components/ConnectedAccountsFlexbox.tsx
571
- var import_jsx_runtime13 = require("react/jsx-runtime");
572
- var ConnectedAccountsFlexbox = (0, import_react7.forwardRef)(
573
- ({ ignoreConnectDialog, onIgnoreConnectDialog, ...props }, ref) => {
574
- const theme = (0, import_material13.useTheme)();
575
- const { totalConnectedAccounts, sortedWallets } = useDetectedWallets();
576
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_flexbox6.FlexCol, { alignItems: "stretch", justifyContent: "start", gap: 2, ref, ...props, children: [
577
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_flexbox6.FlexCol, { alignItems: "start", children: [
578
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material13.Typography, { variant: "h2", sx: { mb: 0.5 }, children: "Detected Web3 Wallets" }),
579
- totalConnectedAccounts ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_material13.Typography, { variant: "subtitle1", color: theme.palette.secondary.main, sx: { opacity: 0.5 }, children: [
580
- "Total Connected Accounts: ",
581
- totalConnectedAccounts
582
- ] }) : null
583
- ] }),
584
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ConnectedWalletsTable, { wallets: sortedWallets, ignoreConnectDialog, onIgnoreConnectDialog })
585
- ] });
586
- }
587
- );
588
- ConnectedAccountsFlexbox.displayName = "ConnectedAccountsFlexbox";
589
- // Annotate the CommonJS export names for ESM import in node:
590
- 0 && (module.exports = {
591
- CheckboxFormControl,
592
- ConnectWalletDialog,
593
- ConnectedAccountsFlexbox,
594
- ConnectedWalletState,
595
- ConnectedWalletTableCells,
596
- ConnectedWalletsAccountsTableCell,
597
- ConnectedWalletsActionsTableCell,
598
- ConnectedWalletsChainNameTableCell,
599
- ConnectedWalletsTable,
600
- ConnectedWalletsWalletTableCell,
601
- EnabledEthWalletConnections,
602
- RevokeWalletConnectionDialog,
603
- WalletConnectionsTableRow,
604
- useActiveProviderDialogState,
605
- useDetectedWallets,
606
- useEnabledWallets,
607
- useEnabledWalletsInner
608
- });
1
+ "use strict";var He=Object.create;var H=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,_e=Object.prototype.hasOwnProperty;var ze=(o,e)=>{for(var t in e)H(o,t,{get:e[t],enumerable:!0})},de=(o,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xe(e))!_e.call(o,n)&&n!==t&&H(o,n,{get:()=>e[n],enumerable:!(l=Ke(e,n))||l.enumerable});return o};var me=(o,e,t)=>(t=o!=null?He(Ve(o)):{},de(e||!o||!o.__esModule?H(t,"default",{value:o,enumerable:!0}):t,o)),Je=o=>de(H({},"__esModule",{value:!0}),o);var Ue={};ze(Ue,{CheckboxFormControl:()=>U,ConnectWalletDialog:()=>Z,ConnectedAccountsFlexbox:()=>Be,ConnectedWalletState:()=>ne,ConnectedWalletTableCells:()=>re,ConnectedWalletsAccountsTableCell:()=>ee,ConnectedWalletsActionsTableCell:()=>oe,ConnectedWalletsChainNameTableCell:()=>te,ConnectedWalletsTable:()=>ce,ConnectedWalletsWalletTableCell:()=>ae,EnabledEthWalletConnections:()=>k,RevokeWalletConnectionDialog:()=>j,WalletConnectionsTableRow:()=>ie,useActiveProviderDialogState:()=>_,useDetectedWallets:()=>$,useEnabledWallets:()=>G,useEnabledWalletsInner:()=>ge});module.exports=Je(Ue);var Ce="XYO|EnabledWallets",k=class{persistPreferences=!0;enabledWallets={};ethWalletsState={};listeners=[];localStorageKey=Ce;constructor(e=Ce){this.localStorageKey=e,this.reviveSettings()}get wallets(){return this.ethWalletsState}disableWallet(e){this.toggleEnabledWallet(e,!1)}enableWallet(e){this.toggleEnabledWallet(e,!0)}resetWallets(e){let t={},l=([n,a])=>{t[n]={enabled:n in this.enabledWallets?this.enabledWallets[n]:!0,wallet:a}};Object.entries(e).forEach(l.bind(this)),this.ethWalletsState=t,this.emitChange()}subscribe(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}toggleEnabledWallet(e,t){e&&this.ethWalletsState[e]&&(this.ethWalletsState[e].enabled=t,this.ethWalletsState={...this.ethWalletsState},this.emitChange())}emitChange(){for(let e of this.listeners)e();this.persistSettings()}isPersistance(e){this.persistPreferences&&e()}persistSettings(){this.isPersistance(()=>{let e=Object.entries(this.ethWalletsState).reduce((t,[l,{enabled:n}])=>(t[l]=n,t),{});localStorage.setItem(this.localStorageKey,JSON.stringify(e))})}reviveSettings(){this.isPersistance(()=>{let e=localStorage.getItem(this.localStorageKey);try{let t=e?JSON.parse(e):{};this.enabledWallets=t}catch(t){console.warn(`Error parsing saved enabled wallet entries: ${t.message}`)}})}};var Y=require("@mui/material"),pe=require("@xylabs/react-flexbox"),Le=require("react");var R=require("@xylabs/react-crypto"),v=require("react"),$e=o=>Object.values(o).reduce((e,t)=>(t.allowedAccounts.length>0?e.unshift(t):e.push(t),e),[]),$=()=>{let o=(0,R.useWalletDiscovery)(),[e,t]=(0,v.useState)(0),[l,n]=(0,v.useState)([]);(0,v.useEffect)(()=>{n($e(o))},[o,e]),(0,v.useEffect)(()=>{let r=()=>{t(m=>m+1)};return window.addEventListener(R.AccountsChangedEventName,r),()=>{window.removeEventListener(R.AccountsChangedEventName,r)}},[o]);let a=(0,v.useMemo)(()=>Object.values(l).reduce((r,m)=>r+m.allowedAccounts.length,0),[l]);return{sortedWallets:l,totalConnectedAccounts:a}};var be=require("@xylabs/react-crypto"),I=require("react");var s,ge=o=>{let e=(0,be.useWalletDiscovery)(),t=(0,I.useMemo)(()=>{s===void 0&&(s=new k),s.resetWallets(e);for(let[l,n]of Object.entries(o??{}))s==null||s.toggleEnabledWallet(l,n);return s},[e,o]);return(0,I.useSyncExternalStore)(t.subscribe.bind(t),()=>t.wallets)},G=o=>{let e=ge(o),t=(0,I.useMemo)(()=>Object.entries(e).reduce((l,[n,a])=>(a.enabled&&(l[n]=a),l),{}),[e]);return{disableWallet:s==null?void 0:s.disableWallet.bind(s),enableWallet:s==null?void 0:s.enableWallet.bind(s),enabledWallets:t,wallets:e}};var D=require("@mui/material"),L=require("react/jsx-runtime"),U=({onCheckChanged:o,...e})=>(0,L.jsx)(D.FormControl,{...e,children:(0,L.jsxs)(D.FormLabel,{children:[(0,L.jsx)(D.Checkbox,{onChange:(t,l)=>o==null?void 0:o(l)}),"Do not show this again."]})});var b=require("@mui/material");var fe=require("@mui/icons-material"),Q=require("@mui/material"),he=require("@xylabs/react-crypto"),B=require("@xylabs/react-flexbox");var q=me(require("./xyo-color-logo-LHR2SMEM.svg"),1),Ge=me(require("./xyo-color-logo-text-only-QPAW5BSQ.svg"),1);var f=require("react/jsx-runtime"),ue=({icon:o,providerName:e,...t})=>(0,f.jsxs)(B.FlexRow,{gap:4,justifyContent:"space-evenly",...t,children:[(0,f.jsxs)(B.FlexCol,{gap:.5,children:[(0,f.jsx)("img",{alt:"XYO Logo",src:q.default,style:{height:"48px"}}),(0,f.jsx)(Q.Typography,{variant:"subtitle1",children:"XYO App"})]}),(0,f.jsx)(fe.SyncAlt,{fontSize:"large"}),(0,f.jsxs)(B.FlexCol,{gap:.5,children:[(0,f.jsx)(he.ConstrainedImage,{constrainedValue:"48px",src:o,alt:e,style:{height:"48px",maxWidth:"48px"}}),(0,f.jsx)(Q.Typography,{variant:"subtitle1",children:e})]})]});var O=require("@mui/material"),xe=require("@xylabs/react-flexbox"),u=require("react/jsx-runtime"),We=o=>(0,u.jsxs)(xe.FlexCol,{gap:4,...o,children:[(0,u.jsx)(O.Typography,{fontWeight:"bold",sx:{textAlign:"center"},children:"This will allow XYO to:"}),(0,u.jsxs)("ul",{children:[(0,u.jsx)("li",{children:"View your wallet account(s) and address(es)"}),(0,u.jsx)("li",{children:"Read-only access to browse the public blockchain(s) you select"})]}),(0,u.jsxs)(O.Typography,{variant:"subtitle1",sx:{textAlign:"center"},children:["You control what accounts to share and what blockchains to view. You can see or revoke access via your wallet's settings at anytime. View more on XYO's sovereign data philosophy"," ",(0,u.jsx)(O.Link,{href:"https://cointelegraph.com/innovation-circle/decentralization-and-sovereignty-debunking-our-approach-to-digital-sovereignty",sx:{fontWeight:"bold"},target:"_blank",children:"here"}),"."]})]});var C=require("react/jsx-runtime"),Z=({activeProvider:o,onIgnoreConnectDialog:e,...t})=>{let{icon:l,providerName:n}=o??{};return(0,C.jsxs)(b.Dialog,{PaperProps:{sx:{display:"flex",gap:4}},...t,children:[(0,C.jsx)(b.DialogTitle,{sx:{textAlign:"center"},children:"XYO Wants To Access The Blockchain on Your Behalf"}),(0,C.jsxs)(b.DialogContent,{sx:{display:"flex",flexDirection:"column",gap:4},children:[(0,C.jsx)(ue,{icon:l,providerName:n}),(0,C.jsx)(We,{}),(0,C.jsx)(U,{onCheckChanged:e})]}),(0,C.jsxs)(b.DialogActions,{children:[(0,C.jsx)(b.Button,{variant:"outlined",onClick:()=>{var r;return(r=t.onClose)==null?void 0:r.call(t,{},"escapeKeyDown")},children:"Close"}),(0,C.jsx)(b.Button,{variant:"contained",onClick:async()=>{var r,m;try{await((r=o==null?void 0:o.connectWallet)==null?void 0:r.call(o)),(m=t.onClose)==null||m.call(t,{},"escapeKeyDown")}catch(p){console.warn(`Error connecting to wallet: ${p.message}`)}},children:"Connect"})]})]})};var i=require("@mui/material"),ve=require("@xylabs/react-crypto"),Te=require("@xylabs/react-flexbox"),g=require("react/jsx-runtime"),j=({activeProvider:o,...e})=>(0,g.jsxs)(i.Dialog,{...e,children:[(0,g.jsxs)(Te.FlexRow,{gap:2,justifyContent:"start",pl:2,children:[(0,g.jsx)(ve.ConstrainedImage,{src:o==null?void 0:o.icon,constrainedValue:"24px"}),(0,g.jsxs)(i.DialogTitle,{sx:{pl:0},children:["Revoke ",o==null?void 0:o.providerName," Access"]})]}),(0,g.jsxs)(i.DialogContent,{children:[(0,g.jsxs)(i.Typography,{children:["Revoking access to your wallet must be done from the wallet's browser extension. Wallets grant access to specific domains please consult ",o==null?void 0:o.providerName,"'s documentation on how to revoke access to this website:"]}),(0,g.jsx)(i.Typography,{children:window.location.origin})]}),(0,g.jsx)(i.DialogActions,{children:(0,g.jsx)(i.Button,{variant:"contained",onClick:()=>{var t;return(t=e.onClose)==null?void 0:t.call(e,{},"escapeKeyDown")},children:"Close"})})]});var F=require("@mui/material"),N=require("react/jsx-runtime"),ee=({additionalAccounts:o,currentAccount:e,totalAccounts:t,tableCellProps:l})=>(0,N.jsx)(F.TableCell,{...l,children:(0,N.jsx)(F.Tooltip,{sx:{cursor:t>0?"pointer":"auto"},title:[...e??[],...o??[]].map((n,a)=>(0,N.jsx)("p",{children:n},a)),children:(0,N.jsx)(F.Typography,{children:t})})});var K=require("@mui/icons-material"),T=require("@mui/material"),ye=require("@xylabs/react-flexbox"),x=require("react/jsx-runtime"),oe=({connected:o,onConnect:e,onRevoke:t,tableCellProps:l})=>(0,x.jsx)(T.TableCell,{...l,children:(0,x.jsxs)(ye.FlexRow,{gap:2,justifyContent:"start",children:[o?(0,x.jsxs)(T.Typography,{sx:{display:"inline-flex",gap:.5},children:[(0,x.jsx)(K.Check,{}),"Connected"]}):(0,x.jsx)(T.Button,{variant:"contained",onClick:e,children:"Connect"}),o?(0,x.jsx)(T.IconButton,{onClick:t,children:(0,x.jsx)(K.InfoOutlined,{})}):null]})});var Pe=require("@mui/material"),we=require("react/jsx-runtime"),te=({chainName:o,tableCellProps:e})=>(0,we.jsx)(Pe.TableCell,{...e,children:o});var X=require("@mui/material"),Se=require("react");var le=require("react/jsx-runtime"),ne=({connected:o,walletRdns:e,tableCellProps:t})=>{let{disableWallet:l,enableWallet:n,wallets:a}=G(),r=(0,Se.useMemo)(()=>e?a[e].enabled:!1,[a,e]);return(0,le.jsx)(X.TableCell,{...t,children:(0,le.jsx)(X.Switch,{disabled:!o,checked:o&&r,onChange:p=>{var d;let P=(d=p.target)==null?void 0:d.checked;e&&(P?n==null||n(e):l==null||l(e))}})})};var V=require("@mui/material"),De=require("@xylabs/react-crypto"),Fe=require("@xylabs/react-flexbox"),M=require("react/jsx-runtime"),ae=({icon:o,walletName:e,tableCellProps:t})=>{let l=(0,V.useTheme)();return(0,M.jsx)(V.TableCell,{...t,children:(0,M.jsxs)(Fe.FlexRow,{gap:2,justifyContent:"start",children:[(0,M.jsx)(De.ConstrainedImage,{constrainedValue:l.spacing(4),src:o}),e]})})};var re=[ae,te,ee,oe,ne];var h=require("@mui/material"),Ie=require("react");var Ee=[{disablePadding:!1,id:"wallet",label:"Wallet",numeric:!1,showOnMobile:!0},{disablePadding:!1,id:"chain",label:"Chain",numeric:!1,showOnMobile:!0},{disablePadding:!1,id:"accounts",label:"Accounts",numeric:!0,showOnMobile:!0},{disablePadding:!1,id:"actions",label:"Actions",numeric:!1,showOnMobile:!0},{disablePadding:!1,id:"enabled",label:"Enabled",numeric:!1,showOnMobile:!0}];var Ae=require("@mui/material"),ke=require("@xylabs/react-crypto"),E=require("react");var se=require("react/jsx-runtime"),ie=({ignoreConnectDialog:o,onConnectClick:e,onRevoke:t,wallet:l,...n})=>{let{currentAccount:a,additionalAccounts:r,chainName:m,connectWallet:p,providerInfo:P}=(0,ke.useEthWallet)(l),d=a!=null&&a.toString()?[a.toString()]:[],z=((r==null?void 0:r.length)??0)+((d==null?void 0:d.length)??0),w=!!((d==null?void 0:d.length)??!1),{icon:W,name:A,rdns:J}=(0,E.useMemo)(()=>P??{icon:void 0,name:void 0,rdns:void 0},[P]),S=(0,E.useMemo)(()=>({connectWallet:p,icon:W,providerName:A}),[p,W,A]),Oe=(0,E.useCallback)(()=>{t==null||t(S)},[S,t]),Ne=(0,E.useCallback)(async()=>{o?await(p==null?void 0:p()):e==null||e(S)},[S,p,o,e]);return(0,se.jsx)(Ae.TableRow,{...n,children:Object.values(re).map((Me,Ye)=>(0,se.jsx)(Me,{additionalAccounts:r,chainName:m,connected:w,currentAccount:d,icon:W,onConnect:Ne,onRevoke:Oe,totalAccounts:z,walletName:A,walletRdns:J},Ye))})};var Re=require("react"),_=o=>{let[e,t]=(0,Re.useState)(!1);return[e,a=>{t(!0),o(a)},()=>{t(!1),o({})}]};var c=require("react/jsx-runtime"),ce=({ignoreConnectDialog:o,onIgnoreConnectDialog:e,wallets:t,...l})=>{let[n,a]=(0,Ie.useState)(),[r,m,p]=_(a),[P,d,z]=_(a);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(h.Table,{...l,children:[(0,c.jsx)(h.TableHead,{children:(0,c.jsx)(h.TableRow,{children:Ee.map(({disablePadding:w,id:W,label:A,align:J,width:S})=>(0,c.jsx)(h.TableCell,{align:J,padding:w?"none":"normal",width:S??"auto",children:A},W))})}),(0,c.jsx)(h.TableBody,{children:(t??[]).map(w=>{var W;return(0,c.jsx)(ie,{ignoreConnectDialog:o,onConnectClick:m,onRevoke:d,wallet:w},(W=w.providerInfo)==null?void 0:W.rdns)})})]}),(0,c.jsx)(j,{open:P,onClose:z,activeProvider:n}),(0,c.jsx)(Z,{activeProvider:n,onClose:p,open:r,onIgnoreConnectDialog:e})]})};var y=require("react/jsx-runtime"),Be=(0,Le.forwardRef)(({ignoreConnectDialog:o,onIgnoreConnectDialog:e,...t},l)=>{let n=(0,Y.useTheme)(),{totalConnectedAccounts:a,sortedWallets:r}=$();return(0,y.jsxs)(pe.FlexCol,{alignItems:"stretch",justifyContent:"start",gap:2,ref:l,...t,children:[(0,y.jsxs)(pe.FlexCol,{alignItems:"start",children:[(0,y.jsx)(Y.Typography,{variant:"h2",sx:{mb:.5},children:"Detected Web3 Wallets"}),a?(0,y.jsxs)(Y.Typography,{variant:"subtitle1",color:n.palette.secondary.main,sx:{opacity:.5},children:["Total Connected Accounts: ",a]}):null]}),(0,y.jsx)(ce,{wallets:r,ignoreConnectDialog:o,onIgnoreConnectDialog:e})]})});Be.displayName="ConnectedAccountsFlexbox";0&&(module.exports={CheckboxFormControl,ConnectWalletDialog,ConnectedAccountsFlexbox,ConnectedWalletState,ConnectedWalletTableCells,ConnectedWalletsAccountsTableCell,ConnectedWalletsActionsTableCell,ConnectedWalletsChainNameTableCell,ConnectedWalletsTable,ConnectedWalletsWalletTableCell,EnabledEthWalletConnections,RevokeWalletConnectionDialog,WalletConnectionsTableRow,useActiveProviderDialogState,useDetectedWallets,useEnabledWallets,useEnabledWalletsInner});
609
2
  //# sourceMappingURL=index.cjs.map