@prohetamine/redstone 0.0.1

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