@springmicro/auth 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3284 @@
1
+ import { bH as xn, bI as Pt } from "./Web3Auth-C1gorwXx.js";
2
+ const In = (t, e) => {
3
+ let n;
4
+ switch (t) {
5
+ case "standard":
6
+ return n = e, `data:image/svg+xml,%3Csvg width='${e}' height='${n}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
7
+ case "circle":
8
+ return n = e, `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${n}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;
9
+ case "text":
10
+ return n = (0.1 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
11
+ case "textWithLogo":
12
+ return n = (0.25 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
13
+ case "textLight":
14
+ return n = (0.1 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
15
+ case "textWithLogoLight":
16
+ return n = (0.25 * e).toFixed(2), `data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
17
+ default:
18
+ return n = e, `data:image/svg+xml,%3Csvg width='${e}' height='${n}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
19
+ }
20
+ };
21
+ class O {
22
+ constructor(e, n) {
23
+ this.scope = e, this.module = n;
24
+ }
25
+ storeObject(e, n) {
26
+ this.setItem(e, JSON.stringify(n));
27
+ }
28
+ loadObject(e) {
29
+ const n = this.getItem(e);
30
+ return n ? JSON.parse(n) : void 0;
31
+ }
32
+ setItem(e, n) {
33
+ localStorage.setItem(this.scopedKey(e), n);
34
+ }
35
+ getItem(e) {
36
+ return localStorage.getItem(this.scopedKey(e));
37
+ }
38
+ removeItem(e) {
39
+ localStorage.removeItem(this.scopedKey(e));
40
+ }
41
+ clear() {
42
+ const e = this.scopedKey(""), n = [];
43
+ for (let s = 0; s < localStorage.length; s++) {
44
+ const i = localStorage.key(s);
45
+ typeof i == "string" && i.startsWith(e) && n.push(i);
46
+ }
47
+ n.forEach((s) => localStorage.removeItem(s));
48
+ }
49
+ scopedKey(e) {
50
+ return `-${this.scope}${this.module ? `:${this.module}` : ""}:${e}`;
51
+ }
52
+ static clearAll() {
53
+ new O("CBWSDK").clear(), new O("walletlink").clear();
54
+ }
55
+ }
56
+ const E = {
57
+ rpc: {
58
+ invalidInput: -32e3,
59
+ resourceNotFound: -32001,
60
+ resourceUnavailable: -32002,
61
+ transactionRejected: -32003,
62
+ methodNotSupported: -32004,
63
+ limitExceeded: -32005,
64
+ parse: -32700,
65
+ invalidRequest: -32600,
66
+ methodNotFound: -32601,
67
+ invalidParams: -32602,
68
+ internal: -32603
69
+ },
70
+ provider: {
71
+ userRejectedRequest: 4001,
72
+ unauthorized: 4100,
73
+ unsupportedMethod: 4200,
74
+ disconnected: 4900,
75
+ chainDisconnected: 4901,
76
+ unsupportedChain: 4902
77
+ }
78
+ }, Re = {
79
+ "-32700": {
80
+ standard: "JSON RPC 2.0",
81
+ message: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
82
+ },
83
+ "-32600": {
84
+ standard: "JSON RPC 2.0",
85
+ message: "The JSON sent is not a valid Request object."
86
+ },
87
+ "-32601": {
88
+ standard: "JSON RPC 2.0",
89
+ message: "The method does not exist / is not available."
90
+ },
91
+ "-32602": {
92
+ standard: "JSON RPC 2.0",
93
+ message: "Invalid method parameter(s)."
94
+ },
95
+ "-32603": {
96
+ standard: "JSON RPC 2.0",
97
+ message: "Internal JSON-RPC error."
98
+ },
99
+ "-32000": {
100
+ standard: "EIP-1474",
101
+ message: "Invalid input."
102
+ },
103
+ "-32001": {
104
+ standard: "EIP-1474",
105
+ message: "Resource not found."
106
+ },
107
+ "-32002": {
108
+ standard: "EIP-1474",
109
+ message: "Resource unavailable."
110
+ },
111
+ "-32003": {
112
+ standard: "EIP-1474",
113
+ message: "Transaction rejected."
114
+ },
115
+ "-32004": {
116
+ standard: "EIP-1474",
117
+ message: "Method not supported."
118
+ },
119
+ "-32005": {
120
+ standard: "EIP-1474",
121
+ message: "Request limit exceeded."
122
+ },
123
+ 4001: {
124
+ standard: "EIP-1193",
125
+ message: "User rejected the request."
126
+ },
127
+ 4100: {
128
+ standard: "EIP-1193",
129
+ message: "The requested account and/or method has not been authorized by the user."
130
+ },
131
+ 4200: {
132
+ standard: "EIP-1193",
133
+ message: "The requested method is not supported by this Ethereum provider."
134
+ },
135
+ 4900: {
136
+ standard: "EIP-1193",
137
+ message: "The provider is disconnected from all chains."
138
+ },
139
+ 4901: {
140
+ standard: "EIP-1193",
141
+ message: "The provider is disconnected from the specified chain."
142
+ },
143
+ 4902: {
144
+ standard: "EIP-3085",
145
+ message: "Unrecognized chain ID."
146
+ }
147
+ }, Rt = "Unspecified error message.", Sn = "Unspecified server error.";
148
+ function Ve(t, e = Rt) {
149
+ if (t && Number.isInteger(t)) {
150
+ const n = t.toString();
151
+ if (Te(Re, n))
152
+ return Re[n].message;
153
+ if (Tt(t))
154
+ return Sn;
155
+ }
156
+ return e;
157
+ }
158
+ function An(t) {
159
+ if (!Number.isInteger(t))
160
+ return !1;
161
+ const e = t.toString();
162
+ return !!(Re[e] || Tt(t));
163
+ }
164
+ function Mn(t, { shouldIncludeStack: e = !1 } = {}) {
165
+ const n = {};
166
+ if (t && typeof t == "object" && !Array.isArray(t) && Te(t, "code") && An(t.code)) {
167
+ const s = t;
168
+ n.code = s.code, s.message && typeof s.message == "string" ? (n.message = s.message, Te(s, "data") && (n.data = s.data)) : (n.message = Ve(n.code), n.data = { originalError: et(t) });
169
+ } else
170
+ n.code = E.rpc.internal, n.message = tt(t, "message") ? t.message : Rt, n.data = { originalError: et(t) };
171
+ return e && (n.stack = tt(t, "stack") ? t.stack : void 0), n;
172
+ }
173
+ function Tt(t) {
174
+ return t >= -32099 && t <= -32e3;
175
+ }
176
+ function et(t) {
177
+ return t && typeof t == "object" && !Array.isArray(t) ? Object.assign({}, t) : t;
178
+ }
179
+ function Te(t, e) {
180
+ return Object.prototype.hasOwnProperty.call(t, e);
181
+ }
182
+ function tt(t, e) {
183
+ return typeof t == "object" && t !== null && e in t && typeof t[e] == "string";
184
+ }
185
+ const b = {
186
+ rpc: {
187
+ parse: (t) => A(E.rpc.parse, t),
188
+ invalidRequest: (t) => A(E.rpc.invalidRequest, t),
189
+ invalidParams: (t) => A(E.rpc.invalidParams, t),
190
+ methodNotFound: (t) => A(E.rpc.methodNotFound, t),
191
+ internal: (t) => A(E.rpc.internal, t),
192
+ server: (t) => {
193
+ if (!t || typeof t != "object" || Array.isArray(t))
194
+ throw new Error("Ethereum RPC Server errors must provide single object argument.");
195
+ const { code: e } = t;
196
+ if (!Number.isInteger(e) || e > -32005 || e < -32099)
197
+ throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');
198
+ return A(e, t);
199
+ },
200
+ invalidInput: (t) => A(E.rpc.invalidInput, t),
201
+ resourceNotFound: (t) => A(E.rpc.resourceNotFound, t),
202
+ resourceUnavailable: (t) => A(E.rpc.resourceUnavailable, t),
203
+ transactionRejected: (t) => A(E.rpc.transactionRejected, t),
204
+ methodNotSupported: (t) => A(E.rpc.methodNotSupported, t),
205
+ limitExceeded: (t) => A(E.rpc.limitExceeded, t)
206
+ },
207
+ provider: {
208
+ userRejectedRequest: (t) => G(E.provider.userRejectedRequest, t),
209
+ unauthorized: (t) => G(E.provider.unauthorized, t),
210
+ unsupportedMethod: (t) => G(E.provider.unsupportedMethod, t),
211
+ disconnected: (t) => G(E.provider.disconnected, t),
212
+ chainDisconnected: (t) => G(E.provider.chainDisconnected, t),
213
+ unsupportedChain: (t) => G(E.provider.unsupportedChain, t),
214
+ custom: (t) => {
215
+ if (!t || typeof t != "object" || Array.isArray(t))
216
+ throw new Error("Ethereum Provider custom errors must provide single object argument.");
217
+ const { code: e, message: n, data: s } = t;
218
+ if (!n || typeof n != "string")
219
+ throw new Error('"message" must be a nonempty string');
220
+ return new Ot(e, n, s);
221
+ }
222
+ }
223
+ };
224
+ function A(t, e) {
225
+ const [n, s] = Nt(e);
226
+ return new Dt(t, n || Ve(t), s);
227
+ }
228
+ function G(t, e) {
229
+ const [n, s] = Nt(e);
230
+ return new Ot(t, n || Ve(t), s);
231
+ }
232
+ function Nt(t) {
233
+ if (t) {
234
+ if (typeof t == "string")
235
+ return [t];
236
+ if (typeof t == "object" && !Array.isArray(t)) {
237
+ const { message: e, data: n } = t;
238
+ if (e && typeof e != "string")
239
+ throw new Error("Must specify string message.");
240
+ return [e || void 0, n];
241
+ }
242
+ }
243
+ return [];
244
+ }
245
+ class Dt extends Error {
246
+ constructor(e, n, s) {
247
+ if (!Number.isInteger(e))
248
+ throw new Error('"code" must be an integer.');
249
+ if (!n || typeof n != "string")
250
+ throw new Error('"message" must be a nonempty string.');
251
+ super(n), this.code = e, s !== void 0 && (this.data = s);
252
+ }
253
+ }
254
+ class Ot extends Dt {
255
+ /**
256
+ * Create an Ethereum Provider JSON-RPC error.
257
+ * `code` must be an integer in the 1000 <= 4999 range.
258
+ */
259
+ constructor(e, n, s) {
260
+ if (!Ln(e))
261
+ throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');
262
+ super(e, n, s);
263
+ }
264
+ }
265
+ function Ln(t) {
266
+ return Number.isInteger(t) && t >= 1e3 && t <= 4999;
267
+ }
268
+ function Ke() {
269
+ return (t) => t;
270
+ }
271
+ const oe = Ke(), Pn = Ke(), Rn = Ke();
272
+ function U(t) {
273
+ return Math.floor(t);
274
+ }
275
+ const Ut = /^[0-9]*$/, jt = /^[a-f0-9]*$/;
276
+ function F(t) {
277
+ return Fe(crypto.getRandomValues(new Uint8Array(t)));
278
+ }
279
+ function Fe(t) {
280
+ return [...t].map((e) => e.toString(16).padStart(2, "0")).join("");
281
+ }
282
+ function ue(t) {
283
+ return new Uint8Array(t.match(/.{1,2}/g).map((e) => Number.parseInt(e, 16)));
284
+ }
285
+ function ne(t, e = !1) {
286
+ const n = t.toString("hex");
287
+ return oe(e ? `0x${n}` : n);
288
+ }
289
+ function xe(t) {
290
+ return ne(Ne(t), !0);
291
+ }
292
+ function T(t) {
293
+ return Rn(t.toString(10));
294
+ }
295
+ function K(t) {
296
+ return oe(`0x${BigInt(t).toString(16)}`);
297
+ }
298
+ function Ht(t) {
299
+ return t.startsWith("0x") || t.startsWith("0X");
300
+ }
301
+ function ze(t) {
302
+ return Ht(t) ? t.slice(2) : t;
303
+ }
304
+ function Wt(t) {
305
+ return Ht(t) ? `0x${t.slice(2)}` : `0x${t}`;
306
+ }
307
+ function be(t) {
308
+ if (typeof t != "string")
309
+ return !1;
310
+ const e = ze(t).toLowerCase();
311
+ return jt.test(e);
312
+ }
313
+ function Tn(t, e = !1) {
314
+ if (typeof t == "string") {
315
+ const n = ze(t).toLowerCase();
316
+ if (jt.test(n))
317
+ return oe(e ? `0x${n}` : n);
318
+ }
319
+ throw b.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`);
320
+ }
321
+ function $e(t, e = !1) {
322
+ let n = Tn(t, !1);
323
+ return n.length % 2 === 1 && (n = oe(`0${n}`)), e ? oe(`0x${n}`) : n;
324
+ }
325
+ function B(t) {
326
+ if (typeof t == "string") {
327
+ const e = ze(t).toLowerCase();
328
+ if (be(e) && e.length === 40)
329
+ return Pn(Wt(e));
330
+ }
331
+ throw b.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`);
332
+ }
333
+ function Ne(t) {
334
+ if (Buffer.isBuffer(t))
335
+ return t;
336
+ if (typeof t == "string") {
337
+ if (be(t)) {
338
+ const e = $e(t, !1);
339
+ return Buffer.from(e, "hex");
340
+ }
341
+ return Buffer.from(t, "utf8");
342
+ }
343
+ throw b.rpc.invalidParams(`Not binary data: ${String(t)}`);
344
+ }
345
+ function se(t) {
346
+ if (typeof t == "number" && Number.isInteger(t))
347
+ return U(t);
348
+ if (typeof t == "string") {
349
+ if (Ut.test(t))
350
+ return U(Number(t));
351
+ if (be(t))
352
+ return U(Number(BigInt($e(t, !0))));
353
+ }
354
+ throw b.rpc.invalidParams(`Not an integer: ${String(t)}`);
355
+ }
356
+ function te(t) {
357
+ if (t !== null && (typeof t == "bigint" || Dn(t)))
358
+ return BigInt(t.toString(10));
359
+ if (typeof t == "number")
360
+ return BigInt(se(t));
361
+ if (typeof t == "string") {
362
+ if (Ut.test(t))
363
+ return BigInt(t);
364
+ if (be(t))
365
+ return BigInt($e(t, !0));
366
+ }
367
+ throw b.rpc.invalidParams(`Not an integer: ${String(t)}`);
368
+ }
369
+ function Nn(t) {
370
+ if (typeof t == "string")
371
+ return JSON.parse(t);
372
+ if (typeof t == "object")
373
+ return t;
374
+ throw b.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`);
375
+ }
376
+ function Dn(t) {
377
+ if (t == null || typeof t.constructor != "function")
378
+ return !1;
379
+ const { constructor: e } = t;
380
+ return typeof e.config == "function" && typeof e.EUCLID == "number";
381
+ }
382
+ function On() {
383
+ const t = document.querySelector('link[sizes="192x192"]') || document.querySelector('link[sizes="180x180"]') || document.querySelector('link[rel="icon"]') || document.querySelector('link[rel="shortcut icon"]'), { protocol: e, host: n } = document.location, s = t ? t.getAttribute("href") : null;
384
+ return !s || s.startsWith("javascript:") || s.startsWith("vbscript:") ? `${e}//${n}/favicon.ico` : s.startsWith("http://") || s.startsWith("https://") || s.startsWith("data:") ? s : s.startsWith("//") ? e + s : `${e}//${n}${s}`;
385
+ }
386
+ async function Un() {
387
+ return crypto.subtle.generateKey({
388
+ name: "ECDH",
389
+ namedCurve: "P-256"
390
+ }, !0, ["deriveKey"]);
391
+ }
392
+ async function jn(t, e) {
393
+ return crypto.subtle.deriveKey({
394
+ name: "ECDH",
395
+ public: e
396
+ }, t, {
397
+ name: "AES-GCM",
398
+ length: 256
399
+ }, !1, ["encrypt", "decrypt"]);
400
+ }
401
+ async function Hn(t, e) {
402
+ const n = crypto.getRandomValues(new Uint8Array(12)), s = await crypto.subtle.encrypt({
403
+ name: "AES-GCM",
404
+ iv: n
405
+ }, t, new TextEncoder().encode(e));
406
+ return { iv: n, cipherText: s };
407
+ }
408
+ async function Wn(t, { iv: e, cipherText: n }) {
409
+ const s = await crypto.subtle.decrypt({
410
+ name: "AES-GCM",
411
+ iv: e
412
+ }, t, n);
413
+ return new TextDecoder().decode(s);
414
+ }
415
+ function Bt(t) {
416
+ switch (t) {
417
+ case "public":
418
+ return "spki";
419
+ case "private":
420
+ return "pkcs8";
421
+ }
422
+ }
423
+ async function qt(t, e) {
424
+ const n = Bt(t), s = await crypto.subtle.exportKey(n, e);
425
+ return Fe(new Uint8Array(s));
426
+ }
427
+ async function Vt(t, e) {
428
+ const n = Bt(t), s = ue(e).buffer;
429
+ return await crypto.subtle.importKey(n, new Uint8Array(s), {
430
+ name: "ECDH",
431
+ namedCurve: "P-256"
432
+ }, !0, t === "private" ? ["deriveKey"] : []);
433
+ }
434
+ async function Bn(t, e) {
435
+ const n = JSON.stringify(t, (s, i) => {
436
+ if (!(i instanceof Error))
437
+ return i;
438
+ const r = i;
439
+ return Object.assign(Object.assign({}, r.code ? { code: r.code } : {}), { message: r.message });
440
+ });
441
+ return Hn(e, n);
442
+ }
443
+ async function qn(t, e) {
444
+ return JSON.parse(await Wn(e, t));
445
+ }
446
+ const Ie = {
447
+ storageKey: "ownPrivateKey",
448
+ keyType: "private"
449
+ }, Se = {
450
+ storageKey: "ownPublicKey",
451
+ keyType: "public"
452
+ }, Ae = {
453
+ storageKey: "peerPublicKey",
454
+ keyType: "public"
455
+ };
456
+ class Vn {
457
+ constructor() {
458
+ this.storage = new O("CBWSDK", "SCWKeyManager"), this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null;
459
+ }
460
+ async getOwnPublicKey() {
461
+ return await this.loadKeysIfNeeded(), this.ownPublicKey;
462
+ }
463
+ // returns null if the shared secret is not yet derived
464
+ async getSharedSecret() {
465
+ return await this.loadKeysIfNeeded(), this.sharedSecret;
466
+ }
467
+ async setPeerPublicKey(e) {
468
+ this.sharedSecret = null, this.peerPublicKey = e, await this.storeKey(Ae, e), await this.loadKeysIfNeeded();
469
+ }
470
+ async clear() {
471
+ this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null, this.storage.removeItem(Se.storageKey), this.storage.removeItem(Ie.storageKey), this.storage.removeItem(Ae.storageKey);
472
+ }
473
+ async generateKeyPair() {
474
+ const e = await Un();
475
+ this.ownPrivateKey = e.privateKey, this.ownPublicKey = e.publicKey, await this.storeKey(Ie, e.privateKey), await this.storeKey(Se, e.publicKey);
476
+ }
477
+ async loadKeysIfNeeded() {
478
+ if (this.ownPrivateKey === null && (this.ownPrivateKey = await this.loadKey(Ie)), this.ownPublicKey === null && (this.ownPublicKey = await this.loadKey(Se)), (this.ownPrivateKey === null || this.ownPublicKey === null) && await this.generateKeyPair(), this.peerPublicKey === null && (this.peerPublicKey = await this.loadKey(Ae)), this.sharedSecret === null) {
479
+ if (this.ownPrivateKey === null || this.peerPublicKey === null)
480
+ return;
481
+ this.sharedSecret = await jn(this.ownPrivateKey, this.peerPublicKey);
482
+ }
483
+ }
484
+ // storage methods
485
+ async loadKey(e) {
486
+ const n = this.storage.getItem(e.storageKey);
487
+ return n ? Vt(e.keyType, n) : null;
488
+ }
489
+ async storeKey(e, n) {
490
+ const s = await qt(e.keyType, n);
491
+ this.storage.setItem(e.storageKey, s);
492
+ }
493
+ }
494
+ const ce = "4.3.0", Kt = "@coinbase/wallet-sdk";
495
+ async function Ze(t, e) {
496
+ const n = Object.assign(Object.assign({}, t), { jsonrpc: "2.0", id: crypto.randomUUID() }), s = await window.fetch(e, {
497
+ method: "POST",
498
+ body: JSON.stringify(n),
499
+ mode: "cors",
500
+ headers: {
501
+ "Content-Type": "application/json",
502
+ "X-Cbw-Sdk-Version": ce,
503
+ "X-Cbw-Sdk-Platform": Kt
504
+ }
505
+ }), { result: i, error: r } = await s.json();
506
+ if (r)
507
+ throw r;
508
+ return i;
509
+ }
510
+ function Kn() {
511
+ return globalThis.coinbaseWalletExtension;
512
+ }
513
+ function Fn() {
514
+ var t, e;
515
+ try {
516
+ const n = globalThis;
517
+ return (t = n.ethereum) !== null && t !== void 0 ? t : (e = n.top) === null || e === void 0 ? void 0 : e.ethereum;
518
+ } catch {
519
+ return;
520
+ }
521
+ }
522
+ function zn({ metadata: t, preference: e }) {
523
+ var n, s;
524
+ const { appName: i, appLogoUrl: r, appChainIds: o } = t;
525
+ if (e.options !== "smartWalletOnly") {
526
+ const d = Kn();
527
+ if (d)
528
+ return (n = d.setAppInfo) === null || n === void 0 || n.call(d, i, r, o, e), d;
529
+ }
530
+ const a = Fn();
531
+ if (a != null && a.isCoinbaseBrowser)
532
+ return (s = a.setAppInfo) === null || s === void 0 || s.call(a, i, r, o, e), a;
533
+ }
534
+ function $n(t) {
535
+ if (!t || typeof t != "object" || Array.isArray(t))
536
+ throw b.rpc.invalidParams({
537
+ message: "Expected a single, non-array, object argument.",
538
+ data: t
539
+ });
540
+ const { method: e, params: n } = t;
541
+ if (typeof e != "string" || e.length === 0)
542
+ throw b.rpc.invalidParams({
543
+ message: "'args.method' must be a non-empty string.",
544
+ data: t
545
+ });
546
+ if (n !== void 0 && !Array.isArray(n) && (typeof n != "object" || n === null))
547
+ throw b.rpc.invalidParams({
548
+ message: "'args.params' must be an object or array if provided.",
549
+ data: t
550
+ });
551
+ switch (e) {
552
+ case "eth_sign":
553
+ case "eth_signTypedData_v2":
554
+ case "eth_subscribe":
555
+ case "eth_unsubscribe":
556
+ throw b.provider.unsupportedMethod();
557
+ }
558
+ }
559
+ const nt = "accounts", st = "activeChain", it = "availableChains", rt = "walletCapabilities";
560
+ class Zn {
561
+ constructor(e) {
562
+ var n, s, i;
563
+ this.metadata = e.metadata, this.communicator = e.communicator, this.callback = e.callback, this.keyManager = new Vn(), this.storage = new O("CBWSDK", "SCWStateManager"), this.accounts = (n = this.storage.loadObject(nt)) !== null && n !== void 0 ? n : [], this.chain = this.storage.loadObject(st) || {
564
+ id: (i = (s = e.metadata.appChainIds) === null || s === void 0 ? void 0 : s[0]) !== null && i !== void 0 ? i : 1
565
+ }, this.handshake = this.handshake.bind(this), this.request = this.request.bind(this), this.createRequestMessage = this.createRequestMessage.bind(this), this.decryptResponseMessage = this.decryptResponseMessage.bind(this);
566
+ }
567
+ async handshake(e) {
568
+ var n, s, i, r;
569
+ await ((s = (n = this.communicator).waitForPopupLoaded) === null || s === void 0 ? void 0 : s.call(n));
570
+ const o = await this.createRequestMessage({
571
+ handshake: {
572
+ method: e.method,
573
+ params: Object.assign({}, this.metadata, (i = e.params) !== null && i !== void 0 ? i : {})
574
+ }
575
+ }), a = await this.communicator.postRequestAndWaitForResponse(o);
576
+ if ("failure" in a.content)
577
+ throw a.content.failure;
578
+ const d = await Vt("public", a.sender);
579
+ await this.keyManager.setPeerPublicKey(d);
580
+ const h = (await this.decryptResponseMessage(a)).result;
581
+ if ("error" in h)
582
+ throw h.error;
583
+ switch (e.method) {
584
+ case "eth_requestAccounts": {
585
+ const c = h.value;
586
+ this.accounts = c, this.storage.storeObject(nt, c), (r = this.callback) === null || r === void 0 || r.call(this, "accountsChanged", c);
587
+ break;
588
+ }
589
+ }
590
+ }
591
+ async request(e) {
592
+ var n;
593
+ if (this.accounts.length === 0)
594
+ switch (e.method) {
595
+ case "wallet_sendCalls":
596
+ return this.sendRequestToPopup(e);
597
+ default:
598
+ throw b.provider.unauthorized();
599
+ }
600
+ switch (e.method) {
601
+ case "eth_requestAccounts":
602
+ return (n = this.callback) === null || n === void 0 || n.call(this, "connect", { chainId: K(this.chain.id) }), this.accounts;
603
+ case "eth_accounts":
604
+ return this.accounts;
605
+ case "eth_coinbase":
606
+ return this.accounts[0];
607
+ case "net_version":
608
+ return this.chain.id;
609
+ case "eth_chainId":
610
+ return K(this.chain.id);
611
+ case "wallet_getCapabilities":
612
+ return this.storage.loadObject(rt);
613
+ case "wallet_switchEthereumChain":
614
+ return this.handleSwitchChainRequest(e);
615
+ case "eth_ecRecover":
616
+ case "personal_sign":
617
+ case "wallet_sign":
618
+ case "personal_ecRecover":
619
+ case "eth_signTransaction":
620
+ case "eth_sendTransaction":
621
+ case "eth_signTypedData_v1":
622
+ case "eth_signTypedData_v3":
623
+ case "eth_signTypedData_v4":
624
+ case "eth_signTypedData":
625
+ case "wallet_addEthereumChain":
626
+ case "wallet_watchAsset":
627
+ case "wallet_sendCalls":
628
+ case "wallet_showCallsStatus":
629
+ case "wallet_grantPermissions":
630
+ return this.sendRequestToPopup(e);
631
+ default:
632
+ if (!this.chain.rpcUrl)
633
+ throw b.rpc.internal("No RPC URL set for chain");
634
+ return Ze(e, this.chain.rpcUrl);
635
+ }
636
+ }
637
+ async sendRequestToPopup(e) {
638
+ var n, s;
639
+ await ((s = (n = this.communicator).waitForPopupLoaded) === null || s === void 0 ? void 0 : s.call(n));
640
+ const i = await this.sendEncryptedRequest(e), o = (await this.decryptResponseMessage(i)).result;
641
+ if ("error" in o)
642
+ throw o.error;
643
+ return o.value;
644
+ }
645
+ async cleanup() {
646
+ var e, n;
647
+ this.storage.clear(), await this.keyManager.clear(), this.accounts = [], this.chain = {
648
+ id: (n = (e = this.metadata.appChainIds) === null || e === void 0 ? void 0 : e[0]) !== null && n !== void 0 ? n : 1
649
+ };
650
+ }
651
+ /**
652
+ * @returns `null` if the request was successful.
653
+ * https://eips.ethereum.org/EIPS/eip-3326#wallet_switchethereumchain
654
+ */
655
+ async handleSwitchChainRequest(e) {
656
+ var n;
657
+ const s = e.params;
658
+ if (!s || !(!((n = s[0]) === null || n === void 0) && n.chainId))
659
+ throw b.rpc.invalidParams();
660
+ const i = se(s[0].chainId);
661
+ if (this.updateChain(i))
662
+ return null;
663
+ const o = await this.sendRequestToPopup(e);
664
+ return o === null && this.updateChain(i), o;
665
+ }
666
+ async sendEncryptedRequest(e) {
667
+ const n = await this.keyManager.getSharedSecret();
668
+ if (!n)
669
+ throw b.provider.unauthorized("No valid session found, try requestAccounts before other methods");
670
+ const s = await Bn({
671
+ action: e,
672
+ chainId: this.chain.id
673
+ }, n), i = await this.createRequestMessage({ encrypted: s });
674
+ return this.communicator.postRequestAndWaitForResponse(i);
675
+ }
676
+ async createRequestMessage(e) {
677
+ const n = await qt("public", await this.keyManager.getOwnPublicKey());
678
+ return {
679
+ id: crypto.randomUUID(),
680
+ sender: n,
681
+ content: e,
682
+ timestamp: /* @__PURE__ */ new Date()
683
+ };
684
+ }
685
+ async decryptResponseMessage(e) {
686
+ var n, s;
687
+ const i = e.content;
688
+ if ("failure" in i)
689
+ throw i.failure;
690
+ const r = await this.keyManager.getSharedSecret();
691
+ if (!r)
692
+ throw b.provider.unauthorized("Invalid session");
693
+ const o = await qn(i.encrypted, r), a = (n = o.data) === null || n === void 0 ? void 0 : n.chains;
694
+ if (a) {
695
+ const l = Object.entries(a).map(([h, c]) => ({
696
+ id: Number(h),
697
+ rpcUrl: c
698
+ }));
699
+ this.storage.storeObject(it, l), this.updateChain(this.chain.id, l);
700
+ }
701
+ const d = (s = o.data) === null || s === void 0 ? void 0 : s.capabilities;
702
+ return d && this.storage.storeObject(rt, d), o;
703
+ }
704
+ updateChain(e, n) {
705
+ var s;
706
+ const i = n ?? this.storage.loadObject(it), r = i == null ? void 0 : i.find((o) => o.id === e);
707
+ return r ? (r !== this.chain && (this.chain = r, this.storage.storeObject(st, r), (s = this.callback) === null || s === void 0 || s.call(this, "chainChanged", K(r.id))), !0) : !1;
708
+ }
709
+ }
710
+ const { keccak_256: Gn } = xn;
711
+ function Ft(t) {
712
+ return Buffer.allocUnsafe(t).fill(0);
713
+ }
714
+ function Yn(t) {
715
+ return t.toString(2).length;
716
+ }
717
+ function zt(t, e) {
718
+ let n = t.toString(16);
719
+ n.length % 2 !== 0 && (n = "0" + n);
720
+ const s = n.match(/.{1,2}/g).map((i) => parseInt(i, 16));
721
+ for (; s.length < e; )
722
+ s.unshift(0);
723
+ return Buffer.from(s);
724
+ }
725
+ function Jn(t, e) {
726
+ const n = t < 0n;
727
+ let s;
728
+ if (n) {
729
+ const i = (1n << BigInt(e)) - 1n;
730
+ s = (~t & i) + 1n;
731
+ } else
732
+ s = t;
733
+ return s &= (1n << BigInt(e)) - 1n, s;
734
+ }
735
+ function $t(t, e, n) {
736
+ const s = Ft(e);
737
+ return t = we(t), n ? t.length < e ? (t.copy(s), s) : t.slice(0, e) : t.length < e ? (t.copy(s, e - t.length), s) : t.slice(-e);
738
+ }
739
+ function Qn(t, e) {
740
+ return $t(t, e, !0);
741
+ }
742
+ function we(t) {
743
+ if (!Buffer.isBuffer(t))
744
+ if (Array.isArray(t))
745
+ t = Buffer.from(t);
746
+ else if (typeof t == "string")
747
+ Zt(t) ? t = Buffer.from(ts(Gt(t)), "hex") : t = Buffer.from(t);
748
+ else if (typeof t == "number")
749
+ t = intToBuffer(t);
750
+ else if (t == null)
751
+ t = Buffer.allocUnsafe(0);
752
+ else if (typeof t == "bigint")
753
+ t = zt(t);
754
+ else if (t.toArray)
755
+ t = Buffer.from(t.toArray());
756
+ else
757
+ throw new Error("invalid type");
758
+ return t;
759
+ }
760
+ function Xn(t) {
761
+ return t = we(t), "0x" + t.toString("hex");
762
+ }
763
+ function es(t, e) {
764
+ if (t = we(t), e || (e = 256), e !== 256)
765
+ throw new Error("unsupported");
766
+ return Buffer.from(Gn(new Uint8Array(t)));
767
+ }
768
+ function ts(t) {
769
+ return t.length % 2 ? "0" + t : t;
770
+ }
771
+ function Zt(t) {
772
+ return typeof t == "string" && t.match(/^0x[0-9A-Fa-f]*$/);
773
+ }
774
+ function Gt(t) {
775
+ return typeof t == "string" && t.startsWith("0x") ? t.slice(2) : t;
776
+ }
777
+ var Yt = {
778
+ zeros: Ft,
779
+ setLength: $t,
780
+ setLengthRight: Qn,
781
+ isHexString: Zt,
782
+ stripHexPrefix: Gt,
783
+ toBuffer: we,
784
+ bufferToHex: Xn,
785
+ keccak: es,
786
+ bitLengthFromBigInt: Yn,
787
+ bufferBEFromBigInt: zt,
788
+ twosFromBigInt: Jn
789
+ };
790
+ const S = Yt;
791
+ function Jt(t) {
792
+ return t.startsWith("int[") ? "int256" + t.slice(3) : t === "int" ? "int256" : t.startsWith("uint[") ? "uint256" + t.slice(4) : t === "uint" ? "uint256" : t.startsWith("fixed[") ? "fixed128x128" + t.slice(5) : t === "fixed" ? "fixed128x128" : t.startsWith("ufixed[") ? "ufixed128x128" + t.slice(6) : t === "ufixed" ? "ufixed128x128" : t;
793
+ }
794
+ function Y(t) {
795
+ return Number.parseInt(/^\D+(\d+)$/.exec(t)[1], 10);
796
+ }
797
+ function ot(t) {
798
+ var e = /^\D+(\d+)x(\d+)$/.exec(t);
799
+ return [Number.parseInt(e[1], 10), Number.parseInt(e[2], 10)];
800
+ }
801
+ function Qt(t) {
802
+ var e = t.match(/(.*)\[(.*?)\]$/);
803
+ return e ? e[2] === "" ? "dynamic" : Number.parseInt(e[2], 10) : null;
804
+ }
805
+ function z(t) {
806
+ var e = typeof t;
807
+ if (e === "string" || e === "number")
808
+ return BigInt(t);
809
+ if (e === "bigint")
810
+ return t;
811
+ throw new Error("Argument is not a number");
812
+ }
813
+ function D(t, e) {
814
+ var n, s, i, r;
815
+ if (t === "address")
816
+ return D("uint160", z(e));
817
+ if (t === "bool")
818
+ return D("uint8", e ? 1 : 0);
819
+ if (t === "string")
820
+ return D("bytes", new Buffer(e, "utf8"));
821
+ if (ss(t)) {
822
+ if (typeof e.length > "u")
823
+ throw new Error("Not an array?");
824
+ if (n = Qt(t), n !== "dynamic" && n !== 0 && e.length > n)
825
+ throw new Error("Elements exceed array size: " + n);
826
+ i = [], t = t.slice(0, t.lastIndexOf("[")), typeof e == "string" && (e = JSON.parse(e));
827
+ for (r in e)
828
+ i.push(D(t, e[r]));
829
+ if (n === "dynamic") {
830
+ var o = D("uint256", e.length);
831
+ i.unshift(o);
832
+ }
833
+ return Buffer.concat(i);
834
+ } else {
835
+ if (t === "bytes")
836
+ return e = new Buffer(e), i = Buffer.concat([D("uint256", e.length), e]), e.length % 32 !== 0 && (i = Buffer.concat([i, S.zeros(32 - e.length % 32)])), i;
837
+ if (t.startsWith("bytes")) {
838
+ if (n = Y(t), n < 1 || n > 32)
839
+ throw new Error("Invalid bytes<N> width: " + n);
840
+ return S.setLengthRight(e, 32);
841
+ } else if (t.startsWith("uint")) {
842
+ if (n = Y(t), n % 8 || n < 8 || n > 256)
843
+ throw new Error("Invalid uint<N> width: " + n);
844
+ s = z(e);
845
+ const a = S.bitLengthFromBigInt(s);
846
+ if (a > n)
847
+ throw new Error("Supplied uint exceeds width: " + n + " vs " + a);
848
+ if (s < 0)
849
+ throw new Error("Supplied uint is negative");
850
+ return S.bufferBEFromBigInt(s, 32);
851
+ } else if (t.startsWith("int")) {
852
+ if (n = Y(t), n % 8 || n < 8 || n > 256)
853
+ throw new Error("Invalid int<N> width: " + n);
854
+ s = z(e);
855
+ const a = S.bitLengthFromBigInt(s);
856
+ if (a > n)
857
+ throw new Error("Supplied int exceeds width: " + n + " vs " + a);
858
+ const d = S.twosFromBigInt(s, 256);
859
+ return S.bufferBEFromBigInt(d, 32);
860
+ } else if (t.startsWith("ufixed")) {
861
+ if (n = ot(t), s = z(e), s < 0)
862
+ throw new Error("Supplied ufixed is negative");
863
+ return D("uint256", s * BigInt(2) ** BigInt(n[1]));
864
+ } else if (t.startsWith("fixed"))
865
+ return n = ot(t), D("int256", z(e) * BigInt(2) ** BigInt(n[1]));
866
+ }
867
+ throw new Error("Unsupported or invalid type: " + t);
868
+ }
869
+ function ns(t) {
870
+ return t === "string" || t === "bytes" || Qt(t) === "dynamic";
871
+ }
872
+ function ss(t) {
873
+ return t.lastIndexOf("]") === t.length - 1;
874
+ }
875
+ function is(t, e) {
876
+ var n = [], s = [], i = 32 * t.length;
877
+ for (var r in t) {
878
+ var o = Jt(t[r]), a = e[r], d = D(o, a);
879
+ ns(o) ? (n.push(D("uint256", i)), s.push(d), i += d.length) : n.push(d);
880
+ }
881
+ return Buffer.concat(n.concat(s));
882
+ }
883
+ function Xt(t, e) {
884
+ if (t.length !== e.length)
885
+ throw new Error("Number of types are not matching the values");
886
+ for (var n, s, i = [], r = 0; r < t.length; r++) {
887
+ var o = Jt(t[r]), a = e[r];
888
+ if (o === "bytes")
889
+ i.push(a);
890
+ else if (o === "string")
891
+ i.push(new Buffer(a, "utf8"));
892
+ else if (o === "bool")
893
+ i.push(new Buffer(a ? "01" : "00", "hex"));
894
+ else if (o === "address")
895
+ i.push(S.setLength(a, 20));
896
+ else if (o.startsWith("bytes")) {
897
+ if (n = Y(o), n < 1 || n > 32)
898
+ throw new Error("Invalid bytes<N> width: " + n);
899
+ i.push(S.setLengthRight(a, n));
900
+ } else if (o.startsWith("uint")) {
901
+ if (n = Y(o), n % 8 || n < 8 || n > 256)
902
+ throw new Error("Invalid uint<N> width: " + n);
903
+ s = z(a);
904
+ const d = S.bitLengthFromBigInt(s);
905
+ if (d > n)
906
+ throw new Error("Supplied uint exceeds width: " + n + " vs " + d);
907
+ i.push(S.bufferBEFromBigInt(s, n / 8));
908
+ } else if (o.startsWith("int")) {
909
+ if (n = Y(o), n % 8 || n < 8 || n > 256)
910
+ throw new Error("Invalid int<N> width: " + n);
911
+ s = z(a);
912
+ const d = S.bitLengthFromBigInt(s);
913
+ if (d > n)
914
+ throw new Error("Supplied int exceeds width: " + n + " vs " + d);
915
+ const l = S.twosFromBigInt(s, n);
916
+ i.push(S.bufferBEFromBigInt(l, n / 8));
917
+ } else
918
+ throw new Error("Unsupported or invalid type: " + o);
919
+ }
920
+ return Buffer.concat(i);
921
+ }
922
+ function rs(t, e) {
923
+ return S.keccak(Xt(t, e));
924
+ }
925
+ var os = {
926
+ rawEncode: is,
927
+ solidityPack: Xt,
928
+ soliditySHA3: rs
929
+ };
930
+ const M = Yt, ie = os, en = {
931
+ type: "object",
932
+ properties: {
933
+ types: {
934
+ type: "object",
935
+ additionalProperties: {
936
+ type: "array",
937
+ items: {
938
+ type: "object",
939
+ properties: {
940
+ name: { type: "string" },
941
+ type: { type: "string" }
942
+ },
943
+ required: ["name", "type"]
944
+ }
945
+ }
946
+ },
947
+ primaryType: { type: "string" },
948
+ domain: { type: "object" },
949
+ message: { type: "object" }
950
+ },
951
+ required: ["types", "primaryType", "domain", "message"]
952
+ }, Me = {
953
+ /**
954
+ * Encodes an object by encoding and concatenating each of its members
955
+ *
956
+ * @param {string} primaryType - Root type
957
+ * @param {Object} data - Object to encode
958
+ * @param {Object} types - Type definitions
959
+ * @returns {string} - Encoded representation of an object
960
+ */
961
+ encodeData(t, e, n, s = !0) {
962
+ const i = ["bytes32"], r = [this.hashType(t, n)];
963
+ if (s) {
964
+ const o = (a, d, l) => {
965
+ if (n[d] !== void 0)
966
+ return ["bytes32", l == null ? "0x0000000000000000000000000000000000000000000000000000000000000000" : M.keccak(this.encodeData(d, l, n, s))];
967
+ if (l === void 0)
968
+ throw new Error(`missing value for field ${a} of type ${d}`);
969
+ if (d === "bytes")
970
+ return ["bytes32", M.keccak(l)];
971
+ if (d === "string")
972
+ return typeof l == "string" && (l = Buffer.from(l, "utf8")), ["bytes32", M.keccak(l)];
973
+ if (d.lastIndexOf("]") === d.length - 1) {
974
+ const h = d.slice(0, d.lastIndexOf("[")), c = l.map((f) => o(a, h, f));
975
+ return ["bytes32", M.keccak(ie.rawEncode(
976
+ c.map(([f]) => f),
977
+ c.map(([, f]) => f)
978
+ ))];
979
+ }
980
+ return [d, l];
981
+ };
982
+ for (const a of n[t]) {
983
+ const [d, l] = o(a.name, a.type, e[a.name]);
984
+ i.push(d), r.push(l);
985
+ }
986
+ } else
987
+ for (const o of n[t]) {
988
+ let a = e[o.name];
989
+ if (a !== void 0)
990
+ if (o.type === "bytes")
991
+ i.push("bytes32"), a = M.keccak(a), r.push(a);
992
+ else if (o.type === "string")
993
+ i.push("bytes32"), typeof a == "string" && (a = Buffer.from(a, "utf8")), a = M.keccak(a), r.push(a);
994
+ else if (n[o.type] !== void 0)
995
+ i.push("bytes32"), a = M.keccak(this.encodeData(o.type, a, n, s)), r.push(a);
996
+ else {
997
+ if (o.type.lastIndexOf("]") === o.type.length - 1)
998
+ throw new Error("Arrays currently unimplemented in encodeData");
999
+ i.push(o.type), r.push(a);
1000
+ }
1001
+ }
1002
+ return ie.rawEncode(i, r);
1003
+ },
1004
+ /**
1005
+ * Encodes the type of an object by encoding a comma delimited list of its members
1006
+ *
1007
+ * @param {string} primaryType - Root type to encode
1008
+ * @param {Object} types - Type definitions
1009
+ * @returns {string} - Encoded representation of the type of an object
1010
+ */
1011
+ encodeType(t, e) {
1012
+ let n = "", s = this.findTypeDependencies(t, e).filter((i) => i !== t);
1013
+ s = [t].concat(s.sort());
1014
+ for (const i of s) {
1015
+ if (!e[i])
1016
+ throw new Error("No type definition specified: " + i);
1017
+ n += i + "(" + e[i].map(({ name: o, type: a }) => a + " " + o).join(",") + ")";
1018
+ }
1019
+ return n;
1020
+ },
1021
+ /**
1022
+ * Finds all types within a type definition object
1023
+ *
1024
+ * @param {string} primaryType - Root type
1025
+ * @param {Object} types - Type definitions
1026
+ * @param {Array} results - current set of accumulated types
1027
+ * @returns {Array} - Set of all types found in the type definition
1028
+ */
1029
+ findTypeDependencies(t, e, n = []) {
1030
+ if (t = t.match(/^\w*/)[0], n.includes(t) || e[t] === void 0)
1031
+ return n;
1032
+ n.push(t);
1033
+ for (const s of e[t])
1034
+ for (const i of this.findTypeDependencies(s.type, e, n))
1035
+ !n.includes(i) && n.push(i);
1036
+ return n;
1037
+ },
1038
+ /**
1039
+ * Hashes an object
1040
+ *
1041
+ * @param {string} primaryType - Root type
1042
+ * @param {Object} data - Object to hash
1043
+ * @param {Object} types - Type definitions
1044
+ * @returns {Buffer} - Hash of an object
1045
+ */
1046
+ hashStruct(t, e, n, s = !0) {
1047
+ return M.keccak(this.encodeData(t, e, n, s));
1048
+ },
1049
+ /**
1050
+ * Hashes the type of an object
1051
+ *
1052
+ * @param {string} primaryType - Root type to hash
1053
+ * @param {Object} types - Type definitions
1054
+ * @returns {string} - Hash of an object
1055
+ */
1056
+ hashType(t, e) {
1057
+ return M.keccak(this.encodeType(t, e));
1058
+ },
1059
+ /**
1060
+ * Removes properties from a message object that are not defined per EIP-712
1061
+ *
1062
+ * @param {Object} data - typed message object
1063
+ * @returns {Object} - typed message object with only allowed fields
1064
+ */
1065
+ sanitizeData(t) {
1066
+ const e = {};
1067
+ for (const n in en.properties)
1068
+ t[n] && (e[n] = t[n]);
1069
+ return e.types && (e.types = Object.assign({ EIP712Domain: [] }, e.types)), e;
1070
+ },
1071
+ /**
1072
+ * Returns the hash of a typed message as per EIP-712 for signing
1073
+ *
1074
+ * @param {Object} typedData - Types message data to sign
1075
+ * @returns {string} - sha3 hash for signing
1076
+ */
1077
+ hash(t, e = !0) {
1078
+ const n = this.sanitizeData(t), s = [Buffer.from("1901", "hex")];
1079
+ return s.push(this.hashStruct("EIP712Domain", n.domain, n.types, e)), n.primaryType !== "EIP712Domain" && s.push(this.hashStruct(n.primaryType, n.message, n.types, e)), M.keccak(Buffer.concat(s));
1080
+ }
1081
+ };
1082
+ var as = {
1083
+ TYPED_MESSAGE_SCHEMA: en,
1084
+ TypedDataUtils: Me,
1085
+ hashForSignTypedDataLegacy: function(t) {
1086
+ return cs(t.data);
1087
+ },
1088
+ hashForSignTypedData_v3: function(t) {
1089
+ return Me.hash(t.data, !1);
1090
+ },
1091
+ hashForSignTypedData_v4: function(t) {
1092
+ return Me.hash(t.data);
1093
+ }
1094
+ };
1095
+ function cs(t) {
1096
+ const e = new Error("Expect argument to be non-empty array");
1097
+ if (typeof t != "object" || !t.length) throw e;
1098
+ const n = t.map(function(r) {
1099
+ return r.type === "bytes" ? M.toBuffer(r.value) : r.value;
1100
+ }), s = t.map(function(r) {
1101
+ return r.type;
1102
+ }), i = t.map(function(r) {
1103
+ if (!r.name) throw e;
1104
+ return r.type + " " + r.name;
1105
+ });
1106
+ return ie.soliditySHA3(
1107
+ ["bytes32", "bytes32"],
1108
+ [
1109
+ ie.soliditySHA3(new Array(t.length).fill("string"), i),
1110
+ ie.soliditySHA3(s, n)
1111
+ ]
1112
+ );
1113
+ }
1114
+ const de = /* @__PURE__ */ Pt(as), ls = "walletUsername", De = "Addresses", ds = "AppVersion";
1115
+ function I(t) {
1116
+ return t.errorMessage !== void 0;
1117
+ }
1118
+ class hs {
1119
+ // @param secret hex representation of 32-byte secret
1120
+ constructor(e) {
1121
+ this.secret = e;
1122
+ }
1123
+ /**
1124
+ *
1125
+ * @param plainText string to be encrypted
1126
+ * returns hex string representation of bytes in the order: initialization vector (iv),
1127
+ * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes. Remaining bytes are the
1128
+ * encrypted plainText.
1129
+ */
1130
+ async encrypt(e) {
1131
+ const n = this.secret;
1132
+ if (n.length !== 64)
1133
+ throw Error("secret must be 256 bits");
1134
+ const s = crypto.getRandomValues(new Uint8Array(12)), i = await crypto.subtle.importKey("raw", ue(n), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), r = new TextEncoder(), o = await window.crypto.subtle.encrypt({
1135
+ name: "AES-GCM",
1136
+ iv: s
1137
+ }, i, r.encode(e)), a = 16, d = o.slice(o.byteLength - a), l = o.slice(0, o.byteLength - a), h = new Uint8Array(d), c = new Uint8Array(l), f = new Uint8Array([...s, ...h, ...c]);
1138
+ return Fe(f);
1139
+ }
1140
+ /**
1141
+ *
1142
+ * @param cipherText hex string representation of bytes in the order: initialization vector (iv),
1143
+ * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes.
1144
+ */
1145
+ async decrypt(e) {
1146
+ const n = this.secret;
1147
+ if (n.length !== 64)
1148
+ throw Error("secret must be 256 bits");
1149
+ return new Promise((s, i) => {
1150
+ (async function() {
1151
+ const r = await crypto.subtle.importKey("raw", ue(n), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), o = ue(e), a = o.slice(0, 12), d = o.slice(12, 28), l = o.slice(28), h = new Uint8Array([...l, ...d]), c = {
1152
+ name: "AES-GCM",
1153
+ iv: new Uint8Array(a)
1154
+ };
1155
+ try {
1156
+ const f = await window.crypto.subtle.decrypt(c, r, h), u = new TextDecoder();
1157
+ s(u.decode(f));
1158
+ } catch (f) {
1159
+ i(f);
1160
+ }
1161
+ })();
1162
+ });
1163
+ }
1164
+ }
1165
+ class us {
1166
+ constructor(e, n, s) {
1167
+ this.linkAPIUrl = e, this.sessionId = n;
1168
+ const i = `${n}:${s}`;
1169
+ this.auth = `Basic ${btoa(i)}`;
1170
+ }
1171
+ // mark unseen events as seen
1172
+ async markUnseenEventsAsSeen(e) {
1173
+ return Promise.all(e.map((n) => fetch(`${this.linkAPIUrl}/events/${n.eventId}/seen`, {
1174
+ method: "POST",
1175
+ headers: {
1176
+ Authorization: this.auth
1177
+ }
1178
+ }))).catch((n) => console.error("Unabled to mark event as failed:", n));
1179
+ }
1180
+ async fetchUnseenEvents() {
1181
+ var e;
1182
+ const n = await fetch(`${this.linkAPIUrl}/events?unseen=true`, {
1183
+ headers: {
1184
+ Authorization: this.auth
1185
+ }
1186
+ });
1187
+ if (n.ok) {
1188
+ const { events: s, error: i } = await n.json();
1189
+ if (i)
1190
+ throw new Error(`Check unseen events failed: ${i}`);
1191
+ const r = (e = s == null ? void 0 : s.filter((o) => o.event === "Web3Response").map((o) => ({
1192
+ type: "Event",
1193
+ sessionId: this.sessionId,
1194
+ eventId: o.id,
1195
+ event: o.event,
1196
+ data: o.data
1197
+ }))) !== null && e !== void 0 ? e : [];
1198
+ return this.markUnseenEventsAsSeen(r), r;
1199
+ }
1200
+ throw new Error(`Check unseen events failed: ${n.status}`);
1201
+ }
1202
+ }
1203
+ var H;
1204
+ (function(t) {
1205
+ t[t.DISCONNECTED = 0] = "DISCONNECTED", t[t.CONNECTING = 1] = "CONNECTING", t[t.CONNECTED = 2] = "CONNECTED";
1206
+ })(H || (H = {}));
1207
+ class fs {
1208
+ setConnectionStateListener(e) {
1209
+ this.connectionStateListener = e;
1210
+ }
1211
+ setIncomingDataListener(e) {
1212
+ this.incomingDataListener = e;
1213
+ }
1214
+ /**
1215
+ * Constructor
1216
+ * @param url WebSocket server URL
1217
+ * @param [WebSocketClass] Custom WebSocket implementation
1218
+ */
1219
+ constructor(e, n = WebSocket) {
1220
+ this.WebSocketClass = n, this.webSocket = null, this.pendingData = [], this.url = e.replace(/^http/, "ws");
1221
+ }
1222
+ /**
1223
+ * Make a websocket connection
1224
+ * @returns a Promise that resolves when connected
1225
+ */
1226
+ async connect() {
1227
+ if (this.webSocket)
1228
+ throw new Error("webSocket object is not null");
1229
+ return new Promise((e, n) => {
1230
+ var s;
1231
+ let i;
1232
+ try {
1233
+ this.webSocket = i = new this.WebSocketClass(this.url);
1234
+ } catch (r) {
1235
+ n(r);
1236
+ return;
1237
+ }
1238
+ (s = this.connectionStateListener) === null || s === void 0 || s.call(this, H.CONNECTING), i.onclose = (r) => {
1239
+ var o;
1240
+ this.clearWebSocket(), n(new Error(`websocket error ${r.code}: ${r.reason}`)), (o = this.connectionStateListener) === null || o === void 0 || o.call(this, H.DISCONNECTED);
1241
+ }, i.onopen = (r) => {
1242
+ var o;
1243
+ e(), (o = this.connectionStateListener) === null || o === void 0 || o.call(this, H.CONNECTED), this.pendingData.length > 0 && ([...this.pendingData].forEach((d) => this.sendData(d)), this.pendingData = []);
1244
+ }, i.onmessage = (r) => {
1245
+ var o, a;
1246
+ if (r.data === "h")
1247
+ (o = this.incomingDataListener) === null || o === void 0 || o.call(this, {
1248
+ type: "Heartbeat"
1249
+ });
1250
+ else
1251
+ try {
1252
+ const d = JSON.parse(r.data);
1253
+ (a = this.incomingDataListener) === null || a === void 0 || a.call(this, d);
1254
+ } catch {
1255
+ }
1256
+ };
1257
+ });
1258
+ }
1259
+ /**
1260
+ * Disconnect from server
1261
+ */
1262
+ disconnect() {
1263
+ var e;
1264
+ const { webSocket: n } = this;
1265
+ if (n) {
1266
+ this.clearWebSocket(), (e = this.connectionStateListener) === null || e === void 0 || e.call(this, H.DISCONNECTED), this.connectionStateListener = void 0, this.incomingDataListener = void 0;
1267
+ try {
1268
+ n.close();
1269
+ } catch {
1270
+ }
1271
+ }
1272
+ }
1273
+ /**
1274
+ * Send data to server
1275
+ * @param data text to send
1276
+ */
1277
+ sendData(e) {
1278
+ const { webSocket: n } = this;
1279
+ if (!n) {
1280
+ this.pendingData.push(e), this.connect();
1281
+ return;
1282
+ }
1283
+ n.send(e);
1284
+ }
1285
+ clearWebSocket() {
1286
+ const { webSocket: e } = this;
1287
+ e && (this.webSocket = null, e.onclose = null, e.onerror = null, e.onmessage = null, e.onopen = null);
1288
+ }
1289
+ }
1290
+ const at = 1e4, ps = 6e4;
1291
+ class gs {
1292
+ /**
1293
+ * Constructor
1294
+ * @param session Session
1295
+ * @param linkAPIUrl Coinbase Wallet link server URL
1296
+ * @param listener WalletLinkConnectionUpdateListener
1297
+ * @param [WebSocketClass] Custom WebSocket implementation
1298
+ */
1299
+ constructor({ session: e, linkAPIUrl: n, listener: s }) {
1300
+ this.destroyed = !1, this.lastHeartbeatResponse = 0, this.nextReqId = U(1), this._connected = !1, this._linked = !1, this.shouldFetchUnseenEventsOnConnect = !1, this.requestResolutions = /* @__PURE__ */ new Map(), this.handleSessionMetadataUpdated = (r) => {
1301
+ if (!r)
1302
+ return;
1303
+ (/* @__PURE__ */ new Map([
1304
+ ["__destroyed", this.handleDestroyed],
1305
+ ["EthereumAddress", this.handleAccountUpdated],
1306
+ ["WalletUsername", this.handleWalletUsernameUpdated],
1307
+ ["AppVersion", this.handleAppVersionUpdated],
1308
+ [
1309
+ "ChainId",
1310
+ // ChainId and JsonRpcUrl are always updated together
1311
+ (a) => r.JsonRpcUrl && this.handleChainUpdated(a, r.JsonRpcUrl)
1312
+ ]
1313
+ ])).forEach((a, d) => {
1314
+ const l = r[d];
1315
+ l !== void 0 && a(l);
1316
+ });
1317
+ }, this.handleDestroyed = (r) => {
1318
+ var o;
1319
+ r === "1" && ((o = this.listener) === null || o === void 0 || o.resetAndReload());
1320
+ }, this.handleAccountUpdated = async (r) => {
1321
+ var o;
1322
+ const a = await this.cipher.decrypt(r);
1323
+ (o = this.listener) === null || o === void 0 || o.accountUpdated(a);
1324
+ }, this.handleMetadataUpdated = async (r, o) => {
1325
+ var a;
1326
+ const d = await this.cipher.decrypt(o);
1327
+ (a = this.listener) === null || a === void 0 || a.metadataUpdated(r, d);
1328
+ }, this.handleWalletUsernameUpdated = async (r) => {
1329
+ this.handleMetadataUpdated(ls, r);
1330
+ }, this.handleAppVersionUpdated = async (r) => {
1331
+ this.handleMetadataUpdated(ds, r);
1332
+ }, this.handleChainUpdated = async (r, o) => {
1333
+ var a;
1334
+ const d = await this.cipher.decrypt(r), l = await this.cipher.decrypt(o);
1335
+ (a = this.listener) === null || a === void 0 || a.chainUpdated(d, l);
1336
+ }, this.session = e, this.cipher = new hs(e.secret), this.listener = s;
1337
+ const i = new fs(`${n}/rpc`, WebSocket);
1338
+ i.setConnectionStateListener(async (r) => {
1339
+ let o = !1;
1340
+ switch (r) {
1341
+ case H.DISCONNECTED:
1342
+ if (!this.destroyed) {
1343
+ const a = async () => {
1344
+ await new Promise((d) => setTimeout(d, 5e3)), this.destroyed || i.connect().catch(() => {
1345
+ a();
1346
+ });
1347
+ };
1348
+ a();
1349
+ }
1350
+ break;
1351
+ case H.CONNECTED:
1352
+ o = await this.handleConnected(), this.updateLastHeartbeat(), setInterval(() => {
1353
+ this.heartbeat();
1354
+ }, at), this.shouldFetchUnseenEventsOnConnect && this.fetchUnseenEventsAPI();
1355
+ break;
1356
+ case H.CONNECTING:
1357
+ break;
1358
+ }
1359
+ this.connected !== o && (this.connected = o);
1360
+ }), i.setIncomingDataListener((r) => {
1361
+ var o;
1362
+ switch (r.type) {
1363
+ case "Heartbeat":
1364
+ this.updateLastHeartbeat();
1365
+ return;
1366
+ case "IsLinkedOK":
1367
+ case "Linked": {
1368
+ const a = r.type === "IsLinkedOK" ? r.linked : void 0;
1369
+ this.linked = a || r.onlineGuests > 0;
1370
+ break;
1371
+ }
1372
+ case "GetSessionConfigOK":
1373
+ case "SessionConfigUpdated": {
1374
+ this.handleSessionMetadataUpdated(r.metadata);
1375
+ break;
1376
+ }
1377
+ case "Event": {
1378
+ this.handleIncomingEvent(r);
1379
+ break;
1380
+ }
1381
+ }
1382
+ r.id !== void 0 && ((o = this.requestResolutions.get(r.id)) === null || o === void 0 || o(r));
1383
+ }), this.ws = i, this.http = new us(n, e.id, e.key);
1384
+ }
1385
+ /**
1386
+ * Make a connection to the server
1387
+ */
1388
+ connect() {
1389
+ if (this.destroyed)
1390
+ throw new Error("instance is destroyed");
1391
+ this.ws.connect();
1392
+ }
1393
+ /**
1394
+ * Terminate connection, and mark as destroyed. To reconnect, create a new
1395
+ * instance of WalletSDKConnection
1396
+ */
1397
+ async destroy() {
1398
+ this.destroyed || (await this.makeRequest({
1399
+ type: "SetSessionConfig",
1400
+ id: U(this.nextReqId++),
1401
+ sessionId: this.session.id,
1402
+ metadata: { __destroyed: "1" }
1403
+ }, { timeout: 1e3 }), this.destroyed = !0, this.ws.disconnect(), this.listener = void 0);
1404
+ }
1405
+ get connected() {
1406
+ return this._connected;
1407
+ }
1408
+ set connected(e) {
1409
+ this._connected = e;
1410
+ }
1411
+ get linked() {
1412
+ return this._linked;
1413
+ }
1414
+ set linked(e) {
1415
+ var n, s;
1416
+ this._linked = e, e && ((n = this.onceLinked) === null || n === void 0 || n.call(this)), (s = this.listener) === null || s === void 0 || s.linkedUpdated(e);
1417
+ }
1418
+ setOnceLinked(e) {
1419
+ return new Promise((n) => {
1420
+ this.linked ? e().then(n) : this.onceLinked = () => {
1421
+ e().then(n), this.onceLinked = void 0;
1422
+ };
1423
+ });
1424
+ }
1425
+ async handleIncomingEvent(e) {
1426
+ var n;
1427
+ if (e.type !== "Event" || e.event !== "Web3Response")
1428
+ return;
1429
+ const s = await this.cipher.decrypt(e.data), i = JSON.parse(s);
1430
+ if (i.type !== "WEB3_RESPONSE")
1431
+ return;
1432
+ const { id: r, response: o } = i;
1433
+ (n = this.listener) === null || n === void 0 || n.handleWeb3ResponseMessage(r, o);
1434
+ }
1435
+ async checkUnseenEvents() {
1436
+ if (!this.connected) {
1437
+ this.shouldFetchUnseenEventsOnConnect = !0;
1438
+ return;
1439
+ }
1440
+ await new Promise((e) => setTimeout(e, 250));
1441
+ try {
1442
+ await this.fetchUnseenEventsAPI();
1443
+ } catch (e) {
1444
+ console.error("Unable to check for unseen events", e);
1445
+ }
1446
+ }
1447
+ async fetchUnseenEventsAPI() {
1448
+ this.shouldFetchUnseenEventsOnConnect = !1, (await this.http.fetchUnseenEvents()).forEach((n) => this.handleIncomingEvent(n));
1449
+ }
1450
+ /**
1451
+ * Publish an event and emit event ID when successful
1452
+ * @param event event name
1453
+ * @param unencryptedData unencrypted event data
1454
+ * @param callWebhook whether the webhook should be invoked
1455
+ * @returns a Promise that emits event ID when successful
1456
+ */
1457
+ async publishEvent(e, n, s = !1) {
1458
+ const i = await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({}, n), { origin: location.origin, location: location.href, relaySource: "coinbaseWalletExtension" in window && window.coinbaseWalletExtension ? "injected_sdk" : "sdk" }))), r = {
1459
+ type: "PublishEvent",
1460
+ id: U(this.nextReqId++),
1461
+ sessionId: this.session.id,
1462
+ event: e,
1463
+ data: i,
1464
+ callWebhook: s
1465
+ };
1466
+ return this.setOnceLinked(async () => {
1467
+ const o = await this.makeRequest(r);
1468
+ if (o.type === "Fail")
1469
+ throw new Error(o.error || "failed to publish event");
1470
+ return o.eventId;
1471
+ });
1472
+ }
1473
+ sendData(e) {
1474
+ this.ws.sendData(JSON.stringify(e));
1475
+ }
1476
+ updateLastHeartbeat() {
1477
+ this.lastHeartbeatResponse = Date.now();
1478
+ }
1479
+ heartbeat() {
1480
+ if (Date.now() - this.lastHeartbeatResponse > at * 2) {
1481
+ this.ws.disconnect();
1482
+ return;
1483
+ }
1484
+ try {
1485
+ this.ws.sendData("h");
1486
+ } catch {
1487
+ }
1488
+ }
1489
+ async makeRequest(e, n = { timeout: ps }) {
1490
+ const s = e.id;
1491
+ this.sendData(e);
1492
+ let i;
1493
+ return Promise.race([
1494
+ new Promise((r, o) => {
1495
+ i = window.setTimeout(() => {
1496
+ o(new Error(`request ${s} timed out`));
1497
+ }, n.timeout);
1498
+ }),
1499
+ new Promise((r) => {
1500
+ this.requestResolutions.set(s, (o) => {
1501
+ clearTimeout(i), r(o), this.requestResolutions.delete(s);
1502
+ });
1503
+ })
1504
+ ]);
1505
+ }
1506
+ async handleConnected() {
1507
+ return (await this.makeRequest({
1508
+ type: "HostSession",
1509
+ id: U(this.nextReqId++),
1510
+ sessionId: this.session.id,
1511
+ sessionKey: this.session.key
1512
+ })).type === "Fail" ? !1 : (this.sendData({
1513
+ type: "IsLinked",
1514
+ id: U(this.nextReqId++),
1515
+ sessionId: this.session.id
1516
+ }), this.sendData({
1517
+ type: "GetSessionConfig",
1518
+ id: U(this.nextReqId++),
1519
+ sessionId: this.session.id
1520
+ }), !0);
1521
+ }
1522
+ }
1523
+ class _s {
1524
+ constructor() {
1525
+ this._nextRequestId = 0, this.callbacks = /* @__PURE__ */ new Map();
1526
+ }
1527
+ makeRequestId() {
1528
+ this._nextRequestId = (this._nextRequestId + 1) % 2147483647;
1529
+ const e = this._nextRequestId, n = Wt(e.toString(16));
1530
+ return this.callbacks.get(n) && this.callbacks.delete(n), e;
1531
+ }
1532
+ }
1533
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1534
+ function ms(t) {
1535
+ return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
1536
+ }
1537
+ function ye(t, ...e) {
1538
+ if (!ms(t))
1539
+ throw new Error("Uint8Array expected");
1540
+ if (e.length > 0 && !e.includes(t.length))
1541
+ throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
1542
+ }
1543
+ function ct(t, e = !0) {
1544
+ if (t.destroyed)
1545
+ throw new Error("Hash instance has been destroyed");
1546
+ if (e && t.finished)
1547
+ throw new Error("Hash#digest() has already been called");
1548
+ }
1549
+ function bs(t, e) {
1550
+ ye(t);
1551
+ const n = e.outputLen;
1552
+ if (t.length < n)
1553
+ throw new Error("digestInto() expects output buffer of length at least " + n);
1554
+ }
1555
+ function Oe(...t) {
1556
+ for (let e = 0; e < t.length; e++)
1557
+ t[e].fill(0);
1558
+ }
1559
+ function Le(t) {
1560
+ return new DataView(t.buffer, t.byteOffset, t.byteLength);
1561
+ }
1562
+ function N(t, e) {
1563
+ return t << 32 - e | t >>> e;
1564
+ }
1565
+ const ws = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", ys = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0"));
1566
+ function vs(t) {
1567
+ if (ye(t), ws)
1568
+ return t.toHex();
1569
+ let e = "";
1570
+ for (let n = 0; n < t.length; n++)
1571
+ e += ys[t[n]];
1572
+ return e;
1573
+ }
1574
+ function ks(t) {
1575
+ if (typeof t != "string")
1576
+ throw new Error("string expected");
1577
+ return new Uint8Array(new TextEncoder().encode(t));
1578
+ }
1579
+ function tn(t) {
1580
+ return typeof t == "string" && (t = ks(t)), ye(t), t;
1581
+ }
1582
+ class Es {
1583
+ }
1584
+ function Cs(t) {
1585
+ const e = (s) => t().update(tn(s)).digest(), n = t();
1586
+ return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
1587
+ }
1588
+ function xs(t, e, n, s) {
1589
+ if (typeof t.setBigUint64 == "function")
1590
+ return t.setBigUint64(e, n, s);
1591
+ const i = BigInt(32), r = BigInt(4294967295), o = Number(n >> i & r), a = Number(n & r), d = s ? 4 : 0, l = s ? 0 : 4;
1592
+ t.setUint32(e + d, o, s), t.setUint32(e + l, a, s);
1593
+ }
1594
+ function Is(t, e, n) {
1595
+ return t & e ^ ~t & n;
1596
+ }
1597
+ function Ss(t, e, n) {
1598
+ return t & e ^ t & n ^ e & n;
1599
+ }
1600
+ class As extends Es {
1601
+ constructor(e, n, s, i) {
1602
+ super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = e, this.outputLen = n, this.padOffset = s, this.isLE = i, this.buffer = new Uint8Array(e), this.view = Le(this.buffer);
1603
+ }
1604
+ update(e) {
1605
+ ct(this), e = tn(e), ye(e);
1606
+ const { view: n, buffer: s, blockLen: i } = this, r = e.length;
1607
+ for (let o = 0; o < r; ) {
1608
+ const a = Math.min(i - this.pos, r - o);
1609
+ if (a === i) {
1610
+ const d = Le(e);
1611
+ for (; i <= r - o; o += i)
1612
+ this.process(d, o);
1613
+ continue;
1614
+ }
1615
+ s.set(e.subarray(o, o + a), this.pos), this.pos += a, o += a, this.pos === i && (this.process(n, 0), this.pos = 0);
1616
+ }
1617
+ return this.length += e.length, this.roundClean(), this;
1618
+ }
1619
+ digestInto(e) {
1620
+ ct(this), bs(e, this), this.finished = !0;
1621
+ const { buffer: n, view: s, blockLen: i, isLE: r } = this;
1622
+ let { pos: o } = this;
1623
+ n[o++] = 128, Oe(this.buffer.subarray(o)), this.padOffset > i - o && (this.process(s, 0), o = 0);
1624
+ for (let c = o; c < i; c++)
1625
+ n[c] = 0;
1626
+ xs(s, i - 8, BigInt(this.length * 8), r), this.process(s, 0);
1627
+ const a = Le(e), d = this.outputLen;
1628
+ if (d % 4)
1629
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
1630
+ const l = d / 4, h = this.get();
1631
+ if (l > h.length)
1632
+ throw new Error("_sha2: outputLen bigger than state");
1633
+ for (let c = 0; c < l; c++)
1634
+ a.setUint32(4 * c, h[c], r);
1635
+ }
1636
+ digest() {
1637
+ const { buffer: e, outputLen: n } = this;
1638
+ this.digestInto(e);
1639
+ const s = e.slice(0, n);
1640
+ return this.destroy(), s;
1641
+ }
1642
+ _cloneInto(e) {
1643
+ e || (e = new this.constructor()), e.set(...this.get());
1644
+ const { blockLen: n, buffer: s, length: i, finished: r, destroyed: o, pos: a } = this;
1645
+ return e.destroyed = o, e.finished = r, e.length = i, e.pos = a, i % n && e.buffer.set(s), e;
1646
+ }
1647
+ clone() {
1648
+ return this._cloneInto();
1649
+ }
1650
+ }
1651
+ const q = /* @__PURE__ */ Uint32Array.from([
1652
+ 1779033703,
1653
+ 3144134277,
1654
+ 1013904242,
1655
+ 2773480762,
1656
+ 1359893119,
1657
+ 2600822924,
1658
+ 528734635,
1659
+ 1541459225
1660
+ ]), Ms = /* @__PURE__ */ Uint32Array.from([
1661
+ 1116352408,
1662
+ 1899447441,
1663
+ 3049323471,
1664
+ 3921009573,
1665
+ 961987163,
1666
+ 1508970993,
1667
+ 2453635748,
1668
+ 2870763221,
1669
+ 3624381080,
1670
+ 310598401,
1671
+ 607225278,
1672
+ 1426881987,
1673
+ 1925078388,
1674
+ 2162078206,
1675
+ 2614888103,
1676
+ 3248222580,
1677
+ 3835390401,
1678
+ 4022224774,
1679
+ 264347078,
1680
+ 604807628,
1681
+ 770255983,
1682
+ 1249150122,
1683
+ 1555081692,
1684
+ 1996064986,
1685
+ 2554220882,
1686
+ 2821834349,
1687
+ 2952996808,
1688
+ 3210313671,
1689
+ 3336571891,
1690
+ 3584528711,
1691
+ 113926993,
1692
+ 338241895,
1693
+ 666307205,
1694
+ 773529912,
1695
+ 1294757372,
1696
+ 1396182291,
1697
+ 1695183700,
1698
+ 1986661051,
1699
+ 2177026350,
1700
+ 2456956037,
1701
+ 2730485921,
1702
+ 2820302411,
1703
+ 3259730800,
1704
+ 3345764771,
1705
+ 3516065817,
1706
+ 3600352804,
1707
+ 4094571909,
1708
+ 275423344,
1709
+ 430227734,
1710
+ 506948616,
1711
+ 659060556,
1712
+ 883997877,
1713
+ 958139571,
1714
+ 1322822218,
1715
+ 1537002063,
1716
+ 1747873779,
1717
+ 1955562222,
1718
+ 2024104815,
1719
+ 2227730452,
1720
+ 2361852424,
1721
+ 2428436474,
1722
+ 2756734187,
1723
+ 3204031479,
1724
+ 3329325298
1725
+ ]), V = /* @__PURE__ */ new Uint32Array(64);
1726
+ class Ls extends As {
1727
+ constructor(e = 32) {
1728
+ super(64, e, 8, !1), this.A = q[0] | 0, this.B = q[1] | 0, this.C = q[2] | 0, this.D = q[3] | 0, this.E = q[4] | 0, this.F = q[5] | 0, this.G = q[6] | 0, this.H = q[7] | 0;
1729
+ }
1730
+ get() {
1731
+ const { A: e, B: n, C: s, D: i, E: r, F: o, G: a, H: d } = this;
1732
+ return [e, n, s, i, r, o, a, d];
1733
+ }
1734
+ // prettier-ignore
1735
+ set(e, n, s, i, r, o, a, d) {
1736
+ this.A = e | 0, this.B = n | 0, this.C = s | 0, this.D = i | 0, this.E = r | 0, this.F = o | 0, this.G = a | 0, this.H = d | 0;
1737
+ }
1738
+ process(e, n) {
1739
+ for (let c = 0; c < 16; c++, n += 4)
1740
+ V[c] = e.getUint32(n, !1);
1741
+ for (let c = 16; c < 64; c++) {
1742
+ const f = V[c - 15], u = V[c - 2], g = N(f, 7) ^ N(f, 18) ^ f >>> 3, v = N(u, 17) ^ N(u, 19) ^ u >>> 10;
1743
+ V[c] = v + V[c - 7] + g + V[c - 16] | 0;
1744
+ }
1745
+ let { A: s, B: i, C: r, D: o, E: a, F: d, G: l, H: h } = this;
1746
+ for (let c = 0; c < 64; c++) {
1747
+ const f = N(a, 6) ^ N(a, 11) ^ N(a, 25), u = h + f + Is(a, d, l) + Ms[c] + V[c] | 0, v = (N(s, 2) ^ N(s, 13) ^ N(s, 22)) + Ss(s, i, r) | 0;
1748
+ h = l, l = d, d = a, a = o + u | 0, o = r, r = i, i = s, s = u + v | 0;
1749
+ }
1750
+ s = s + this.A | 0, i = i + this.B | 0, r = r + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, d = d + this.F | 0, l = l + this.G | 0, h = h + this.H | 0, this.set(s, i, r, o, a, d, l, h);
1751
+ }
1752
+ roundClean() {
1753
+ Oe(V);
1754
+ }
1755
+ destroy() {
1756
+ this.set(0, 0, 0, 0, 0, 0, 0, 0), Oe(this.buffer);
1757
+ }
1758
+ }
1759
+ const Ps = /* @__PURE__ */ Cs(() => new Ls()), Rs = Ps, lt = "session:id", dt = "session:secret", ht = "session:linked";
1760
+ class J {
1761
+ constructor(e, n, s, i = !1) {
1762
+ this.storage = e, this.id = n, this.secret = s, this.key = vs(Rs(`${n}, ${s} WalletLink`)), this._linked = !!i;
1763
+ }
1764
+ static create(e) {
1765
+ const n = F(16), s = F(32);
1766
+ return new J(e, n, s).save();
1767
+ }
1768
+ static load(e) {
1769
+ const n = e.getItem(lt), s = e.getItem(ht), i = e.getItem(dt);
1770
+ return n && i ? new J(e, n, i, s === "1") : null;
1771
+ }
1772
+ get linked() {
1773
+ return this._linked;
1774
+ }
1775
+ set linked(e) {
1776
+ this._linked = e, this.persistLinked();
1777
+ }
1778
+ save() {
1779
+ return this.storage.setItem(lt, this.id), this.storage.setItem(dt, this.secret), this.persistLinked(), this;
1780
+ }
1781
+ persistLinked() {
1782
+ this.storage.setItem(ht, this._linked ? "1" : "0");
1783
+ }
1784
+ }
1785
+ function Ts() {
1786
+ try {
1787
+ return window.frameElement !== null;
1788
+ } catch {
1789
+ return !1;
1790
+ }
1791
+ }
1792
+ function Ns() {
1793
+ try {
1794
+ return Ts() && window.top ? window.top.location : window.location;
1795
+ } catch {
1796
+ return window.location;
1797
+ }
1798
+ }
1799
+ function Ds() {
1800
+ var t;
1801
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t = window == null ? void 0 : window.navigator) === null || t === void 0 ? void 0 : t.userAgent);
1802
+ }
1803
+ function nn() {
1804
+ var t, e;
1805
+ return (e = (t = window == null ? void 0 : window.matchMedia) === null || t === void 0 ? void 0 : t.call(window, "(prefers-color-scheme: dark)").matches) !== null && e !== void 0 ? e : !1;
1806
+ }
1807
+ const Os = '@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';
1808
+ function sn() {
1809
+ const t = document.createElement("style");
1810
+ t.type = "text/css", t.appendChild(document.createTextNode(Os)), document.documentElement.appendChild(t);
1811
+ }
1812
+ function rn(t) {
1813
+ var e, n, s = "";
1814
+ if (typeof t == "string" || typeof t == "number") s += t;
1815
+ else if (typeof t == "object") if (Array.isArray(t)) for (e = 0; e < t.length; e++) t[e] && (n = rn(t[e])) && (s && (s += " "), s += n);
1816
+ else for (e in t) t[e] && (s && (s += " "), s += e);
1817
+ return s;
1818
+ }
1819
+ function re() {
1820
+ for (var t, e, n = 0, s = ""; n < arguments.length; ) (t = arguments[n++]) && (e = rn(t)) && (s && (s += " "), s += e);
1821
+ return s;
1822
+ }
1823
+ var ve, k, on, $, ut, an, cn, ln, Ge, Ue, je, ae = {}, dn = [], Us = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, ke = Array.isArray;
1824
+ function W(t, e) {
1825
+ for (var n in e) t[n] = e[n];
1826
+ return t;
1827
+ }
1828
+ function Ye(t) {
1829
+ t && t.parentNode && t.parentNode.removeChild(t);
1830
+ }
1831
+ function y(t, e, n) {
1832
+ var s, i, r, o = {};
1833
+ for (r in e) r == "key" ? s = e[r] : r == "ref" ? i = e[r] : o[r] = e[r];
1834
+ if (arguments.length > 2 && (o.children = arguments.length > 3 ? ve.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (r in t.defaultProps) o[r] === void 0 && (o[r] = t.defaultProps[r]);
1835
+ return fe(t, o, s, i, null);
1836
+ }
1837
+ function fe(t, e, n, s, i) {
1838
+ var r = { type: t, props: e, key: n, ref: s, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++on, __i: -1, __u: 0 };
1839
+ return i == null && k.vnode != null && k.vnode(r), r;
1840
+ }
1841
+ function Ee(t) {
1842
+ return t.children;
1843
+ }
1844
+ function pe(t, e) {
1845
+ this.props = t, this.context = e;
1846
+ }
1847
+ function Q(t, e) {
1848
+ if (e == null) return t.__ ? Q(t.__, t.__i + 1) : null;
1849
+ for (var n; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) return n.__e;
1850
+ return typeof t.type == "function" ? Q(t) : null;
1851
+ }
1852
+ function hn(t) {
1853
+ var e, n;
1854
+ if ((t = t.__) != null && t.__c != null) {
1855
+ for (t.__e = t.__c.base = null, e = 0; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) {
1856
+ t.__e = t.__c.base = n.__e;
1857
+ break;
1858
+ }
1859
+ return hn(t);
1860
+ }
1861
+ }
1862
+ function ft(t) {
1863
+ (!t.__d && (t.__d = !0) && $.push(t) && !_e.__r++ || ut != k.debounceRendering) && ((ut = k.debounceRendering) || an)(_e);
1864
+ }
1865
+ function _e() {
1866
+ for (var t, e, n, s, i, r, o, a = 1; $.length; ) $.length > a && $.sort(cn), t = $.shift(), a = $.length, t.__d && (n = void 0, s = void 0, i = (s = (e = t).__v).__e, r = [], o = [], e.__P && ((n = W({}, s)).__v = s.__v + 1, k.vnode && k.vnode(n), Je(e.__P, n, s, e.__n, e.__P.namespaceURI, 32 & s.__u ? [i] : null, r, i ?? Q(s), !!(32 & s.__u), o), n.__v = s.__v, n.__.__k[n.__i] = n, pn(r, n, o), s.__e = s.__ = null, n.__e != i && hn(n)));
1867
+ _e.__r = 0;
1868
+ }
1869
+ function un(t, e, n, s, i, r, o, a, d, l, h) {
1870
+ var c, f, u, g, v, p, _, m = s && s.__k || dn, w = e.length;
1871
+ for (d = js(n, e, m, d, w), c = 0; c < w; c++) (u = n.__k[c]) != null && (f = u.__i == -1 ? ae : m[u.__i] || ae, u.__i = c, p = Je(t, u, f, i, r, o, a, d, l, h), g = u.__e, u.ref && f.ref != u.ref && (f.ref && Qe(f.ref, null, u), h.push(u.ref, u.__c || g, u)), v == null && g != null && (v = g), (_ = !!(4 & u.__u)) || f.__k === u.__k ? d = fn(u, d, t, _) : typeof u.type == "function" && p !== void 0 ? d = p : g && (d = g.nextSibling), u.__u &= -7);
1872
+ return n.__e = v, d;
1873
+ }
1874
+ function js(t, e, n, s, i) {
1875
+ var r, o, a, d, l, h = n.length, c = h, f = 0;
1876
+ for (t.__k = new Array(i), r = 0; r < i; r++) (o = e[r]) != null && typeof o != "boolean" && typeof o != "function" ? (d = r + f, (o = t.__k[r] = typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? fe(null, o, null, null, null) : ke(o) ? fe(Ee, { children: o }, null, null, null) : o.constructor == null && o.__b > 0 ? fe(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : o).__ = t, o.__b = t.__b + 1, a = null, (l = o.__i = Hs(o, n, d, c)) != -1 && (c--, (a = n[l]) && (a.__u |= 2)), a == null || a.__v == null ? (l == -1 && (i > h ? f-- : i < h && f++), typeof o.type != "function" && (o.__u |= 4)) : l != d && (l == d - 1 ? f-- : l == d + 1 ? f++ : (l > d ? f-- : f++, o.__u |= 4))) : t.__k[r] = null;
1877
+ if (c) for (r = 0; r < h; r++) (a = n[r]) != null && !(2 & a.__u) && (a.__e == s && (s = Q(a)), _n(a, a));
1878
+ return s;
1879
+ }
1880
+ function fn(t, e, n, s) {
1881
+ var i, r;
1882
+ if (typeof t.type == "function") {
1883
+ for (i = t.__k, r = 0; i && r < i.length; r++) i[r] && (i[r].__ = t, e = fn(i[r], e, n, s));
1884
+ return e;
1885
+ }
1886
+ t.__e != e && (s && (e && t.type && !e.parentNode && (e = Q(t)), n.insertBefore(t.__e, e || null)), e = t.__e);
1887
+ do
1888
+ e = e && e.nextSibling;
1889
+ while (e != null && e.nodeType == 8);
1890
+ return e;
1891
+ }
1892
+ function Hs(t, e, n, s) {
1893
+ var i, r, o, a = t.key, d = t.type, l = e[n], h = l != null && (2 & l.__u) == 0;
1894
+ if (l === null && t.key == null || h && a == l.key && d == l.type) return n;
1895
+ if (s > (h ? 1 : 0)) {
1896
+ for (i = n - 1, r = n + 1; i >= 0 || r < e.length; ) if ((l = e[o = i >= 0 ? i-- : r++]) != null && !(2 & l.__u) && a == l.key && d == l.type) return o;
1897
+ }
1898
+ return -1;
1899
+ }
1900
+ function pt(t, e, n) {
1901
+ e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || Us.test(e) ? n : n + "px";
1902
+ }
1903
+ function he(t, e, n, s, i) {
1904
+ var r, o;
1905
+ e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
1906
+ else {
1907
+ if (typeof s == "string" && (t.style.cssText = s = ""), s) for (e in s) n && e in n || pt(t.style, e, "");
1908
+ if (n) for (e in n) s && n[e] == s[e] || pt(t.style, e, n[e]);
1909
+ }
1910
+ else if (e[0] == "o" && e[1] == "n") r = e != (e = e.replace(ln, "$1")), o = e.toLowerCase(), e = o in t || e == "onFocusOut" || e == "onFocusIn" ? o.slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + r] = n, n ? s ? n.u = s.u : (n.u = Ge, t.addEventListener(e, r ? je : Ue, r)) : t.removeEventListener(e, r ? je : Ue, r);
1911
+ else {
1912
+ if (i == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
1913
+ else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try {
1914
+ t[e] = n ?? "";
1915
+ break e;
1916
+ } catch {
1917
+ }
1918
+ typeof n == "function" || (n == null || n === !1 && e[4] != "-" ? t.removeAttribute(e) : t.setAttribute(e, e == "popover" && n == 1 ? "" : n));
1919
+ }
1920
+ }
1921
+ function gt(t) {
1922
+ return function(e) {
1923
+ if (this.l) {
1924
+ var n = this.l[e.type + t];
1925
+ if (e.t == null) e.t = Ge++;
1926
+ else if (e.t < n.u) return;
1927
+ return n(k.event ? k.event(e) : e);
1928
+ }
1929
+ };
1930
+ }
1931
+ function Je(t, e, n, s, i, r, o, a, d, l) {
1932
+ var h, c, f, u, g, v, p, _, m, w, L, P, X, Xe, le, ee, Ce, R = e.type;
1933
+ if (e.constructor != null) return null;
1934
+ 128 & n.__u && (d = !!(32 & n.__u), r = [a = e.__e = n.__e]), (h = k.__b) && h(e);
1935
+ e: if (typeof R == "function") try {
1936
+ if (_ = e.props, m = "prototype" in R && R.prototype.render, w = (h = R.contextType) && s[h.__c], L = h ? w ? w.props.value : h.__ : s, n.__c ? p = (c = e.__c = n.__c).__ = c.__E : (m ? e.__c = c = new R(_, L) : (e.__c = c = new pe(_, L), c.constructor = R, c.render = Bs), w && w.sub(c), c.props = _, c.state || (c.state = {}), c.context = L, c.__n = s, f = c.__d = !0, c.__h = [], c._sb = []), m && c.__s == null && (c.__s = c.state), m && R.getDerivedStateFromProps != null && (c.__s == c.state && (c.__s = W({}, c.__s)), W(c.__s, R.getDerivedStateFromProps(_, c.__s))), u = c.props, g = c.state, c.__v = e, f) m && R.getDerivedStateFromProps == null && c.componentWillMount != null && c.componentWillMount(), m && c.componentDidMount != null && c.__h.push(c.componentDidMount);
1937
+ else {
1938
+ if (m && R.getDerivedStateFromProps == null && _ !== u && c.componentWillReceiveProps != null && c.componentWillReceiveProps(_, L), !c.__e && c.shouldComponentUpdate != null && c.shouldComponentUpdate(_, c.__s, L) === !1 || e.__v == n.__v) {
1939
+ for (e.__v != n.__v && (c.props = _, c.state = c.__s, c.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(Z) {
1940
+ Z && (Z.__ = e);
1941
+ }), P = 0; P < c._sb.length; P++) c.__h.push(c._sb[P]);
1942
+ c._sb = [], c.__h.length && o.push(c);
1943
+ break e;
1944
+ }
1945
+ c.componentWillUpdate != null && c.componentWillUpdate(_, c.__s, L), m && c.componentDidUpdate != null && c.__h.push(function() {
1946
+ c.componentDidUpdate(u, g, v);
1947
+ });
1948
+ }
1949
+ if (c.context = L, c.props = _, c.__P = t, c.__e = !1, X = k.__r, Xe = 0, m) {
1950
+ for (c.state = c.__s, c.__d = !1, X && X(e), h = c.render(c.props, c.state, c.context), le = 0; le < c._sb.length; le++) c.__h.push(c._sb[le]);
1951
+ c._sb = [];
1952
+ } else do
1953
+ c.__d = !1, X && X(e), h = c.render(c.props, c.state, c.context), c.state = c.__s;
1954
+ while (c.__d && ++Xe < 25);
1955
+ c.state = c.__s, c.getChildContext != null && (s = W(W({}, s), c.getChildContext())), m && !f && c.getSnapshotBeforeUpdate != null && (v = c.getSnapshotBeforeUpdate(u, g)), ee = h, h != null && h.type === Ee && h.key == null && (ee = gn(h.props.children)), a = un(t, ke(ee) ? ee : [ee], e, n, s, i, r, o, a, d, l), c.base = e.__e, e.__u &= -161, c.__h.length && o.push(c), p && (c.__E = c.__ = null);
1956
+ } catch (Z) {
1957
+ if (e.__v = null, d || r != null) if (Z.then) {
1958
+ for (e.__u |= d ? 160 : 128; a && a.nodeType == 8 && a.nextSibling; ) a = a.nextSibling;
1959
+ r[r.indexOf(a)] = null, e.__e = a;
1960
+ } else {
1961
+ for (Ce = r.length; Ce--; ) Ye(r[Ce]);
1962
+ He(e);
1963
+ }
1964
+ else e.__e = n.__e, e.__k = n.__k, Z.then || He(e);
1965
+ k.__e(Z, e, n);
1966
+ }
1967
+ else r == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : a = e.__e = Ws(n.__e, e, n, s, i, r, o, d, l);
1968
+ return (h = k.diffed) && h(e), 128 & e.__u ? void 0 : a;
1969
+ }
1970
+ function He(t) {
1971
+ t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(He);
1972
+ }
1973
+ function pn(t, e, n) {
1974
+ for (var s = 0; s < n.length; s++) Qe(n[s], n[++s], n[++s]);
1975
+ k.__c && k.__c(e, t), t.some(function(i) {
1976
+ try {
1977
+ t = i.__h, i.__h = [], t.some(function(r) {
1978
+ r.call(i);
1979
+ });
1980
+ } catch (r) {
1981
+ k.__e(r, i.__v);
1982
+ }
1983
+ });
1984
+ }
1985
+ function gn(t) {
1986
+ return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : ke(t) ? t.map(gn) : W({}, t);
1987
+ }
1988
+ function Ws(t, e, n, s, i, r, o, a, d) {
1989
+ var l, h, c, f, u, g, v, p = n.props, _ = e.props, m = e.type;
1990
+ if (m == "svg" ? i = "http://www.w3.org/2000/svg" : m == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), r != null) {
1991
+ for (l = 0; l < r.length; l++) if ((u = r[l]) && "setAttribute" in u == !!m && (m ? u.localName == m : u.nodeType == 3)) {
1992
+ t = u, r[l] = null;
1993
+ break;
1994
+ }
1995
+ }
1996
+ if (t == null) {
1997
+ if (m == null) return document.createTextNode(_);
1998
+ t = document.createElementNS(i, m, _.is && _), a && (k.__m && k.__m(e, r), a = !1), r = null;
1999
+ }
2000
+ if (m == null) p === _ || a && t.data == _ || (t.data = _);
2001
+ else {
2002
+ if (r = r && ve.call(t.childNodes), p = n.props || ae, !a && r != null) for (p = {}, l = 0; l < t.attributes.length; l++) p[(u = t.attributes[l]).name] = u.value;
2003
+ for (l in p) if (u = p[l], l != "children") {
2004
+ if (l == "dangerouslySetInnerHTML") c = u;
2005
+ else if (!(l in _)) {
2006
+ if (l == "value" && "defaultValue" in _ || l == "checked" && "defaultChecked" in _) continue;
2007
+ he(t, l, null, u, i);
2008
+ }
2009
+ }
2010
+ for (l in _) u = _[l], l == "children" ? f = u : l == "dangerouslySetInnerHTML" ? h = u : l == "value" ? g = u : l == "checked" ? v = u : a && typeof u != "function" || p[l] === u || he(t, l, u, p[l], i);
2011
+ if (h) a || c && (h.__html == c.__html || h.__html == t.innerHTML) || (t.innerHTML = h.__html), e.__k = [];
2012
+ else if (c && (t.innerHTML = ""), un(e.type == "template" ? t.content : t, ke(f) ? f : [f], e, n, s, m == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, r, o, r ? r[0] : n.__k && Q(n, 0), a, d), r != null) for (l = r.length; l--; ) Ye(r[l]);
2013
+ a || (l = "value", m == "progress" && g == null ? t.removeAttribute("value") : g != null && (g !== t[l] || m == "progress" && !g || m == "option" && g != p[l]) && he(t, l, g, p[l], i), l = "checked", v != null && v != t[l] && he(t, l, v, p[l], i));
2014
+ }
2015
+ return t;
2016
+ }
2017
+ function Qe(t, e, n) {
2018
+ try {
2019
+ if (typeof t == "function") {
2020
+ var s = typeof t.__u == "function";
2021
+ s && t.__u(), s && e == null || (t.__u = t(e));
2022
+ } else t.current = e;
2023
+ } catch (i) {
2024
+ k.__e(i, n);
2025
+ }
2026
+ }
2027
+ function _n(t, e, n) {
2028
+ var s, i;
2029
+ if (k.unmount && k.unmount(t), (s = t.ref) && (s.current && s.current != t.__e || Qe(s, null, e)), (s = t.__c) != null) {
2030
+ if (s.componentWillUnmount) try {
2031
+ s.componentWillUnmount();
2032
+ } catch (r) {
2033
+ k.__e(r, e);
2034
+ }
2035
+ s.base = s.__P = null;
2036
+ }
2037
+ if (s = t.__k) for (i = 0; i < s.length; i++) s[i] && _n(s[i], e, n || typeof t.type != "function");
2038
+ n || Ye(t.__e), t.__c = t.__ = t.__e = void 0;
2039
+ }
2040
+ function Bs(t, e, n) {
2041
+ return this.constructor(t, n);
2042
+ }
2043
+ function We(t, e, n) {
2044
+ var s, i, r, o;
2045
+ e == document && (e = document.documentElement), k.__ && k.__(t, e), i = (s = !1) ? null : e.__k, r = [], o = [], Je(e, t = e.__k = y(Ee, null, [t]), i || ae, ae, e.namespaceURI, i ? null : e.firstChild ? ve.call(e.childNodes) : null, r, i ? i.__e : e.firstChild, s, o), pn(r, t, o);
2046
+ }
2047
+ ve = dn.slice, k = { __e: function(t, e, n, s) {
2048
+ for (var i, r, o; e = e.__; ) if ((i = e.__c) && !i.__) try {
2049
+ if ((r = i.constructor) && r.getDerivedStateFromError != null && (i.setState(r.getDerivedStateFromError(t)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(t, s || {}), o = i.__d), o) return i.__E = i;
2050
+ } catch (a) {
2051
+ t = a;
2052
+ }
2053
+ throw t;
2054
+ } }, on = 0, pe.prototype.setState = function(t, e) {
2055
+ var n;
2056
+ n = this.__s != null && this.__s != this.state ? this.__s : this.__s = W({}, this.state), typeof t == "function" && (t = t(W({}, n), this.props)), t && W(n, t), t != null && this.__v && (e && this._sb.push(e), ft(this));
2057
+ }, pe.prototype.forceUpdate = function(t) {
2058
+ this.__v && (this.__e = !0, t && this.__h.push(t), ft(this));
2059
+ }, pe.prototype.render = Ee, $ = [], an = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, cn = function(t, e) {
2060
+ return t.__v.__b - e.__v.__b;
2061
+ }, _e.__r = 0, ln = /(PointerCapture)$|Capture$/i, Ge = 0, Ue = gt(!1), je = gt(!0);
2062
+ var me, C, Pe, _t, Be = 0, mn = [], x = k, mt = x.__b, bt = x.__r, wt = x.diffed, yt = x.__c, vt = x.unmount, kt = x.__;
2063
+ function bn(t, e) {
2064
+ x.__h && x.__h(C, t, Be || e), Be = 0;
2065
+ var n = C.__H || (C.__H = { __: [], __h: [] });
2066
+ return t >= n.__.length && n.__.push({}), n.__[t];
2067
+ }
2068
+ function Et(t) {
2069
+ return Be = 1, qs(wn, t);
2070
+ }
2071
+ function qs(t, e, n) {
2072
+ var s = bn(me++, 2);
2073
+ if (s.t = t, !s.__c && (s.__ = [wn(void 0, e), function(a) {
2074
+ var d = s.__N ? s.__N[0] : s.__[0], l = s.t(d, a);
2075
+ d !== l && (s.__N = [l, s.__[1]], s.__c.setState({}));
2076
+ }], s.__c = C, !C.__f)) {
2077
+ var i = function(a, d, l) {
2078
+ if (!s.__c.__H) return !0;
2079
+ var h = s.__c.__H.__.filter(function(f) {
2080
+ return !!f.__c;
2081
+ });
2082
+ if (h.every(function(f) {
2083
+ return !f.__N;
2084
+ })) return !r || r.call(this, a, d, l);
2085
+ var c = s.__c.props !== a;
2086
+ return h.forEach(function(f) {
2087
+ if (f.__N) {
2088
+ var u = f.__[0];
2089
+ f.__ = f.__N, f.__N = void 0, u !== f.__[0] && (c = !0);
2090
+ }
2091
+ }), r && r.call(this, a, d, l) || c;
2092
+ };
2093
+ C.__f = !0;
2094
+ var r = C.shouldComponentUpdate, o = C.componentWillUpdate;
2095
+ C.componentWillUpdate = function(a, d, l) {
2096
+ if (this.__e) {
2097
+ var h = r;
2098
+ r = void 0, i(a, d, l), r = h;
2099
+ }
2100
+ o && o.call(this, a, d, l);
2101
+ }, C.shouldComponentUpdate = i;
2102
+ }
2103
+ return s.__N || s.__;
2104
+ }
2105
+ function Vs(t, e) {
2106
+ var n = bn(me++, 3);
2107
+ !x.__s && zs(n.__H, e) && (n.__ = t, n.u = e, C.__H.__h.push(n));
2108
+ }
2109
+ function Ks() {
2110
+ for (var t; t = mn.shift(); ) if (t.__P && t.__H) try {
2111
+ t.__H.__h.forEach(ge), t.__H.__h.forEach(qe), t.__H.__h = [];
2112
+ } catch (e) {
2113
+ t.__H.__h = [], x.__e(e, t.__v);
2114
+ }
2115
+ }
2116
+ x.__b = function(t) {
2117
+ C = null, mt && mt(t);
2118
+ }, x.__ = function(t, e) {
2119
+ t && e.__k && e.__k.__m && (t.__m = e.__k.__m), kt && kt(t, e);
2120
+ }, x.__r = function(t) {
2121
+ bt && bt(t), me = 0;
2122
+ var e = (C = t.__c).__H;
2123
+ e && (Pe === C ? (e.__h = [], C.__h = [], e.__.forEach(function(n) {
2124
+ n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
2125
+ })) : (e.__h.forEach(ge), e.__h.forEach(qe), e.__h = [], me = 0)), Pe = C;
2126
+ }, x.diffed = function(t) {
2127
+ wt && wt(t);
2128
+ var e = t.__c;
2129
+ e && e.__H && (e.__H.__h.length && (mn.push(e) !== 1 && _t === x.requestAnimationFrame || ((_t = x.requestAnimationFrame) || Fs)(Ks)), e.__H.__.forEach(function(n) {
2130
+ n.u && (n.__H = n.u), n.u = void 0;
2131
+ })), Pe = C = null;
2132
+ }, x.__c = function(t, e) {
2133
+ e.some(function(n) {
2134
+ try {
2135
+ n.__h.forEach(ge), n.__h = n.__h.filter(function(s) {
2136
+ return !s.__ || qe(s);
2137
+ });
2138
+ } catch (s) {
2139
+ e.some(function(i) {
2140
+ i.__h && (i.__h = []);
2141
+ }), e = [], x.__e(s, n.__v);
2142
+ }
2143
+ }), yt && yt(t, e);
2144
+ }, x.unmount = function(t) {
2145
+ vt && vt(t);
2146
+ var e, n = t.__c;
2147
+ n && n.__H && (n.__H.__.forEach(function(s) {
2148
+ try {
2149
+ ge(s);
2150
+ } catch (i) {
2151
+ e = i;
2152
+ }
2153
+ }), n.__H = void 0, e && x.__e(e, n.__v));
2154
+ };
2155
+ var Ct = typeof requestAnimationFrame == "function";
2156
+ function Fs(t) {
2157
+ var e, n = function() {
2158
+ clearTimeout(s), Ct && cancelAnimationFrame(e), setTimeout(t);
2159
+ }, s = setTimeout(n, 35);
2160
+ Ct && (e = requestAnimationFrame(n));
2161
+ }
2162
+ function ge(t) {
2163
+ var e = C, n = t.__c;
2164
+ typeof n == "function" && (t.__c = void 0, n()), C = e;
2165
+ }
2166
+ function qe(t) {
2167
+ var e = C;
2168
+ t.__c = t.__(), C = e;
2169
+ }
2170
+ function zs(t, e) {
2171
+ return !t || t.length !== e.length || e.some(function(n, s) {
2172
+ return n !== t[s];
2173
+ });
2174
+ }
2175
+ function wn(t, e) {
2176
+ return typeof e == "function" ? e(t) : e;
2177
+ }
2178
+ const $s = ".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}", Zs = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+", Gs = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";
2179
+ class Ys {
2180
+ constructor() {
2181
+ this.items = /* @__PURE__ */ new Map(), this.nextItemKey = 0, this.root = null, this.darkMode = nn();
2182
+ }
2183
+ attach(e) {
2184
+ this.root = document.createElement("div"), this.root.className = "-cbwsdk-snackbar-root", e.appendChild(this.root), this.render();
2185
+ }
2186
+ presentItem(e) {
2187
+ const n = this.nextItemKey++;
2188
+ return this.items.set(n, e), this.render(), () => {
2189
+ this.items.delete(n), this.render();
2190
+ };
2191
+ }
2192
+ clear() {
2193
+ this.items.clear(), this.render();
2194
+ }
2195
+ render() {
2196
+ this.root && We(y(
2197
+ "div",
2198
+ null,
2199
+ y(yn, { darkMode: this.darkMode }, Array.from(this.items.entries()).map(([e, n]) => y(Js, Object.assign({}, n, { key: e }))))
2200
+ ), this.root);
2201
+ }
2202
+ }
2203
+ const yn = (t) => y(
2204
+ "div",
2205
+ { class: re("-cbwsdk-snackbar-container") },
2206
+ y("style", null, $s),
2207
+ y("div", { class: "-cbwsdk-snackbar" }, t.children)
2208
+ ), Js = ({ autoExpand: t, message: e, menuItems: n }) => {
2209
+ const [s, i] = Et(!0), [r, o] = Et(t ?? !1);
2210
+ Vs(() => {
2211
+ const d = [
2212
+ window.setTimeout(() => {
2213
+ i(!1);
2214
+ }, 1),
2215
+ window.setTimeout(() => {
2216
+ o(!0);
2217
+ }, 1e4)
2218
+ ];
2219
+ return () => {
2220
+ d.forEach(window.clearTimeout);
2221
+ };
2222
+ });
2223
+ const a = () => {
2224
+ o(!r);
2225
+ };
2226
+ return y(
2227
+ "div",
2228
+ { class: re("-cbwsdk-snackbar-instance", s && "-cbwsdk-snackbar-instance-hidden", r && "-cbwsdk-snackbar-instance-expanded") },
2229
+ y(
2230
+ "div",
2231
+ { class: "-cbwsdk-snackbar-instance-header", onClick: a },
2232
+ y("img", { src: Zs, class: "-cbwsdk-snackbar-instance-header-cblogo" }),
2233
+ " ",
2234
+ y("div", { class: "-cbwsdk-snackbar-instance-header-message" }, e),
2235
+ y(
2236
+ "div",
2237
+ { class: "-gear-container" },
2238
+ !r && y(
2239
+ "svg",
2240
+ { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
2241
+ y("circle", { cx: "12", cy: "12", r: "12", fill: "#F5F7F8" })
2242
+ ),
2243
+ y("img", { src: Gs, class: "-gear-icon", title: "Expand" })
2244
+ )
2245
+ ),
2246
+ n && n.length > 0 && y("div", { class: "-cbwsdk-snackbar-instance-menu" }, n.map((d, l) => y(
2247
+ "div",
2248
+ { class: re("-cbwsdk-snackbar-instance-menu-item", d.isRed && "-cbwsdk-snackbar-instance-menu-item-is-red"), onClick: d.onClick, key: l },
2249
+ y(
2250
+ "svg",
2251
+ { width: d.svgWidth, height: d.svgHeight, viewBox: "0 0 10 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
2252
+ y("path", { "fill-rule": d.defaultFillRule, "clip-rule": d.defaultClipRule, d: d.path, fill: "#AAAAAA" })
2253
+ ),
2254
+ y("span", { class: re("-cbwsdk-snackbar-instance-menu-item-info", d.isRed && "-cbwsdk-snackbar-instance-menu-item-info-is-red") }, d.info)
2255
+ )))
2256
+ );
2257
+ };
2258
+ class Qs {
2259
+ constructor() {
2260
+ this.attached = !1, this.snackbar = new Ys();
2261
+ }
2262
+ attach() {
2263
+ if (this.attached)
2264
+ throw new Error("Coinbase Wallet SDK UI is already attached");
2265
+ const e = document.documentElement, n = document.createElement("div");
2266
+ n.className = "-cbwsdk-css-reset", e.appendChild(n), this.snackbar.attach(n), this.attached = !0, sn();
2267
+ }
2268
+ showConnecting(e) {
2269
+ let n;
2270
+ return e.isUnlinkedErrorState ? n = {
2271
+ autoExpand: !0,
2272
+ message: "Connection lost",
2273
+ menuItems: [
2274
+ {
2275
+ isRed: !1,
2276
+ info: "Reset connection",
2277
+ svgWidth: "10",
2278
+ svgHeight: "11",
2279
+ path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",
2280
+ defaultFillRule: "evenodd",
2281
+ defaultClipRule: "evenodd",
2282
+ onClick: e.onResetConnection
2283
+ }
2284
+ ]
2285
+ } : n = {
2286
+ message: "Confirm on phone",
2287
+ menuItems: [
2288
+ {
2289
+ isRed: !0,
2290
+ info: "Cancel transaction",
2291
+ svgWidth: "11",
2292
+ svgHeight: "11",
2293
+ path: "M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",
2294
+ defaultFillRule: "inherit",
2295
+ defaultClipRule: "inherit",
2296
+ onClick: e.onCancel
2297
+ },
2298
+ {
2299
+ isRed: !1,
2300
+ info: "Reset connection",
2301
+ svgWidth: "10",
2302
+ svgHeight: "11",
2303
+ path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",
2304
+ defaultFillRule: "evenodd",
2305
+ defaultClipRule: "evenodd",
2306
+ onClick: e.onResetConnection
2307
+ }
2308
+ ]
2309
+ }, this.snackbar.presentItem(n);
2310
+ }
2311
+ }
2312
+ const Xs = ".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";
2313
+ class ei {
2314
+ constructor() {
2315
+ this.root = null, this.darkMode = nn();
2316
+ }
2317
+ attach() {
2318
+ const e = document.documentElement;
2319
+ this.root = document.createElement("div"), this.root.className = "-cbwsdk-css-reset", e.appendChild(this.root), sn();
2320
+ }
2321
+ present(e) {
2322
+ this.render(e);
2323
+ }
2324
+ clear() {
2325
+ this.render(null);
2326
+ }
2327
+ render(e) {
2328
+ this.root && (We(null, this.root), e && We(y(ti, Object.assign({}, e, { onDismiss: () => {
2329
+ this.clear();
2330
+ }, darkMode: this.darkMode })), this.root));
2331
+ }
2332
+ }
2333
+ const ti = ({ title: t, buttonText: e, darkMode: n, onButtonClick: s, onDismiss: i }) => {
2334
+ const r = n ? "dark" : "light";
2335
+ return y(
2336
+ yn,
2337
+ { darkMode: n },
2338
+ y(
2339
+ "div",
2340
+ { class: "-cbwsdk-redirect-dialog" },
2341
+ y("style", null, Xs),
2342
+ y("div", { class: "-cbwsdk-redirect-dialog-backdrop", onClick: i }),
2343
+ y(
2344
+ "div",
2345
+ { class: re("-cbwsdk-redirect-dialog-box", r) },
2346
+ y("p", null, t),
2347
+ y("button", { onClick: s }, e)
2348
+ )
2349
+ )
2350
+ );
2351
+ }, ni = "https://keys.coinbase.com/connect", si = "http://rpc.wallet.coinbase.com", xt = "https://www.walletlink.org", ii = "https://go.cb-w.com/walletlink";
2352
+ class It {
2353
+ constructor() {
2354
+ this.attached = !1, this.redirectDialog = new ei();
2355
+ }
2356
+ attach() {
2357
+ if (this.attached)
2358
+ throw new Error("Coinbase Wallet SDK UI is already attached");
2359
+ this.redirectDialog.attach(), this.attached = !0;
2360
+ }
2361
+ redirectToCoinbaseWallet(e) {
2362
+ const n = new URL(ii);
2363
+ n.searchParams.append("redirect_url", Ns().href), e && n.searchParams.append("wl_url", e);
2364
+ const s = document.createElement("a");
2365
+ s.target = "cbw-opener", s.href = n.href, s.rel = "noreferrer noopener", s.click();
2366
+ }
2367
+ openCoinbaseWalletDeeplink(e) {
2368
+ this.redirectDialog.present({
2369
+ title: "Redirecting to Coinbase Wallet...",
2370
+ buttonText: "Open",
2371
+ onButtonClick: () => {
2372
+ this.redirectToCoinbaseWallet(e);
2373
+ }
2374
+ }), setTimeout(() => {
2375
+ this.redirectToCoinbaseWallet(e);
2376
+ }, 99);
2377
+ }
2378
+ showConnecting(e) {
2379
+ return () => {
2380
+ this.redirectDialog.clear();
2381
+ };
2382
+ }
2383
+ }
2384
+ class j {
2385
+ constructor(e) {
2386
+ this.chainCallbackParams = { chainId: "", jsonRpcUrl: "" }, this.isMobileWeb = Ds(), this.linkedUpdated = (r) => {
2387
+ this.isLinked = r;
2388
+ const o = this.storage.getItem(De);
2389
+ if (r && (this._session.linked = r), this.isUnlinkedErrorState = !1, o) {
2390
+ const a = o.split(" "), d = this.storage.getItem("IsStandaloneSigning") === "true";
2391
+ a[0] !== "" && !r && this._session.linked && !d && (this.isUnlinkedErrorState = !0);
2392
+ }
2393
+ }, this.metadataUpdated = (r, o) => {
2394
+ this.storage.setItem(r, o);
2395
+ }, this.chainUpdated = (r, o) => {
2396
+ this.chainCallbackParams.chainId === r && this.chainCallbackParams.jsonRpcUrl === o || (this.chainCallbackParams = {
2397
+ chainId: r,
2398
+ jsonRpcUrl: o
2399
+ }, this.chainCallback && this.chainCallback(o, Number.parseInt(r, 10)));
2400
+ }, this.accountUpdated = (r) => {
2401
+ this.accountsCallback && this.accountsCallback([r]), j.accountRequestCallbackIds.size > 0 && (Array.from(j.accountRequestCallbackIds.values()).forEach((o) => {
2402
+ this.invokeCallback(o, {
2403
+ method: "requestEthereumAccounts",
2404
+ result: [r]
2405
+ });
2406
+ }), j.accountRequestCallbackIds.clear());
2407
+ }, this.resetAndReload = this.resetAndReload.bind(this), this.linkAPIUrl = e.linkAPIUrl, this.storage = e.storage, this.metadata = e.metadata, this.accountsCallback = e.accountsCallback, this.chainCallback = e.chainCallback;
2408
+ const { session: n, ui: s, connection: i } = this.subscribe();
2409
+ this._session = n, this.connection = i, this.relayEventManager = new _s(), this.ui = s, this.ui.attach();
2410
+ }
2411
+ subscribe() {
2412
+ const e = J.load(this.storage) || J.create(this.storage), { linkAPIUrl: n } = this, s = new gs({
2413
+ session: e,
2414
+ linkAPIUrl: n,
2415
+ listener: this
2416
+ }), i = this.isMobileWeb ? new It() : new Qs();
2417
+ return s.connect(), { session: e, ui: i, connection: s };
2418
+ }
2419
+ resetAndReload() {
2420
+ this.connection.destroy().then(() => {
2421
+ const e = J.load(this.storage);
2422
+ (e == null ? void 0 : e.id) === this._session.id && O.clearAll(), document.location.reload();
2423
+ }).catch((e) => {
2424
+ });
2425
+ }
2426
+ signEthereumTransaction(e) {
2427
+ return this.sendRequest({
2428
+ method: "signEthereumTransaction",
2429
+ params: {
2430
+ fromAddress: e.fromAddress,
2431
+ toAddress: e.toAddress,
2432
+ weiValue: T(e.weiValue),
2433
+ data: ne(e.data, !0),
2434
+ nonce: e.nonce,
2435
+ gasPriceInWei: e.gasPriceInWei ? T(e.gasPriceInWei) : null,
2436
+ maxFeePerGas: e.gasPriceInWei ? T(e.gasPriceInWei) : null,
2437
+ maxPriorityFeePerGas: e.gasPriceInWei ? T(e.gasPriceInWei) : null,
2438
+ gasLimit: e.gasLimit ? T(e.gasLimit) : null,
2439
+ chainId: e.chainId,
2440
+ shouldSubmit: !1
2441
+ }
2442
+ });
2443
+ }
2444
+ signAndSubmitEthereumTransaction(e) {
2445
+ return this.sendRequest({
2446
+ method: "signEthereumTransaction",
2447
+ params: {
2448
+ fromAddress: e.fromAddress,
2449
+ toAddress: e.toAddress,
2450
+ weiValue: T(e.weiValue),
2451
+ data: ne(e.data, !0),
2452
+ nonce: e.nonce,
2453
+ gasPriceInWei: e.gasPriceInWei ? T(e.gasPriceInWei) : null,
2454
+ maxFeePerGas: e.maxFeePerGas ? T(e.maxFeePerGas) : null,
2455
+ maxPriorityFeePerGas: e.maxPriorityFeePerGas ? T(e.maxPriorityFeePerGas) : null,
2456
+ gasLimit: e.gasLimit ? T(e.gasLimit) : null,
2457
+ chainId: e.chainId,
2458
+ shouldSubmit: !0
2459
+ }
2460
+ });
2461
+ }
2462
+ submitEthereumTransaction(e, n) {
2463
+ return this.sendRequest({
2464
+ method: "submitEthereumTransaction",
2465
+ params: {
2466
+ signedTransaction: ne(e, !0),
2467
+ chainId: n
2468
+ }
2469
+ });
2470
+ }
2471
+ getWalletLinkSession() {
2472
+ return this._session;
2473
+ }
2474
+ sendRequest(e) {
2475
+ let n = null;
2476
+ const s = F(8), i = (r) => {
2477
+ this.publishWeb3RequestCanceledEvent(s), this.handleErrorResponse(s, e.method, r), n == null || n();
2478
+ };
2479
+ return new Promise((r, o) => {
2480
+ n = this.ui.showConnecting({
2481
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
2482
+ onCancel: i,
2483
+ onResetConnection: this.resetAndReload
2484
+ // eslint-disable-line @typescript-eslint/unbound-method
2485
+ }), this.relayEventManager.callbacks.set(s, (a) => {
2486
+ if (n == null || n(), I(a))
2487
+ return o(new Error(a.errorMessage));
2488
+ r(a);
2489
+ }), this.publishWeb3RequestEvent(s, e);
2490
+ });
2491
+ }
2492
+ publishWeb3RequestEvent(e, n) {
2493
+ const s = { type: "WEB3_REQUEST", id: e, request: n };
2494
+ this.publishEvent("Web3Request", s, !0).then((i) => {
2495
+ }).catch((i) => {
2496
+ this.handleWeb3ResponseMessage(s.id, {
2497
+ method: n.method,
2498
+ errorMessage: i.message
2499
+ });
2500
+ }), this.isMobileWeb && this.openCoinbaseWalletDeeplink(n.method);
2501
+ }
2502
+ // copied from MobileRelay
2503
+ openCoinbaseWalletDeeplink(e) {
2504
+ if (this.ui instanceof It)
2505
+ switch (e) {
2506
+ case "requestEthereumAccounts":
2507
+ case "switchEthereumChain":
2508
+ return;
2509
+ default:
2510
+ window.addEventListener("blur", () => {
2511
+ window.addEventListener("focus", () => {
2512
+ this.connection.checkUnseenEvents();
2513
+ }, { once: !0 });
2514
+ }, { once: !0 }), this.ui.openCoinbaseWalletDeeplink();
2515
+ break;
2516
+ }
2517
+ }
2518
+ publishWeb3RequestCanceledEvent(e) {
2519
+ const n = {
2520
+ type: "WEB3_REQUEST_CANCELED",
2521
+ id: e
2522
+ };
2523
+ this.publishEvent("Web3RequestCanceled", n, !1).then();
2524
+ }
2525
+ publishEvent(e, n, s) {
2526
+ return this.connection.publishEvent(e, n, s);
2527
+ }
2528
+ handleWeb3ResponseMessage(e, n) {
2529
+ if (n.method === "requestEthereumAccounts") {
2530
+ j.accountRequestCallbackIds.forEach((s) => this.invokeCallback(s, n)), j.accountRequestCallbackIds.clear();
2531
+ return;
2532
+ }
2533
+ this.invokeCallback(e, n);
2534
+ }
2535
+ handleErrorResponse(e, n, s) {
2536
+ var i;
2537
+ const r = (i = s == null ? void 0 : s.message) !== null && i !== void 0 ? i : "Unspecified error message.";
2538
+ this.handleWeb3ResponseMessage(e, {
2539
+ method: n,
2540
+ errorMessage: r
2541
+ });
2542
+ }
2543
+ invokeCallback(e, n) {
2544
+ const s = this.relayEventManager.callbacks.get(e);
2545
+ s && (s(n), this.relayEventManager.callbacks.delete(e));
2546
+ }
2547
+ requestEthereumAccounts() {
2548
+ const { appName: e, appLogoUrl: n } = this.metadata, s = {
2549
+ method: "requestEthereumAccounts",
2550
+ params: {
2551
+ appName: e,
2552
+ appLogoUrl: n
2553
+ }
2554
+ }, i = F(8);
2555
+ return new Promise((r, o) => {
2556
+ this.relayEventManager.callbacks.set(i, (a) => {
2557
+ if (I(a))
2558
+ return o(new Error(a.errorMessage));
2559
+ r(a);
2560
+ }), j.accountRequestCallbackIds.add(i), this.publishWeb3RequestEvent(i, s);
2561
+ });
2562
+ }
2563
+ watchAsset(e, n, s, i, r, o) {
2564
+ const a = {
2565
+ method: "watchAsset",
2566
+ params: {
2567
+ type: e,
2568
+ options: {
2569
+ address: n,
2570
+ symbol: s,
2571
+ decimals: i,
2572
+ image: r
2573
+ },
2574
+ chainId: o
2575
+ }
2576
+ };
2577
+ let d = null;
2578
+ const l = F(8), h = (c) => {
2579
+ this.publishWeb3RequestCanceledEvent(l), this.handleErrorResponse(l, a.method, c), d == null || d();
2580
+ };
2581
+ return d = this.ui.showConnecting({
2582
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
2583
+ onCancel: h,
2584
+ onResetConnection: this.resetAndReload
2585
+ // eslint-disable-line @typescript-eslint/unbound-method
2586
+ }), new Promise((c, f) => {
2587
+ this.relayEventManager.callbacks.set(l, (u) => {
2588
+ if (d == null || d(), I(u))
2589
+ return f(new Error(u.errorMessage));
2590
+ c(u);
2591
+ }), this.publishWeb3RequestEvent(l, a);
2592
+ });
2593
+ }
2594
+ addEthereumChain(e, n, s, i, r, o) {
2595
+ const a = {
2596
+ method: "addEthereumChain",
2597
+ params: {
2598
+ chainId: e,
2599
+ rpcUrls: n,
2600
+ blockExplorerUrls: i,
2601
+ chainName: r,
2602
+ iconUrls: s,
2603
+ nativeCurrency: o
2604
+ }
2605
+ };
2606
+ let d = null;
2607
+ const l = F(8), h = (c) => {
2608
+ this.publishWeb3RequestCanceledEvent(l), this.handleErrorResponse(l, a.method, c), d == null || d();
2609
+ };
2610
+ return d = this.ui.showConnecting({
2611
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
2612
+ onCancel: h,
2613
+ onResetConnection: this.resetAndReload
2614
+ // eslint-disable-line @typescript-eslint/unbound-method
2615
+ }), new Promise((c, f) => {
2616
+ this.relayEventManager.callbacks.set(l, (u) => {
2617
+ if (d == null || d(), I(u))
2618
+ return f(new Error(u.errorMessage));
2619
+ c(u);
2620
+ }), this.publishWeb3RequestEvent(l, a);
2621
+ });
2622
+ }
2623
+ switchEthereumChain(e, n) {
2624
+ const s = {
2625
+ method: "switchEthereumChain",
2626
+ params: Object.assign({ chainId: e }, { address: n })
2627
+ };
2628
+ let i = null;
2629
+ const r = F(8), o = (a) => {
2630
+ this.publishWeb3RequestCanceledEvent(r), this.handleErrorResponse(r, s.method, a), i == null || i();
2631
+ };
2632
+ return i = this.ui.showConnecting({
2633
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
2634
+ onCancel: o,
2635
+ onResetConnection: this.resetAndReload
2636
+ // eslint-disable-line @typescript-eslint/unbound-method
2637
+ }), new Promise((a, d) => {
2638
+ this.relayEventManager.callbacks.set(r, (l) => {
2639
+ if (i == null || i(), I(l) && l.errorCode)
2640
+ return d(b.provider.custom({
2641
+ code: l.errorCode,
2642
+ message: "Unrecognized chain ID. Try adding the chain using addEthereumChain first."
2643
+ }));
2644
+ if (I(l))
2645
+ return d(new Error(l.errorMessage));
2646
+ a(l);
2647
+ }), this.publishWeb3RequestEvent(r, s);
2648
+ });
2649
+ }
2650
+ }
2651
+ j.accountRequestCallbackIds = /* @__PURE__ */ new Set();
2652
+ const St = "DefaultChainId", At = "DefaultJsonRpcUrl";
2653
+ class vn {
2654
+ constructor(e) {
2655
+ this._relay = null, this._addresses = [], this.metadata = e.metadata, this._storage = new O("walletlink", xt), this.callback = e.callback || null;
2656
+ const n = this._storage.getItem(De);
2657
+ if (n) {
2658
+ const s = n.split(" ");
2659
+ s[0] !== "" && (this._addresses = s.map((i) => B(i)));
2660
+ }
2661
+ this.initializeRelay();
2662
+ }
2663
+ getSession() {
2664
+ const e = this.initializeRelay(), { id: n, secret: s } = e.getWalletLinkSession();
2665
+ return { id: n, secret: s };
2666
+ }
2667
+ async handshake() {
2668
+ await this._eth_requestAccounts();
2669
+ }
2670
+ get selectedAddress() {
2671
+ return this._addresses[0] || void 0;
2672
+ }
2673
+ get jsonRpcUrl() {
2674
+ var e;
2675
+ return (e = this._storage.getItem(At)) !== null && e !== void 0 ? e : void 0;
2676
+ }
2677
+ set jsonRpcUrl(e) {
2678
+ this._storage.setItem(At, e);
2679
+ }
2680
+ updateProviderInfo(e, n) {
2681
+ var s;
2682
+ this.jsonRpcUrl = e;
2683
+ const i = this.getChainId();
2684
+ this._storage.setItem(St, n.toString(10)), se(n) !== i && ((s = this.callback) === null || s === void 0 || s.call(this, "chainChanged", K(n)));
2685
+ }
2686
+ async watchAsset(e) {
2687
+ const n = Array.isArray(e) ? e[0] : e;
2688
+ if (!n.type)
2689
+ throw b.rpc.invalidParams("Type is required");
2690
+ if ((n == null ? void 0 : n.type) !== "ERC20")
2691
+ throw b.rpc.invalidParams(`Asset of type '${n.type}' is not supported`);
2692
+ if (!(n != null && n.options))
2693
+ throw b.rpc.invalidParams("Options are required");
2694
+ if (!(n != null && n.options.address))
2695
+ throw b.rpc.invalidParams("Address is required");
2696
+ const s = this.getChainId(), { address: i, symbol: r, image: o, decimals: a } = n.options, l = await this.initializeRelay().watchAsset(n.type, i, r, a, o, s == null ? void 0 : s.toString());
2697
+ return I(l) ? !1 : !!l.result;
2698
+ }
2699
+ async addEthereumChain(e) {
2700
+ var n, s;
2701
+ const i = e[0];
2702
+ if (((n = i.rpcUrls) === null || n === void 0 ? void 0 : n.length) === 0)
2703
+ throw b.rpc.invalidParams("please pass in at least 1 rpcUrl");
2704
+ if (!i.chainName || i.chainName.trim() === "")
2705
+ throw b.rpc.invalidParams("chainName is a required field");
2706
+ if (!i.nativeCurrency)
2707
+ throw b.rpc.invalidParams("nativeCurrency is a required field");
2708
+ const r = Number.parseInt(i.chainId, 16);
2709
+ if (r === this.getChainId())
2710
+ return !1;
2711
+ const o = this.initializeRelay(), { rpcUrls: a = [], blockExplorerUrls: d = [], chainName: l, iconUrls: h = [], nativeCurrency: c } = i, f = await o.addEthereumChain(r.toString(), a, h, d, l, c);
2712
+ if (I(f))
2713
+ return !1;
2714
+ if (((s = f.result) === null || s === void 0 ? void 0 : s.isApproved) === !0)
2715
+ return this.updateProviderInfo(a[0], r), null;
2716
+ throw b.rpc.internal("unable to add ethereum chain");
2717
+ }
2718
+ async switchEthereumChain(e) {
2719
+ const n = e[0], s = Number.parseInt(n.chainId, 16), r = await this.initializeRelay().switchEthereumChain(s.toString(10), this.selectedAddress || void 0);
2720
+ if (I(r))
2721
+ throw r;
2722
+ const o = r.result;
2723
+ return o.isApproved && o.rpcUrl.length > 0 && this.updateProviderInfo(o.rpcUrl, s), null;
2724
+ }
2725
+ async cleanup() {
2726
+ this.callback = null, this._relay && this._relay.resetAndReload(), this._storage.clear();
2727
+ }
2728
+ _setAddresses(e, n) {
2729
+ var s;
2730
+ if (!Array.isArray(e))
2731
+ throw new Error("addresses is not an array");
2732
+ const i = e.map((r) => B(r));
2733
+ JSON.stringify(i) !== JSON.stringify(this._addresses) && (this._addresses = i, (s = this.callback) === null || s === void 0 || s.call(this, "accountsChanged", i), this._storage.setItem(De, i.join(" ")));
2734
+ }
2735
+ async request(e) {
2736
+ const n = e.params || [];
2737
+ switch (e.method) {
2738
+ case "eth_accounts":
2739
+ return [...this._addresses];
2740
+ case "eth_coinbase":
2741
+ return this.selectedAddress || null;
2742
+ case "net_version":
2743
+ return this.getChainId().toString(10);
2744
+ case "eth_chainId":
2745
+ return K(this.getChainId());
2746
+ case "eth_requestAccounts":
2747
+ return this._eth_requestAccounts();
2748
+ case "eth_ecRecover":
2749
+ case "personal_ecRecover":
2750
+ return this.ecRecover(e);
2751
+ case "personal_sign":
2752
+ return this.personalSign(e);
2753
+ case "eth_signTransaction":
2754
+ return this._eth_signTransaction(n);
2755
+ case "eth_sendRawTransaction":
2756
+ return this._eth_sendRawTransaction(n);
2757
+ case "eth_sendTransaction":
2758
+ return this._eth_sendTransaction(n);
2759
+ case "eth_signTypedData_v1":
2760
+ case "eth_signTypedData_v3":
2761
+ case "eth_signTypedData_v4":
2762
+ case "eth_signTypedData":
2763
+ return this.signTypedData(e);
2764
+ case "wallet_addEthereumChain":
2765
+ return this.addEthereumChain(n);
2766
+ case "wallet_switchEthereumChain":
2767
+ return this.switchEthereumChain(n);
2768
+ case "wallet_watchAsset":
2769
+ return this.watchAsset(n);
2770
+ default:
2771
+ if (!this.jsonRpcUrl)
2772
+ throw b.rpc.internal("No RPC URL set for chain");
2773
+ return Ze(e, this.jsonRpcUrl);
2774
+ }
2775
+ }
2776
+ _ensureKnownAddress(e) {
2777
+ const n = B(e);
2778
+ if (!this._addresses.map((i) => B(i)).includes(n))
2779
+ throw new Error("Unknown Ethereum address");
2780
+ }
2781
+ _prepareTransactionParams(e) {
2782
+ const n = e.from ? B(e.from) : this.selectedAddress;
2783
+ if (!n)
2784
+ throw new Error("Ethereum address is unavailable");
2785
+ this._ensureKnownAddress(n);
2786
+ const s = e.to ? B(e.to) : null, i = e.value != null ? te(e.value) : BigInt(0), r = e.data ? Ne(e.data) : Buffer.alloc(0), o = e.nonce != null ? se(e.nonce) : null, a = e.gasPrice != null ? te(e.gasPrice) : null, d = e.maxFeePerGas != null ? te(e.maxFeePerGas) : null, l = e.maxPriorityFeePerGas != null ? te(e.maxPriorityFeePerGas) : null, h = e.gas != null ? te(e.gas) : null, c = e.chainId ? se(e.chainId) : this.getChainId();
2787
+ return {
2788
+ fromAddress: n,
2789
+ toAddress: s,
2790
+ weiValue: i,
2791
+ data: r,
2792
+ nonce: o,
2793
+ gasPriceInWei: a,
2794
+ maxFeePerGas: d,
2795
+ maxPriorityFeePerGas: l,
2796
+ gasLimit: h,
2797
+ chainId: c
2798
+ };
2799
+ }
2800
+ async ecRecover(e) {
2801
+ const { method: n, params: s } = e;
2802
+ if (!Array.isArray(s))
2803
+ throw b.rpc.invalidParams();
2804
+ const r = await this.initializeRelay().sendRequest({
2805
+ method: "ethereumAddressFromSignedMessage",
2806
+ params: {
2807
+ message: xe(s[0]),
2808
+ signature: xe(s[1]),
2809
+ addPrefix: n === "personal_ecRecover"
2810
+ }
2811
+ });
2812
+ if (I(r))
2813
+ throw r;
2814
+ return r.result;
2815
+ }
2816
+ getChainId() {
2817
+ var e;
2818
+ return Number.parseInt((e = this._storage.getItem(St)) !== null && e !== void 0 ? e : "1", 10);
2819
+ }
2820
+ async _eth_requestAccounts() {
2821
+ var e, n;
2822
+ if (this._addresses.length > 0)
2823
+ return (e = this.callback) === null || e === void 0 || e.call(this, "connect", { chainId: K(this.getChainId()) }), this._addresses;
2824
+ const i = await this.initializeRelay().requestEthereumAccounts();
2825
+ if (I(i))
2826
+ throw i;
2827
+ if (!i.result)
2828
+ throw new Error("accounts received is empty");
2829
+ return this._setAddresses(i.result), (n = this.callback) === null || n === void 0 || n.call(this, "connect", { chainId: K(this.getChainId()) }), this._addresses;
2830
+ }
2831
+ async personalSign({ params: e }) {
2832
+ if (!Array.isArray(e))
2833
+ throw b.rpc.invalidParams();
2834
+ const n = e[1], s = e[0];
2835
+ this._ensureKnownAddress(n);
2836
+ const r = await this.initializeRelay().sendRequest({
2837
+ method: "signEthereumMessage",
2838
+ params: {
2839
+ address: B(n),
2840
+ message: xe(s),
2841
+ addPrefix: !0,
2842
+ typedDataJson: null
2843
+ }
2844
+ });
2845
+ if (I(r))
2846
+ throw r;
2847
+ return r.result;
2848
+ }
2849
+ async _eth_signTransaction(e) {
2850
+ const n = this._prepareTransactionParams(e[0] || {}), i = await this.initializeRelay().signEthereumTransaction(n);
2851
+ if (I(i))
2852
+ throw i;
2853
+ return i.result;
2854
+ }
2855
+ async _eth_sendRawTransaction(e) {
2856
+ const n = Ne(e[0]), i = await this.initializeRelay().submitEthereumTransaction(n, this.getChainId());
2857
+ if (I(i))
2858
+ throw i;
2859
+ return i.result;
2860
+ }
2861
+ async _eth_sendTransaction(e) {
2862
+ const n = this._prepareTransactionParams(e[0] || {}), i = await this.initializeRelay().signAndSubmitEthereumTransaction(n);
2863
+ if (I(i))
2864
+ throw i;
2865
+ return i.result;
2866
+ }
2867
+ async signTypedData(e) {
2868
+ const { method: n, params: s } = e;
2869
+ if (!Array.isArray(s))
2870
+ throw b.rpc.invalidParams();
2871
+ const i = (l) => {
2872
+ const h = {
2873
+ eth_signTypedData_v1: de.hashForSignTypedDataLegacy,
2874
+ eth_signTypedData_v3: de.hashForSignTypedData_v3,
2875
+ eth_signTypedData_v4: de.hashForSignTypedData_v4,
2876
+ eth_signTypedData: de.hashForSignTypedData_v4
2877
+ };
2878
+ return ne(h[n]({
2879
+ data: Nn(l)
2880
+ }), !0);
2881
+ }, r = s[n === "eth_signTypedData_v1" ? 1 : 0], o = s[n === "eth_signTypedData_v1" ? 0 : 1];
2882
+ this._ensureKnownAddress(r);
2883
+ const d = await this.initializeRelay().sendRequest({
2884
+ method: "signEthereumMessage",
2885
+ params: {
2886
+ address: B(r),
2887
+ message: i(o),
2888
+ typedDataJson: JSON.stringify(o, null, 2),
2889
+ addPrefix: !1
2890
+ }
2891
+ });
2892
+ if (I(d))
2893
+ throw d;
2894
+ return d.result;
2895
+ }
2896
+ initializeRelay() {
2897
+ return this._relay || (this._relay = new j({
2898
+ linkAPIUrl: xt,
2899
+ storage: this._storage,
2900
+ metadata: this.metadata,
2901
+ accountsCallback: this._setAddresses.bind(this),
2902
+ chainCallback: this.updateProviderInfo.bind(this)
2903
+ })), this._relay;
2904
+ }
2905
+ }
2906
+ const kn = "SignerType", En = new O("CBWSDK", "SignerConfigurator");
2907
+ function ri() {
2908
+ return En.getItem(kn);
2909
+ }
2910
+ function oi(t) {
2911
+ En.setItem(kn, t);
2912
+ }
2913
+ async function ai(t) {
2914
+ const { communicator: e, metadata: n, handshakeRequest: s, callback: i } = t;
2915
+ li(e, n, i).catch(() => {
2916
+ });
2917
+ const r = {
2918
+ id: crypto.randomUUID(),
2919
+ event: "selectSignerType",
2920
+ data: Object.assign(Object.assign({}, t.preference), { handshakeRequest: s })
2921
+ }, { data: o } = await e.postRequestAndWaitForResponse(r);
2922
+ return o;
2923
+ }
2924
+ function ci(t) {
2925
+ const { signerType: e, metadata: n, communicator: s, callback: i } = t;
2926
+ switch (e) {
2927
+ case "scw":
2928
+ return new Zn({
2929
+ metadata: n,
2930
+ callback: i,
2931
+ communicator: s
2932
+ });
2933
+ case "walletlink":
2934
+ return new vn({
2935
+ metadata: n,
2936
+ callback: i
2937
+ });
2938
+ }
2939
+ }
2940
+ async function li(t, e, n) {
2941
+ await t.onMessage(({ event: i }) => i === "WalletLinkSessionRequest");
2942
+ const s = new vn({
2943
+ metadata: e,
2944
+ callback: n
2945
+ });
2946
+ t.postMessage({
2947
+ event: "WalletLinkUpdate",
2948
+ data: { session: s.getSession() }
2949
+ }), await s.handshake(), t.postMessage({
2950
+ event: "WalletLinkUpdate",
2951
+ data: { connected: !0 }
2952
+ });
2953
+ }
2954
+ const di = `Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.
2955
+
2956
+ Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`, hi = () => {
2957
+ let t;
2958
+ return {
2959
+ getCrossOriginOpenerPolicy: () => t === void 0 ? "undefined" : t,
2960
+ checkCrossOriginOpenerPolicy: async () => {
2961
+ if (typeof window > "u") {
2962
+ t = "non-browser-env";
2963
+ return;
2964
+ }
2965
+ try {
2966
+ const e = `${window.location.origin}${window.location.pathname}`, n = await fetch(e, {
2967
+ method: "HEAD"
2968
+ });
2969
+ if (!n.ok)
2970
+ throw new Error(`HTTP error! status: ${n.status}`);
2971
+ const s = n.headers.get("Cross-Origin-Opener-Policy");
2972
+ t = s ?? "null", t === "same-origin" && console.error(di);
2973
+ } catch (e) {
2974
+ console.error("Error checking Cross-Origin-Opener-Policy:", e.message), t = "error";
2975
+ }
2976
+ }
2977
+ };
2978
+ }, { checkCrossOriginOpenerPolicy: ui, getCrossOriginOpenerPolicy: fi } = hi(), Mt = 420, Lt = 540;
2979
+ function pi(t) {
2980
+ const e = (window.innerWidth - Mt) / 2 + window.screenX, n = (window.innerHeight - Lt) / 2 + window.screenY;
2981
+ _i(t);
2982
+ const s = `wallet_${crypto.randomUUID()}`, i = window.open(t, s, `width=${Mt}, height=${Lt}, left=${e}, top=${n}`);
2983
+ if (i == null || i.focus(), !i)
2984
+ throw b.rpc.internal("Pop up window failed to open");
2985
+ return i;
2986
+ }
2987
+ function gi(t) {
2988
+ t && !t.closed && t.close();
2989
+ }
2990
+ function _i(t) {
2991
+ const e = {
2992
+ sdkName: Kt,
2993
+ sdkVersion: ce,
2994
+ origin: window.location.origin,
2995
+ coop: fi()
2996
+ };
2997
+ for (const [n, s] of Object.entries(e))
2998
+ t.searchParams.append(n, s.toString());
2999
+ }
3000
+ class mi {
3001
+ constructor({ url: e = ni, metadata: n, preference: s }) {
3002
+ this.popup = null, this.listeners = /* @__PURE__ */ new Map(), this.postMessage = async (i) => {
3003
+ (await this.waitForPopupLoaded()).postMessage(i, this.url.origin);
3004
+ }, this.postRequestAndWaitForResponse = async (i) => {
3005
+ const r = this.onMessage(({ requestId: o }) => o === i.id);
3006
+ return this.postMessage(i), await r;
3007
+ }, this.onMessage = async (i) => new Promise((r, o) => {
3008
+ const a = (d) => {
3009
+ if (d.origin !== this.url.origin)
3010
+ return;
3011
+ const l = d.data;
3012
+ i(l) && (r(l), window.removeEventListener("message", a), this.listeners.delete(a));
3013
+ };
3014
+ window.addEventListener("message", a), this.listeners.set(a, { reject: o });
3015
+ }), this.disconnect = () => {
3016
+ gi(this.popup), this.popup = null, this.listeners.forEach(({ reject: i }, r) => {
3017
+ i(b.provider.userRejectedRequest("Request rejected")), window.removeEventListener("message", r);
3018
+ }), this.listeners.clear();
3019
+ }, this.waitForPopupLoaded = async () => this.popup && !this.popup.closed ? (this.popup.focus(), this.popup) : (this.popup = pi(this.url), this.onMessage(({ event: i }) => i === "PopupUnload").then(this.disconnect).catch(() => {
3020
+ }), this.onMessage(({ event: i }) => i === "PopupLoaded").then((i) => {
3021
+ this.postMessage({
3022
+ requestId: i.id,
3023
+ data: {
3024
+ version: ce,
3025
+ metadata: this.metadata,
3026
+ preference: this.preference,
3027
+ location: window.location.toString()
3028
+ }
3029
+ });
3030
+ }).then(() => {
3031
+ if (!this.popup)
3032
+ throw b.rpc.internal();
3033
+ return this.popup;
3034
+ })), this.url = new URL(e), this.metadata = n, this.preference = s;
3035
+ }
3036
+ }
3037
+ function bi(t) {
3038
+ const e = Mn(wi(t), {
3039
+ shouldIncludeStack: !0
3040
+ }), n = new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");
3041
+ return n.searchParams.set("version", ce), n.searchParams.set("code", e.code.toString()), n.searchParams.set("message", e.message), Object.assign(Object.assign({}, e), { docUrl: n.href });
3042
+ }
3043
+ function wi(t) {
3044
+ var e;
3045
+ if (typeof t == "string")
3046
+ return {
3047
+ message: t,
3048
+ code: E.rpc.internal
3049
+ };
3050
+ if (I(t)) {
3051
+ const n = t.errorMessage, s = (e = t.errorCode) !== null && e !== void 0 ? e : n.match(/(denied|rejected)/i) ? E.provider.userRejectedRequest : void 0;
3052
+ return Object.assign(Object.assign({}, t), {
3053
+ message: n,
3054
+ code: s,
3055
+ data: { method: t.method }
3056
+ });
3057
+ }
3058
+ return t;
3059
+ }
3060
+ var Cn = { exports: {} };
3061
+ (function(t) {
3062
+ var e = Object.prototype.hasOwnProperty, n = "~";
3063
+ function s() {
3064
+ }
3065
+ Object.create && (s.prototype = /* @__PURE__ */ Object.create(null), new s().__proto__ || (n = !1));
3066
+ function i(d, l, h) {
3067
+ this.fn = d, this.context = l, this.once = h || !1;
3068
+ }
3069
+ function r(d, l, h, c, f) {
3070
+ if (typeof h != "function")
3071
+ throw new TypeError("The listener must be a function");
3072
+ var u = new i(h, c || d, f), g = n ? n + l : l;
3073
+ return d._events[g] ? d._events[g].fn ? d._events[g] = [d._events[g], u] : d._events[g].push(u) : (d._events[g] = u, d._eventsCount++), d;
3074
+ }
3075
+ function o(d, l) {
3076
+ --d._eventsCount === 0 ? d._events = new s() : delete d._events[l];
3077
+ }
3078
+ function a() {
3079
+ this._events = new s(), this._eventsCount = 0;
3080
+ }
3081
+ a.prototype.eventNames = function() {
3082
+ var l = [], h, c;
3083
+ if (this._eventsCount === 0) return l;
3084
+ for (c in h = this._events)
3085
+ e.call(h, c) && l.push(n ? c.slice(1) : c);
3086
+ return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(h)) : l;
3087
+ }, a.prototype.listeners = function(l) {
3088
+ var h = n ? n + l : l, c = this._events[h];
3089
+ if (!c) return [];
3090
+ if (c.fn) return [c.fn];
3091
+ for (var f = 0, u = c.length, g = new Array(u); f < u; f++)
3092
+ g[f] = c[f].fn;
3093
+ return g;
3094
+ }, a.prototype.listenerCount = function(l) {
3095
+ var h = n ? n + l : l, c = this._events[h];
3096
+ return c ? c.fn ? 1 : c.length : 0;
3097
+ }, a.prototype.emit = function(l, h, c, f, u, g) {
3098
+ var v = n ? n + l : l;
3099
+ if (!this._events[v]) return !1;
3100
+ var p = this._events[v], _ = arguments.length, m, w;
3101
+ if (p.fn) {
3102
+ switch (p.once && this.removeListener(l, p.fn, void 0, !0), _) {
3103
+ case 1:
3104
+ return p.fn.call(p.context), !0;
3105
+ case 2:
3106
+ return p.fn.call(p.context, h), !0;
3107
+ case 3:
3108
+ return p.fn.call(p.context, h, c), !0;
3109
+ case 4:
3110
+ return p.fn.call(p.context, h, c, f), !0;
3111
+ case 5:
3112
+ return p.fn.call(p.context, h, c, f, u), !0;
3113
+ case 6:
3114
+ return p.fn.call(p.context, h, c, f, u, g), !0;
3115
+ }
3116
+ for (w = 1, m = new Array(_ - 1); w < _; w++)
3117
+ m[w - 1] = arguments[w];
3118
+ p.fn.apply(p.context, m);
3119
+ } else {
3120
+ var L = p.length, P;
3121
+ for (w = 0; w < L; w++)
3122
+ switch (p[w].once && this.removeListener(l, p[w].fn, void 0, !0), _) {
3123
+ case 1:
3124
+ p[w].fn.call(p[w].context);
3125
+ break;
3126
+ case 2:
3127
+ p[w].fn.call(p[w].context, h);
3128
+ break;
3129
+ case 3:
3130
+ p[w].fn.call(p[w].context, h, c);
3131
+ break;
3132
+ case 4:
3133
+ p[w].fn.call(p[w].context, h, c, f);
3134
+ break;
3135
+ default:
3136
+ if (!m) for (P = 1, m = new Array(_ - 1); P < _; P++)
3137
+ m[P - 1] = arguments[P];
3138
+ p[w].fn.apply(p[w].context, m);
3139
+ }
3140
+ }
3141
+ return !0;
3142
+ }, a.prototype.on = function(l, h, c) {
3143
+ return r(this, l, h, c, !1);
3144
+ }, a.prototype.once = function(l, h, c) {
3145
+ return r(this, l, h, c, !0);
3146
+ }, a.prototype.removeListener = function(l, h, c, f) {
3147
+ var u = n ? n + l : l;
3148
+ if (!this._events[u]) return this;
3149
+ if (!h)
3150
+ return o(this, u), this;
3151
+ var g = this._events[u];
3152
+ if (g.fn)
3153
+ g.fn === h && (!f || g.once) && (!c || g.context === c) && o(this, u);
3154
+ else {
3155
+ for (var v = 0, p = [], _ = g.length; v < _; v++)
3156
+ (g[v].fn !== h || f && !g[v].once || c && g[v].context !== c) && p.push(g[v]);
3157
+ p.length ? this._events[u] = p.length === 1 ? p[0] : p : o(this, u);
3158
+ }
3159
+ return this;
3160
+ }, a.prototype.removeAllListeners = function(l) {
3161
+ var h;
3162
+ return l ? (h = n ? n + l : l, this._events[h] && o(this, h)) : (this._events = new s(), this._eventsCount = 0), this;
3163
+ }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, t.exports = a;
3164
+ })(Cn);
3165
+ var yi = Cn.exports;
3166
+ const vi = /* @__PURE__ */ Pt(yi);
3167
+ class ki extends vi {
3168
+ }
3169
+ var Ei = function(t, e) {
3170
+ var n = {};
3171
+ for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && e.indexOf(s) < 0 && (n[s] = t[s]);
3172
+ if (t != null && typeof Object.getOwnPropertySymbols == "function")
3173
+ for (var i = 0, s = Object.getOwnPropertySymbols(t); i < s.length; i++)
3174
+ e.indexOf(s[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, s[i]) && (n[s[i]] = t[s[i]]);
3175
+ return n;
3176
+ };
3177
+ class Ci extends ki {
3178
+ constructor(e) {
3179
+ var { metadata: n } = e, s = e.preference, { keysUrl: i } = s, r = Ei(s, ["keysUrl"]);
3180
+ super(), this.signer = null, this.isCoinbaseWallet = !0, this.metadata = n, this.preference = r, this.communicator = new mi({
3181
+ url: i,
3182
+ metadata: n,
3183
+ preference: r
3184
+ });
3185
+ const o = ri();
3186
+ o && (this.signer = this.initSigner(o));
3187
+ }
3188
+ async request(e) {
3189
+ try {
3190
+ if ($n(e), !this.signer)
3191
+ switch (e.method) {
3192
+ case "eth_requestAccounts": {
3193
+ const n = await this.requestSignerSelection(e), s = this.initSigner(n);
3194
+ await s.handshake(e), this.signer = s, oi(n);
3195
+ break;
3196
+ }
3197
+ case "wallet_sendCalls": {
3198
+ const n = this.initSigner("scw");
3199
+ await n.handshake({ method: "handshake" });
3200
+ const s = await n.request(e);
3201
+ return await n.cleanup(), s;
3202
+ }
3203
+ case "wallet_getCallsStatus":
3204
+ return Ze(e, si);
3205
+ case "net_version":
3206
+ return 1;
3207
+ case "eth_chainId":
3208
+ return K(1);
3209
+ default:
3210
+ throw b.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");
3211
+ }
3212
+ return await this.signer.request(e);
3213
+ } catch (n) {
3214
+ const { code: s } = n;
3215
+ return s === E.provider.unauthorized && this.disconnect(), Promise.reject(bi(n));
3216
+ }
3217
+ }
3218
+ /** @deprecated Use `.request({ method: 'eth_requestAccounts' })` instead. */
3219
+ async enable() {
3220
+ return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'), await this.request({
3221
+ method: "eth_requestAccounts"
3222
+ });
3223
+ }
3224
+ async disconnect() {
3225
+ var e;
3226
+ await ((e = this.signer) === null || e === void 0 ? void 0 : e.cleanup()), this.signer = null, O.clearAll(), this.emit("disconnect", b.provider.disconnected("User initiated disconnection"));
3227
+ }
3228
+ requestSignerSelection(e) {
3229
+ return ai({
3230
+ communicator: this.communicator,
3231
+ preference: this.preference,
3232
+ metadata: this.metadata,
3233
+ handshakeRequest: e,
3234
+ callback: this.emit.bind(this)
3235
+ });
3236
+ }
3237
+ initSigner(e) {
3238
+ return ci({
3239
+ signerType: e,
3240
+ metadata: this.metadata,
3241
+ communicator: this.communicator,
3242
+ callback: this.emit.bind(this)
3243
+ });
3244
+ }
3245
+ }
3246
+ function xi(t) {
3247
+ if (t) {
3248
+ if (!["all", "smartWalletOnly", "eoaOnly"].includes(t.options))
3249
+ throw new Error(`Invalid options: ${t.options}`);
3250
+ if (t.attribution && t.attribution.auto !== void 0 && t.attribution.dataSuffix !== void 0)
3251
+ throw new Error("Attribution cannot contain both auto and dataSuffix properties");
3252
+ }
3253
+ }
3254
+ class Si {
3255
+ constructor(e) {
3256
+ this.metadata = {
3257
+ appName: e.appName || "Dapp",
3258
+ appLogoUrl: e.appLogoUrl || On(),
3259
+ appChainIds: e.appChainIds || []
3260
+ }, this.storeLatestVersion(), ui();
3261
+ }
3262
+ makeWeb3Provider(e = { options: "all" }) {
3263
+ var n;
3264
+ xi(e);
3265
+ const s = { metadata: this.metadata, preference: e };
3266
+ return (n = zn(s)) !== null && n !== void 0 ? n : new Ci(s);
3267
+ }
3268
+ /**
3269
+ * Official Coinbase Wallet logo for developers to use on their frontend
3270
+ * @param type Type of wallet logo: "standard" | "circle" | "text" | "textWithLogo" | "textLight" | "textWithLogoLight"
3271
+ * @param width Width of the logo (Optional)
3272
+ * @returns SVG Data URI
3273
+ */
3274
+ getCoinbaseWalletLogo(e, n = 240) {
3275
+ return In(e, n);
3276
+ }
3277
+ storeLatestVersion() {
3278
+ new O("CBWSDK").setItem("VERSION", ce);
3279
+ }
3280
+ }
3281
+ export {
3282
+ Si as CoinbaseWalletSDK,
3283
+ Si as default
3284
+ };