@directcryptopay/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/README.md +357 -0
  2. package/dist/ConstantsUtil-B-_-u8aQ.js +6 -0
  3. package/dist/add-KF4m4jFK.js +19 -0
  4. package/dist/all-wallets-D6NAjQgX.js +10 -0
  5. package/dist/app-store-D7TTn-EO.js +21 -0
  6. package/dist/apple-DjX2E2hE.js +22 -0
  7. package/dist/arrow-bottom-C0YrNJYB.js +12 -0
  8. package/dist/arrow-bottom-circle-Dlxvx_XG.js +15 -0
  9. package/dist/arrow-left-x8_-lUyK.js +12 -0
  10. package/dist/arrow-right-BTZybj80.js +12 -0
  11. package/dist/arrow-top-LzH7iLCp.js +12 -0
  12. package/dist/bank-23jp-IV_.js +18 -0
  13. package/dist/browser-EjoorDid.js +18 -0
  14. package/dist/card-DGgWwtwC.js +18 -0
  15. package/dist/ccip-BMANewTU.js +150 -0
  16. package/dist/checkmark-B1qcQhBo.js +15 -0
  17. package/dist/checkmark-bold-Cyc4IEEJ.js +12 -0
  18. package/dist/chevron-bottom-ClHs08rB.js +12 -0
  19. package/dist/chevron-left-O8h_551_.js +12 -0
  20. package/dist/chevron-right-DP3xpyIA.js +12 -0
  21. package/dist/chevron-top-CuwkBUs9.js +12 -0
  22. package/dist/chrome-store-zfT_aJ3R.js +65 -0
  23. package/dist/clock-DHZqivIS.js +12 -0
  24. package/dist/close-Cp9rNAw4.js +12 -0
  25. package/dist/coinPlaceholder-U7-T1KKQ.js +12 -0
  26. package/dist/compass-Ds5-PRSR.js +12 -0
  27. package/dist/copy-Jg4HdIMf.js +19 -0
  28. package/dist/core/api.d.ts +30 -0
  29. package/dist/core/config.d.ts +59 -0
  30. package/dist/core/logic.d.ts +2 -0
  31. package/dist/core/wallet.d.ts +34 -0
  32. package/dist/cursor-DmMevduB.js +7 -0
  33. package/dist/cursor-transparent-Dn9-1SV8.js +16 -0
  34. package/dist/dcp-sdk.umd.js +12000 -0
  35. package/dist/dcp.d.ts +10 -0
  36. package/dist/desktop-C4udXXlZ.js +13 -0
  37. package/dist/disconnect-wd1BYLxt.js +12 -0
  38. package/dist/discord-DthxuCAP.js +21 -0
  39. package/dist/email-B3jSnUFE.js +696 -0
  40. package/dist/embedded-wallet-CJHmoBI2.js +468 -0
  41. package/dist/etherscan-Cjp4xfMW.js +10 -0
  42. package/dist/exclamation-triangle-CRNR5WOy.js +8 -0
  43. package/dist/extension-Cydk0mZt.js +12 -0
  44. package/dist/external-link-CuPTAoq9.js +12 -0
  45. package/dist/facebook-CghqXmdf.js +30 -0
  46. package/dist/farcaster-BREqMX4y.js +16 -0
  47. package/dist/filters-Dn_Ys7ew.js +12 -0
  48. package/dist/github-C-A7JmIY.js +22 -0
  49. package/dist/google-CCdM_naE.js +22 -0
  50. package/dist/hashTypedData-D2Qmzscs.js +197 -0
  51. package/dist/help-circle-DIH4vyj3.js +16 -0
  52. package/dist/id-DkJ0gBuy.js +16 -0
  53. package/dist/if-defined-BciplFKz.js +744 -0
  54. package/dist/image-qMjyiXM0.js +8 -0
  55. package/dist/index--3Zp0jAb.js +45 -0
  56. package/dist/index-1adX-Fit.js +65 -0
  57. package/dist/index-AvC0IGDl.js +7864 -0
  58. package/dist/index-B2-vKLd8.js +276 -0
  59. package/dist/index-B2iDt0TJ.js +146 -0
  60. package/dist/index-B5zkXsLJ.js +320 -0
  61. package/dist/index-B7K86vWu.js +1742 -0
  62. package/dist/index-BBkcvSiY.js +511 -0
  63. package/dist/index-BdjxQs66.js +181 -0
  64. package/dist/index-Bijd4_Ns.js +294 -0
  65. package/dist/index-BpXOsxzU.js +387 -0
  66. package/dist/index-C1QEJL-2.js +572 -0
  67. package/dist/index-C27dwOyE.js +243 -0
  68. package/dist/index-C4BX3QW8.js +58 -0
  69. package/dist/index-CMPIqsB1.js +170 -0
  70. package/dist/index-CTYngdl0.js +21991 -0
  71. package/dist/index-CUdQyyFn.js +51 -0
  72. package/dist/index-CX60z_g2.js +573 -0
  73. package/dist/index-CppCc1n8.js +65 -0
  74. package/dist/index-CqVegmN4.js +559 -0
  75. package/dist/index-CuiyMA8F.js +78 -0
  76. package/dist/index-CwB_qRfM.js +305 -0
  77. package/dist/index-CxOF7GqE.js +265 -0
  78. package/dist/index-D-IzHD_8.js +54 -0
  79. package/dist/index-DRNiFv9I.js +218 -0
  80. package/dist/index-Da8oZh8H.js +838 -0
  81. package/dist/index-DiHImG4L.js +44236 -0
  82. package/dist/index-DmOMXRG1.js +181 -0
  83. package/dist/index-DoSYqTQg.js +199 -0
  84. package/dist/index-DpHXq5_E.js +603 -0
  85. package/dist/index-DtCsAVBg.js +78 -0
  86. package/dist/index-Ij6XA6_4.js +77 -0
  87. package/dist/index-SzyBYfzA.js +8490 -0
  88. package/dist/index-eW8y-mXH.js +257 -0
  89. package/dist/index-fxzIDZsb.js +75 -0
  90. package/dist/index-lbhz9evJ.js +97 -0
  91. package/dist/index.d.ts +3 -0
  92. package/dist/index.js +4 -0
  93. package/dist/info-DMIGgjkL.js +7 -0
  94. package/dist/info-circle-CJuIKZSx.js +16 -0
  95. package/dist/lightbulb-qFT6WEWV.js +7 -0
  96. package/dist/localBatchGatewayRequest-CsMVMFBc.js +91 -0
  97. package/dist/mail-DoYgQvOt.js +12 -0
  98. package/dist/mobile-URtsh7o-.js +13 -0
  99. package/dist/more-DoQd10TF.js +15 -0
  100. package/dist/network-placeholder-BBA2Ue6C.js +18 -0
  101. package/dist/nftPlaceholder-C9RXWz9k.js +12 -0
  102. package/dist/off-YcuDQczT.js +12 -0
  103. package/dist/onramp-BfqDIx4o.js +1279 -0
  104. package/dist/parseSignature-280HB24T.js +3560 -0
  105. package/dist/play-store-sFaloG_r.js +36 -0
  106. package/dist/plus-l0wekSht.js +17 -0
  107. package/dist/qr-code-CihrUU4G.js +10 -0
  108. package/dist/receive-dfY1Cu-g.js +186 -0
  109. package/dist/recycle-horizontal-nXu6YaPw.js +13 -0
  110. package/dist/ref-huAzXCX0.js +41 -0
  111. package/dist/refresh-D2ZbVeNC.js +12 -0
  112. package/dist/reown-logo-BMaTMJmc.js +16 -0
  113. package/dist/search-YVM9q3J-.js +12 -0
  114. package/dist/secp256k1-BrysY3Sv.js +1302 -0
  115. package/dist/secp256k1-DPQgTBwQ.js +1510 -0
  116. package/dist/send-BwQZPKxI.js +19 -0
  117. package/dist/send-GyetMVu1.js +1038 -0
  118. package/dist/socials-B0W91J9k.js +574 -0
  119. package/dist/swapHorizontal-Dy_oQEkp.js +12 -0
  120. package/dist/swapHorizontalBold-C4JpaMpc.js +12 -0
  121. package/dist/swapHorizontalMedium-D5NuVZFh.js +20 -0
  122. package/dist/swapHorizontalRoundedBold-Bq4P2MCj.js +12 -0
  123. package/dist/swapVertical-CVQ8Mg03.js +12 -0
  124. package/dist/swaps-CA04SSdK.js +1637 -0
  125. package/dist/telegram-BP4SgW_L.js +20 -0
  126. package/dist/three-dots-BJYGJ-dQ.js +9 -0
  127. package/dist/transactions-Bq-98Tsg.js +37 -0
  128. package/dist/twitch-DTATWo9M.js +22 -0
  129. package/dist/twitterIcon-D5UWPInb.js +10 -0
  130. package/dist/types.d.ts +128 -0
  131. package/dist/ui/Modal.d.ts +9 -0
  132. package/dist/ui/index.d.ts +6 -0
  133. package/dist/verify-Byvj8Wi1.js +12 -0
  134. package/dist/verify-filled-B40taNm0.js +12 -0
  135. package/dist/w3m-modal-HV6SE74G.js +1037 -0
  136. package/dist/wallet-Cp-6Kk88.js +12 -0
  137. package/dist/wallet-placeholder-C3juwA9o.js +18 -0
  138. package/dist/walletconnect-CRkIiLCx.js +36 -0
  139. package/dist/warning-circle-DtvCLwG4.js +16 -0
  140. package/dist/x-Cqyx5eCt.js +16 -0
  141. package/package.json +70 -0
