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