0xtrails 0.0.1 → 0.0.2

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