@@ -0,0 +1,1637 @@
1
+ import { cz as P, cA as C, cT as D, d2 as j, cB as u, d6 as K, d3 as W, cE as S, cS as _, cY as V, cN as M, cX as F, cC as Q, cD as q } from "./index-DiHImG4L.js";
2
+ import { r as s, n as h, c as E, U as m } from "./if-defined-BciplFKz.js";
3
+ import "./index-Bijd4_Ns.js";
4
+ import { M as R } from "./index-CuiyMA8F.js";
5
+ import "./index-B2iDt0TJ.js";
6
+ import { S as n } from "./index-CX60z_g2.js";
7
+ import "./index-Ij6XA6_4.js";
8
+ import "./index-CxOF7GqE.js";
9
+ import "./index-CUdQyyFn.js";
10
+ const H = {
11
+ numericInputKeyDown(c, t, e) {
12
+ const o = [
13
+ "Backspace",
14
+ "Meta",
15
+ "Ctrl",
16
+ "a",
17
+ "A",
18
+ "c",
19
+ "C",
20
+ "x",
21
+ "X",
22
+ "v",
23
+ "V",
24
+ "ArrowLeft",
25
+ "ArrowRight",
26
+ "Tab"
27
+ ], a = c.metaKey || c.ctrlKey, i = c.key, r = i.toLocaleLowerCase(), l = r === "a", x = r === "c", v = r === "v", N = r === "x", U = i === ",", L = i === ".", O = i >= "0" && i <= "9";
28
+ !a && (l || x || v || N) && c.preventDefault(), t === "0" && !U && !L && i === "0" && c.preventDefault(), t === "0" && O && (e(i), c.preventDefault()), (U || L) && (t || (e("0."), c.preventDefault()), (t != null && t.includes(".") || t != null && t.includes(",")) && c.preventDefault()), !O && !o.includes(i) && !L && !U && c.preventDefault();
29
+ }
30
+ }, G = P`
31
+ :host {
32
+ width: 100%;
33
+ }
34
+
35
+ .details-container > wui-flex {
36
+ background: var(--wui-color-gray-glass-002);
37
+ border-radius: var(--wui-border-radius-xxs);
38
+ width: 100%;
39
+ }
40
+
41
+ .details-container > wui-flex > button {
42
+ border: none;
43
+ background: none;
44
+ padding: var(--wui-spacing-s);
45
+ border-radius: var(--wui-border-radius-xxs);
46
+ cursor: pointer;
47
+ }
48
+
49
+ .details-content-container {
50
+ padding: var(--wui-spacing-1xs);
51
+ padding-top: 0px;
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: center;
55
+ }
56
+
57
+ .details-content-container > wui-flex {
58
+ width: 100%;
59
+ }
60
+
61
+ .details-row {
62
+ width: 100%;
63
+ padding: var(--wui-spacing-s);
64
+ padding-left: var(--wui-spacing-s);
65
+ padding-right: var(--wui-spacing-1xs);
66
+ border-radius: calc(var(--wui-border-radius-5xs) + var(--wui-border-radius-4xs));
67
+ background: var(--wui-color-gray-glass-002);
68
+ }
69
+
70
+ .details-row-title {
71
+ white-space: nowrap;
72
+ }
73
+
74
+ .details-row.provider-free-row {
75
+ padding-right: var(--wui-spacing-xs);
76
+ }
77
+ `;
78
+ var k = function(c, t, e, o) {
79
+ var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
80
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
81
+ else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
82
+ return a > 3 && i && Object.defineProperty(t, e, i), i;
83
+ };
84
+ const X = K.CONVERT_SLIPPAGE_TOLERANCE;
85
+ let f = class extends C {
86
+ constructor() {
87
+ var t;
88
+ super(), this.unsubscribe = [], this.networkName = (t = D.state.activeCaipNetwork) == null ? void 0 : t.name, this.detailsOpen = !1, this.sourceToken = n.state.sourceToken, this.toToken = n.state.toToken, this.toTokenAmount = n.state.toTokenAmount, this.sourceTokenPriceInUSD = n.state.sourceTokenPriceInUSD, this.toTokenPriceInUSD = n.state.toTokenPriceInUSD, this.priceImpact = n.state.priceImpact, this.maxSlippage = n.state.maxSlippage, this.networkTokenSymbol = n.state.networkTokenSymbol, this.inputError = n.state.inputError, this.unsubscribe.push(n.subscribe((e) => {
89
+ this.sourceToken = e.sourceToken, this.toToken = e.toToken, this.toTokenAmount = e.toTokenAmount, this.priceImpact = e.priceImpact, this.maxSlippage = e.maxSlippage, this.sourceTokenPriceInUSD = e.sourceTokenPriceInUSD, this.toTokenPriceInUSD = e.toTokenPriceInUSD, this.inputError = e.inputError;
90
+ }));
91
+ }
92
+ render() {
93
+ const t = this.toTokenAmount && this.maxSlippage ? j.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString() : null;
94
+ if (!this.sourceToken || !this.toToken || this.inputError)
95
+ return null;
96
+ const e = this.sourceTokenPriceInUSD && this.toTokenPriceInUSD ? 1 / this.toTokenPriceInUSD * this.sourceTokenPriceInUSD : 0;
97
+ return u`
98
+ <wui-flex flexDirection="column" alignItems="center" gap="1xs" class="details-container">
99
+ <wui-flex flexDirection="column">
100
+ <button @click=${this.toggleDetails.bind(this)}>
101
+ <wui-flex justifyContent="space-between" .padding=${["0", "xs", "0", "xs"]}>
102
+ <wui-flex justifyContent="flex-start" flexGrow="1" gap="xs">
103
+ <wui-text variant="small-400" color="fg-100">
104
+ 1 ${this.sourceToken.symbol} =
105
+ ${m.formatNumberToLocalString(e, 3)}
106
+ ${this.toToken.symbol}
107
+ </wui-text>
108
+ <wui-text variant="small-400" color="fg-200">
109
+ $${m.formatNumberToLocalString(this.sourceTokenPriceInUSD)}
110
+ </wui-text>
111
+ </wui-flex>
112
+ <wui-icon name="chevronBottom"></wui-icon>
113
+ </wui-flex>
114
+ </button>
115
+ ${this.detailsOpen ? u`
116
+ <wui-flex flexDirection="column" gap="xs" class="details-content-container">
117
+ ${this.priceImpact ? u` <wui-flex flexDirection="column" gap="xs">
118
+ <wui-flex
119
+ justifyContent="space-between"
120
+ alignItems="center"
121
+ class="details-row"
122
+ >
123
+ <wui-flex alignItems="center" gap="xs">
124
+ <wui-text class="details-row-title" variant="small-400" color="fg-150">
125
+ Price impact
126
+ </wui-text>
127
+ <w3m-tooltip-trigger
128
+ text="Price impact reflects the change in market price due to your trade"
129
+ >
130
+ <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon>
131
+ </w3m-tooltip-trigger>
132
+ </wui-flex>
133
+ <wui-flex>
134
+ <wui-text variant="small-400" color="fg-200">
135
+ ${m.formatNumberToLocalString(this.priceImpact, 3)}%
136
+ </wui-text>
137
+ </wui-flex>
138
+ </wui-flex>
139
+ </wui-flex>` : null}
140
+ ${this.maxSlippage && this.sourceToken.symbol ? u`<wui-flex flexDirection="column" gap="xs">
141
+ <wui-flex
142
+ justifyContent="space-between"
143
+ alignItems="center"
144
+ class="details-row"
145
+ >
146
+ <wui-flex alignItems="center" gap="xs">
147
+ <wui-text class="details-row-title" variant="small-400" color="fg-150">
148
+ Max. slippage
149
+ </wui-text>
150
+ <w3m-tooltip-trigger
151
+ text=${`Max slippage sets the minimum amount you must receive for the transaction to proceed. ${t ? `Transaction will be reversed if you receive less than ${m.formatNumberToLocalString(t, 6)} ${this.toToken.symbol} due to price changes.` : ""}`}
152
+ >
153
+ <wui-icon size="xs" color="fg-250" name="infoCircle"></wui-icon>
154
+ </w3m-tooltip-trigger>
155
+ </wui-flex>
156
+ <wui-flex>
157
+ <wui-text variant="small-400" color="fg-200">
158
+ ${m.formatNumberToLocalString(this.maxSlippage, 6)}
159
+ ${this.toToken.symbol} ${X}%
160
+ </wui-text>
161
+ </wui-flex>
162
+ </wui-flex>
163
+ </wui-flex>` : null}
164
+ <wui-flex flexDirection="column" gap="xs">
165
+ <wui-flex
166
+ justifyContent="space-between"
167
+ alignItems="center"
168
+ class="details-row provider-free-row"
169
+ >
170
+ <wui-flex alignItems="center" gap="xs">
171
+ <wui-text class="details-row-title" variant="small-400" color="fg-150">
172
+ Provider fee
173
+ </wui-text>
174
+ </wui-flex>
175
+ <wui-flex>
176
+ <wui-text variant="small-400" color="fg-200">0.85%</wui-text>
177
+ </wui-flex>
178
+ </wui-flex>
179
+ </wui-flex>
180
+ </wui-flex>
181
+ ` : null}
182
+ </wui-flex>
183
+ </wui-flex>
184
+ `;
185
+ }
186
+ toggleDetails() {
187
+ this.detailsOpen = !this.detailsOpen;
188
+ }
189
+ };
190
+ f.styles = [G];
191
+ k([
192
+ s()
193
+ ], f.prototype, "networkName", void 0);
194
+ k([
195
+ h()
196
+ ], f.prototype, "detailsOpen", void 0);
197
+ k([
198
+ s()
199
+ ], f.prototype, "sourceToken", void 0);
200
+ k([
201
+ s()
202
+ ], f.prototype, "toToken", void 0);
203
+ k([
204
+ s()
205
+ ], f.prototype, "toTokenAmount", void 0);
206
+ k([
207
+ s()
208
+ ], f.prototype, "sourceTokenPriceInUSD", void 0);
209
+ k([
210
+ s()
211
+ ], f.prototype, "toTokenPriceInUSD", void 0);
212
+ k([
213
+ s()
214
+ ], f.prototype, "priceImpact", void 0);
215
+ k([
216
+ s()
217
+ ], f.prototype, "maxSlippage", void 0);
218
+ k([
219
+ s()
220
+ ], f.prototype, "networkTokenSymbol", void 0);
221
+ k([
222
+ s()
223
+ ], f.prototype, "inputError", void 0);
224
+ f = k([
225
+ E("w3m-swap-details")
226
+ ], f);
227
+ const Y = P`
228
+ :host {
229
+ width: 100%;
230
+ }
231
+
232
+ :host > wui-flex {
233
+ display: flex;
234
+ flex-direction: row;
235
+ justify-content: space-between;
236
+ align-items: center;
237
+ border-radius: var(--wui-border-radius-s);
238
+ padding: var(--wui-spacing-xl);
239
+ padding-right: var(--wui-spacing-s);
240
+ background-color: var(--wui-color-gray-glass-002);
241
+ box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002);
242
+ width: 100%;
243
+ height: 100px;
244
+ box-sizing: border-box;
245
+ position: relative;
246
+ }
247
+
248
+ wui-shimmer.market-value {
249
+ opacity: 0;
250
+ }
251
+
252
+ :host > wui-flex > svg.input_mask {
253
+ position: absolute;
254
+ inset: 0;
255
+ z-index: 5;
256
+ }
257
+
258
+ :host wui-flex .input_mask__border,
259
+ :host wui-flex .input_mask__background {
260
+ transition: fill var(--wui-duration-md) var(--wui-ease-out-power-1);
261
+ will-change: fill;
262
+ }
263
+
264
+ :host wui-flex .input_mask__border {
265
+ fill: var(--wui-color-gray-glass-020);
266
+ }
267
+
268
+ :host wui-flex .input_mask__background {
269
+ fill: var(--wui-color-gray-glass-002);
270
+ }
271
+ `;
272
+ var z = function(c, t, e, o) {
273
+ var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
274
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
275
+ else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
276
+ return a > 3 && i && Object.defineProperty(t, e, i), i;
277
+ };
278
+ let B = class extends C {
279
+ constructor() {
280
+ super(...arguments), this.target = "sourceToken";
281
+ }
282
+ render() {
283
+ return u`
284
+ <wui-flex class justifyContent="space-between">
285
+ <wui-flex
286
+ flex="1"
287
+ flexDirection="column"
288
+ alignItems="flex-start"
289
+ justifyContent="center"
290
+ class="swap-input"
291
+ gap="xxs"
292
+ >
293
+ <wui-shimmer width="80px" height="40px" borderRadius="xxs" variant="light"></wui-shimmer>
294
+ </wui-flex>
295
+ ${this.templateTokenSelectButton()}
296
+ </wui-flex>
297
+ `;
298
+ }
299
+ templateTokenSelectButton() {
300
+ return u`
301
+ <wui-flex
302
+ class="swap-token-button"
303
+ flexDirection="column"
304
+ alignItems="flex-end"
305
+ justifyContent="center"
306
+ gap="xxs"
307
+ >
308
+ <wui-shimmer width="80px" height="40px" borderRadius="3xl" variant="light"></wui-shimmer>
309
+ </wui-flex>
310
+ `;
311
+ }
312
+ };
313
+ B.styles = [Y];
314
+ z([
315
+ h()
316
+ ], B.prototype, "target", void 0);
317
+ B = z([
318
+ E("w3m-swap-input-skeleton")
319
+ ], B);
320
+ const Z = P`
321
+ :host > wui-flex {
322
+ display: flex;
323
+ flex-direction: row;
324
+ justify-content: space-between;
325
+ align-items: center;
326
+ border-radius: var(--wui-border-radius-s);
327
+ background-color: var(--wui-color-gray-glass-002);
328
+ padding: var(--wui-spacing-xl);
329
+ padding-right: var(--wui-spacing-s);
330
+ width: 100%;
331
+ height: 100px;
332
+ box-sizing: border-box;
333
+ box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-002);
334
+ position: relative;
335
+ transition: box-shadow var(--wui-ease-out-power-1) var(--wui-duration-lg);
336
+ will-change: background-color;
337
+ }
338
+
339
+ :host wui-flex.focus {
340
+ box-shadow: inset 0px 0px 0px 1px var(--wui-color-gray-glass-005);
341
+ }
342
+
343
+ :host > wui-flex .swap-input,
344
+ :host > wui-flex .swap-token-button {
345
+ z-index: 10;
346
+ }
347
+
348
+ :host > wui-flex .swap-input {
349
+ -webkit-mask-image: linear-gradient(
350
+ 270deg,
351
+ transparent 0px,
352
+ transparent 8px,
353
+ black 24px,
354
+ black 25px,
355
+ black 32px,
356
+ black 100%
357
+ );
358
+ mask-image: linear-gradient(
359
+ 270deg,
360
+ transparent 0px,
361
+ transparent 8px,
362
+ black 24px,
363
+ black 25px,
364
+ black 32px,
365
+ black 100%
366
+ );
367
+ }
368
+
369
+ :host > wui-flex .swap-input input {
370
+ background: none;
371
+ border: none;
372
+ height: 42px;
373
+ width: 100%;
374
+ font-size: 32px;
375
+ font-style: normal;
376
+ font-weight: 400;
377
+ line-height: 130%;
378
+ letter-spacing: -1.28px;
379
+ outline: none;
380
+ caret-color: var(--wui-color-accent-100);
381
+ color: var(--wui-color-fg-100);
382
+ padding: 0px;
383
+ }
384
+
385
+ :host > wui-flex .swap-input input:focus-visible {
386
+ outline: none;
387
+ }
388
+
389
+ :host > wui-flex .swap-input input::-webkit-outer-spin-button,
390
+ :host > wui-flex .swap-input input::-webkit-inner-spin-button {
391
+ -webkit-appearance: none;
392
+ margin: 0;
393
+ }
394
+
395
+ .max-value-button {
396
+ background-color: transparent;
397
+ border: none;
398
+ cursor: pointer;
399
+ color: var(--wui-color-gray-glass-020);
400
+ padding-left: 0px;
401
+ }
402
+
403
+ .market-value {
404
+ min-height: 18px;
405
+ }
406
+ `;
407
+ var y = function(c, t, e, o) {
408
+ var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
409
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
410
+ else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
411
+ return a > 3 && i && Object.defineProperty(t, e, i), i;
412
+ };
413
+ const J = 5e-5;
414
+ let b = class extends C {
415
+ constructor() {
416
+ super(...arguments), this.focused = !1, this.price = 0, this.target = "sourceToken", this.onSetAmount = null, this.onSetMaxValue = null;
417
+ }
418
+ render() {
419
+ const t = this.marketValue || "0", e = j.bigNumber(t).gt("0");
420
+ return u`
421
+ <wui-flex class="${this.focused ? "focus" : ""}" justifyContent="space-between">
422
+ <wui-flex
423
+ flex="1"
424
+ flexDirection="column"
425
+ alignItems="flex-start"
426
+ justifyContent="center"
427
+ class="swap-input"
428
+ >
429
+ <input
430
+ data-testid="swap-input-${this.target}"
431
+ @focusin=${() => this.onFocusChange(!0)}
432
+ @focusout=${() => this.onFocusChange(!1)}
433
+ ?disabled=${this.disabled}
434
+ .value=${this.value}
435
+ @input=${this.dispatchInputChangeEvent}
436
+ @keydown=${this.handleKeydown}
437
+ placeholder="0"
438
+ type="text"
439
+ inputmode="decimal"
440
+ />
441
+ <wui-text class="market-value" variant="small-400" color="fg-200">
442
+ ${e ? `$${m.formatNumberToLocalString(this.marketValue, 2)}` : null}
443
+ </wui-text>
444
+ </wui-flex>
445
+ ${this.templateTokenSelectButton()}
446
+ </wui-flex>
447
+ `;
448
+ }
449
+ handleKeydown(t) {
450
+ return H.numericInputKeyDown(t, this.value, (e) => {
451
+ var o;
452
+ return (o = this.onSetAmount) == null ? void 0 : o.call(this, this.target, e);
453
+ });
454
+ }
455
+ dispatchInputChangeEvent(t) {
456
+ if (!this.onSetAmount)
457
+ return;
458
+ const e = t.target.value.replace(/[^0-9.]/gu, "");
459
+ e === "," || e === "." ? this.onSetAmount(this.target, "0.") : e.endsWith(",") ? this.onSetAmount(this.target, e.replace(",", ".")) : this.onSetAmount(this.target, e);
460
+ }
461
+ setMaxValueToInput() {
462
+ var t;
463
+ (t = this.onSetMaxValue) == null || t.call(this, this.target, this.balance);
464
+ }
465
+ templateTokenSelectButton() {
466
+ return this.token ? u`
467
+ <wui-flex
468
+ class="swap-token-button"
469
+ flexDirection="column"
470
+ alignItems="flex-end"
471
+ justifyContent="center"
472
+ gap="xxs"
473
+ >
474
+ <wui-token-button
475
+ data-testid="swap-input-token-${this.target}"
476
+ text=${this.token.symbol}
477
+ imageSrc=${this.token.logoUri}
478
+ @click=${this.onSelectToken.bind(this)}
479
+ >
480
+ </wui-token-button>
481
+ <wui-flex alignItems="center" gap="xxs"> ${this.tokenBalanceTemplate()} </wui-flex>
482
+ </wui-flex>
483
+ ` : u` <wui-button
484
+ data-testid="swap-select-token-button-${this.target}"
485
+ class="swap-token-button"
486
+ size="md"
487
+ variant="accent"
488
+ @click=${this.onSelectToken.bind(this)}
489
+ >
490
+ Select token
491
+ </wui-button>`;
492
+ }
493
+ tokenBalanceTemplate() {
494
+ const t = j.multiply(this.balance, this.price), e = t ? t == null ? void 0 : t.gt(J) : !1;
495
+ return u`
496
+ ${e ? u`<wui-text variant="small-400" color="fg-200">
497
+ ${m.formatNumberToLocalString(this.balance, 2)}
498
+ </wui-text>` : null}
499
+ ${this.target === "sourceToken" ? this.tokenActionButtonTemplate(e) : null}
500
+ `;
501
+ }
502
+ tokenActionButtonTemplate(t) {
503
+ return t ? u` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}>
504
+ <wui-text color="accent-100" variant="small-600">Max</wui-text>
505
+ </button>` : u` <button class="max-value-button" @click=${this.onBuyToken.bind(this)}>
506
+ <wui-text color="accent-100" variant="small-600">Buy</wui-text>
507
+ </button>`;
508
+ }
509
+ onFocusChange(t) {
510
+ this.focused = t;
511
+ }
512
+ onSelectToken() {
513
+ W.sendEvent({ type: "track", event: "CLICK_SELECT_TOKEN_TO_SWAP" }), S.push("SwapSelectToken", {
514
+ target: this.target
515
+ });
516
+ }
517
+ onBuyToken() {
518
+ S.push("OnRampProviders");
519
+ }
520
+ };
521
+ b.styles = [Z];
522
+ y([
523
+ h()
524
+ ], b.prototype, "focused", void 0);
525
+ y([
526
+ h()
527
+ ], b.prototype, "balance", void 0);
528
+ y([
529
+ h()
530
+ ], b.prototype, "value", void 0);
531
+ y([
532
+ h()
533
+ ], b.prototype, "price", void 0);
534
+ y([
535
+ h()
536
+ ], b.prototype, "marketValue", void 0);
537
+ y([
538
+ h()
539
+ ], b.prototype, "disabled", void 0);
540
+ y([
541
+ h()
542
+ ], b.prototype, "target", void 0);
543
+ y([
544
+ h()
545
+ ], b.prototype, "token", void 0);
546
+ y([
547
+ h()
548
+ ], b.prototype, "onSetAmount", void 0);
549
+ y([
550
+ h()
551
+ ], b.prototype, "onSetMaxValue", void 0);
552
+ b = y([
553
+ E("w3m-swap-input")
554
+ ], b);
555
+ const tt = P`
556
+ :host > wui-flex:first-child {
557
+ overflow-y: auto;
558
+ overflow-x: hidden;
559
+ scrollbar-width: none;
560
+ }
561
+
562
+ :host > wui-flex:first-child::-webkit-scrollbar {
563
+ display: none;
564
+ }
565
+
566
+ wui-loading-hexagon {
567
+ position: absolute;
568
+ }
569
+
570
+ .action-button {
571
+ width: 100%;
572
+ border-radius: var(--wui-border-radius-xs);
573
+ }
574
+
575
+ .action-button:disabled {
576
+ border-color: 1px solid var(--wui-color-gray-glass-005);
577
+ }
578
+
579
+ .swap-inputs-container {
580
+ position: relative;
581
+ }
582
+
583
+ .replace-tokens-button-container {
584
+ display: flex;
585
+ justify-content: center;
586
+ align-items: center;
587
+ position: absolute;
588
+ top: 50%;
589
+ left: 50%;
590
+ transform: translate(-50%, -50%);
591
+ gap: var(--wui-spacing-1xs);
592
+ border-radius: var(--wui-border-radius-xs);
593
+ background-color: var(--wui-color-modal-bg-base);
594
+ padding: var(--wui-spacing-xxs);
595
+ }
596
+
597
+ .replace-tokens-button-container > button {
598
+ display: flex;
599
+ justify-content: center;
600
+ align-items: center;
601
+ height: 40px;
602
+ width: 40px;
603
+ padding: var(--wui-spacing-xs);
604
+ border: none;
605
+ border-radius: var(--wui-border-radius-xxs);
606
+ background: var(--wui-color-gray-glass-002);
607
+ transition: background-color var(--wui-duration-md) var(--wui-ease-out-power-1);
608
+ will-change: background-color;
609
+ z-index: 20;
610
+ }
611
+
612
+ .replace-tokens-button-container > button:hover {
613
+ background: var(--wui-color-gray-glass-005);
614
+ }
615
+
616
+ .details-container > wui-flex {
617
+ background: var(--wui-color-gray-glass-002);
618
+ border-radius: var(--wui-border-radius-xxs);
619
+ width: 100%;
620
+ }
621
+
622
+ .details-container > wui-flex > button {
623
+ border: none;
624
+ background: none;
625
+ padding: var(--wui-spacing-s);
626
+ border-radius: var(--wui-border-radius-xxs);
627
+ transition: background 0.2s linear;
628
+ }
629
+
630
+ .details-container > wui-flex > button:hover {
631
+ background: var(--wui-color-gray-glass-002);
632
+ }
633
+
634
+ .details-content-container {
635
+ padding: var(--wui-spacing-1xs);
636
+ display: flex;
637
+ align-items: center;
638
+ justify-content: center;
639
+ }
640
+
641
+ .details-content-container > wui-flex {
642
+ width: 100%;
643
+ }
644
+
645
+ .details-row {
646
+ width: 100%;
647
+ padding: var(--wui-spacing-s) var(--wui-spacing-xl);
648
+ border-radius: var(--wui-border-radius-xxs);
649
+ background: var(--wui-color-gray-glass-002);
650
+ }
651
+ `;
652
+ var w = function(c, t, e, o) {
653
+ var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
654
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
655
+ else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
656
+ return a > 3 && i && Object.defineProperty(t, e, i), i;
657
+ };
658
+ let p = class extends C {
659
+ constructor() {
660
+ var t, e;
661
+ super(), this.unsubscribe = [], this.initialParams = (t = S.state.data) == null ? void 0 : t.swap, this.detailsOpen = !1, this.caipAddress = _.state.caipAddress, this.caipNetworkId = (e = D.state.activeCaipNetwork) == null ? void 0 : e.caipNetworkId, this.initialized = n.state.initialized, this.loadingQuote = n.state.loadingQuote, this.loadingPrices = n.state.loadingPrices, this.loadingTransaction = n.state.loadingTransaction, this.sourceToken = n.state.sourceToken, this.sourceTokenAmount = n.state.sourceTokenAmount, this.sourceTokenPriceInUSD = n.state.sourceTokenPriceInUSD, this.toToken = n.state.toToken, this.toTokenAmount = n.state.toTokenAmount, this.toTokenPriceInUSD = n.state.toTokenPriceInUSD, this.inputError = n.state.inputError, this.fetchError = n.state.fetchError, this.onDebouncedGetSwapCalldata = V.debounce(async () => {
662
+ await n.swapTokens();
663
+ }, 200), D.subscribeKey("activeCaipNetwork", (o) => this.onCaipNetworkChange({
664
+ newCaipNetwork: o,
665
+ resetSwapState: !0,
666
+ initializeSwapState: !1
667
+ })), _.subscribeKey("caipAddress", (o) => this.onCaipAddressChange({
668
+ newCaipAddress: o,
669
+ resetSwapState: !0,
670
+ initializeSwapState: !1
671
+ })), this.unsubscribe.push(D.subscribeKey("activeCaipNetwork", (o) => this.onCaipNetworkChange({
672
+ newCaipNetwork: o,
673
+ resetSwapState: !1,
674
+ initializeSwapState: !0
675
+ })), _.subscribeKey("caipAddress", (o) => this.onCaipAddressChange({
676
+ newCaipAddress: o,
677
+ resetSwapState: !1,
678
+ initializeSwapState: !0
679
+ })), M.subscribeKey("open", (o) => {
680
+ o || n.resetState();
681
+ }), S.subscribeKey("view", (o) => {
682
+ o.includes("Swap") || n.resetValues();
683
+ }), n.subscribe((o) => {
684
+ this.initialized = o.initialized, this.loadingQuote = o.loadingQuote, this.loadingPrices = o.loadingPrices, this.loadingTransaction = o.loadingTransaction, this.sourceToken = o.sourceToken, this.sourceTokenAmount = o.sourceTokenAmount, this.sourceTokenPriceInUSD = o.sourceTokenPriceInUSD, this.toToken = o.toToken, this.toTokenAmount = o.toTokenAmount, this.toTokenPriceInUSD = o.toTokenPriceInUSD, this.inputError = o.inputError, this.fetchError = o.fetchError;
685
+ }));
686
+ }
687
+ async firstUpdated() {
688
+ n.initializeState(), this.watchTokensAndValues(), await this.handleSwapParameters();
689
+ }
690
+ disconnectedCallback() {
691
+ this.unsubscribe.forEach((t) => t == null ? void 0 : t()), clearInterval(this.interval);
692
+ }
693
+ render() {
694
+ return u`
695
+ <wui-flex flexDirection="column" .padding=${["0", "l", "l", "l"]} gap="s">
696
+ ${this.initialized ? this.templateSwap() : this.templateLoading()}
697
+ </wui-flex>
698
+ `;
699
+ }
700
+ watchTokensAndValues() {
701
+ this.interval = setInterval(() => {
702
+ n.getNetworkTokenPrice(), n.getMyTokensWithBalance(), n.swapTokens();
703
+ }, 1e4);
704
+ }
705
+ templateSwap() {
706
+ return u`
707
+ <wui-flex flexDirection="column" gap="s">
708
+ <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container">
709
+ ${this.templateTokenInput("sourceToken", this.sourceToken)}
710
+ ${this.templateTokenInput("toToken", this.toToken)} ${this.templateReplaceTokensButton()}
711
+ </wui-flex>
712
+ ${this.templateDetails()} ${this.templateActionButton()}
713
+ </wui-flex>
714
+ `;
715
+ }
716
+ actionButtonLabel() {
717
+ return this.fetchError ? "Swap" : !this.sourceToken || !this.toToken ? "Select token" : this.sourceTokenAmount ? this.inputError ? this.inputError : "Review swap" : "Enter amount";
718
+ }
719
+ templateReplaceTokensButton() {
720
+ return u`
721
+ <wui-flex class="replace-tokens-button-container">
722
+ <button @click=${this.onSwitchTokens.bind(this)}>
723
+ <wui-icon name="recycleHorizontal" color="fg-250" size="lg"></wui-icon>
724
+ </button>
725
+ </wui-flex>
726
+ `;
727
+ }
728
+ templateLoading() {
729
+ return u`
730
+ <wui-flex flexDirection="column" gap="l">
731
+ <wui-flex flexDirection="column" alignItems="center" gap="xs" class="swap-inputs-container">
732
+ <w3m-swap-input-skeleton target="sourceToken"></w3m-swap-input-skeleton>
733
+ <w3m-swap-input-skeleton target="toToken"></w3m-swap-input-skeleton>
734
+ ${this.templateReplaceTokensButton()}
735
+ </wui-flex>
736
+ ${this.templateActionButton()}
737
+ </wui-flex>
738
+ `;
739
+ }
740
+ templateTokenInput(t, e) {
741
+ var l, x;
742
+ const o = (l = n.state.myTokensWithBalance) == null ? void 0 : l.find((v) => (v == null ? void 0 : v.address) === (e == null ? void 0 : e.address)), a = t === "toToken" ? this.toTokenAmount : this.sourceTokenAmount, i = t === "toToken" ? this.toTokenPriceInUSD : this.sourceTokenPriceInUSD, r = j.parseLocalStringToNumber(a) * i;
743
+ return u`<w3m-swap-input
744
+ .value=${t === "toToken" ? this.toTokenAmount : this.sourceTokenAmount}
745
+ .disabled=${t === "toToken"}
746
+ .onSetAmount=${this.handleChangeAmount.bind(this)}
747
+ target=${t}
748
+ .token=${e}
749
+ .balance=${(x = o == null ? void 0 : o.quantity) == null ? void 0 : x.numeric}
750
+ .price=${o == null ? void 0 : o.price}
751
+ .marketValue=${r}
752
+ .onSetMaxValue=${this.onSetMaxValue.bind(this)}
753
+ ></w3m-swap-input>`;
754
+ }
755
+ onSetMaxValue(t, e) {
756
+ const o = j.bigNumber(e || "0");
757
+ this.handleChangeAmount(t, o.gt(0) ? o.toFixed(20) : "0");
758
+ }
759
+ templateDetails() {
760
+ return !this.sourceToken || !this.toToken || this.inputError ? null : u`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
761
+ }
762
+ handleChangeAmount(t, e) {
763
+ n.clearError(), t === "sourceToken" ? n.setSourceTokenAmount(e) : n.setToTokenAmount(e), this.onDebouncedGetSwapCalldata();
764
+ }
765
+ templateActionButton() {
766
+ const t = !this.toToken || !this.sourceToken, e = !this.sourceTokenAmount, o = this.loadingQuote || this.loadingPrices || this.loadingTransaction, a = o || t || e || this.inputError;
767
+ return u` <wui-flex gap="xs">
768
+ <wui-button
769
+ data-testid="swap-action-button"
770
+ class="action-button"
771
+ fullWidth
772
+ size="lg"
773
+ borderRadius="xs"
774
+ variant=${t ? "neutral" : "main"}
775
+ .loading=${o}
776
+ .disabled=${a}
777
+ @click=${this.onSwapPreview.bind(this)}
778
+ >
779
+ ${this.actionButtonLabel()}
780
+ </wui-button>
781
+ </wui-flex>`;
782
+ }
783
+ onSwitchTokens() {
784
+ n.switchTokens();
785
+ }
786
+ async onSwapPreview() {
787
+ var e, o, a;
788
+ const t = D.state.activeChain;
789
+ this.fetchError && await n.swapTokens(), W.sendEvent({
790
+ type: "track",
791
+ event: "INITIATE_SWAP",
792
+ properties: {
793
+ network: this.caipNetworkId || "",
794
+ swapFromToken: ((e = this.sourceToken) == null ? void 0 : e.symbol) || "",
795
+ swapToToken: ((o = this.toToken) == null ? void 0 : o.symbol) || "",
796
+ swapFromAmount: this.sourceTokenAmount || "",
797
+ swapToAmount: this.toTokenAmount || "",
798
+ isSmartAccount: ((a = _.state.preferredAccountTypes) == null ? void 0 : a[t]) === F.ACCOUNT_TYPES.SMART_ACCOUNT
799
+ }
800
+ }), S.push("SwapPreview");
801
+ }
802
+ async handleSwapParameters() {
803
+ this.initialParams && (n.state.initialized || await new Promise((e) => {
804
+ const o = n.subscribeKey("initialized", (a) => {
805
+ a && (o == null || o(), e());
806
+ });
807
+ }), await this.setSwapParameters(this.initialParams));
808
+ }
809
+ async setSwapParameters({ amount: t, fromToken: e, toToken: o }) {
810
+ (!n.state.tokens || !n.state.myTokensWithBalance) && await new Promise((r) => {
811
+ const l = n.subscribeKey("myTokensWithBalance", (x) => {
812
+ x && x.length > 0 && (l == null || l(), r());
813
+ });
814
+ setTimeout(() => {
815
+ l == null || l(), r();
816
+ }, 5e3);
817
+ });
818
+ const a = [
819
+ ...n.state.tokens || [],
820
+ ...n.state.myTokensWithBalance || []
821
+ ];
822
+ if (e) {
823
+ const i = a.find((r) => r.symbol.toLowerCase() === e.toLowerCase());
824
+ i && n.setSourceToken(i);
825
+ }
826
+ if (o) {
827
+ const i = a.find((r) => r.symbol.toLowerCase() === o.toLowerCase());
828
+ i && n.setToToken(i);
829
+ }
830
+ t && !isNaN(Number(t)) && n.setSourceTokenAmount(t);
831
+ }
832
+ onCaipAddressChange({ newCaipAddress: t, resetSwapState: e, initializeSwapState: o }) {
833
+ this.caipAddress !== t && (this.caipAddress = t, e && n.resetState(), o && n.initializeState());
834
+ }
835
+ onCaipNetworkChange({ newCaipNetwork: t, resetSwapState: e, initializeSwapState: o }) {
836
+ this.caipNetworkId !== (t == null ? void 0 : t.caipNetworkId) && (this.caipNetworkId = t == null ? void 0 : t.caipNetworkId, e && n.resetState(), o && n.initializeState());
837
+ }
838
+ };
839
+ p.styles = tt;
840
+ w([
841
+ h({ type: Object })
842
+ ], p.prototype, "initialParams", void 0);
843
+ w([
844
+ s()
845
+ ], p.prototype, "interval", void 0);
846
+ w([
847
+ s()
848
+ ], p.prototype, "detailsOpen", void 0);
849
+ w([
850
+ s()
851
+ ], p.prototype, "caipAddress", void 0);
852
+ w([
853
+ s()
854
+ ], p.prototype, "caipNetworkId", void 0);
855
+ w([
856
+ s()
857
+ ], p.prototype, "initialized", void 0);
858
+ w([
859
+ s()
860
+ ], p.prototype, "loadingQuote", void 0);
861
+ w([
862
+ s()
863
+ ], p.prototype, "loadingPrices", void 0);
864
+ w([
865
+ s()
866
+ ], p.prototype, "loadingTransaction", void 0);
867
+ w([
868
+ s()
869
+ ], p.prototype, "sourceToken", void 0);
870
+ w([
871
+ s()
872
+ ], p.prototype, "sourceTokenAmount", void 0);
873
+ w([
874
+ s()
875
+ ], p.prototype, "sourceTokenPriceInUSD", void 0);
876
+ w([
877
+ s()
878
+ ], p.prototype, "toToken", void 0);
879
+ w([
880
+ s()
881
+ ], p.prototype, "toTokenAmount", void 0);
882
+ w([
883
+ s()
884
+ ], p.prototype, "toTokenPriceInUSD", void 0);
885
+ w([
886
+ s()
887
+ ], p.prototype, "inputError", void 0);
888
+ w([
889
+ s()
890
+ ], p.prototype, "fetchError", void 0);
891
+ p = w([
892
+ E("w3m-swap-view")
893
+ ], p);
894
+ const et = P`
895
+ :host > wui-flex:first-child {
896
+ overflow-y: auto;
897
+ overflow-x: hidden;
898
+ scrollbar-width: none;
899
+ }
900
+
901
+ :host > wui-flex:first-child::-webkit-scrollbar {
902
+ display: none;
903
+ }
904
+
905
+ .preview-container,
906
+ .details-container {
907
+ width: 100%;
908
+ }
909
+
910
+ .token-image {
911
+ width: 24px;
912
+ height: 24px;
913
+ box-shadow: 0 0 0 2px var(--wui-color-gray-glass-005);
914
+ border-radius: 12px;
915
+ }
916
+
917
+ wui-loading-hexagon {
918
+ position: absolute;
919
+ }
920
+
921
+ .token-item {
922
+ display: flex;
923
+ align-items: center;
924
+ justify-content: center;
925
+ gap: var(--wui-spacing-xxs);
926
+ padding: var(--wui-spacing-xs);
927
+ height: 40px;
928
+ border: none;
929
+ border-radius: 80px;
930
+ background: var(--wui-color-gray-glass-002);
931
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-002);
932
+ cursor: pointer;
933
+ transition: background 0.2s linear;
934
+ }
935
+
936
+ .token-item:hover {
937
+ background: var(--wui-color-gray-glass-005);
938
+ }
939
+
940
+ .preview-token-details-container {
941
+ width: 100%;
942
+ }
943
+
944
+ .details-row {
945
+ width: 100%;
946
+ padding: var(--wui-spacing-s) var(--wui-spacing-xl);
947
+ border-radius: var(--wui-border-radius-xxs);
948
+ background: var(--wui-color-gray-glass-002);
949
+ }
950
+
951
+ .action-buttons-container {
952
+ width: 100%;
953
+ gap: var(--wui-spacing-xs);
954
+ }
955
+
956
+ .action-buttons-container > button {
957
+ display: flex;
958
+ align-items: center;
959
+ justify-content: center;
960
+ background: transparent;
961
+ height: 48px;
962
+ border-radius: var(--wui-border-radius-xs);
963
+ border: none;
964
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
965
+ }
966
+
967
+ .action-buttons-container > button:disabled {
968
+ opacity: 0.8;
969
+ cursor: not-allowed;
970
+ }
971
+
972
+ .action-button > wui-loading-spinner {
973
+ display: inline-block;
974
+ }
975
+
976
+ .cancel-button:hover,
977
+ .action-button:hover {
978
+ cursor: pointer;
979
+ }
980
+
981
+ .action-buttons-container > wui-button.cancel-button {
982
+ flex: 2;
983
+ }
984
+
985
+ .action-buttons-container > wui-button.action-button {
986
+ flex: 4;
987
+ }
988
+
989
+ .action-buttons-container > button.action-button > wui-text {
990
+ color: white;
991
+ }
992
+
993
+ .details-container > wui-flex {
994
+ background: var(--wui-color-gray-glass-002);
995
+ border-radius: var(--wui-border-radius-xxs);
996
+ width: 100%;
997
+ }
998
+
999
+ .details-container > wui-flex > button {
1000
+ border: none;
1001
+ background: none;
1002
+ padding: var(--wui-spacing-s);
1003
+ border-radius: var(--wui-border-radius-xxs);
1004
+ transition: background 0.2s linear;
1005
+ }
1006
+
1007
+ .details-container > wui-flex > button:hover {
1008
+ background: var(--wui-color-gray-glass-002);
1009
+ }
1010
+
1011
+ .details-content-container {
1012
+ padding: var(--wui-spacing-1xs);
1013
+ display: flex;
1014
+ align-items: center;
1015
+ justify-content: center;
1016
+ }
1017
+
1018
+ .details-content-container > wui-flex {
1019
+ width: 100%;
1020
+ }
1021
+
1022
+ .details-row {
1023
+ width: 100%;
1024
+ padding: var(--wui-spacing-s) var(--wui-spacing-xl);
1025
+ border-radius: var(--wui-border-radius-xxs);
1026
+ background: var(--wui-color-gray-glass-002);
1027
+ }
1028
+ `;
1029
+ var g = function(c, t, e, o) {
1030
+ var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
1031
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
1032
+ else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
1033
+ return a > 3 && i && Object.defineProperty(t, e, i), i;
1034
+ };
1035
+ let d = class extends C {
1036
+ constructor() {
1037
+ super(), this.unsubscribe = [], this.detailsOpen = !0, this.approvalTransaction = n.state.approvalTransaction, this.swapTransaction = n.state.swapTransaction, this.sourceToken = n.state.sourceToken, this.sourceTokenAmount = n.state.sourceTokenAmount ?? "", this.sourceTokenPriceInUSD = n.state.sourceTokenPriceInUSD, this.toToken = n.state.toToken, this.toTokenAmount = n.state.toTokenAmount ?? "", this.toTokenPriceInUSD = n.state.toTokenPriceInUSD, this.caipNetwork = D.state.activeCaipNetwork, this.balanceSymbol = _.state.balanceSymbol, this.inputError = n.state.inputError, this.loadingQuote = n.state.loadingQuote, this.loadingApprovalTransaction = n.state.loadingApprovalTransaction, this.loadingBuildTransaction = n.state.loadingBuildTransaction, this.loadingTransaction = n.state.loadingTransaction, this.unsubscribe.push(_.subscribeKey("balanceSymbol", (t) => {
1038
+ this.balanceSymbol !== t && S.goBack();
1039
+ }), D.subscribeKey("activeCaipNetwork", (t) => {
1040
+ this.caipNetwork !== t && (this.caipNetwork = t);
1041
+ }), n.subscribe((t) => {
1042
+ this.approvalTransaction = t.approvalTransaction, this.swapTransaction = t.swapTransaction, this.sourceToken = t.sourceToken, this.toToken = t.toToken, this.toTokenPriceInUSD = t.toTokenPriceInUSD, this.sourceTokenAmount = t.sourceTokenAmount ?? "", this.toTokenAmount = t.toTokenAmount ?? "", this.inputError = t.inputError, t.inputError && S.goBack(), this.loadingQuote = t.loadingQuote, this.loadingApprovalTransaction = t.loadingApprovalTransaction, this.loadingBuildTransaction = t.loadingBuildTransaction, this.loadingTransaction = t.loadingTransaction;
1043
+ }));
1044
+ }
1045
+ firstUpdated() {
1046
+ n.getTransaction(), this.refreshTransaction();
1047
+ }
1048
+ disconnectedCallback() {
1049
+ this.unsubscribe.forEach((t) => t == null ? void 0 : t()), clearInterval(this.interval);
1050
+ }
1051
+ render() {
1052
+ return u`
1053
+ <wui-flex flexDirection="column" .padding=${["0", "l", "l", "l"]} gap="s">
1054
+ ${this.templateSwap()}
1055
+ </wui-flex>
1056
+ `;
1057
+ }
1058
+ refreshTransaction() {
1059
+ this.interval = setInterval(() => {
1060
+ n.getApprovalLoadingState() || n.getTransaction();
1061
+ }, 1e4);
1062
+ }
1063
+ templateSwap() {
1064
+ var x, v, N, U;
1065
+ const t = `${m.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${(x = this.sourceToken) == null ? void 0 : x.symbol}`, e = `${m.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${(v = this.toToken) == null ? void 0 : v.symbol}`, o = parseFloat(this.sourceTokenAmount) * this.sourceTokenPriceInUSD, a = parseFloat(this.toTokenAmount) * this.toTokenPriceInUSD, i = m.formatNumberToLocalString(o), r = m.formatNumberToLocalString(a), l = this.loadingQuote || this.loadingBuildTransaction || this.loadingTransaction || this.loadingApprovalTransaction;
1066
+ return u`
1067
+ <wui-flex flexDirection="column" alignItems="center" gap="l">
1068
+ <wui-flex class="preview-container" flexDirection="column" alignItems="flex-start" gap="l">
1069
+ <wui-flex
1070
+ class="preview-token-details-container"
1071
+ alignItems="center"
1072
+ justifyContent="space-between"
1073
+ gap="l"
1074
+ >
1075
+ <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs">
1076
+ <wui-text variant="small-400" color="fg-150">Send</wui-text>
1077
+ <wui-text variant="paragraph-400" color="fg-100">$${i}</wui-text>
1078
+ </wui-flex>
1079
+ <wui-token-button
1080
+ flexDirection="row-reverse"
1081
+ text=${t}
1082
+ imageSrc=${(N = this.sourceToken) == null ? void 0 : N.logoUri}
1083
+ >
1084
+ </wui-token-button>
1085
+ </wui-flex>
1086
+ <wui-icon name="recycleHorizontal" color="fg-200" size="md"></wui-icon>
1087
+ <wui-flex
1088
+ class="preview-token-details-container"
1089
+ alignItems="center"
1090
+ justifyContent="space-between"
1091
+ gap="l"
1092
+ >
1093
+ <wui-flex flexDirection="column" alignItems="flex-start" gap="4xs">
1094
+ <wui-text variant="small-400" color="fg-150">Receive</wui-text>
1095
+ <wui-text variant="paragraph-400" color="fg-100">$${r}</wui-text>
1096
+ </wui-flex>
1097
+ <wui-token-button
1098
+ flexDirection="row-reverse"
1099
+ text=${e}
1100
+ imageSrc=${(U = this.toToken) == null ? void 0 : U.logoUri}
1101
+ >
1102
+ </wui-token-button>
1103
+ </wui-flex>
1104
+ </wui-flex>
1105
+
1106
+ ${this.templateDetails()}
1107
+
1108
+ <wui-flex flexDirection="row" alignItems="center" justifyContent="center" gap="xs">
1109
+ <wui-icon size="sm" color="fg-200" name="infoCircle"></wui-icon>
1110
+ <wui-text variant="small-400" color="fg-200">Review transaction carefully</wui-text>
1111
+ </wui-flex>
1112
+
1113
+ <wui-flex
1114
+ class="action-buttons-container"
1115
+ flexDirection="row"
1116
+ alignItems="center"
1117
+ justifyContent="space-between"
1118
+ gap="xs"
1119
+ >
1120
+ <wui-button
1121
+ class="cancel-button"
1122
+ fullWidth
1123
+ size="lg"
1124
+ borderRadius="xs"
1125
+ variant="neutral"
1126
+ @click=${this.onCancelTransaction.bind(this)}
1127
+ >
1128
+ <wui-text variant="paragraph-600" color="fg-200">Cancel</wui-text>
1129
+ </wui-button>
1130
+ <wui-button
1131
+ class="action-button"
1132
+ fullWidth
1133
+ size="lg"
1134
+ borderRadius="xs"
1135
+ variant="main"
1136
+ ?loading=${l}
1137
+ ?disabled=${l}
1138
+ @click=${this.onSendTransaction.bind(this)}
1139
+ >
1140
+ <wui-text variant="paragraph-600" color="inverse-100">
1141
+ ${this.actionButtonLabel()}
1142
+ </wui-text>
1143
+ </wui-button>
1144
+ </wui-flex>
1145
+ </wui-flex>
1146
+ `;
1147
+ }
1148
+ templateDetails() {
1149
+ return !this.sourceToken || !this.toToken || this.inputError ? null : u`<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
1150
+ }
1151
+ actionButtonLabel() {
1152
+ return this.loadingApprovalTransaction ? "Approving..." : this.approvalTransaction ? "Approve" : "Swap";
1153
+ }
1154
+ onCancelTransaction() {
1155
+ S.goBack();
1156
+ }
1157
+ onSendTransaction() {
1158
+ this.approvalTransaction ? n.sendTransactionForApproval(this.approvalTransaction) : n.sendTransactionForSwap(this.swapTransaction);
1159
+ }
1160
+ };
1161
+ d.styles = et;
1162
+ g([
1163
+ s()
1164
+ ], d.prototype, "interval", void 0);
1165
+ g([
1166
+ s()
1167
+ ], d.prototype, "detailsOpen", void 0);
1168
+ g([
1169
+ s()
1170
+ ], d.prototype, "approvalTransaction", void 0);
1171
+ g([
1172
+ s()
1173
+ ], d.prototype, "swapTransaction", void 0);
1174
+ g([
1175
+ s()
1176
+ ], d.prototype, "sourceToken", void 0);
1177
+ g([
1178
+ s()
1179
+ ], d.prototype, "sourceTokenAmount", void 0);
1180
+ g([
1181
+ s()
1182
+ ], d.prototype, "sourceTokenPriceInUSD", void 0);
1183
+ g([
1184
+ s()
1185
+ ], d.prototype, "toToken", void 0);
1186
+ g([
1187
+ s()
1188
+ ], d.prototype, "toTokenAmount", void 0);
1189
+ g([
1190
+ s()
1191
+ ], d.prototype, "toTokenPriceInUSD", void 0);
1192
+ g([
1193
+ s()
1194
+ ], d.prototype, "caipNetwork", void 0);
1195
+ g([
1196
+ s()
1197
+ ], d.prototype, "balanceSymbol", void 0);
1198
+ g([
1199
+ s()
1200
+ ], d.prototype, "inputError", void 0);
1201
+ g([
1202
+ s()
1203
+ ], d.prototype, "loadingQuote", void 0);
1204
+ g([
1205
+ s()
1206
+ ], d.prototype, "loadingApprovalTransaction", void 0);
1207
+ g([
1208
+ s()
1209
+ ], d.prototype, "loadingBuildTransaction", void 0);
1210
+ g([
1211
+ s()
1212
+ ], d.prototype, "loadingTransaction", void 0);
1213
+ d = g([
1214
+ E("w3m-swap-preview-view")
1215
+ ], d);
1216
+ const ot = P`
1217
+ :host {
1218
+ height: 60px;
1219
+ min-height: 60px;
1220
+ }
1221
+
1222
+ :host > wui-flex {
1223
+ cursor: pointer;
1224
+ height: 100%;
1225
+ display: flex;
1226
+ column-gap: var(--wui-spacing-s);
1227
+ padding: var(--wui-spacing-xs);
1228
+ padding-right: var(--wui-spacing-l);
1229
+ width: 100%;
1230
+ background-color: transparent;
1231
+ border-radius: var(--wui-border-radius-xs);
1232
+ color: var(--wui-color-fg-250);
1233
+ transition:
1234
+ background-color var(--wui-ease-out-power-1) var(--wui-duration-lg),
1235
+ opacity var(--wui-ease-out-power-1) var(--wui-duration-lg);
1236
+ will-change: background-color, opacity;
1237
+ }
1238
+
1239
+ @media (hover: hover) and (pointer: fine) {
1240
+ :host > wui-flex:hover {
1241
+ background-color: var(--wui-color-gray-glass-002);
1242
+ }
1243
+
1244
+ :host > wui-flex:active {
1245
+ background-color: var(--wui-color-gray-glass-005);
1246
+ }
1247
+ }
1248
+
1249
+ :host([disabled]) > wui-flex {
1250
+ opacity: 0.6;
1251
+ }
1252
+
1253
+ :host([disabled]) > wui-flex:hover {
1254
+ background-color: transparent;
1255
+ }
1256
+
1257
+ :host > wui-flex > wui-flex {
1258
+ flex: 1;
1259
+ }
1260
+
1261
+ :host > wui-flex > wui-image,
1262
+ :host > wui-flex > .token-item-image-placeholder {
1263
+ width: 40px;
1264
+ max-width: 40px;
1265
+ height: 40px;
1266
+ border-radius: var(--wui-border-radius-3xl);
1267
+ position: relative;
1268
+ }
1269
+
1270
+ :host > wui-flex > .token-item-image-placeholder {
1271
+ display: flex;
1272
+ align-items: center;
1273
+ justify-content: center;
1274
+ }
1275
+
1276
+ :host > wui-flex > wui-image::after,
1277
+ :host > wui-flex > .token-item-image-placeholder::after {
1278
+ position: absolute;
1279
+ content: '';
1280
+ inset: 0;
1281
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
1282
+ border-radius: var(--wui-border-radius-l);
1283
+ }
1284
+
1285
+ button > wui-icon-box[data-variant='square-blue'] {
1286
+ border-radius: var(--wui-border-radius-3xs);
1287
+ position: relative;
1288
+ border: none;
1289
+ width: 36px;
1290
+ height: 36px;
1291
+ }
1292
+ `;
1293
+ var A = function(c, t, e, o) {
1294
+ var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
1295
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
1296
+ else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
1297
+ return a > 3 && i && Object.defineProperty(t, e, i), i;
1298
+ };
1299
+ let $ = class extends C {
1300
+ constructor() {
1301
+ super(), this.observer = new IntersectionObserver(() => {
1302
+ }), this.imageSrc = void 0, this.name = void 0, this.symbol = void 0, this.price = void 0, this.amount = void 0, this.visible = !1, this.imageError = !1, this.observer = new IntersectionObserver((t) => {
1303
+ t.forEach((e) => {
1304
+ e.isIntersecting ? this.visible = !0 : this.visible = !1;
1305
+ });
1306
+ }, { threshold: 0.1 });
1307
+ }
1308
+ firstUpdated() {
1309
+ this.observer.observe(this);
1310
+ }
1311
+ disconnectedCallback() {
1312
+ this.observer.disconnect();
1313
+ }
1314
+ render() {
1315
+ var e;
1316
+ if (!this.visible)
1317
+ return null;
1318
+ const t = this.amount && this.price ? (e = j.multiply(this.price, this.amount)) == null ? void 0 : e.toFixed(3) : null;
1319
+ return u`
1320
+ <wui-flex alignItems="center">
1321
+ ${this.visualTemplate()}
1322
+ <wui-flex flexDirection="column" gap="3xs">
1323
+ <wui-flex justifyContent="space-between">
1324
+ <wui-text variant="paragraph-500" color="fg-100" lineClamp="1">${this.name}</wui-text>
1325
+ ${t ? u`
1326
+ <wui-text variant="paragraph-500" color="fg-100">
1327
+ $${m.formatNumberToLocalString(t, 3)}
1328
+ </wui-text>
1329
+ ` : null}
1330
+ </wui-flex>
1331
+ <wui-flex justifyContent="space-between">
1332
+ <wui-text variant="small-400" color="fg-200" lineClamp="1">${this.symbol}</wui-text>
1333
+ ${this.amount ? u`<wui-text variant="small-400" color="fg-200">
1334
+ ${m.formatNumberToLocalString(this.amount, 4)}
1335
+ </wui-text>` : null}
1336
+ </wui-flex>
1337
+ </wui-flex>
1338
+ </wui-flex>
1339
+ `;
1340
+ }
1341
+ visualTemplate() {
1342
+ return this.imageError ? u`<wui-flex class="token-item-image-placeholder">
1343
+ <wui-icon name="image" color="inherit"></wui-icon>
1344
+ </wui-flex>` : this.imageSrc ? u`<wui-image
1345
+ width="40"
1346
+ height="40"
1347
+ src=${this.imageSrc}
1348
+ @onLoadError=${this.imageLoadError}
1349
+ ></wui-image>` : null;
1350
+ }
1351
+ imageLoadError() {
1352
+ this.imageError = !0;
1353
+ }
1354
+ };
1355
+ $.styles = [Q, q, ot];
1356
+ A([
1357
+ h()
1358
+ ], $.prototype, "imageSrc", void 0);
1359
+ A([
1360
+ h()
1361
+ ], $.prototype, "name", void 0);
1362
+ A([
1363
+ h()
1364
+ ], $.prototype, "symbol", void 0);
1365
+ A([
1366
+ h()
1367
+ ], $.prototype, "price", void 0);
1368
+ A([
1369
+ h()
1370
+ ], $.prototype, "amount", void 0);
1371
+ A([
1372
+ s()
1373
+ ], $.prototype, "visible", void 0);
1374
+ A([
1375
+ s()
1376
+ ], $.prototype, "imageError", void 0);
1377
+ $ = A([
1378
+ E("wui-token-list-item")
1379
+ ], $);
1380
+ const it = P`
1381
+ :host {
1382
+ --tokens-scroll--top-opacity: 0;
1383
+ --tokens-scroll--bottom-opacity: 1;
1384
+ --suggested-tokens-scroll--left-opacity: 0;
1385
+ --suggested-tokens-scroll--right-opacity: 1;
1386
+ }
1387
+
1388
+ :host > wui-flex:first-child {
1389
+ overflow-y: hidden;
1390
+ overflow-x: hidden;
1391
+ scrollbar-width: none;
1392
+ scrollbar-height: none;
1393
+ }
1394
+
1395
+ :host > wui-flex:first-child::-webkit-scrollbar {
1396
+ display: none;
1397
+ }
1398
+
1399
+ wui-loading-hexagon {
1400
+ position: absolute;
1401
+ }
1402
+
1403
+ .suggested-tokens-container {
1404
+ overflow-x: auto;
1405
+ mask-image: linear-gradient(
1406
+ to right,
1407
+ rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 0px,
1408
+ rgba(200, 200, 200, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 1px,
1409
+ black 50px,
1410
+ black 90px,
1411
+ black calc(100% - 90px),
1412
+ black calc(100% - 50px),
1413
+ rgba(155, 155, 155, calc(1 - var(--suggested-tokens-scroll--right-opacity))) calc(100% - 1px),
1414
+ rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--right-opacity))) 100%
1415
+ );
1416
+ }
1417
+
1418
+ .suggested-tokens-container::-webkit-scrollbar {
1419
+ display: none;
1420
+ }
1421
+
1422
+ .tokens-container {
1423
+ border-top: 1px solid var(--wui-color-gray-glass-005);
1424
+ height: 100%;
1425
+ max-height: 390px;
1426
+ }
1427
+
1428
+ .tokens {
1429
+ width: 100%;
1430
+ overflow-y: auto;
1431
+ mask-image: linear-gradient(
1432
+ to bottom,
1433
+ rgba(0, 0, 0, calc(1 - var(--tokens-scroll--top-opacity))) 0px,
1434
+ rgba(200, 200, 200, calc(1 - var(--tokens-scroll--top-opacity))) 1px,
1435
+ black 50px,
1436
+ black 90px,
1437
+ black calc(100% - 90px),
1438
+ black calc(100% - 50px),
1439
+ rgba(155, 155, 155, calc(1 - var(--tokens-scroll--bottom-opacity))) calc(100% - 1px),
1440
+ rgba(0, 0, 0, calc(1 - var(--tokens-scroll--bottom-opacity))) 100%
1441
+ );
1442
+ }
1443
+
1444
+ .network-search-input,
1445
+ .select-network-button {
1446
+ height: 40px;
1447
+ }
1448
+
1449
+ .select-network-button {
1450
+ border: none;
1451
+ display: flex;
1452
+ flex-direction: row;
1453
+ align-items: center;
1454
+ justify-content: center;
1455
+ gap: var(--wui-spacing-xs);
1456
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-005);
1457
+ background-color: transparent;
1458
+ border-radius: var(--wui-border-radius-xxs);
1459
+ padding: var(--wui-spacing-xs);
1460
+ align-items: center;
1461
+ transition: background-color 0.2s linear;
1462
+ }
1463
+
1464
+ .select-network-button:hover {
1465
+ background-color: var(--wui-color-gray-glass-002);
1466
+ }
1467
+
1468
+ .select-network-button > wui-image {
1469
+ width: 26px;
1470
+ height: 26px;
1471
+ border-radius: var(--wui-border-radius-xs);
1472
+ box-shadow: inset 0 0 0 1px var(--wui-color-gray-glass-010);
1473
+ }
1474
+ `;
1475
+ var I = function(c, t, e, o) {
1476
+ var a = arguments.length, i = a < 3 ? t : o === null ? o = Object.getOwnPropertyDescriptor(t, e) : o, r;
1477
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(c, t, e, o);
1478
+ else for (var l = c.length - 1; l >= 0; l--) (r = c[l]) && (i = (a < 3 ? r(i) : a > 3 ? r(t, e, i) : r(t, e)) || i);
1479
+ return a > 3 && i && Object.defineProperty(t, e, i), i;
1480
+ };
1481
+ let T = class extends C {
1482
+ constructor() {
1483
+ var t;
1484
+ super(), this.unsubscribe = [], this.targetToken = (t = S.state.data) == null ? void 0 : t.target, this.sourceToken = n.state.sourceToken, this.sourceTokenAmount = n.state.sourceTokenAmount, this.toToken = n.state.toToken, this.myTokensWithBalance = n.state.myTokensWithBalance, this.popularTokens = n.state.popularTokens, this.searchValue = "", this.unsubscribe.push(n.subscribe((e) => {
1485
+ this.sourceToken = e.sourceToken, this.toToken = e.toToken, this.myTokensWithBalance = e.myTokensWithBalance;
1486
+ }));
1487
+ }
1488
+ updated() {
1489
+ var o, a;
1490
+ const t = (o = this.renderRoot) == null ? void 0 : o.querySelector(".suggested-tokens-container");
1491
+ t == null || t.addEventListener("scroll", this.handleSuggestedTokensScroll.bind(this));
1492
+ const e = (a = this.renderRoot) == null ? void 0 : a.querySelector(".tokens");
1493
+ e == null || e.addEventListener("scroll", this.handleTokenListScroll.bind(this));
1494
+ }
1495
+ disconnectedCallback() {
1496
+ var o, a;
1497
+ super.disconnectedCallback();
1498
+ const t = (o = this.renderRoot) == null ? void 0 : o.querySelector(".suggested-tokens-container"), e = (a = this.renderRoot) == null ? void 0 : a.querySelector(".tokens");
1499
+ t == null || t.removeEventListener("scroll", this.handleSuggestedTokensScroll.bind(this)), e == null || e.removeEventListener("scroll", this.handleTokenListScroll.bind(this)), clearInterval(this.interval);
1500
+ }
1501
+ render() {
1502
+ return u`
1503
+ <wui-flex flexDirection="column" gap="s">
1504
+ ${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()}
1505
+ </wui-flex>
1506
+ `;
1507
+ }
1508
+ onSelectToken(t) {
1509
+ this.targetToken === "sourceToken" ? n.setSourceToken(t) : (n.setToToken(t), this.sourceToken && this.sourceTokenAmount && n.swapTokens()), S.goBack();
1510
+ }
1511
+ templateSearchInput() {
1512
+ return u`
1513
+ <wui-flex .padding=${["3xs", "s", "0", "s"]} gap="xs">
1514
+ <wui-input-text
1515
+ data-testid="swap-select-token-search-input"
1516
+ class="network-search-input"
1517
+ size="sm"
1518
+ placeholder="Search token"
1519
+ icon="search"
1520
+ .value=${this.searchValue}
1521
+ @inputChange=${this.onSearchInputChange.bind(this)}
1522
+ ></wui-input-text>
1523
+ </wui-flex>
1524
+ `;
1525
+ }
1526
+ templateTokens() {
1527
+ const t = this.myTokensWithBalance ? Object.values(this.myTokensWithBalance) : [], e = this.popularTokens ? this.popularTokens : [], o = this.filterTokensWithText(t, this.searchValue), a = this.filterTokensWithText(e, this.searchValue);
1528
+ return u`
1529
+ <wui-flex class="tokens-container">
1530
+ <wui-flex class="tokens" .padding=${["0", "s", "s", "s"]} flexDirection="column">
1531
+ ${(o == null ? void 0 : o.length) > 0 ? u`
1532
+ <wui-flex justifyContent="flex-start" padding="s">
1533
+ <wui-text variant="paragraph-500" color="fg-200">Your tokens</wui-text>
1534
+ </wui-flex>
1535
+ ${o.map((i) => {
1536
+ var l, x, v;
1537
+ const r = i.symbol === ((l = this.sourceToken) == null ? void 0 : l.symbol) || i.symbol === ((x = this.toToken) == null ? void 0 : x.symbol);
1538
+ return u`
1539
+ <wui-token-list-item
1540
+ data-testid="swap-select-token-item-${i.symbol}"
1541
+ name=${i.name}
1542
+ ?disabled=${r}
1543
+ symbol=${i.symbol}
1544
+ price=${i == null ? void 0 : i.price}
1545
+ amount=${(v = i == null ? void 0 : i.quantity) == null ? void 0 : v.numeric}
1546
+ imageSrc=${i.logoUri}
1547
+ @click=${() => {
1548
+ r || this.onSelectToken(i);
1549
+ }}
1550
+ >
1551
+ </wui-token-list-item>
1552
+ `;
1553
+ })}
1554
+ ` : null}
1555
+
1556
+ <wui-flex justifyContent="flex-start" padding="s">
1557
+ <wui-text variant="paragraph-500" color="fg-200">Tokens</wui-text>
1558
+ </wui-flex>
1559
+ ${(a == null ? void 0 : a.length) > 0 ? a.map((i) => u`
1560
+ <wui-token-list-item
1561
+ data-testid="swap-select-token-item-${i.symbol}"
1562
+ name=${i.name}
1563
+ symbol=${i.symbol}
1564
+ imageSrc=${i.logoUri}
1565
+ @click=${() => this.onSelectToken(i)}
1566
+ >
1567
+ </wui-token-list-item>
1568
+ `) : null}
1569
+ </wui-flex>
1570
+ </wui-flex>
1571
+ `;
1572
+ }
1573
+ templateSuggestedTokens() {
1574
+ const t = n.state.suggestedTokens ? n.state.suggestedTokens.slice(0, 8) : null;
1575
+ return t ? u`
1576
+ <wui-flex class="suggested-tokens-container" .padding=${["0", "s", "0", "s"]} gap="xs">
1577
+ ${t.map((e) => u`
1578
+ <wui-token-button
1579
+ text=${e.symbol}
1580
+ imageSrc=${e.logoUri}
1581
+ @click=${() => this.onSelectToken(e)}
1582
+ >
1583
+ </wui-token-button>
1584
+ `)}
1585
+ </wui-flex>
1586
+ ` : null;
1587
+ }
1588
+ onSearchInputChange(t) {
1589
+ this.searchValue = t.detail;
1590
+ }
1591
+ handleSuggestedTokensScroll() {
1592
+ var e;
1593
+ const t = (e = this.renderRoot) == null ? void 0 : e.querySelector(".suggested-tokens-container");
1594
+ t && (t.style.setProperty("--suggested-tokens-scroll--left-opacity", R.interpolate([0, 100], [0, 1], t.scrollLeft).toString()), t.style.setProperty("--suggested-tokens-scroll--right-opacity", R.interpolate([0, 100], [0, 1], t.scrollWidth - t.scrollLeft - t.offsetWidth).toString()));
1595
+ }
1596
+ handleTokenListScroll() {
1597
+ var e;
1598
+ const t = (e = this.renderRoot) == null ? void 0 : e.querySelector(".tokens");
1599
+ t && (t.style.setProperty("--tokens-scroll--top-opacity", R.interpolate([0, 100], [0, 1], t.scrollTop).toString()), t.style.setProperty("--tokens-scroll--bottom-opacity", R.interpolate([0, 100], [0, 1], t.scrollHeight - t.scrollTop - t.offsetHeight).toString()));
1600
+ }
1601
+ filterTokensWithText(t, e) {
1602
+ return t.filter((o) => `${o.symbol} ${o.name} ${o.address}`.toLowerCase().includes(e.toLowerCase()));
1603
+ }
1604
+ };
1605
+ T.styles = it;
1606
+ I([
1607
+ s()
1608
+ ], T.prototype, "interval", void 0);
1609
+ I([
1610
+ s()
1611
+ ], T.prototype, "targetToken", void 0);
1612
+ I([
1613
+ s()
1614
+ ], T.prototype, "sourceToken", void 0);
1615
+ I([
1616
+ s()
1617
+ ], T.prototype, "sourceTokenAmount", void 0);
1618
+ I([
1619
+ s()
1620
+ ], T.prototype, "toToken", void 0);
1621
+ I([
1622
+ s()
1623
+ ], T.prototype, "myTokensWithBalance", void 0);
1624
+ I([
1625
+ s()
1626
+ ], T.prototype, "popularTokens", void 0);
1627
+ I([
1628
+ s()
1629
+ ], T.prototype, "searchValue", void 0);
1630
+ T = I([
1631
+ E("w3m-swap-select-token-view")
1632
+ ], T);
1633
+ export {
1634
+ d as W3mSwapPreviewView,
1635
+ T as W3mSwapSelectTokenView,
1636
+ p as W3mSwapView
1637
+ };