@m0-foundation/swap-component 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 (240) hide show
  1. package/dist/m0-swap-component/ConstantsUtil-btJ3XIXu.js +28 -0
  2. package/dist/m0-swap-component/ConstantsUtil-btJ3XIXu.js.map +1 -0
  3. package/dist/m0-swap-component/HelpersUtil-5wkO4kIW.js +142 -0
  4. package/dist/m0-swap-component/HelpersUtil-5wkO4kIW.js.map +1 -0
  5. package/dist/m0-swap-component/PhArrowCircleDown-BiDIiYXi.js +76 -0
  6. package/dist/m0-swap-component/PhArrowCircleDown-BiDIiYXi.js.map +1 -0
  7. package/dist/m0-swap-component/PhArrowClockwise-BRnlxNUR.js +76 -0
  8. package/dist/m0-swap-component/PhArrowClockwise-BRnlxNUR.js.map +1 -0
  9. package/dist/m0-swap-component/PhArrowDown-Co2hyXIs.js +76 -0
  10. package/dist/m0-swap-component/PhArrowDown-Co2hyXIs.js.map +1 -0
  11. package/dist/m0-swap-component/PhArrowLeft-Cb8ijwK6.js +76 -0
  12. package/dist/m0-swap-component/PhArrowLeft-Cb8ijwK6.js.map +1 -0
  13. package/dist/m0-swap-component/PhArrowRight-B9t--Gmh.js +76 -0
  14. package/dist/m0-swap-component/PhArrowRight-B9t--Gmh.js.map +1 -0
  15. package/dist/m0-swap-component/PhArrowSquareOut-eGBMEr5T.js +76 -0
  16. package/dist/m0-swap-component/PhArrowSquareOut-eGBMEr5T.js.map +1 -0
  17. package/dist/m0-swap-component/PhArrowUp-CjSpT-xh.js +76 -0
  18. package/dist/m0-swap-component/PhArrowUp-CjSpT-xh.js.map +1 -0
  19. package/dist/m0-swap-component/PhArrowUpRight-B8u6wk-A.js +76 -0
  20. package/dist/m0-swap-component/PhArrowUpRight-B8u6wk-A.js.map +1 -0
  21. package/dist/m0-swap-component/PhArrowsClockwise-CBcfV6j6.js +76 -0
  22. package/dist/m0-swap-component/PhArrowsClockwise-CBcfV6j6.js.map +1 -0
  23. package/dist/m0-swap-component/PhArrowsDownUp-CMVR84b1.js +76 -0
  24. package/dist/m0-swap-component/PhArrowsDownUp-CMVR84b1.js.map +1 -0
  25. package/dist/m0-swap-component/PhArrowsLeftRight-CmXk8rs2.js +76 -0
  26. package/dist/m0-swap-component/PhArrowsLeftRight-CmXk8rs2.js.map +1 -0
  27. package/dist/m0-swap-component/PhBank-BigtjnS8.js +76 -0
  28. package/dist/m0-swap-component/PhBank-BigtjnS8.js.map +1 -0
  29. package/dist/m0-swap-component/PhBrowser-BOulLD8D.js +76 -0
  30. package/dist/m0-swap-component/PhBrowser-BOulLD8D.js.map +1 -0
  31. package/dist/m0-swap-component/PhCaretDown-BvvZ65ad.js +76 -0
  32. package/dist/m0-swap-component/PhCaretDown-BvvZ65ad.js.map +1 -0
  33. package/dist/m0-swap-component/PhCaretLeft-DtwjZbZ7.js +76 -0
  34. package/dist/m0-swap-component/PhCaretLeft-DtwjZbZ7.js.map +1 -0
  35. package/dist/m0-swap-component/PhCaretRight-C8LuSZkO.js +76 -0
  36. package/dist/m0-swap-component/PhCaretRight-C8LuSZkO.js.map +1 -0
  37. package/dist/m0-swap-component/PhCaretUp-B2lAObip.js +76 -0
  38. package/dist/m0-swap-component/PhCaretUp-B2lAObip.js.map +1 -0
  39. package/dist/m0-swap-component/PhCheck-DQtuVrQf.js +76 -0
  40. package/dist/m0-swap-component/PhCheck-DQtuVrQf.js.map +1 -0
  41. package/dist/m0-swap-component/PhCircleHalf-CXfZ0QZv.js +76 -0
  42. package/dist/m0-swap-component/PhCircleHalf-CXfZ0QZv.js.map +1 -0
  43. package/dist/m0-swap-component/PhClock-CXsmuc_a.js +76 -0
  44. package/dist/m0-swap-component/PhClock-CXsmuc_a.js.map +1 -0
  45. package/dist/m0-swap-component/PhCompass-Cg-qnMon.js +76 -0
  46. package/dist/m0-swap-component/PhCompass-Cg-qnMon.js.map +1 -0
  47. package/dist/m0-swap-component/PhCopy-kGRKcvb4.js +76 -0
  48. package/dist/m0-swap-component/PhCopy-kGRKcvb4.js.map +1 -0
  49. package/dist/m0-swap-component/PhCreditCard-jYFausLO.js +76 -0
  50. package/dist/m0-swap-component/PhCreditCard-jYFausLO.js.map +1 -0
  51. package/dist/m0-swap-component/PhCurrencyDollar-C8vSY3fy.js +76 -0
  52. package/dist/m0-swap-component/PhCurrencyDollar-C8vSY3fy.js.map +1 -0
  53. package/dist/m0-swap-component/PhDesktop-AczlBCho.js +76 -0
  54. package/dist/m0-swap-component/PhDesktop-AczlBCho.js.map +1 -0
  55. package/dist/m0-swap-component/PhDeviceMobile-3rFbdWLA.js +76 -0
  56. package/dist/m0-swap-component/PhDeviceMobile-3rFbdWLA.js.map +1 -0
  57. package/dist/m0-swap-component/PhDotsThree-cJsXXsvY.js +76 -0
  58. package/dist/m0-swap-component/PhDotsThree-cJsXXsvY.js.map +1 -0
  59. package/dist/m0-swap-component/PhEnvelope-C1bxHVXw.js +76 -0
  60. package/dist/m0-swap-component/PhEnvelope-C1bxHVXw.js.map +1 -0
  61. package/dist/m0-swap-component/PhFunnelSimple-DhqB9fsu.js +76 -0
  62. package/dist/m0-swap-component/PhFunnelSimple-DhqB9fsu.js.map +1 -0
  63. package/dist/m0-swap-component/PhGlobe-BFp6kx95.js +76 -0
  64. package/dist/m0-swap-component/PhGlobe-BFp6kx95.js.map +1 -0
  65. package/dist/m0-swap-component/PhIdentificationCard-BdYxckWB.js +76 -0
  66. package/dist/m0-swap-component/PhIdentificationCard-BdYxckWB.js.map +1 -0
  67. package/dist/m0-swap-component/PhImage-CXxX5oq3.js +76 -0
  68. package/dist/m0-swap-component/PhImage-CXxX5oq3.js.map +1 -0
  69. package/dist/m0-swap-component/PhInfo-BcuP36hY.js +76 -0
  70. package/dist/m0-swap-component/PhInfo-BcuP36hY.js.map +1 -0
  71. package/dist/m0-swap-component/PhLightbulb-DkWwRl94.js +76 -0
  72. package/dist/m0-swap-component/PhLightbulb-DkWwRl94.js.map +1 -0
  73. package/dist/m0-swap-component/PhMagnifyingGlass-B_fFjslY.js +76 -0
  74. package/dist/m0-swap-component/PhMagnifyingGlass-B_fFjslY.js.map +1 -0
  75. package/dist/m0-swap-component/PhPaperPlaneRight-BIzGG3QW.js +76 -0
  76. package/dist/m0-swap-component/PhPaperPlaneRight-BIzGG3QW.js.map +1 -0
  77. package/dist/m0-swap-component/PhPlus-BGosT2zu.js +76 -0
  78. package/dist/m0-swap-component/PhPlus-BGosT2zu.js.map +1 -0
  79. package/dist/m0-swap-component/PhPower-BMqDnP1n.js +76 -0
  80. package/dist/m0-swap-component/PhPower-BMqDnP1n.js.map +1 -0
  81. package/dist/m0-swap-component/PhPuzzlePiece-DNMpiJNU.js +76 -0
  82. package/dist/m0-swap-component/PhPuzzlePiece-DNMpiJNU.js.map +1 -0
  83. package/dist/m0-swap-component/PhQrCode-DrHkqrU4.js +76 -0
  84. package/dist/m0-swap-component/PhQrCode-DrHkqrU4.js.map +1 -0
  85. package/dist/m0-swap-component/PhQuestion-zTfvwqNz.js +76 -0
  86. package/dist/m0-swap-component/PhQuestion-zTfvwqNz.js.map +1 -0
  87. package/dist/m0-swap-component/PhQuestionMark-h3Nk1Yf1.js +76 -0
  88. package/dist/m0-swap-component/PhQuestionMark-h3Nk1Yf1.js.map +1 -0
  89. package/dist/m0-swap-component/PhSealCheck-DPPqSt6G.js +76 -0
  90. package/dist/m0-swap-component/PhSealCheck-DPPqSt6G.js.map +1 -0
  91. package/dist/m0-swap-component/PhSignOut-CJgnrE_v.js +76 -0
  92. package/dist/m0-swap-component/PhSignOut-CJgnrE_v.js.map +1 -0
  93. package/dist/m0-swap-component/PhSpinner-CMTEIWbw.js +76 -0
  94. package/dist/m0-swap-component/PhSpinner-CMTEIWbw.js.map +1 -0
  95. package/dist/m0-swap-component/PhTrash-CeDVW4am.js +76 -0
  96. package/dist/m0-swap-component/PhTrash-CeDVW4am.js.map +1 -0
  97. package/dist/m0-swap-component/PhUser-lQ9WUtAV.js +76 -0
  98. package/dist/m0-swap-component/PhUser-lQ9WUtAV.js.map +1 -0
  99. package/dist/m0-swap-component/PhVault-EnLnS_IQ.js +76 -0
  100. package/dist/m0-swap-component/PhVault-EnLnS_IQ.js.map +1 -0
  101. package/dist/m0-swap-component/PhWallet-CUeDZydd.js +76 -0
  102. package/dist/m0-swap-component/PhWallet-CUeDZydd.js.map +1 -0
  103. package/dist/m0-swap-component/PhWarning-CokeGZs2.js +76 -0
  104. package/dist/m0-swap-component/PhWarning-CokeGZs2.js.map +1 -0
  105. package/dist/m0-swap-component/PhWarningCircle-vWtA7S0R.js +76 -0
  106. package/dist/m0-swap-component/PhWarningCircle-vWtA7S0R.js.map +1 -0
  107. package/dist/m0-swap-component/PhX-DwCRIvoc.js +76 -0
  108. package/dist/m0-swap-component/PhX-DwCRIvoc.js.map +1 -0
  109. package/dist/m0-swap-component/data-capture-BmovBbKV.js +573 -0
  110. package/dist/m0-swap-component/data-capture-BmovBbKV.js.map +1 -0
  111. package/dist/m0-swap-component/email-B4niz3Ms.js +445 -0
  112. package/dist/m0-swap-component/email-B4niz3Ms.js.map +1 -0
  113. package/dist/m0-swap-component/embedded-wallet-D6bzjX_K.js +988 -0
  114. package/dist/m0-swap-component/embedded-wallet-D6bzjX_K.js.map +1 -0
  115. package/dist/m0-swap-component/features-EhJNVE-M.js +355 -0
  116. package/dist/m0-swap-component/features-EhJNVE-M.js.map +1 -0
  117. package/dist/m0-swap-component/if-defined-2CMpVr2R.js +12 -0
  118. package/dist/m0-swap-component/if-defined-2CMpVr2R.js.map +1 -0
  119. package/dist/m0-swap-component/index-B4xuj7uR.js +965 -0
  120. package/dist/m0-swap-component/index-B4xuj7uR.js.map +1 -0
  121. package/dist/m0-swap-component/index-BVZ66GYf.js +206 -0
  122. package/dist/m0-swap-component/index-BVZ66GYf.js.map +1 -0
  123. package/dist/m0-swap-component/index-BZXyMieH.js +150 -0
  124. package/dist/m0-swap-component/index-BZXyMieH.js.map +1 -0
  125. package/dist/m0-swap-component/index-Bj5sA_Ri.js +252 -0
  126. package/dist/m0-swap-component/index-Bj5sA_Ri.js.map +1 -0
  127. package/dist/m0-swap-component/index-Bs-pPJYj.js +129 -0
  128. package/dist/m0-swap-component/index-Bs-pPJYj.js.map +1 -0
  129. package/dist/m0-swap-component/index-CMS76VPf.js +474 -0
  130. package/dist/m0-swap-component/index-CMS76VPf.js.map +1 -0
  131. package/dist/m0-swap-component/index-CoMTkqee.js +95 -0
  132. package/dist/m0-swap-component/index-CoMTkqee.js.map +1 -0
  133. package/dist/m0-swap-component/index-DE0OtbL2.js +3566 -0
  134. package/dist/m0-swap-component/index-DE0OtbL2.js.map +1 -0
  135. package/dist/m0-swap-component/index-DEG-YczD.js +231 -0
  136. package/dist/m0-swap-component/index-DEG-YczD.js.map +1 -0
  137. package/dist/m0-swap-component/index-DY_Ijq_4.js +4345 -0
  138. package/dist/m0-swap-component/index-DY_Ijq_4.js.map +1 -0
  139. package/dist/m0-swap-component/index-IRpGhIhy.js +9394 -0
  140. package/dist/m0-swap-component/index-IRpGhIhy.js.map +1 -0
  141. package/dist/m0-swap-component/index-Z70nBYWG.js +113 -0
  142. package/dist/m0-swap-component/index-Z70nBYWG.js.map +1 -0
  143. package/dist/m0-swap-component/index-iNFotRMa.js +73 -0
  144. package/dist/m0-swap-component/index-iNFotRMa.js.map +1 -0
  145. package/dist/m0-swap-component/index-n1fooC-v.js +37757 -0
  146. package/dist/m0-swap-component/index-n1fooC-v.js.map +1 -0
  147. package/dist/m0-swap-component/index.esm.js +2 -0
  148. package/dist/m0-swap-component/index.esm.js.map +1 -0
  149. package/dist/m0-swap-component/loader.esm.js.map +1 -0
  150. package/dist/m0-swap-component/m0-swap-component.esm.js +48 -0
  151. package/dist/m0-swap-component/m0-swap-component.esm.js.map +1 -0
  152. package/dist/m0-swap-component/native-CPtqJIn7.js +18 -0
  153. package/dist/m0-swap-component/native-CPtqJIn7.js.map +1 -0
  154. package/dist/m0-swap-component/onramp-BppY2eDR.js +1003 -0
  155. package/dist/m0-swap-component/onramp-BppY2eDR.js.map +1 -0
  156. package/dist/m0-swap-component/pay-with-exchange-BJYQgTMB.js +639 -0
  157. package/dist/m0-swap-component/pay-with-exchange-BJYQgTMB.js.map +1 -0
  158. package/dist/m0-swap-component/property-BN-VaT99.js +625 -0
  159. package/dist/m0-swap-component/property-BN-VaT99.js.map +1 -0
  160. package/dist/m0-swap-component/receive-BptRM_5_.js +281 -0
  161. package/dist/m0-swap-component/receive-BptRM_5_.js.map +1 -0
  162. package/dist/m0-swap-component/ref-3xALOvo5.js +25 -0
  163. package/dist/m0-swap-component/ref-3xALOvo5.js.map +1 -0
  164. package/dist/m0-swap-component/send-BCyHM4Zr.js +1408 -0
  165. package/dist/m0-swap-component/send-BCyHM4Zr.js.map +1 -0
  166. package/dist/m0-swap-component/socials-BbajCSWV.js +824 -0
  167. package/dist/m0-swap-component/socials-BbajCSWV.js.map +1 -0
  168. package/dist/m0-swap-component/swap-module-5ZLM-vAV.js +140887 -0
  169. package/dist/m0-swap-component/swap-module-5ZLM-vAV.js.map +1 -0
  170. package/dist/m0-swap-component/swap-module.entry.esm.js.map +1 -0
  171. package/dist/m0-swap-component/swap-module.entry.js +15 -0
  172. package/dist/m0-swap-component/swaps-DyGe65DR.js +2121 -0
  173. package/dist/m0-swap-component/swaps-DyGe65DR.js.map +1 -0
  174. package/dist/m0-swap-component/transactions-BZ9l4zt5.js +60 -0
  175. package/dist/m0-swap-component/transactions-BZ9l4zt5.js.map +1 -0
  176. package/dist/m0-swap-component/utils-RCeZbvdb.js +95 -0
  177. package/dist/m0-swap-component/utils-RCeZbvdb.js.map +1 -0
  178. package/dist/m0-swap-component/w3m-modal-D0HWVPsj.js +2097 -0
  179. package/dist/m0-swap-component/w3m-modal-D0HWVPsj.js.map +1 -0
  180. package/dist/m0-swap-component/wui-button-BeTWD3Va.js +223 -0
  181. package/dist/m0-swap-component/wui-button-BeTWD3Va.js.map +1 -0
  182. package/dist/m0-swap-component/wui-email-input-CgnfUH0c.js +65 -0
  183. package/dist/m0-swap-component/wui-email-input-CgnfUH0c.js.map +1 -0
  184. package/dist/m0-swap-component/wui-icon-B0uTDhW-.js +4 -0
  185. package/dist/m0-swap-component/wui-icon-B0uTDhW-.js.map +1 -0
  186. package/dist/m0-swap-component/wui-icon-box-s87lODBB.js +4 -0
  187. package/dist/m0-swap-component/wui-icon-box-s87lODBB.js.map +1 -0
  188. package/dist/m0-swap-component/wui-icon-link-BFpV9kPE.js +127 -0
  189. package/dist/m0-swap-component/wui-icon-link-BFpV9kPE.js.map +1 -0
  190. package/dist/m0-swap-component/wui-image-BvjxoR51.js +4 -0
  191. package/dist/m0-swap-component/wui-image-BvjxoR51.js.map +1 -0
  192. package/dist/m0-swap-component/wui-input-amount-CWQfP3RO.js +182 -0
  193. package/dist/m0-swap-component/wui-input-amount-CWQfP3RO.js.map +1 -0
  194. package/dist/m0-swap-component/wui-input-text-g0sN4B2y.js +4 -0
  195. package/dist/m0-swap-component/wui-input-text-g0sN4B2y.js.map +1 -0
  196. package/dist/m0-swap-component/wui-link-VqM3wLny.js +123 -0
  197. package/dist/m0-swap-component/wui-link-VqM3wLny.js.map +1 -0
  198. package/dist/m0-swap-component/wui-list-item-BIijofqN.js +170 -0
  199. package/dist/m0-swap-component/wui-list-item-BIijofqN.js.map +1 -0
  200. package/dist/m0-swap-component/wui-list-social-C7GhkRc8.js +119 -0
  201. package/dist/m0-swap-component/wui-list-social-C7GhkRc8.js.map +1 -0
  202. package/dist/m0-swap-component/wui-list-token-C94lmAbT.js +134 -0
  203. package/dist/m0-swap-component/wui-list-token-C94lmAbT.js.map +1 -0
  204. package/dist/m0-swap-component/wui-list-wallet-C7fnQvCW.js +622 -0
  205. package/dist/m0-swap-component/wui-list-wallet-C7fnQvCW.js.map +1 -0
  206. package/dist/m0-swap-component/wui-loading-spinner-CW2_5SKA.js +4 -0
  207. package/dist/m0-swap-component/wui-loading-spinner-CW2_5SKA.js.map +1 -0
  208. package/dist/m0-swap-component/wui-loading-thumbnail-y3sGkT5j.js +337 -0
  209. package/dist/m0-swap-component/wui-loading-thumbnail-y3sGkT5j.js.map +1 -0
  210. package/dist/m0-swap-component/wui-qr-code-DekJTDGf.js +3412 -0
  211. package/dist/m0-swap-component/wui-qr-code-DekJTDGf.js.map +1 -0
  212. package/dist/m0-swap-component/wui-separator-DMZIL_Av.js +67 -0
  213. package/dist/m0-swap-component/wui-separator-DMZIL_Av.js.map +1 -0
  214. package/dist/m0-swap-component/wui-shimmer-CVFC8fMx.js +4 -0
  215. package/dist/m0-swap-component/wui-shimmer-CVFC8fMx.js.map +1 -0
  216. package/dist/m0-swap-component/wui-text-BS_lZKY4.js +1127 -0
  217. package/dist/m0-swap-component/wui-text-BS_lZKY4.js.map +1 -0
  218. package/dist/m0-swap-component/wui-token-button-CsOFoNJG.js +214 -0
  219. package/dist/m0-swap-component/wui-token-button-CsOFoNJG.js.map +1 -0
  220. package/dist/m0-swap-component/wui-visual-hU2Mkyrv.js +565 -0
  221. package/dist/m0-swap-component/wui-visual-hU2Mkyrv.js.map +1 -0
  222. package/dist/m0-swap-component/wui-wallet-switch-CWbdtfbN.js +459 -0
  223. package/dist/m0-swap-component/wui-wallet-switch-CWbdtfbN.js.map +1 -0
  224. package/dist/types/components/swap-module/balances.d.ts +16 -0
  225. package/dist/types/components/swap-module/chains.d.ts +16 -0
  226. package/dist/types/components/swap-module/store.d.ts +34 -0
  227. package/dist/types/components/swap-module/swap-module.d.ts +113 -0
  228. package/dist/types/components/swap-module/utils/constants.d.ts +7 -0
  229. package/dist/types/components/swap-module/utils/formatters.d.ts +23 -0
  230. package/dist/types/components/swap-module/utils/reown.d.ts +59 -0
  231. package/dist/types/components/swap-module/utils/wallet.d.ts +83 -0
  232. package/dist/types/components.d.ts +165 -0
  233. package/dist/types/index.d.ts +1 -0
  234. package/dist/types/stencil-public-runtime.d.ts +1732 -0
  235. package/loader/cdn.js +1 -0
  236. package/loader/index.cjs.js +1 -0
  237. package/loader/index.d.ts +24 -0
  238. package/loader/index.es2017.js +1 -0
  239. package/loader/index.js +2 -0
  240. package/package.json +60 -0
@@ -0,0 +1,2121 @@
1
+ import { d as css, f as ConstantsUtil, a as i, h as ChainController, x as SwapController, y as NumberUtil, b, c as customElement, I as InputUtil, o as EventsController, R as RouterController, n as CoreHelperUtil, M as ModalController, k as getPreferredAccountType, l as W3mFrameRpcConstants, r as resetStyles, e as elementStyles, z as MathUtil } from './swap-module-5ZLM-vAV.js';
2
+ import { r, n } from './wui-text-BS_lZKY4.js';
3
+ import './wui-button-BeTWD3Va.js';
4
+ import './wui-icon-B0uTDhW-.js';
5
+ import './wui-icon-box-s87lODBB.js';
6
+ import './index-DEG-YczD.js';
7
+ import './wui-shimmer-CVFC8fMx.js';
8
+ import './wui-token-button-CsOFoNJG.js';
9
+ import './wui-input-text-g0sN4B2y.js';
10
+ import './index-BZXyMieH.js';
11
+ import './index-iNFotRMa.js';
12
+ import './index-DY_Ijq_4.js';
13
+ import 'buffer';
14
+ import 'ox/BlockOverrides';
15
+ import 'ox/erc8010';
16
+ import 'ox/AbiConstructor';
17
+ import 'ox/AbiFunction';
18
+ import 'ox/erc6492';
19
+ import 'events';
20
+ import 'ox';
21
+ import 'ox/tempo';
22
+ import 'ox/Hex';
23
+ import 'ox/Secp256k1';
24
+ import 'ox/Signature';
25
+ import './index-CoMTkqee.js';
26
+ import './index-Bs-pPJYj.js';
27
+ import './if-defined-2CMpVr2R.js';
28
+ import './index-Bj5sA_Ri.js';
29
+ import './ref-3xALOvo5.js';
30
+
31
+ var styles$7 = css `
32
+ :host {
33
+ width: 100%;
34
+ }
35
+
36
+ .details-container > wui-flex {
37
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
38
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
39
+ width: 100%;
40
+ }
41
+
42
+ .details-container > wui-flex > button {
43
+ border: none;
44
+ background: none;
45
+ padding: ${({ spacing }) => spacing['3']};
46
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
47
+ cursor: pointer;
48
+ }
49
+
50
+ .details-content-container {
51
+ padding: ${({ spacing }) => spacing['2']};
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: ${({ spacing }) => spacing['3']};
65
+ padding-left: ${({ spacing }) => spacing['3']};
66
+ padding-right: ${({ spacing }) => spacing['2']};
67
+ border-radius: calc(
68
+ ${({ borderRadius }) => borderRadius['1']} + ${({ borderRadius }) => borderRadius['1']}
69
+ );
70
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
71
+ }
72
+
73
+ .details-row-title {
74
+ white-space: nowrap;
75
+ }
76
+
77
+ .details-row.provider-free-row {
78
+ padding-right: ${({ spacing }) => spacing['2']};
79
+ }
80
+ `;
81
+
82
+ var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
83
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
84
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
85
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
86
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
87
+ };
88
+ const slippageRate = ConstantsUtil.CONVERT_SLIPPAGE_TOLERANCE;
89
+ let WuiSwapDetails = class WuiSwapDetails extends i {
90
+ constructor() {
91
+ super();
92
+ this.unsubscribe = [];
93
+ this.networkName = ChainController.state.activeCaipNetwork?.name;
94
+ this.detailsOpen = false;
95
+ this.sourceToken = SwapController.state.sourceToken;
96
+ this.toToken = SwapController.state.toToken;
97
+ this.toTokenAmount = SwapController.state.toTokenAmount;
98
+ this.sourceTokenPriceInUSD = SwapController.state.sourceTokenPriceInUSD;
99
+ this.toTokenPriceInUSD = SwapController.state.toTokenPriceInUSD;
100
+ this.priceImpact = SwapController.state.priceImpact;
101
+ this.maxSlippage = SwapController.state.maxSlippage;
102
+ this.networkTokenSymbol = SwapController.state.networkTokenSymbol;
103
+ this.inputError = SwapController.state.inputError;
104
+ this.unsubscribe.push(...[
105
+ SwapController.subscribe(newState => {
106
+ this.sourceToken = newState.sourceToken;
107
+ this.toToken = newState.toToken;
108
+ this.toTokenAmount = newState.toTokenAmount;
109
+ this.priceImpact = newState.priceImpact;
110
+ this.maxSlippage = newState.maxSlippage;
111
+ this.sourceTokenPriceInUSD = newState.sourceTokenPriceInUSD;
112
+ this.toTokenPriceInUSD = newState.toTokenPriceInUSD;
113
+ this.inputError = newState.inputError;
114
+ })
115
+ ]);
116
+ }
117
+ render() {
118
+ const minReceivedAmount = this.toTokenAmount && this.maxSlippage
119
+ ? NumberUtil.bigNumber(this.toTokenAmount).minus(this.maxSlippage).toString()
120
+ : null;
121
+ if (!this.sourceToken || !this.toToken || this.inputError) {
122
+ return null;
123
+ }
124
+ const toTokenSwappedAmount = this.sourceTokenPriceInUSD && this.toTokenPriceInUSD
125
+ ? (1 / this.toTokenPriceInUSD) * this.sourceTokenPriceInUSD
126
+ : 0;
127
+ return b `
128
+ <wui-flex flexDirection="column" alignItems="center" gap="01" class="details-container">
129
+ <wui-flex flexDirection="column">
130
+ <button @click=${this.toggleDetails.bind(this)}>
131
+ <wui-flex justifyContent="space-between" .padding=${['0', '2', '0', '2']}>
132
+ <wui-flex justifyContent="flex-start" flexGrow="1" gap="2">
133
+ <wui-text variant="sm-regular" color="primary">
134
+ 1 ${this.sourceToken.symbol} =
135
+ ${NumberUtil.formatNumberToLocalString(toTokenSwappedAmount, 3)}
136
+ ${this.toToken.symbol}
137
+ </wui-text>
138
+ <wui-text variant="sm-regular" color="secondary">
139
+ $${NumberUtil.formatNumberToLocalString(this.sourceTokenPriceInUSD)}
140
+ </wui-text>
141
+ </wui-flex>
142
+ <wui-icon name="chevronBottom"></wui-icon>
143
+ </wui-flex>
144
+ </button>
145
+ ${this.detailsOpen
146
+ ? b `
147
+ <wui-flex flexDirection="column" gap="2" class="details-content-container">
148
+ ${this.priceImpact
149
+ ? b ` <wui-flex flexDirection="column" gap="2">
150
+ <wui-flex
151
+ justifyContent="space-between"
152
+ alignItems="center"
153
+ class="details-row"
154
+ >
155
+ <wui-flex alignItems="center" gap="2">
156
+ <wui-text
157
+ class="details-row-title"
158
+ variant="sm-regular"
159
+ color="secondary"
160
+ >
161
+ Price impact
162
+ </wui-text>
163
+ <w3m-tooltip-trigger
164
+ text="Price impact reflects the change in market price due to your trade"
165
+ >
166
+ <wui-icon size="sm" color="default" name="info"></wui-icon>
167
+ </w3m-tooltip-trigger>
168
+ </wui-flex>
169
+ <wui-flex>
170
+ <wui-text variant="sm-regular" color="secondary">
171
+ ${NumberUtil.formatNumberToLocalString(this.priceImpact, 3)}%
172
+ </wui-text>
173
+ </wui-flex>
174
+ </wui-flex>
175
+ </wui-flex>`
176
+ : null}
177
+ ${this.maxSlippage && this.sourceToken.symbol
178
+ ? b `<wui-flex flexDirection="column" gap="2">
179
+ <wui-flex
180
+ justifyContent="space-between"
181
+ alignItems="center"
182
+ class="details-row"
183
+ >
184
+ <wui-flex alignItems="center" gap="2">
185
+ <wui-text
186
+ class="details-row-title"
187
+ variant="sm-regular"
188
+ color="secondary"
189
+ >
190
+ Max. slippage
191
+ </wui-text>
192
+ <w3m-tooltip-trigger
193
+ text=${`Max slippage sets the minimum amount you must receive for the transaction to proceed. ${minReceivedAmount
194
+ ? `Transaction will be reversed if you receive less than ${NumberUtil.formatNumberToLocalString(minReceivedAmount, 6)} ${this.toToken.symbol} due to price changes.`
195
+ : ''}`}
196
+ >
197
+ <wui-icon size="sm" color="default" name="info"></wui-icon>
198
+ </w3m-tooltip-trigger>
199
+ </wui-flex>
200
+ <wui-flex>
201
+ <wui-text variant="sm-regular" color="secondary">
202
+ ${NumberUtil.formatNumberToLocalString(this.maxSlippage, 6)}
203
+ ${this.toToken.symbol} ${slippageRate}%
204
+ </wui-text>
205
+ </wui-flex>
206
+ </wui-flex>
207
+ </wui-flex>`
208
+ : null}
209
+ <wui-flex flexDirection="column" gap="2">
210
+ <wui-flex
211
+ justifyContent="space-between"
212
+ alignItems="center"
213
+ class="details-row provider-free-row"
214
+ >
215
+ <wui-flex alignItems="center" gap="2">
216
+ <wui-text class="details-row-title" variant="sm-regular" color="secondary">
217
+ Provider fee
218
+ </wui-text>
219
+ </wui-flex>
220
+ <wui-flex>
221
+ <wui-text variant="sm-regular" color="secondary">0.85%</wui-text>
222
+ </wui-flex>
223
+ </wui-flex>
224
+ </wui-flex>
225
+ </wui-flex>
226
+ `
227
+ : null}
228
+ </wui-flex>
229
+ </wui-flex>
230
+ `;
231
+ }
232
+ toggleDetails() {
233
+ this.detailsOpen = !this.detailsOpen;
234
+ }
235
+ };
236
+ WuiSwapDetails.styles = [styles$7];
237
+ __decorate$7([
238
+ r()
239
+ ], WuiSwapDetails.prototype, "networkName", void 0);
240
+ __decorate$7([
241
+ n()
242
+ ], WuiSwapDetails.prototype, "detailsOpen", void 0);
243
+ __decorate$7([
244
+ r()
245
+ ], WuiSwapDetails.prototype, "sourceToken", void 0);
246
+ __decorate$7([
247
+ r()
248
+ ], WuiSwapDetails.prototype, "toToken", void 0);
249
+ __decorate$7([
250
+ r()
251
+ ], WuiSwapDetails.prototype, "toTokenAmount", void 0);
252
+ __decorate$7([
253
+ r()
254
+ ], WuiSwapDetails.prototype, "sourceTokenPriceInUSD", void 0);
255
+ __decorate$7([
256
+ r()
257
+ ], WuiSwapDetails.prototype, "toTokenPriceInUSD", void 0);
258
+ __decorate$7([
259
+ r()
260
+ ], WuiSwapDetails.prototype, "priceImpact", void 0);
261
+ __decorate$7([
262
+ r()
263
+ ], WuiSwapDetails.prototype, "maxSlippage", void 0);
264
+ __decorate$7([
265
+ r()
266
+ ], WuiSwapDetails.prototype, "networkTokenSymbol", void 0);
267
+ __decorate$7([
268
+ r()
269
+ ], WuiSwapDetails.prototype, "inputError", void 0);
270
+ WuiSwapDetails = __decorate$7([
271
+ customElement('w3m-swap-details')
272
+ ], WuiSwapDetails);
273
+
274
+ var styles$6 = css `
275
+ :host {
276
+ width: 100%;
277
+ }
278
+
279
+ :host > wui-flex {
280
+ display: flex;
281
+ flex-direction: row;
282
+ justify-content: space-between;
283
+ align-items: center;
284
+ border-radius: ${({ borderRadius }) => borderRadius['5']};
285
+ padding: ${({ spacing }) => spacing['5']};
286
+ padding-right: ${({ spacing }) => spacing['3']};
287
+ background-color: ${({ tokens }) => tokens.theme.foregroundPrimary};
288
+ box-shadow: inset 0px 0px 0px 1px ${({ tokens }) => tokens.theme.foregroundPrimary};
289
+ width: 100%;
290
+ height: 100px;
291
+ box-sizing: border-box;
292
+ position: relative;
293
+ }
294
+
295
+ wui-shimmer.market-value {
296
+ opacity: 0;
297
+ }
298
+
299
+ :host > wui-flex > svg.input_mask {
300
+ position: absolute;
301
+ inset: 0;
302
+ z-index: 5;
303
+ }
304
+
305
+ :host wui-flex .input_mask__border,
306
+ :host wui-flex .input_mask__background {
307
+ transition: fill ${({ durations }) => durations['md']}
308
+ ${({ easings }) => easings['ease-out-power-1']};
309
+ will-change: fill;
310
+ }
311
+
312
+ :host wui-flex .input_mask__border {
313
+ fill: ${({ tokens }) => tokens.core.glass010};
314
+ }
315
+
316
+ :host wui-flex .input_mask__background {
317
+ fill: ${({ tokens }) => tokens.theme.foregroundPrimary};
318
+ }
319
+ `;
320
+
321
+ var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
322
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
323
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
324
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
325
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
326
+ };
327
+ let W3mSwapInputSkeleton = class W3mSwapInputSkeleton extends i {
328
+ constructor() {
329
+ super(...arguments);
330
+ this.target = 'sourceToken';
331
+ }
332
+ render() {
333
+ return b `
334
+ <wui-flex class justifyContent="space-between">
335
+ <wui-flex
336
+ flex="1"
337
+ flexDirection="column"
338
+ alignItems="flex-start"
339
+ justifyContent="center"
340
+ class="swap-input"
341
+ gap="1"
342
+ >
343
+ <wui-shimmer width="80px" height="40px" rounded variant="light"></wui-shimmer>
344
+ </wui-flex>
345
+ ${this.templateTokenSelectButton()}
346
+ </wui-flex>
347
+ `;
348
+ }
349
+ templateTokenSelectButton() {
350
+ return b `
351
+ <wui-flex
352
+ class="swap-token-button"
353
+ flexDirection="column"
354
+ alignItems="flex-end"
355
+ justifyContent="center"
356
+ gap="1"
357
+ >
358
+ <wui-shimmer width="80px" height="40px" rounded variant="light"></wui-shimmer>
359
+ </wui-flex>
360
+ `;
361
+ }
362
+ };
363
+ W3mSwapInputSkeleton.styles = [styles$6];
364
+ __decorate$6([
365
+ n()
366
+ ], W3mSwapInputSkeleton.prototype, "target", void 0);
367
+ W3mSwapInputSkeleton = __decorate$6([
368
+ customElement('w3m-swap-input-skeleton')
369
+ ], W3mSwapInputSkeleton);
370
+
371
+ var styles$5 = css `
372
+ :host > wui-flex {
373
+ display: flex;
374
+ flex-direction: row;
375
+ justify-content: space-between;
376
+ align-items: center;
377
+ border-radius: ${({ borderRadius }) => borderRadius['5']};
378
+ background-color: ${({ tokens }) => tokens.theme.foregroundPrimary};
379
+ padding: ${({ spacing }) => spacing['5']};
380
+ padding-right: ${({ spacing }) => spacing['3']};
381
+ width: 100%;
382
+ height: 100px;
383
+ box-sizing: border-box;
384
+ box-shadow: inset 0px 0px 0px 1px ${({ tokens }) => tokens.theme.foregroundPrimary};
385
+ position: relative;
386
+ transition: box-shadow ${({ easings }) => easings['ease-out-power-1']}
387
+ ${({ durations }) => durations['lg']};
388
+ will-change: background-color;
389
+ }
390
+
391
+ :host wui-flex.focus {
392
+ box-shadow: inset 0px 0px 0px 1px ${({ tokens }) => tokens.core.glass010};
393
+ }
394
+
395
+ :host > wui-flex .swap-input,
396
+ :host > wui-flex .swap-token-button {
397
+ z-index: 10;
398
+ }
399
+
400
+ :host > wui-flex .swap-input {
401
+ -webkit-mask-image: linear-gradient(
402
+ 270deg,
403
+ transparent 0px,
404
+ transparent 8px,
405
+ black 24px,
406
+ black 25px,
407
+ black 32px,
408
+ black 100%
409
+ );
410
+ mask-image: linear-gradient(
411
+ 270deg,
412
+ transparent 0px,
413
+ transparent 8px,
414
+ black 24px,
415
+ black 25px,
416
+ black 32px,
417
+ black 100%
418
+ );
419
+ }
420
+
421
+ :host > wui-flex .swap-input input {
422
+ background: none;
423
+ border: none;
424
+ height: 42px;
425
+ width: 100%;
426
+ font-size: 32px;
427
+ font-style: normal;
428
+ font-weight: 400;
429
+ line-height: 130%;
430
+ letter-spacing: -1.28px;
431
+ outline: none;
432
+ caret-color: ${({ tokens }) => tokens.core.textAccentPrimary};
433
+ color: ${({ tokens }) => tokens.theme.textPrimary};
434
+ padding: 0px;
435
+ }
436
+
437
+ :host > wui-flex .swap-input input:focus-visible {
438
+ outline: none;
439
+ }
440
+
441
+ :host > wui-flex .swap-input input::-webkit-outer-spin-button,
442
+ :host > wui-flex .swap-input input::-webkit-inner-spin-button {
443
+ -webkit-appearance: none;
444
+ margin: 0;
445
+ }
446
+
447
+ .max-value-button {
448
+ background-color: transparent;
449
+ border: none;
450
+ cursor: pointer;
451
+ color: ${({ tokens }) => tokens.core.glass010};
452
+ padding-left: 0px;
453
+ }
454
+
455
+ .market-value {
456
+ min-height: 18px;
457
+ }
458
+ `;
459
+
460
+ var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
461
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
462
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
463
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
464
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
465
+ };
466
+ const MINIMUM_USD_VALUE_TO_CONVERT = 0.00005;
467
+ let W3mSwapInput = class W3mSwapInput extends i {
468
+ constructor() {
469
+ super(...arguments);
470
+ this.focused = false;
471
+ this.price = 0;
472
+ this.target = 'sourceToken';
473
+ this.onSetAmount = null;
474
+ this.onSetMaxValue = null;
475
+ }
476
+ render() {
477
+ const marketValue = this.marketValue || '0';
478
+ const isMarketValueGreaterThanZero = NumberUtil.bigNumber(marketValue).gt('0');
479
+ return b `
480
+ <wui-flex
481
+ class="${this.focused ? 'focus' : ''}"
482
+ justifyContent="space-between"
483
+ alignItems="center"
484
+ >
485
+ <wui-flex
486
+ flex="1"
487
+ flexDirection="column"
488
+ alignItems="flex-start"
489
+ justifyContent="center"
490
+ class="swap-input"
491
+ >
492
+ <input
493
+ data-testid="swap-input-${this.target}"
494
+ @focusin=${() => this.onFocusChange(true)}
495
+ @focusout=${() => this.onFocusChange(false)}
496
+ ?disabled=${this.disabled}
497
+ value=${this.value || ''}
498
+ @input=${this.dispatchInputChangeEvent}
499
+ @keydown=${this.handleKeydown}
500
+ placeholder="0"
501
+ type="text"
502
+ inputmode="decimal"
503
+ pattern="[0-9,.]*"
504
+ />
505
+ <wui-text class="market-value" variant="sm-regular" color="secondary">
506
+ ${isMarketValueGreaterThanZero
507
+ ? `$${NumberUtil.formatNumberToLocalString(this.marketValue, 2)}`
508
+ : null}
509
+ </wui-text>
510
+ </wui-flex>
511
+ ${this.templateTokenSelectButton()}
512
+ </wui-flex>
513
+ `;
514
+ }
515
+ handleKeydown(event) {
516
+ return InputUtil.numericInputKeyDown(event, this.value, (value) => this.onSetAmount?.(this.target, value));
517
+ }
518
+ dispatchInputChangeEvent(event) {
519
+ if (!this.onSetAmount) {
520
+ return;
521
+ }
522
+ const value = event.target.value.replace(/[^0-9.]/gu, '');
523
+ if (value === ',' || value === '.') {
524
+ this.onSetAmount(this.target, '0.');
525
+ }
526
+ else if (value.endsWith(',')) {
527
+ this.onSetAmount(this.target, value.replace(',', '.'));
528
+ }
529
+ else {
530
+ this.onSetAmount(this.target, value);
531
+ }
532
+ }
533
+ setMaxValueToInput() {
534
+ this.onSetMaxValue?.(this.target, this.balance);
535
+ }
536
+ templateTokenSelectButton() {
537
+ if (!this.token) {
538
+ return b ` <wui-button
539
+ data-testid="swap-select-token-button-${this.target}"
540
+ class="swap-token-button"
541
+ size="md"
542
+ variant="neutral-secondary"
543
+ @click=${this.onSelectToken.bind(this)}
544
+ >
545
+ Select token
546
+ </wui-button>`;
547
+ }
548
+ return b `
549
+ <wui-flex
550
+ class="swap-token-button"
551
+ flexDirection="column"
552
+ alignItems="flex-end"
553
+ justifyContent="center"
554
+ gap="1"
555
+ >
556
+ <wui-token-button
557
+ data-testid="swap-input-token-${this.target}"
558
+ text=${this.token.symbol}
559
+ imageSrc=${this.token.logoUri}
560
+ @click=${this.onSelectToken.bind(this)}
561
+ >
562
+ </wui-token-button>
563
+ <wui-flex alignItems="center" gap="1"> ${this.tokenBalanceTemplate()} </wui-flex>
564
+ </wui-flex>
565
+ `;
566
+ }
567
+ tokenBalanceTemplate() {
568
+ const balanceValueInUSD = NumberUtil.multiply(this.balance, this.price);
569
+ const haveBalance = balanceValueInUSD
570
+ ? balanceValueInUSD?.gt(MINIMUM_USD_VALUE_TO_CONVERT)
571
+ : false;
572
+ return b `
573
+ ${haveBalance
574
+ ? b `<wui-text variant="sm-regular" color="secondary">
575
+ ${NumberUtil.formatNumberToLocalString(this.balance, 2)}
576
+ </wui-text>`
577
+ : null}
578
+ ${this.target === 'sourceToken' ? this.tokenActionButtonTemplate(haveBalance) : null}
579
+ `;
580
+ }
581
+ tokenActionButtonTemplate(haveBalance) {
582
+ if (haveBalance) {
583
+ return b ` <button class="max-value-button" @click=${this.setMaxValueToInput.bind(this)}>
584
+ <wui-text color="accent-primary" variant="sm-medium">Max</wui-text>
585
+ </button>`;
586
+ }
587
+ return b ` <button class="max-value-button" @click=${this.onBuyToken.bind(this)}>
588
+ <wui-text color="accent-primary" variant="sm-medium">Buy</wui-text>
589
+ </button>`;
590
+ }
591
+ onFocusChange(state) {
592
+ this.focused = state;
593
+ }
594
+ onSelectToken() {
595
+ EventsController.sendEvent({ type: 'track', event: 'CLICK_SELECT_TOKEN_TO_SWAP' });
596
+ RouterController.push('SwapSelectToken', {
597
+ target: this.target
598
+ });
599
+ }
600
+ onBuyToken() {
601
+ RouterController.push('OnRampProviders');
602
+ }
603
+ };
604
+ W3mSwapInput.styles = [styles$5];
605
+ __decorate$5([
606
+ n()
607
+ ], W3mSwapInput.prototype, "focused", void 0);
608
+ __decorate$5([
609
+ n()
610
+ ], W3mSwapInput.prototype, "balance", void 0);
611
+ __decorate$5([
612
+ n()
613
+ ], W3mSwapInput.prototype, "value", void 0);
614
+ __decorate$5([
615
+ n()
616
+ ], W3mSwapInput.prototype, "price", void 0);
617
+ __decorate$5([
618
+ n()
619
+ ], W3mSwapInput.prototype, "marketValue", void 0);
620
+ __decorate$5([
621
+ n()
622
+ ], W3mSwapInput.prototype, "disabled", void 0);
623
+ __decorate$5([
624
+ n()
625
+ ], W3mSwapInput.prototype, "target", void 0);
626
+ __decorate$5([
627
+ n()
628
+ ], W3mSwapInput.prototype, "token", void 0);
629
+ __decorate$5([
630
+ n()
631
+ ], W3mSwapInput.prototype, "onSetAmount", void 0);
632
+ __decorate$5([
633
+ n()
634
+ ], W3mSwapInput.prototype, "onSetMaxValue", void 0);
635
+ W3mSwapInput = __decorate$5([
636
+ customElement('w3m-swap-input')
637
+ ], W3mSwapInput);
638
+
639
+ var styles$4 = css `
640
+ :host > wui-flex:first-child {
641
+ overflow-y: auto;
642
+ overflow-x: hidden;
643
+ scrollbar-width: none;
644
+ }
645
+
646
+ :host > wui-flex:first-child::-webkit-scrollbar {
647
+ display: none;
648
+ }
649
+
650
+ wui-loading-hexagon {
651
+ position: absolute;
652
+ }
653
+
654
+ .action-button {
655
+ width: 100%;
656
+ border-radius: ${({ borderRadius }) => borderRadius['4']};
657
+ }
658
+
659
+ .action-button:disabled {
660
+ border-color: 1px solid ${({ tokens }) => tokens.core.glass010};
661
+ }
662
+
663
+ .swap-inputs-container {
664
+ position: relative;
665
+ }
666
+
667
+ wui-icon-box {
668
+ width: 32px;
669
+ height: 32px;
670
+ border-radius: ${({ borderRadius }) => borderRadius['10']} !important;
671
+ border: 4px solid ${({ tokens }) => tokens.theme.backgroundPrimary};
672
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
673
+ position: absolute;
674
+ top: 50%;
675
+ left: 50%;
676
+ transform: translate(-50%, -50%);
677
+ z-index: 3;
678
+ }
679
+
680
+ .replace-tokens-button-container {
681
+ display: flex;
682
+ justify-content: center;
683
+ align-items: center;
684
+ position: absolute;
685
+ top: 50%;
686
+ left: 50%;
687
+ transform: translate(-50%, -50%);
688
+ gap: ${({ spacing }) => spacing['2']};
689
+ border-radius: ${({ borderRadius }) => borderRadius['4']};
690
+ background-color: ${({ tokens }) => tokens.theme.backgroundPrimary};
691
+ padding: ${({ spacing }) => spacing['2']};
692
+ }
693
+
694
+ .details-container > wui-flex {
695
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
696
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
697
+ width: 100%;
698
+ }
699
+
700
+ .details-container > wui-flex > button {
701
+ border: none;
702
+ background: none;
703
+ padding: ${({ spacing }) => spacing['3']};
704
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
705
+ transition: background ${({ durations }) => durations['lg']}
706
+ ${({ easings }) => easings['ease-out-power-2']};
707
+ will-change: background;
708
+ }
709
+
710
+ .details-container > wui-flex > button:hover {
711
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
712
+ }
713
+
714
+ .details-content-container {
715
+ padding: ${({ spacing }) => spacing['2']};
716
+ display: flex;
717
+ align-items: center;
718
+ justify-content: center;
719
+ }
720
+
721
+ .details-content-container > wui-flex {
722
+ width: 100%;
723
+ }
724
+
725
+ .details-row {
726
+ width: 100%;
727
+ padding: ${({ spacing }) => spacing['3']} ${({ spacing }) => spacing['5']};
728
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
729
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
730
+ }
731
+ `;
732
+
733
+ var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
734
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
735
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
736
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
737
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
738
+ };
739
+ let W3mSwapView = class W3mSwapView extends i {
740
+ subscribe({ resetSwapState, initializeSwapState }) {
741
+ return () => {
742
+ ChainController.subscribeKey('activeCaipNetwork', newCaipNetwork => this.onCaipNetworkChange({
743
+ newCaipNetwork,
744
+ resetSwapState,
745
+ initializeSwapState
746
+ }));
747
+ ChainController.subscribeChainProp('accountState', val => {
748
+ this.onCaipAddressChange({
749
+ newCaipAddress: val?.caipAddress,
750
+ resetSwapState,
751
+ initializeSwapState
752
+ });
753
+ });
754
+ };
755
+ }
756
+ constructor() {
757
+ super();
758
+ this.unsubscribe = [];
759
+ this.initialParams = RouterController.state.data?.swap;
760
+ this.detailsOpen = false;
761
+ this.caipAddress = ChainController.getAccountData()?.caipAddress;
762
+ this.caipNetworkId = ChainController.state.activeCaipNetwork?.caipNetworkId;
763
+ this.initialized = SwapController.state.initialized;
764
+ this.loadingQuote = SwapController.state.loadingQuote;
765
+ this.loadingPrices = SwapController.state.loadingPrices;
766
+ this.loadingTransaction = SwapController.state.loadingTransaction;
767
+ this.sourceToken = SwapController.state.sourceToken;
768
+ this.sourceTokenAmount = SwapController.state.sourceTokenAmount;
769
+ this.sourceTokenPriceInUSD = SwapController.state.sourceTokenPriceInUSD;
770
+ this.toToken = SwapController.state.toToken;
771
+ this.toTokenAmount = SwapController.state.toTokenAmount;
772
+ this.toTokenPriceInUSD = SwapController.state.toTokenPriceInUSD;
773
+ this.inputError = SwapController.state.inputError;
774
+ this.fetchError = SwapController.state.fetchError;
775
+ this.lastTokenPriceUpdate = 0;
776
+ this.minTokenPriceUpdateInterval = 10_000;
777
+ this.visibilityChangeHandler = () => {
778
+ if (document?.hidden) {
779
+ clearInterval(this.interval);
780
+ this.interval = undefined;
781
+ }
782
+ else {
783
+ this.startTokenPriceInterval();
784
+ }
785
+ };
786
+ this.startTokenPriceInterval = () => {
787
+ if (this.interval &&
788
+ Date.now() - this.lastTokenPriceUpdate < this.minTokenPriceUpdateInterval) {
789
+ return;
790
+ }
791
+ if (this.lastTokenPriceUpdate &&
792
+ Date.now() - this.lastTokenPriceUpdate > this.minTokenPriceUpdateInterval) {
793
+ this.fetchTokensAndValues();
794
+ }
795
+ clearInterval(this.interval);
796
+ this.interval = setInterval(() => {
797
+ this.fetchTokensAndValues();
798
+ }, this.minTokenPriceUpdateInterval);
799
+ };
800
+ this.watchTokensAndValues = () => {
801
+ if (!this.sourceToken || !this.toToken) {
802
+ return;
803
+ }
804
+ this.subscribeToVisibilityChange();
805
+ this.startTokenPriceInterval();
806
+ };
807
+ this.onDebouncedGetSwapCalldata = CoreHelperUtil.debounce(async () => {
808
+ await SwapController.swapTokens();
809
+ }, 200);
810
+ this.subscribe({ resetSwapState: true, initializeSwapState: false })();
811
+ this.unsubscribe.push(...[
812
+ this.subscribe({ resetSwapState: false, initializeSwapState: true }),
813
+ ModalController.subscribeKey('open', isOpen => {
814
+ if (!isOpen) {
815
+ SwapController.resetState();
816
+ }
817
+ }),
818
+ RouterController.subscribeKey('view', newRoute => {
819
+ if (!newRoute.includes('Swap')) {
820
+ SwapController.resetValues();
821
+ }
822
+ }),
823
+ SwapController.subscribe(newState => {
824
+ this.initialized = newState.initialized;
825
+ this.loadingQuote = newState.loadingQuote;
826
+ this.loadingPrices = newState.loadingPrices;
827
+ this.loadingTransaction = newState.loadingTransaction;
828
+ this.sourceToken = newState.sourceToken;
829
+ this.sourceTokenAmount = newState.sourceTokenAmount;
830
+ this.sourceTokenPriceInUSD = newState.sourceTokenPriceInUSD;
831
+ this.toToken = newState.toToken;
832
+ this.toTokenAmount = newState.toTokenAmount;
833
+ this.toTokenPriceInUSD = newState.toTokenPriceInUSD;
834
+ this.inputError = newState.inputError;
835
+ this.fetchError = newState.fetchError;
836
+ if (newState.sourceToken && newState.toToken) {
837
+ this.watchTokensAndValues();
838
+ }
839
+ })
840
+ ]);
841
+ }
842
+ async firstUpdated() {
843
+ SwapController.initializeState();
844
+ this.watchTokensAndValues();
845
+ await this.handleSwapParameters();
846
+ }
847
+ disconnectedCallback() {
848
+ this.unsubscribe.forEach(unsubscribe => unsubscribe?.());
849
+ clearInterval(this.interval);
850
+ document?.removeEventListener('visibilitychange', this.visibilityChangeHandler);
851
+ }
852
+ render() {
853
+ return b `
854
+ <wui-flex flexDirection="column" .padding=${['0', '4', '4', '4']} gap="3">
855
+ ${this.initialized ? this.templateSwap() : this.templateLoading()}
856
+ </wui-flex>
857
+ `;
858
+ }
859
+ subscribeToVisibilityChange() {
860
+ document?.removeEventListener('visibilitychange', this.visibilityChangeHandler);
861
+ document?.addEventListener('visibilitychange', this.visibilityChangeHandler);
862
+ }
863
+ fetchTokensAndValues() {
864
+ SwapController.getNetworkTokenPrice();
865
+ SwapController.getMyTokensWithBalance();
866
+ SwapController.swapTokens();
867
+ this.lastTokenPriceUpdate = Date.now();
868
+ }
869
+ templateSwap() {
870
+ return b `
871
+ <wui-flex flexDirection="column" gap="3">
872
+ <wui-flex flexDirection="column" alignItems="center" gap="2" class="swap-inputs-container">
873
+ ${this.templateTokenInput('sourceToken', this.sourceToken)}
874
+ ${this.templateTokenInput('toToken', this.toToken)} ${this.templateReplaceTokensButton()}
875
+ </wui-flex>
876
+ ${this.templateDetails()} ${this.templateActionButton()}
877
+ </wui-flex>
878
+ `;
879
+ }
880
+ actionButtonLabel() {
881
+ const haveNoAmount = !this.sourceTokenAmount || this.sourceTokenAmount === '0';
882
+ if (this.fetchError) {
883
+ return 'Swap';
884
+ }
885
+ if (!this.sourceToken || !this.toToken) {
886
+ return 'Select token';
887
+ }
888
+ if (haveNoAmount) {
889
+ return 'Enter amount';
890
+ }
891
+ if (this.inputError) {
892
+ return this.inputError;
893
+ }
894
+ return 'Review swap';
895
+ }
896
+ templateReplaceTokensButton() {
897
+ return b `
898
+ <wui-flex class="replace-tokens-button-container">
899
+ <wui-icon-box
900
+ @click=${this.onSwitchTokens.bind(this)}
901
+ icon="recycleHorizontal"
902
+ size="md"
903
+ variant="default"
904
+ ></wui-icon-box>
905
+ </wui-flex>
906
+ `;
907
+ }
908
+ templateLoading() {
909
+ return b `
910
+ <wui-flex flexDirection="column" gap="4">
911
+ <wui-flex flexDirection="column" alignItems="center" gap="2" class="swap-inputs-container">
912
+ <w3m-swap-input-skeleton target="sourceToken"></w3m-swap-input-skeleton>
913
+ <w3m-swap-input-skeleton target="toToken"></w3m-swap-input-skeleton>
914
+ ${this.templateReplaceTokensButton()}
915
+ </wui-flex>
916
+ ${this.templateActionButton()}
917
+ </wui-flex>
918
+ `;
919
+ }
920
+ templateTokenInput(target, token) {
921
+ const myToken = SwapController.state.myTokensWithBalance?.find(ct => ct?.address === token?.address);
922
+ const amount = target === 'toToken' ? this.toTokenAmount : this.sourceTokenAmount;
923
+ const price = target === 'toToken' ? this.toTokenPriceInUSD : this.sourceTokenPriceInUSD;
924
+ const marketValue = NumberUtil.parseLocalStringToNumber(amount) * price;
925
+ return b `<w3m-swap-input
926
+ .value=${target === 'toToken' ? this.toTokenAmount : this.sourceTokenAmount}
927
+ .disabled=${target === 'toToken'}
928
+ .onSetAmount=${this.handleChangeAmount.bind(this)}
929
+ target=${target}
930
+ .token=${token}
931
+ .balance=${myToken?.quantity?.numeric}
932
+ .price=${myToken?.price}
933
+ .marketValue=${marketValue}
934
+ .onSetMaxValue=${this.onSetMaxValue.bind(this)}
935
+ ></w3m-swap-input>`;
936
+ }
937
+ onSetMaxValue(target, balance) {
938
+ const maxValue = NumberUtil.bigNumber(balance || '0');
939
+ this.handleChangeAmount(target, maxValue.gt(0) ? maxValue.toFixed(20) : '0');
940
+ }
941
+ templateDetails() {
942
+ if (!this.sourceToken || !this.toToken || this.inputError) {
943
+ return null;
944
+ }
945
+ return b `<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
946
+ }
947
+ handleChangeAmount(target, value) {
948
+ SwapController.clearError();
949
+ if (target === 'sourceToken') {
950
+ SwapController.setSourceTokenAmount(value);
951
+ }
952
+ else {
953
+ SwapController.setToTokenAmount(value);
954
+ }
955
+ this.onDebouncedGetSwapCalldata();
956
+ }
957
+ templateActionButton() {
958
+ const haveNoTokenSelected = !this.toToken || !this.sourceToken;
959
+ const haveNoAmount = !this.sourceTokenAmount || this.sourceTokenAmount === '0';
960
+ const loading = this.loadingQuote || this.loadingPrices || this.loadingTransaction;
961
+ const disabled = loading || haveNoTokenSelected || haveNoAmount || this.inputError;
962
+ return b ` <wui-flex gap="2">
963
+ <wui-button
964
+ data-testid="swap-action-button"
965
+ class="action-button"
966
+ fullWidth
967
+ size="lg"
968
+ borderRadius="xs"
969
+ variant="accent-primary"
970
+ ?loading=${Boolean(loading)}
971
+ ?disabled=${Boolean(disabled)}
972
+ @click=${this.onSwapPreview.bind(this)}
973
+ >
974
+ ${this.actionButtonLabel()}
975
+ </wui-button>
976
+ </wui-flex>`;
977
+ }
978
+ async onSwitchTokens() {
979
+ await SwapController.switchTokens();
980
+ }
981
+ async onSwapPreview() {
982
+ if (this.fetchError) {
983
+ await SwapController.swapTokens();
984
+ }
985
+ EventsController.sendEvent({
986
+ type: 'track',
987
+ event: 'INITIATE_SWAP',
988
+ properties: {
989
+ network: this.caipNetworkId || '',
990
+ swapFromToken: this.sourceToken?.symbol || '',
991
+ swapToToken: this.toToken?.symbol || '',
992
+ swapFromAmount: this.sourceTokenAmount || '',
993
+ swapToAmount: this.toTokenAmount || '',
994
+ isSmartAccount: getPreferredAccountType(ChainController.state.activeChain) ===
995
+ W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT
996
+ }
997
+ });
998
+ RouterController.push('SwapPreview');
999
+ }
1000
+ async handleSwapParameters() {
1001
+ if (!this.initialParams) {
1002
+ return;
1003
+ }
1004
+ if (!SwapController.state.initialized) {
1005
+ const waitForInitialization = new Promise(resolve => {
1006
+ const unsubscribe = SwapController.subscribeKey('initialized', initialized => {
1007
+ if (initialized) {
1008
+ unsubscribe?.();
1009
+ resolve();
1010
+ }
1011
+ });
1012
+ });
1013
+ await waitForInitialization;
1014
+ }
1015
+ await this.setSwapParameters(this.initialParams);
1016
+ }
1017
+ async setSwapParameters({ amount, fromToken, toToken }) {
1018
+ if (!SwapController.state.tokens || !SwapController.state.myTokensWithBalance) {
1019
+ const waitForTokens = new Promise(resolve => {
1020
+ const unsubscribe = SwapController.subscribeKey('myTokensWithBalance', tokens => {
1021
+ if (tokens && tokens.length > 0) {
1022
+ unsubscribe?.();
1023
+ resolve();
1024
+ }
1025
+ });
1026
+ setTimeout(() => {
1027
+ unsubscribe?.();
1028
+ resolve();
1029
+ }, 5000);
1030
+ });
1031
+ await waitForTokens;
1032
+ }
1033
+ const allTokens = [
1034
+ ...(SwapController.state.tokens || []),
1035
+ ...(SwapController.state.myTokensWithBalance || [])
1036
+ ];
1037
+ if (fromToken) {
1038
+ const token = allTokens.find(t => t.symbol.toLowerCase() === fromToken.toLowerCase());
1039
+ if (token) {
1040
+ SwapController.setSourceToken(token);
1041
+ }
1042
+ }
1043
+ if (toToken) {
1044
+ const token = allTokens.find(t => t.symbol.toLowerCase() === toToken.toLowerCase());
1045
+ if (token) {
1046
+ SwapController.setToToken(token);
1047
+ }
1048
+ }
1049
+ if (amount && !isNaN(Number(amount))) {
1050
+ SwapController.setSourceTokenAmount(amount);
1051
+ }
1052
+ }
1053
+ onCaipAddressChange({ newCaipAddress, resetSwapState, initializeSwapState }) {
1054
+ if (this.caipAddress !== newCaipAddress) {
1055
+ this.caipAddress = newCaipAddress;
1056
+ if (resetSwapState) {
1057
+ SwapController.resetState();
1058
+ }
1059
+ if (initializeSwapState) {
1060
+ SwapController.initializeState();
1061
+ }
1062
+ }
1063
+ }
1064
+ onCaipNetworkChange({ newCaipNetwork, resetSwapState, initializeSwapState }) {
1065
+ if (this.caipNetworkId !== newCaipNetwork?.caipNetworkId) {
1066
+ this.caipNetworkId = newCaipNetwork?.caipNetworkId;
1067
+ if (resetSwapState) {
1068
+ SwapController.resetState();
1069
+ }
1070
+ if (initializeSwapState) {
1071
+ SwapController.initializeState();
1072
+ }
1073
+ }
1074
+ }
1075
+ };
1076
+ W3mSwapView.styles = styles$4;
1077
+ __decorate$4([
1078
+ n({ type: Object })
1079
+ ], W3mSwapView.prototype, "initialParams", void 0);
1080
+ __decorate$4([
1081
+ r()
1082
+ ], W3mSwapView.prototype, "interval", void 0);
1083
+ __decorate$4([
1084
+ r()
1085
+ ], W3mSwapView.prototype, "detailsOpen", void 0);
1086
+ __decorate$4([
1087
+ r()
1088
+ ], W3mSwapView.prototype, "caipAddress", void 0);
1089
+ __decorate$4([
1090
+ r()
1091
+ ], W3mSwapView.prototype, "caipNetworkId", void 0);
1092
+ __decorate$4([
1093
+ r()
1094
+ ], W3mSwapView.prototype, "initialized", void 0);
1095
+ __decorate$4([
1096
+ r()
1097
+ ], W3mSwapView.prototype, "loadingQuote", void 0);
1098
+ __decorate$4([
1099
+ r()
1100
+ ], W3mSwapView.prototype, "loadingPrices", void 0);
1101
+ __decorate$4([
1102
+ r()
1103
+ ], W3mSwapView.prototype, "loadingTransaction", void 0);
1104
+ __decorate$4([
1105
+ r()
1106
+ ], W3mSwapView.prototype, "sourceToken", void 0);
1107
+ __decorate$4([
1108
+ r()
1109
+ ], W3mSwapView.prototype, "sourceTokenAmount", void 0);
1110
+ __decorate$4([
1111
+ r()
1112
+ ], W3mSwapView.prototype, "sourceTokenPriceInUSD", void 0);
1113
+ __decorate$4([
1114
+ r()
1115
+ ], W3mSwapView.prototype, "toToken", void 0);
1116
+ __decorate$4([
1117
+ r()
1118
+ ], W3mSwapView.prototype, "toTokenAmount", void 0);
1119
+ __decorate$4([
1120
+ r()
1121
+ ], W3mSwapView.prototype, "toTokenPriceInUSD", void 0);
1122
+ __decorate$4([
1123
+ r()
1124
+ ], W3mSwapView.prototype, "inputError", void 0);
1125
+ __decorate$4([
1126
+ r()
1127
+ ], W3mSwapView.prototype, "fetchError", void 0);
1128
+ __decorate$4([
1129
+ r()
1130
+ ], W3mSwapView.prototype, "lastTokenPriceUpdate", void 0);
1131
+ W3mSwapView = __decorate$4([
1132
+ customElement('w3m-swap-view')
1133
+ ], W3mSwapView);
1134
+
1135
+ var styles$3 = css `
1136
+ :host > wui-flex:first-child {
1137
+ overflow-y: auto;
1138
+ overflow-x: hidden;
1139
+ scrollbar-width: none;
1140
+ }
1141
+
1142
+ :host > wui-flex:first-child::-webkit-scrollbar {
1143
+ display: none;
1144
+ }
1145
+
1146
+ .preview-container,
1147
+ .details-container {
1148
+ width: 100%;
1149
+ }
1150
+
1151
+ .token-image {
1152
+ width: 24px;
1153
+ height: 24px;
1154
+ box-shadow: 0 0 0 2px ${({ tokens }) => tokens.core.glass010};
1155
+ border-radius: 12px;
1156
+ }
1157
+
1158
+ wui-loading-hexagon {
1159
+ position: absolute;
1160
+ }
1161
+
1162
+ .token-item {
1163
+ display: flex;
1164
+ align-items: center;
1165
+ justify-content: center;
1166
+ gap: ${({ spacing }) => spacing['2']};
1167
+ padding: ${({ spacing }) => spacing['2']};
1168
+ height: 40px;
1169
+ border: none;
1170
+ border-radius: 80px;
1171
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
1172
+ box-shadow: inset 0 0 0 1px ${({ tokens }) => tokens.theme.foregroundPrimary};
1173
+ cursor: pointer;
1174
+ transition: background ${({ durations }) => durations['lg']}
1175
+ ${({ easings }) => easings['ease-out-power-2']};
1176
+ will-change: background;
1177
+ }
1178
+
1179
+ .token-item:hover {
1180
+ background: ${({ tokens }) => tokens.core.glass010};
1181
+ }
1182
+
1183
+ .preview-token-details-container {
1184
+ width: 100%;
1185
+ }
1186
+
1187
+ .details-row {
1188
+ width: 100%;
1189
+ padding: ${({ spacing }) => spacing['3']} ${({ spacing }) => spacing['5']};
1190
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
1191
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
1192
+ }
1193
+
1194
+ .action-buttons-container {
1195
+ width: 100%;
1196
+ gap: ${({ spacing }) => spacing['2']};
1197
+ }
1198
+
1199
+ .action-buttons-container > button {
1200
+ display: flex;
1201
+ align-items: center;
1202
+ justify-content: center;
1203
+ background: transparent;
1204
+ height: 48px;
1205
+ border-radius: ${({ borderRadius }) => borderRadius['4']};
1206
+ border: none;
1207
+ box-shadow: inset 0 0 0 1px ${({ tokens }) => tokens.core.glass010};
1208
+ }
1209
+
1210
+ .action-buttons-container > button:disabled {
1211
+ opacity: 0.8;
1212
+ cursor: not-allowed;
1213
+ }
1214
+
1215
+ .action-button > wui-loading-spinner {
1216
+ display: inline-block;
1217
+ }
1218
+
1219
+ .cancel-button:hover,
1220
+ .action-button:hover {
1221
+ cursor: pointer;
1222
+ }
1223
+
1224
+ .action-buttons-container > wui-button.cancel-button {
1225
+ flex: 2;
1226
+ }
1227
+
1228
+ .action-buttons-container > wui-button.action-button {
1229
+ flex: 4;
1230
+ }
1231
+
1232
+ .action-buttons-container > button.action-button > wui-text {
1233
+ color: white;
1234
+ }
1235
+
1236
+ .details-container > wui-flex {
1237
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
1238
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
1239
+ width: 100%;
1240
+ }
1241
+
1242
+ .details-container > wui-flex > button {
1243
+ border: none;
1244
+ background: none;
1245
+ padding: ${({ spacing }) => spacing['3']};
1246
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
1247
+ transition: background ${({ durations }) => durations['lg']}
1248
+ ${({ easings }) => easings['ease-out-power-2']};
1249
+ will-change: background;
1250
+ }
1251
+
1252
+ .details-container > wui-flex > button:hover {
1253
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
1254
+ }
1255
+
1256
+ .details-content-container {
1257
+ padding: ${({ spacing }) => spacing['2']};
1258
+ display: flex;
1259
+ align-items: center;
1260
+ justify-content: center;
1261
+ }
1262
+
1263
+ .details-content-container > wui-flex {
1264
+ width: 100%;
1265
+ }
1266
+
1267
+ .details-row {
1268
+ width: 100%;
1269
+ padding: ${({ spacing }) => spacing['3']} ${({ spacing }) => spacing['5']};
1270
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
1271
+ background: ${({ tokens }) => tokens.theme.foregroundPrimary};
1272
+ }
1273
+ `;
1274
+
1275
+ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1276
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1277
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1278
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1279
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1280
+ };
1281
+ let W3mSwapPreviewView = class W3mSwapPreviewView extends i {
1282
+ constructor() {
1283
+ super();
1284
+ this.unsubscribe = [];
1285
+ this.detailsOpen = true;
1286
+ this.approvalTransaction = SwapController.state.approvalTransaction;
1287
+ this.swapTransaction = SwapController.state.swapTransaction;
1288
+ this.sourceToken = SwapController.state.sourceToken;
1289
+ this.sourceTokenAmount = SwapController.state.sourceTokenAmount ?? '';
1290
+ this.sourceTokenPriceInUSD = SwapController.state.sourceTokenPriceInUSD;
1291
+ this.balanceSymbol = ChainController.getAccountData()?.balanceSymbol;
1292
+ this.toToken = SwapController.state.toToken;
1293
+ this.toTokenAmount = SwapController.state.toTokenAmount ?? '';
1294
+ this.toTokenPriceInUSD = SwapController.state.toTokenPriceInUSD;
1295
+ this.caipNetwork = ChainController.state.activeCaipNetwork;
1296
+ this.inputError = SwapController.state.inputError;
1297
+ this.loadingQuote = SwapController.state.loadingQuote;
1298
+ this.loadingApprovalTransaction = SwapController.state.loadingApprovalTransaction;
1299
+ this.loadingBuildTransaction = SwapController.state.loadingBuildTransaction;
1300
+ this.loadingTransaction = SwapController.state.loadingTransaction;
1301
+ this.unsubscribe.push(...[
1302
+ ChainController.subscribeChainProp('accountState', val => {
1303
+ if (val?.balanceSymbol !== this.balanceSymbol) {
1304
+ RouterController.goBack();
1305
+ }
1306
+ }),
1307
+ ChainController.subscribeKey('activeCaipNetwork', newCaipNetwork => {
1308
+ if (this.caipNetwork !== newCaipNetwork) {
1309
+ this.caipNetwork = newCaipNetwork;
1310
+ }
1311
+ }),
1312
+ SwapController.subscribe(newState => {
1313
+ this.approvalTransaction = newState.approvalTransaction;
1314
+ this.swapTransaction = newState.swapTransaction;
1315
+ this.sourceToken = newState.sourceToken;
1316
+ this.toToken = newState.toToken;
1317
+ this.toTokenPriceInUSD = newState.toTokenPriceInUSD;
1318
+ this.sourceTokenAmount = newState.sourceTokenAmount ?? '';
1319
+ this.toTokenAmount = newState.toTokenAmount ?? '';
1320
+ this.inputError = newState.inputError;
1321
+ if (newState.inputError) {
1322
+ RouterController.goBack();
1323
+ }
1324
+ this.loadingQuote = newState.loadingQuote;
1325
+ this.loadingApprovalTransaction = newState.loadingApprovalTransaction;
1326
+ this.loadingBuildTransaction = newState.loadingBuildTransaction;
1327
+ this.loadingTransaction = newState.loadingTransaction;
1328
+ })
1329
+ ]);
1330
+ }
1331
+ firstUpdated() {
1332
+ SwapController.getTransaction();
1333
+ this.refreshTransaction();
1334
+ }
1335
+ disconnectedCallback() {
1336
+ this.unsubscribe.forEach(unsubscribe => unsubscribe?.());
1337
+ clearInterval(this.interval);
1338
+ }
1339
+ render() {
1340
+ return b `
1341
+ <wui-flex flexDirection="column" .padding=${['0', '4', '4', '4']} gap="3">
1342
+ ${this.templateSwap()}
1343
+ </wui-flex>
1344
+ `;
1345
+ }
1346
+ refreshTransaction() {
1347
+ this.interval = setInterval(() => {
1348
+ if (!SwapController.getApprovalLoadingState()) {
1349
+ SwapController.getTransaction();
1350
+ }
1351
+ }, 10_000);
1352
+ }
1353
+ templateSwap() {
1354
+ const sourceTokenText = `${NumberUtil.formatNumberToLocalString(parseFloat(this.sourceTokenAmount))} ${this.sourceToken?.symbol}`;
1355
+ const toTokenText = `${NumberUtil.formatNumberToLocalString(parseFloat(this.toTokenAmount))} ${this.toToken?.symbol}`;
1356
+ const sourceTokenValue = parseFloat(this.sourceTokenAmount) * this.sourceTokenPriceInUSD;
1357
+ const toTokenValue = parseFloat(this.toTokenAmount) * this.toTokenPriceInUSD;
1358
+ const sentPrice = NumberUtil.formatNumberToLocalString(sourceTokenValue);
1359
+ const receivePrice = NumberUtil.formatNumberToLocalString(toTokenValue);
1360
+ const loading = this.loadingQuote ||
1361
+ this.loadingBuildTransaction ||
1362
+ this.loadingTransaction ||
1363
+ this.loadingApprovalTransaction;
1364
+ return b `
1365
+ <wui-flex flexDirection="column" alignItems="center" gap="4">
1366
+ <wui-flex class="preview-container" flexDirection="column" alignItems="flex-start" gap="4">
1367
+ <wui-flex
1368
+ class="preview-token-details-container"
1369
+ alignItems="center"
1370
+ justifyContent="space-between"
1371
+ gap="4"
1372
+ >
1373
+ <wui-flex flexDirection="column" alignItems="flex-start" gap="01">
1374
+ <wui-text variant="sm-regular" color="secondary">Send</wui-text>
1375
+ <wui-text variant="md-regular" color="primary">$${sentPrice}</wui-text>
1376
+ </wui-flex>
1377
+ <wui-token-button
1378
+ flexDirection="row-reverse"
1379
+ text=${sourceTokenText}
1380
+ imageSrc=${this.sourceToken?.logoUri}
1381
+ >
1382
+ </wui-token-button>
1383
+ </wui-flex>
1384
+ <wui-icon name="recycleHorizontal" color="default" size="md"></wui-icon>
1385
+ <wui-flex
1386
+ class="preview-token-details-container"
1387
+ alignItems="center"
1388
+ justifyContent="space-between"
1389
+ gap="4"
1390
+ >
1391
+ <wui-flex flexDirection="column" alignItems="flex-start" gap="01">
1392
+ <wui-text variant="sm-regular" color="secondary">Receive</wui-text>
1393
+ <wui-text variant="md-regular" color="primary">$${receivePrice}</wui-text>
1394
+ </wui-flex>
1395
+ <wui-token-button
1396
+ flexDirection="row-reverse"
1397
+ text=${toTokenText}
1398
+ imageSrc=${this.toToken?.logoUri}
1399
+ >
1400
+ </wui-token-button>
1401
+ </wui-flex>
1402
+ </wui-flex>
1403
+
1404
+ ${this.templateDetails()}
1405
+
1406
+ <wui-flex flexDirection="row" alignItems="center" justifyContent="center" gap="2">
1407
+ <wui-icon size="sm" color="default" name="info"></wui-icon>
1408
+ <wui-text variant="sm-regular" color="secondary">Review transaction carefully</wui-text>
1409
+ </wui-flex>
1410
+
1411
+ <wui-flex
1412
+ class="action-buttons-container"
1413
+ flexDirection="row"
1414
+ alignItems="center"
1415
+ justifyContent="space-between"
1416
+ gap="2"
1417
+ >
1418
+ <wui-button
1419
+ class="cancel-button"
1420
+ fullWidth
1421
+ size="lg"
1422
+ borderRadius="xs"
1423
+ variant="neutral-secondary"
1424
+ @click=${this.onCancelTransaction.bind(this)}
1425
+ >
1426
+ <wui-text variant="md-medium" color="secondary">Cancel</wui-text>
1427
+ </wui-button>
1428
+ <wui-button
1429
+ class="action-button"
1430
+ fullWidth
1431
+ size="lg"
1432
+ borderRadius="xs"
1433
+ variant="accent-primary"
1434
+ ?loading=${loading}
1435
+ ?disabled=${loading}
1436
+ @click=${this.onSendTransaction.bind(this)}
1437
+ >
1438
+ <wui-text variant="md-medium" color="invert"> ${this.actionButtonLabel()} </wui-text>
1439
+ </wui-button>
1440
+ </wui-flex>
1441
+ </wui-flex>
1442
+ `;
1443
+ }
1444
+ templateDetails() {
1445
+ if (!this.sourceToken || !this.toToken || this.inputError) {
1446
+ return null;
1447
+ }
1448
+ return b `<w3m-swap-details .detailsOpen=${this.detailsOpen}></w3m-swap-details>`;
1449
+ }
1450
+ actionButtonLabel() {
1451
+ if (this.loadingApprovalTransaction) {
1452
+ return 'Approving...';
1453
+ }
1454
+ if (this.approvalTransaction) {
1455
+ return 'Approve';
1456
+ }
1457
+ return 'Swap';
1458
+ }
1459
+ onCancelTransaction() {
1460
+ RouterController.goBack();
1461
+ }
1462
+ onSendTransaction() {
1463
+ if (this.approvalTransaction) {
1464
+ SwapController.sendTransactionForApproval(this.approvalTransaction);
1465
+ }
1466
+ else {
1467
+ SwapController.sendTransactionForSwap(this.swapTransaction);
1468
+ }
1469
+ }
1470
+ };
1471
+ W3mSwapPreviewView.styles = styles$3;
1472
+ __decorate$3([
1473
+ r()
1474
+ ], W3mSwapPreviewView.prototype, "interval", void 0);
1475
+ __decorate$3([
1476
+ r()
1477
+ ], W3mSwapPreviewView.prototype, "detailsOpen", void 0);
1478
+ __decorate$3([
1479
+ r()
1480
+ ], W3mSwapPreviewView.prototype, "approvalTransaction", void 0);
1481
+ __decorate$3([
1482
+ r()
1483
+ ], W3mSwapPreviewView.prototype, "swapTransaction", void 0);
1484
+ __decorate$3([
1485
+ r()
1486
+ ], W3mSwapPreviewView.prototype, "sourceToken", void 0);
1487
+ __decorate$3([
1488
+ r()
1489
+ ], W3mSwapPreviewView.prototype, "sourceTokenAmount", void 0);
1490
+ __decorate$3([
1491
+ r()
1492
+ ], W3mSwapPreviewView.prototype, "sourceTokenPriceInUSD", void 0);
1493
+ __decorate$3([
1494
+ r()
1495
+ ], W3mSwapPreviewView.prototype, "balanceSymbol", void 0);
1496
+ __decorate$3([
1497
+ r()
1498
+ ], W3mSwapPreviewView.prototype, "toToken", void 0);
1499
+ __decorate$3([
1500
+ r()
1501
+ ], W3mSwapPreviewView.prototype, "toTokenAmount", void 0);
1502
+ __decorate$3([
1503
+ r()
1504
+ ], W3mSwapPreviewView.prototype, "toTokenPriceInUSD", void 0);
1505
+ __decorate$3([
1506
+ r()
1507
+ ], W3mSwapPreviewView.prototype, "caipNetwork", void 0);
1508
+ __decorate$3([
1509
+ r()
1510
+ ], W3mSwapPreviewView.prototype, "inputError", void 0);
1511
+ __decorate$3([
1512
+ r()
1513
+ ], W3mSwapPreviewView.prototype, "loadingQuote", void 0);
1514
+ __decorate$3([
1515
+ r()
1516
+ ], W3mSwapPreviewView.prototype, "loadingApprovalTransaction", void 0);
1517
+ __decorate$3([
1518
+ r()
1519
+ ], W3mSwapPreviewView.prototype, "loadingBuildTransaction", void 0);
1520
+ __decorate$3([
1521
+ r()
1522
+ ], W3mSwapPreviewView.prototype, "loadingTransaction", void 0);
1523
+ W3mSwapPreviewView = __decorate$3([
1524
+ customElement('w3m-swap-preview-view')
1525
+ ], W3mSwapPreviewView);
1526
+
1527
+ var styles$2 = css `
1528
+ :host {
1529
+ width: 100%;
1530
+ height: 60px;
1531
+ min-height: 60px;
1532
+ }
1533
+
1534
+ :host > wui-flex {
1535
+ cursor: pointer;
1536
+ height: 100%;
1537
+ display: flex;
1538
+ column-gap: ${({ spacing }) => spacing['3']};
1539
+ padding: ${({ spacing }) => spacing['2']};
1540
+ padding-right: ${({ spacing }) => spacing['4']};
1541
+ width: 100%;
1542
+ background-color: transparent;
1543
+ border-radius: ${({ borderRadius }) => borderRadius['4']};
1544
+ color: ${({ tokens }) => tokens.theme.foregroundSecondary};
1545
+ transition:
1546
+ background-color ${({ durations }) => durations['lg']}
1547
+ ${({ easings }) => easings['ease-out-power-2']},
1548
+ opacity ${({ durations }) => durations['lg']} ${({ easings }) => easings['ease-out-power-2']};
1549
+ will-change: background-color, opacity;
1550
+ }
1551
+
1552
+ @media (hover: hover) and (pointer: fine) {
1553
+ :host > wui-flex:hover {
1554
+ background-color: ${({ tokens }) => tokens.theme.foregroundPrimary};
1555
+ }
1556
+
1557
+ :host > wui-flex:active {
1558
+ background-color: ${({ tokens }) => tokens.core.glass010};
1559
+ }
1560
+ }
1561
+
1562
+ :host([disabled]) > wui-flex {
1563
+ opacity: 0.6;
1564
+ }
1565
+
1566
+ :host([disabled]) > wui-flex:hover {
1567
+ background-color: transparent;
1568
+ }
1569
+
1570
+ :host > wui-flex > wui-flex {
1571
+ flex: 1;
1572
+ }
1573
+
1574
+ :host > wui-flex > wui-image,
1575
+ :host > wui-flex > .token-item-image-placeholder {
1576
+ width: 40px;
1577
+ max-width: 40px;
1578
+ height: 40px;
1579
+ border-radius: ${({ borderRadius }) => borderRadius['20']};
1580
+ position: relative;
1581
+ }
1582
+
1583
+ :host > wui-flex > .token-item-image-placeholder {
1584
+ display: flex;
1585
+ align-items: center;
1586
+ justify-content: center;
1587
+ }
1588
+
1589
+ :host > wui-flex > wui-image::after,
1590
+ :host > wui-flex > .token-item-image-placeholder::after {
1591
+ position: absolute;
1592
+ content: '';
1593
+ inset: 0;
1594
+ box-shadow: inset 0 0 0 1px ${({ tokens }) => tokens.core.glass010};
1595
+ border-radius: ${({ borderRadius }) => borderRadius['8']};
1596
+ }
1597
+
1598
+ button > wui-icon-box[data-variant='square-blue'] {
1599
+ border-radius: ${({ borderRadius }) => borderRadius['2']};
1600
+ position: relative;
1601
+ border: none;
1602
+ width: 36px;
1603
+ height: 36px;
1604
+ }
1605
+ `;
1606
+
1607
+ var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1608
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1609
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1610
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1611
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1612
+ };
1613
+ let WuiTokenListItem = class WuiTokenListItem extends i {
1614
+ constructor() {
1615
+ super();
1616
+ this.observer = new IntersectionObserver(() => undefined);
1617
+ this.imageSrc = undefined;
1618
+ this.name = undefined;
1619
+ this.symbol = undefined;
1620
+ this.price = undefined;
1621
+ this.amount = undefined;
1622
+ this.visible = false;
1623
+ this.imageError = false;
1624
+ this.observer = new IntersectionObserver(entries => {
1625
+ entries.forEach(entry => {
1626
+ if (entry.isIntersecting) {
1627
+ this.visible = true;
1628
+ }
1629
+ else {
1630
+ this.visible = false;
1631
+ }
1632
+ });
1633
+ }, { threshold: 0.1 });
1634
+ }
1635
+ firstUpdated() {
1636
+ this.observer.observe(this);
1637
+ }
1638
+ disconnectedCallback() {
1639
+ this.observer.disconnect();
1640
+ }
1641
+ render() {
1642
+ if (!this.visible) {
1643
+ return null;
1644
+ }
1645
+ const value = this.amount && this.price ? NumberUtil.multiply(this.price, this.amount)?.toFixed(3) : null;
1646
+ return b `
1647
+ <wui-flex alignItems="center">
1648
+ ${this.visualTemplate()}
1649
+ <wui-flex flexDirection="column" gap="1">
1650
+ <wui-flex justifyContent="space-between">
1651
+ <wui-text variant="md-medium" color="primary" lineClamp="1">${this.name}</wui-text>
1652
+ ${value
1653
+ ? b `
1654
+ <wui-text variant="md-medium" color="primary">
1655
+ $${NumberUtil.formatNumberToLocalString(value, 3)}
1656
+ </wui-text>
1657
+ `
1658
+ : null}
1659
+ </wui-flex>
1660
+ <wui-flex justifyContent="space-between">
1661
+ <wui-text variant="sm-regular" color="secondary" lineClamp="1">${this.symbol}</wui-text>
1662
+ ${this.amount
1663
+ ? b `<wui-text variant="sm-regular" color="secondary">
1664
+ ${NumberUtil.formatNumberToLocalString(this.amount, 5)}
1665
+ </wui-text>`
1666
+ : null}
1667
+ </wui-flex>
1668
+ </wui-flex>
1669
+ </wui-flex>
1670
+ `;
1671
+ }
1672
+ visualTemplate() {
1673
+ if (this.imageError) {
1674
+ return b `<wui-flex class="token-item-image-placeholder">
1675
+ <wui-icon name="image" color="inherit"></wui-icon>
1676
+ </wui-flex>`;
1677
+ }
1678
+ if (this.imageSrc) {
1679
+ return b `<wui-image
1680
+ width="40"
1681
+ height="40"
1682
+ src=${this.imageSrc}
1683
+ @onLoadError=${this.imageLoadError}
1684
+ ></wui-image>`;
1685
+ }
1686
+ return null;
1687
+ }
1688
+ imageLoadError() {
1689
+ this.imageError = true;
1690
+ }
1691
+ };
1692
+ WuiTokenListItem.styles = [resetStyles, elementStyles, styles$2];
1693
+ __decorate$2([
1694
+ n()
1695
+ ], WuiTokenListItem.prototype, "imageSrc", void 0);
1696
+ __decorate$2([
1697
+ n()
1698
+ ], WuiTokenListItem.prototype, "name", void 0);
1699
+ __decorate$2([
1700
+ n()
1701
+ ], WuiTokenListItem.prototype, "symbol", void 0);
1702
+ __decorate$2([
1703
+ n()
1704
+ ], WuiTokenListItem.prototype, "price", void 0);
1705
+ __decorate$2([
1706
+ n()
1707
+ ], WuiTokenListItem.prototype, "amount", void 0);
1708
+ __decorate$2([
1709
+ r()
1710
+ ], WuiTokenListItem.prototype, "visible", void 0);
1711
+ __decorate$2([
1712
+ r()
1713
+ ], WuiTokenListItem.prototype, "imageError", void 0);
1714
+ WuiTokenListItem = __decorate$2([
1715
+ customElement('wui-token-list-item')
1716
+ ], WuiTokenListItem);
1717
+
1718
+ var styles$1 = css `
1719
+ :host {
1720
+ width: 100%;
1721
+ }
1722
+
1723
+ :host > wui-flex {
1724
+ cursor: pointer;
1725
+ height: 100%;
1726
+ width: 100%;
1727
+ display: flex;
1728
+ column-gap: ${({ spacing }) => spacing['3']};
1729
+ padding: ${({ spacing }) => spacing['2']};
1730
+ padding-right: ${({ spacing }) => spacing['4']};
1731
+ }
1732
+
1733
+ wui-flex {
1734
+ display: flex;
1735
+ flex: 1;
1736
+ }
1737
+ `;
1738
+
1739
+ var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1740
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1741
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1742
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1743
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1744
+ };
1745
+ let WuiTokenListItemLoader = class WuiTokenListItemLoader extends i {
1746
+ render() {
1747
+ return b `
1748
+ <wui-flex alignItems="center">
1749
+ <wui-shimmer width="40px" height="40px"></wui-shimmer>
1750
+ <wui-flex flexDirection="column" gap="1">
1751
+ <wui-shimmer width="72px" height="16px" borderRadius="4xs"></wui-shimmer>
1752
+ <wui-shimmer width="148px" height="14px" borderRadius="4xs"></wui-shimmer>
1753
+ </wui-flex>
1754
+ <wui-flex flexDirection="column" gap="1" alignItems="flex-end">
1755
+ <wui-shimmer width="24px" height="12px" borderRadius="4xs"></wui-shimmer>
1756
+ <wui-shimmer width="32px" height="12px" borderRadius="4xs"></wui-shimmer>
1757
+ </wui-flex>
1758
+ </wui-flex>
1759
+ `;
1760
+ }
1761
+ };
1762
+ WuiTokenListItemLoader.styles = [resetStyles, styles$1];
1763
+ WuiTokenListItemLoader = __decorate$1([
1764
+ customElement('wui-token-list-item-loader')
1765
+ ], WuiTokenListItemLoader);
1766
+
1767
+ var styles = css `
1768
+ :host {
1769
+ --tokens-scroll--top-opacity: 0;
1770
+ --tokens-scroll--bottom-opacity: 1;
1771
+ --suggested-tokens-scroll--left-opacity: 0;
1772
+ --suggested-tokens-scroll--right-opacity: 1;
1773
+ }
1774
+
1775
+ :host > wui-flex:first-child {
1776
+ overflow-y: hidden;
1777
+ overflow-x: hidden;
1778
+ scrollbar-width: none;
1779
+ scrollbar-height: none;
1780
+ }
1781
+
1782
+ :host > wui-flex:first-child::-webkit-scrollbar {
1783
+ display: none;
1784
+ }
1785
+
1786
+ wui-loading-hexagon {
1787
+ position: absolute;
1788
+ }
1789
+
1790
+ .suggested-tokens-container {
1791
+ overflow-x: auto;
1792
+ mask-image: linear-gradient(
1793
+ to right,
1794
+ rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 0px,
1795
+ rgba(200, 200, 200, calc(1 - var(--suggested-tokens-scroll--left-opacity))) 1px,
1796
+ black 50px,
1797
+ black 90px,
1798
+ black calc(100% - 90px),
1799
+ black calc(100% - 50px),
1800
+ rgba(155, 155, 155, calc(1 - var(--suggested-tokens-scroll--right-opacity))) calc(100% - 1px),
1801
+ rgba(0, 0, 0, calc(1 - var(--suggested-tokens-scroll--right-opacity))) 100%
1802
+ );
1803
+ }
1804
+
1805
+ .suggested-tokens-container::-webkit-scrollbar {
1806
+ display: none;
1807
+ }
1808
+
1809
+ .tokens-container {
1810
+ border-top: 1px solid ${({ tokens }) => tokens.core.glass010};
1811
+ height: 100%;
1812
+ max-height: 390px;
1813
+ }
1814
+
1815
+ .tokens {
1816
+ width: 100%;
1817
+ overflow-y: auto;
1818
+ mask-image: linear-gradient(
1819
+ to bottom,
1820
+ rgba(0, 0, 0, calc(1 - var(--tokens-scroll--top-opacity))) 0px,
1821
+ rgba(200, 200, 200, calc(1 - var(--tokens-scroll--top-opacity))) 1px,
1822
+ black 50px,
1823
+ black 90px,
1824
+ black calc(100% - 90px),
1825
+ black calc(100% - 50px),
1826
+ rgba(155, 155, 155, calc(1 - var(--tokens-scroll--bottom-opacity))) calc(100% - 1px),
1827
+ rgba(0, 0, 0, calc(1 - var(--tokens-scroll--bottom-opacity))) 100%
1828
+ );
1829
+ }
1830
+
1831
+ .network-search-input,
1832
+ .select-network-button {
1833
+ height: 40px;
1834
+ }
1835
+
1836
+ .select-network-button {
1837
+ border: none;
1838
+ display: flex;
1839
+ flex-direction: row;
1840
+ align-items: center;
1841
+ justify-content: center;
1842
+ gap: ${({ spacing }) => spacing['2']};
1843
+ box-shadow: inset 0 0 0 1px ${({ tokens }) => tokens.core.glass010};
1844
+ background-color: transparent;
1845
+ border-radius: ${({ borderRadius }) => borderRadius['3']};
1846
+ padding: ${({ spacing }) => spacing['2']};
1847
+ align-items: center;
1848
+ transition: background-color ${({ durations }) => durations['lg']}
1849
+ ${({ easings }) => easings['ease-out-power-2']};
1850
+ will-change: background-color;
1851
+ }
1852
+
1853
+ .select-network-button:hover {
1854
+ background-color: ${({ tokens }) => tokens.theme.foregroundPrimary};
1855
+ }
1856
+
1857
+ .select-network-button > wui-image {
1858
+ width: 26px;
1859
+ height: 26px;
1860
+ border-radius: ${({ borderRadius }) => borderRadius['4']};
1861
+ box-shadow: inset 0 0 0 1px ${({ tokens }) => tokens.core.glass010};
1862
+ }
1863
+ `;
1864
+
1865
+ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1866
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1867
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1868
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1869
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1870
+ };
1871
+ let W3mSwapSelectTokenView = class W3mSwapSelectTokenView extends i {
1872
+ constructor() {
1873
+ super();
1874
+ this.unsubscribe = [];
1875
+ this.targetToken = RouterController.state.data?.target;
1876
+ this.sourceToken = SwapController.state.sourceToken;
1877
+ this.sourceTokenAmount = SwapController.state.sourceTokenAmount;
1878
+ this.toToken = SwapController.state.toToken;
1879
+ this.myTokensWithBalance = SwapController.state.myTokensWithBalance;
1880
+ this.popularTokens = SwapController.state.popularTokens;
1881
+ this.suggestedTokens = SwapController.state.suggestedTokens;
1882
+ this.tokensLoading = SwapController.state.tokensLoading;
1883
+ this.searchValue = '';
1884
+ this.unsubscribe.push(SwapController.subscribe(newState => {
1885
+ this.sourceToken = newState.sourceToken;
1886
+ this.toToken = newState.toToken;
1887
+ this.myTokensWithBalance = newState.myTokensWithBalance;
1888
+ this.popularTokens = newState.popularTokens;
1889
+ this.suggestedTokens = newState.suggestedTokens;
1890
+ this.tokensLoading = newState.tokensLoading;
1891
+ }));
1892
+ }
1893
+ async firstUpdated() {
1894
+ await SwapController.getTokenList();
1895
+ }
1896
+ updated() {
1897
+ const suggestedTokensContainer = this.renderRoot?.querySelector('.suggested-tokens-container');
1898
+ suggestedTokensContainer?.addEventListener('scroll', this.handleSuggestedTokensScroll.bind(this));
1899
+ const tokensList = this.renderRoot?.querySelector('.tokens');
1900
+ tokensList?.addEventListener('scroll', this.handleTokenListScroll.bind(this));
1901
+ }
1902
+ disconnectedCallback() {
1903
+ super.disconnectedCallback();
1904
+ const suggestedTokensContainer = this.renderRoot?.querySelector('.suggested-tokens-container');
1905
+ const tokensList = this.renderRoot?.querySelector('.tokens');
1906
+ suggestedTokensContainer?.removeEventListener('scroll', this.handleSuggestedTokensScroll.bind(this));
1907
+ tokensList?.removeEventListener('scroll', this.handleTokenListScroll.bind(this));
1908
+ clearInterval(this.interval);
1909
+ }
1910
+ render() {
1911
+ return b `
1912
+ <wui-flex flexDirection="column" gap="3">
1913
+ ${this.templateSearchInput()} ${this.templateSuggestedTokens()} ${this.templateTokens()}
1914
+ </wui-flex>
1915
+ `;
1916
+ }
1917
+ onSelectToken(token) {
1918
+ if (this.targetToken === 'sourceToken') {
1919
+ SwapController.setSourceToken(token);
1920
+ }
1921
+ else {
1922
+ SwapController.setToToken(token);
1923
+ if (this.sourceToken && this.sourceTokenAmount) {
1924
+ SwapController.swapTokens();
1925
+ }
1926
+ }
1927
+ RouterController.goBack();
1928
+ }
1929
+ templateSearchInput() {
1930
+ return b `
1931
+ <wui-flex .padding=${['1', '3', '0', '3']} gap="2">
1932
+ <wui-input-text
1933
+ data-testid="swap-select-token-search-input"
1934
+ class="network-search-input"
1935
+ size="sm"
1936
+ placeholder="Search token"
1937
+ icon="search"
1938
+ .value=${this.searchValue}
1939
+ @inputChange=${this.onSearchInputChange.bind(this)}
1940
+ ></wui-input-text>
1941
+ </wui-flex>
1942
+ `;
1943
+ }
1944
+ templateMyTokens() {
1945
+ const yourTokens = this.myTokensWithBalance ? Object.values(this.myTokensWithBalance) : [];
1946
+ const filteredYourTokens = this.filterTokensWithText(yourTokens, this.searchValue);
1947
+ if (filteredYourTokens?.length > 0) {
1948
+ return b `<wui-flex justifyContent="flex-start" padding="2">
1949
+ <wui-text variant="md-medium" color="secondary">Your tokens</wui-text>
1950
+ </wui-flex>
1951
+ ${filteredYourTokens.map(token => {
1952
+ const selected = token.symbol === this.sourceToken?.symbol || token.symbol === this.toToken?.symbol;
1953
+ return b `
1954
+ <wui-token-list-item
1955
+ data-testid="swap-select-token-item-${token.symbol}"
1956
+ name=${token.name}
1957
+ ?disabled=${selected}
1958
+ symbol=${token.symbol}
1959
+ price=${token?.price}
1960
+ amount=${token?.quantity?.numeric}
1961
+ imageSrc=${token.logoUri}
1962
+ @click=${() => {
1963
+ if (!selected) {
1964
+ this.onSelectToken(token);
1965
+ }
1966
+ }}
1967
+ >
1968
+ </wui-token-list-item>
1969
+ `;
1970
+ })}`;
1971
+ }
1972
+ return null;
1973
+ }
1974
+ templateAllTokens() {
1975
+ const tokens = this.popularTokens ? this.popularTokens : [];
1976
+ const filteredTokens = this.filterTokensWithText(tokens, this.searchValue);
1977
+ if (this.tokensLoading) {
1978
+ return b `
1979
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1980
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1981
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1982
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1983
+ <wui-token-list-item-loader></wui-token-list-item-loader>
1984
+ `;
1985
+ }
1986
+ if (filteredTokens?.length > 0) {
1987
+ return b `
1988
+ ${filteredTokens.map(token => b `
1989
+ <wui-token-list-item
1990
+ data-testid="swap-select-token-item-${token.symbol}"
1991
+ name=${token.name}
1992
+ symbol=${token.symbol}
1993
+ imageSrc=${token.logoUri}
1994
+ @click=${() => this.onSelectToken(token)}
1995
+ >
1996
+ </wui-token-list-item>
1997
+ `)}
1998
+ `;
1999
+ }
2000
+ return null;
2001
+ }
2002
+ templateTokens() {
2003
+ return b `
2004
+ <wui-flex class="tokens-container">
2005
+ <wui-flex class="tokens" .padding=${['0', '2', '2', '2']} flexDirection="column">
2006
+ ${this.templateMyTokens()}
2007
+ <wui-flex justifyContent="flex-start" padding="3">
2008
+ <wui-text variant="md-medium" color="secondary">Tokens</wui-text>
2009
+ </wui-flex>
2010
+ ${this.templateAllTokens()}
2011
+ </wui-flex>
2012
+ </wui-flex>
2013
+ `;
2014
+ }
2015
+ templateSuggestedTokens() {
2016
+ const tokens = this.suggestedTokens ? this.suggestedTokens.slice(0, 8) : null;
2017
+ if (this.tokensLoading) {
2018
+ return b `
2019
+ <wui-flex
2020
+ class="suggested-tokens-container"
2021
+ .padding=${['0', '3', '0', '3']}
2022
+ gap="2"
2023
+ >
2024
+ <wui-token-button loading></wui-token-button>
2025
+ <wui-token-button loading></wui-token-button>
2026
+ <wui-token-button loading></wui-token-button>
2027
+ <wui-token-button loading></wui-token-button>
2028
+ <wui-token-button loading></wui-token-button>
2029
+ </wui-flex>
2030
+ `;
2031
+ }
2032
+ if (!tokens) {
2033
+ return null;
2034
+ }
2035
+ return b `
2036
+ <wui-flex
2037
+ class="suggested-tokens-container"
2038
+ .padding=${['0', '3', '0', '3']}
2039
+ gap="2"
2040
+ >
2041
+ ${tokens.map(token => b `
2042
+ <wui-token-button
2043
+ text=${token.symbol}
2044
+ imageSrc=${token.logoUri}
2045
+ @click=${() => this.onSelectToken(token)}
2046
+ >
2047
+ </wui-token-button>
2048
+ `)}
2049
+ </wui-flex>
2050
+ `;
2051
+ }
2052
+ onSearchInputChange(event) {
2053
+ this.searchValue = event.detail;
2054
+ }
2055
+ handleSuggestedTokensScroll() {
2056
+ const container = this.renderRoot?.querySelector('.suggested-tokens-container');
2057
+ if (!container) {
2058
+ return;
2059
+ }
2060
+ container.style.setProperty('--suggested-tokens-scroll--left-opacity', MathUtil.interpolate([0, 100], [0, 1], container.scrollLeft).toString());
2061
+ container.style.setProperty('--suggested-tokens-scroll--right-opacity', MathUtil.interpolate([0, 100], [0, 1], container.scrollWidth - container.scrollLeft - container.offsetWidth).toString());
2062
+ }
2063
+ handleTokenListScroll() {
2064
+ const container = this.renderRoot?.querySelector('.tokens');
2065
+ if (!container) {
2066
+ return;
2067
+ }
2068
+ container.style.setProperty('--tokens-scroll--top-opacity', MathUtil.interpolate([0, 100], [0, 1], container.scrollTop).toString());
2069
+ container.style.setProperty('--tokens-scroll--bottom-opacity', MathUtil.interpolate([0, 100], [0, 1], container.scrollHeight - container.scrollTop - container.offsetHeight).toString());
2070
+ }
2071
+ filterTokensWithText(tokens, text) {
2072
+ return tokens
2073
+ .filter(token => `${token.symbol} ${token.name} ${token.address}`.toLowerCase().includes(text.toLowerCase()))
2074
+ .sort((a, b) => {
2075
+ const aText = `${a.symbol} ${a.name} ${a.address}`.toLowerCase();
2076
+ const bText = `${b.symbol} ${b.name} ${b.address}`.toLowerCase();
2077
+ const aIndex = aText.indexOf(text.toLowerCase());
2078
+ const bIndex = bText.indexOf(text.toLowerCase());
2079
+ return aIndex - bIndex;
2080
+ });
2081
+ }
2082
+ };
2083
+ W3mSwapSelectTokenView.styles = styles;
2084
+ __decorate([
2085
+ r()
2086
+ ], W3mSwapSelectTokenView.prototype, "interval", void 0);
2087
+ __decorate([
2088
+ r()
2089
+ ], W3mSwapSelectTokenView.prototype, "targetToken", void 0);
2090
+ __decorate([
2091
+ r()
2092
+ ], W3mSwapSelectTokenView.prototype, "sourceToken", void 0);
2093
+ __decorate([
2094
+ r()
2095
+ ], W3mSwapSelectTokenView.prototype, "sourceTokenAmount", void 0);
2096
+ __decorate([
2097
+ r()
2098
+ ], W3mSwapSelectTokenView.prototype, "toToken", void 0);
2099
+ __decorate([
2100
+ r()
2101
+ ], W3mSwapSelectTokenView.prototype, "myTokensWithBalance", void 0);
2102
+ __decorate([
2103
+ r()
2104
+ ], W3mSwapSelectTokenView.prototype, "popularTokens", void 0);
2105
+ __decorate([
2106
+ r()
2107
+ ], W3mSwapSelectTokenView.prototype, "suggestedTokens", void 0);
2108
+ __decorate([
2109
+ r()
2110
+ ], W3mSwapSelectTokenView.prototype, "tokensLoading", void 0);
2111
+ __decorate([
2112
+ r()
2113
+ ], W3mSwapSelectTokenView.prototype, "searchValue", void 0);
2114
+ W3mSwapSelectTokenView = __decorate([
2115
+ customElement('w3m-swap-select-token-view')
2116
+ ], W3mSwapSelectTokenView);
2117
+
2118
+ export { W3mSwapPreviewView, W3mSwapSelectTokenView, W3mSwapView };
2119
+ //# sourceMappingURL=swaps-DyGe65DR.js.map
2120
+
2121
+ //# sourceMappingURL=swaps-DyGe65DR.js.map