@imtbl/sdk 1.26.5 → 1.26.6-alpha

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 (35) hide show
  1. package/dist/blockchain_data.js +2 -2
  2. package/dist/browser/checkout/{BridgeWidget-a9311716.js → BridgeWidget-bc16e57e.js} +1 -1
  3. package/dist/browser/checkout/{HorizontalMenu-actual-ae4ab7e2.js → HorizontalMenu-actual-91b73081.js} +1 -1
  4. package/dist/browser/checkout/{OnRampWidget-35cea8e8.js → OnRampWidget-3d396f4d.js} +1 -1
  5. package/dist/browser/checkout/{SaleWidget-6bf9a917.js → SaleWidget-3e1bddec.js} +2 -2
  6. package/dist/browser/checkout/{SpendingCapHero-df9b9edf.js → SpendingCapHero-84219118.js} +1 -1
  7. package/dist/browser/checkout/{SwapWidget-80f526d6.js → SwapWidget-73832b8c.js} +1 -1
  8. package/dist/browser/checkout/{TopUpView-de3745a8.js → TopUpView-d04120e3.js} +1 -1
  9. package/dist/browser/checkout/{WalletWidget-3adae453.js → WalletWidget-f96385f7.js} +1 -1
  10. package/dist/browser/checkout/{auto-track-019f4c77.js → auto-track-17040529.js} +1 -1
  11. package/dist/browser/checkout/{balance-c7e007a8.js → balance-a74e7655.js} +1 -1
  12. package/dist/browser/checkout/{index-6ec4d4e9.js → index-00d43e20.js} +1 -1
  13. package/dist/browser/checkout/index-27f9173e.js +1 -0
  14. package/dist/browser/checkout/{index-a7ac7e3b.js → index-7ac7c034.js} +1 -1
  15. package/dist/browser/checkout/{index-a91d7cc6.js → index-ab70a8f3.js} +2 -2
  16. package/dist/browser/checkout/{index-77a27204.js → index-b525fc3a.js} +1 -1
  17. package/dist/browser/checkout/{index-ba631d40.js → index-cd30780c.js} +1 -1
  18. package/dist/browser/checkout/{index-c3ce994e.js → index-da873cdc.js} +1 -1
  19. package/dist/browser/checkout/{index-10620204.js → index-f4fe93b7.js} +1 -1
  20. package/dist/browser/checkout/{index.umd-d1ba0fda.js → index.umd-253a2ddb.js} +1 -1
  21. package/dist/browser/checkout/{retry-3b633bcd.js → retry-3b188035.js} +1 -1
  22. package/dist/browser/checkout/sdk.js +4 -4
  23. package/dist/browser/checkout/widgets-esm.js +1 -1
  24. package/dist/browser/checkout/widgets.js +3 -3
  25. package/dist/checkout.js +4 -4
  26. package/dist/config.js +1 -1
  27. package/dist/index.browser.js +4 -4
  28. package/dist/index.browser.js.map +1 -1
  29. package/dist/index.cjs +7 -7
  30. package/dist/index.js +7 -7
  31. package/dist/orderbook.js +1 -1
  32. package/dist/passport.js +4 -4
  33. package/dist/x.js +3 -3
  34. package/package.json +1 -1
  35. package/dist/browser/checkout/index-7241c80c.js +0 -1
@@ -1 +1 @@
1
- import{a as o,P as e,B as t,Q as n,R as r,j as i}from"./index-a91d7cc6.js";function C(){return o(t,{sx:{...e,background:"base.color.translucent.emphasis.100"},children:o(t,{sx:{...n,...r},children:i("svg",{width:"430",height:"305",viewBox:"0 0 430 305",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o("path",{d:"M94.0614 105.632L93.6321 104L92 104.429L92.4292 106.061L94.0614 105.632Z",fill:"white"}),o("path",{d:"M63.6531 193.101L63.1006 191L60.9996 191.553L61.5521 193.654L63.6531 193.101Z",fill:"white"}),o("path",{d:"M344.489 224.345L342.345 224L342 226.145L344.144 226.49L344.489 224.345Z",fill:"white"}),o("path",{d:"M372.286 139.905L372.905 138.619L371.619 138L371 139.286L372.286 139.905Z",fill:"white"}),o("path",{d:"M341.653 78.101L341.101 76L339 76.5525L339.552 78.6535L341.653 78.101Z",fill:"white"}),o("path",{d:"M359.286 242.905L359.905 241.619L358.619 241L358 242.286L359.286 242.905Z",fill:"white"}),o("path",{d:"M87.0123 112.087L86.0869 111L85.0002 111.925L85.9256 113.012L87.0123 112.087Z",fill:"white"}),o("path",{d:"M84.2862 248.905L84.9053 247.619L83.6192 247L83.0001 248.286L84.2862 248.905Z",fill:"white"}),o("path",{d:"M215.496 262.992C268.237 262.992 310.993 220.237 310.993 167.496C310.993 114.755 268.237 72 215.496 72C162.755 72 120 114.755 120 167.496C120 220.237 162.755 262.992 215.496 262.992Z",fill:"white",fillOpacity:"0.24",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M159.82 95.1695C179.975 79.6536 204.651 73.1506 227.89 77.0665C261.089 82.6606 253.281 101.028 199.197 121.314C151.934 139.037 123.49 136.348 143.823 110.95C148.422 105.208 153.721 99.8623 159.82 95.1695Z",fill:"white",fillOpacity:"0.08"}),o("path",{d:"M215.497 227.183C171.451 227.183 135.159 219.871 130.194 210.462H130.187C145.912 241.626 178.21 263.001 215.497 263.001C252.705 263.001 284.942 241.719 300.706 210.664C295.33 219.98 259.232 227.183 215.505 227.183H215.497Z",fill:"#36E0F8",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M284.219 219.607L283.978 219.84C281.275 222.482 256.583 215.986 253.172 218.418C222.389 240.36 182.779 269.061 146.099 219.397C146.099 219.397 140.761 217.641 138.609 216.686C139.425 217.96 140.279 219.226 141.165 220.469C170.425 261.516 227.423 271.073 268.47 241.813C276.97 235.752 284.118 228.503 289.852 220.454L292.424 216.841L288.252 218.302C287.086 218.713 285.851 219.11 284.553 219.498L284.227 219.599L284.219 219.607Z",fill:"black"}),o("path",{d:"M215.496 241.4C262.183 241.4 300.03 226.557 300.03 208.248C300.03 189.938 262.183 175.095 215.496 175.095C168.81 175.095 130.963 189.938 130.963 208.248C130.963 226.557 168.81 241.4 215.496 241.4Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M300.705 210.659C300.705 210.659 300.705 210.65 300.705 210.641C300.705 210.641 300.705 210.65 300.705 210.659Z",fill:"#EBE9E9",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 204.511C208.952 204.511 221.377 199.638 221.377 193.626C221.377 187.614 208.952 182.741 193.624 182.741C178.297 182.741 165.871 187.614 165.871 193.626C165.871 199.638 178.297 204.511 193.624 204.511Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 204.511C208.954 204.511 221.377 199.64 221.377 193.626V201.349C221.377 207.363 208.954 212.234 193.624 212.234C178.295 212.234 165.871 207.363 165.871 201.349V193.626C165.871 199.64 178.295 204.511 193.624 204.511Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 204.41C199.49 204.294 201.573 204.084 203.546 203.789V211.512C201.573 211.807 199.49 212.017 197.33 212.133V204.41Z",fill:"#D0F500"}),o("path",{d:"M206.398 203.291C211.246 202.304 215.255 200.774 217.905 198.901V206.624C215.255 208.497 211.246 210.027 206.398 211.014V203.291Z",fill:"black"}),o("path",{d:"M193.624 204.511C208.954 204.511 221.377 199.64 221.377 193.626V201.349C221.377 207.363 208.954 212.234 193.624 212.234C178.295 212.234 165.871 207.363 165.871 201.349V193.626C165.871 199.64 178.295 204.511 193.624 204.511Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 211.015C211.246 210.028 215.255 208.497 217.905 206.625",stroke:"#A66CFF",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 196.788C208.952 196.788 221.377 191.914 221.377 185.903C221.377 179.891 208.952 175.017 193.624 175.017C178.297 175.017 165.871 179.891 165.871 185.903C165.871 191.914 178.297 196.788 193.624 196.788Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 196.788C208.954 196.788 221.377 191.917 221.377 185.903V193.626C221.377 199.639 208.954 204.511 193.624 204.511C178.295 204.511 165.871 199.639 165.871 193.626V185.903C165.871 191.917 178.295 196.788 193.624 196.788Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 196.687C199.49 196.57 201.573 196.361 203.546 196.065V203.788C201.573 204.084 199.49 204.293 197.33 204.41V196.687Z",fill:"#36E0F8"}),o("path",{d:"M206.398 195.568C211.246 194.581 215.255 193.051 217.905 191.178V198.901C215.255 200.774 211.246 202.304 206.398 203.291V195.568Z",fill:"black"}),o("path",{d:"M193.624 196.788C208.954 196.788 221.377 191.917 221.377 185.903V193.626C221.377 199.639 208.954 204.511 193.624 204.511C178.295 204.511 165.871 199.639 165.871 193.626V185.903C165.871 191.917 178.295 196.788 193.624 196.788Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 203.291C211.246 202.304 215.255 200.774 217.905 198.901",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 189.065C208.952 189.065 221.377 184.192 221.377 178.18C221.377 172.168 208.952 167.294 193.624 167.294C178.297 167.294 165.871 172.168 165.871 178.18C165.871 184.192 178.297 189.065 193.624 189.065Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 189.065C208.954 189.065 221.377 184.194 221.377 178.18V185.903C221.377 191.917 208.954 196.788 193.624 196.788C178.295 196.788 165.871 191.917 165.871 185.903V178.18C165.871 184.194 178.295 189.065 193.624 189.065Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 188.965C199.49 188.849 201.573 188.639 203.546 188.343V196.067C201.573 196.362 199.49 196.571 197.33 196.688V188.965Z",fill:"#F191FA"}),o("path",{d:"M206.398 187.845C211.246 186.858 215.255 185.327 217.905 183.455V191.178C215.255 193.05 211.246 194.581 206.398 195.568V187.845Z",fill:"black"}),o("path",{d:"M193.624 189.065C208.954 189.065 221.377 184.194 221.377 178.18V185.903C221.377 191.917 208.954 196.788 193.624 196.788C178.295 196.788 165.871 191.917 165.871 185.903V178.18C165.871 184.194 178.295 189.065 193.624 189.065Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 195.569C211.246 194.582 215.255 193.052 217.905 191.179",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 212.934C253.929 212.934 266.354 208.06 266.354 202.049C266.354 196.037 253.929 191.164 238.601 191.164C223.274 191.164 210.848 196.037 210.848 202.049C210.848 208.06 223.274 212.934 238.601 212.934Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 212.935C253.931 212.935 266.354 208.063 266.354 202.049V209.772C266.354 215.786 253.931 220.658 238.601 220.658C223.272 220.658 210.848 215.786 210.848 209.772V202.049C210.848 208.063 223.272 212.935 238.601 212.935Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 212.833C244.467 212.717 246.55 212.507 248.523 212.212V219.935C246.55 220.23 244.467 220.44 242.307 220.556V212.833Z",fill:"#F191FA"}),o("path",{d:"M251.375 211.713C256.223 210.727 260.232 209.196 262.882 207.324V215.047C260.232 216.919 256.223 218.45 251.375 219.436V211.713Z",fill:"black"}),o("path",{d:"M238.601 212.935C253.931 212.935 266.354 208.063 266.354 202.049V209.772C266.354 215.786 253.931 220.658 238.601 220.658C223.272 220.658 210.848 215.786 210.848 209.772V202.049C210.848 208.063 223.272 212.935 238.601 212.935Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 219.437C256.223 218.45 260.232 216.919 262.882 215.047",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 205.21C253.929 205.21 266.354 200.336 266.354 194.324C266.354 188.313 253.929 183.439 238.601 183.439C223.274 183.439 210.848 188.313 210.848 194.324C210.848 200.336 223.274 205.21 238.601 205.21Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 205.21C253.931 205.21 266.354 200.339 266.354 194.325V202.048C266.354 208.062 253.931 212.934 238.601 212.934C223.272 212.934 210.848 208.062 210.848 202.048V194.325C210.848 200.339 223.272 205.21 238.601 205.21Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 205.109C244.467 204.993 246.55 204.783 248.523 204.488V212.211C246.55 212.506 244.467 212.716 242.307 212.832V205.109Z",fill:"#36E0F8"}),o("path",{d:"M251.375 203.989C256.223 203.003 260.232 201.472 262.882 199.6V207.323C260.232 209.195 256.223 210.726 251.375 211.712V203.989Z",fill:"black"}),o("path",{d:"M238.601 205.21C253.931 205.21 266.354 200.339 266.354 194.325V202.048C266.354 208.062 253.931 212.934 238.601 212.934C223.272 212.934 210.848 208.062 210.848 202.048V194.325C210.848 200.339 223.272 205.21 238.601 205.21Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 211.713C256.223 210.726 260.232 209.195 262.882 207.323",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 197.487C253.929 197.487 266.354 192.613 266.354 186.602C266.354 180.59 253.929 175.716 238.601 175.716C223.274 175.716 210.848 180.59 210.848 186.602C210.848 192.613 223.274 197.487 238.601 197.487Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 197.487C253.931 197.487 266.354 192.616 266.354 186.602V194.325C266.354 200.339 253.931 205.21 238.601 205.21C223.272 205.21 210.848 200.339 210.848 194.325V186.602C210.848 192.616 223.272 197.487 238.601 197.487Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 197.386C244.467 197.27 246.55 197.06 248.523 196.765V204.488C246.55 204.783 244.467 204.992 242.307 205.109V197.386Z",fill:"#F191FA"}),o("path",{d:"M251.375 196.267C256.223 195.28 260.232 193.75 262.882 191.877V199.6C260.232 201.473 256.223 203.003 251.375 203.99V196.267Z",fill:"#9AEFFB"}),o("path",{d:"M238.601 197.487C253.931 197.487 266.354 192.616 266.354 186.602V194.325C266.354 200.339 253.931 205.21 238.601 205.21C223.272 205.21 210.848 200.339 210.848 194.325V186.602C210.848 192.616 223.272 197.487 238.601 197.487Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 203.99C256.223 203.004 260.232 201.473 262.882 199.601",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M232.652 189.678C247.979 189.678 260.405 184.804 260.405 178.793C260.405 172.781 247.979 167.908 232.652 167.908C217.324 167.908 204.899 172.781 204.899 178.793C204.899 184.804 217.324 189.678 232.652 189.678Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M232.652 189.678C247.981 189.678 260.405 184.807 260.405 178.793V186.516C260.405 192.53 247.981 197.401 232.652 197.401C217.323 197.401 204.899 192.53 204.899 186.516V178.793C204.899 184.807 217.323 189.678 232.652 189.678Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M236.358 189.578C238.518 189.461 240.6 189.251 242.574 188.956V196.679C240.6 196.974 238.518 197.184 236.358 197.301V189.578Z",fill:"#F191FA"}),o("path",{d:"M245.426 188.458C250.274 187.471 254.283 185.94 256.932 184.067V191.791C254.283 193.663 250.274 195.194 245.426 196.18V188.458Z",fill:"black"}),o("path",{d:"M232.652 189.678C247.981 189.678 260.405 184.807 260.405 178.793V186.516C260.405 192.53 247.981 197.401 232.652 197.401C217.323 197.401 204.899 192.53 204.899 186.516V178.793C204.899 184.807 217.323 189.678 232.652 189.678Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M245.426 196.182C250.274 195.195 254.283 193.664 256.932 191.792",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M240.99 180.021C256.317 180.021 268.743 175.148 268.743 169.136C268.743 163.124 256.317 158.25 240.99 158.25C225.662 158.25 213.237 163.124 213.237 169.136C213.237 175.148 225.662 180.021 240.99 180.021Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M240.99 180.021C256.319 180.021 268.743 175.15 268.743 169.136V176.859C268.743 182.873 256.319 187.744 240.99 187.744C225.66 187.744 213.237 182.873 213.237 176.859V169.136C213.237 175.15 225.66 180.021 240.99 180.021Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M244.696 179.92C246.856 179.804 248.938 179.594 250.911 179.299V187.022C248.938 187.317 246.856 187.527 244.696 187.643V179.92Z",fill:"#9AEFFB"}),o("path",{d:"M253.763 178.801C258.612 177.815 262.621 176.284 265.27 174.412V182.135C262.621 184.007 258.612 185.538 253.763 186.524V178.801Z",fill:"black"}),o("path",{d:"M240.99 180.021C256.319 180.021 268.743 175.15 268.743 169.136V176.859C268.743 182.873 256.319 187.744 240.99 187.744C225.66 187.744 213.237 182.873 213.237 176.859V169.136C213.237 175.15 225.66 180.021 240.99 180.021Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M253.763 186.525C258.612 185.538 262.621 184.007 265.27 182.135",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M189.911 223.803C205.238 223.803 217.664 218.929 217.664 212.918C217.664 206.906 205.238 202.032 189.911 202.032C174.583 202.032 162.158 206.906 162.158 212.918C162.158 218.929 174.583 223.803 189.911 223.803Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M189.911 223.803C205.24 223.803 217.664 218.932 217.664 212.918V220.641C217.664 226.655 205.24 231.526 189.911 231.526C174.581 231.526 162.158 226.655 162.158 220.641V212.918C162.158 218.932 174.581 223.803 189.911 223.803Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.625 223.71C195.785 223.593 197.867 223.384 199.84 223.088V230.811C197.867 231.107 195.785 231.316 193.625 231.433V223.71Z",fill:"#F191FA"}),o("path",{d:"M202.685 222.583C207.533 221.596 211.542 220.066 214.191 218.193V225.916C211.542 227.789 207.533 229.319 202.685 230.306V222.583Z",fill:"#9AEFFB"}),o("path",{d:"M189.911 223.803C205.24 223.803 217.664 218.932 217.664 212.918V220.641C217.664 226.655 205.24 231.526 189.911 231.526C174.581 231.526 162.158 226.655 162.158 220.641V212.918C162.158 218.932 174.581 223.803 189.911 223.803Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M202.685 230.306C207.533 229.32 211.542 227.789 214.191 225.917",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M300.705 210.658C300.705 210.658 300.705 210.649 300.705 210.641C300.705 210.641 300.705 210.649 300.705 210.658Z",fill:"#A66CFF",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"})]})})})}export{C as S};
1
+ import{a as o,P as e,B as t,Q as n,R as r,j as i}from"./index-ab70a8f3.js";function C(){return o(t,{sx:{...e,background:"base.color.translucent.emphasis.100"},children:o(t,{sx:{...n,...r},children:i("svg",{width:"430",height:"305",viewBox:"0 0 430 305",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o("path",{d:"M94.0614 105.632L93.6321 104L92 104.429L92.4292 106.061L94.0614 105.632Z",fill:"white"}),o("path",{d:"M63.6531 193.101L63.1006 191L60.9996 191.553L61.5521 193.654L63.6531 193.101Z",fill:"white"}),o("path",{d:"M344.489 224.345L342.345 224L342 226.145L344.144 226.49L344.489 224.345Z",fill:"white"}),o("path",{d:"M372.286 139.905L372.905 138.619L371.619 138L371 139.286L372.286 139.905Z",fill:"white"}),o("path",{d:"M341.653 78.101L341.101 76L339 76.5525L339.552 78.6535L341.653 78.101Z",fill:"white"}),o("path",{d:"M359.286 242.905L359.905 241.619L358.619 241L358 242.286L359.286 242.905Z",fill:"white"}),o("path",{d:"M87.0123 112.087L86.0869 111L85.0002 111.925L85.9256 113.012L87.0123 112.087Z",fill:"white"}),o("path",{d:"M84.2862 248.905L84.9053 247.619L83.6192 247L83.0001 248.286L84.2862 248.905Z",fill:"white"}),o("path",{d:"M215.496 262.992C268.237 262.992 310.993 220.237 310.993 167.496C310.993 114.755 268.237 72 215.496 72C162.755 72 120 114.755 120 167.496C120 220.237 162.755 262.992 215.496 262.992Z",fill:"white",fillOpacity:"0.24",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M159.82 95.1695C179.975 79.6536 204.651 73.1506 227.89 77.0665C261.089 82.6606 253.281 101.028 199.197 121.314C151.934 139.037 123.49 136.348 143.823 110.95C148.422 105.208 153.721 99.8623 159.82 95.1695Z",fill:"white",fillOpacity:"0.08"}),o("path",{d:"M215.497 227.183C171.451 227.183 135.159 219.871 130.194 210.462H130.187C145.912 241.626 178.21 263.001 215.497 263.001C252.705 263.001 284.942 241.719 300.706 210.664C295.33 219.98 259.232 227.183 215.505 227.183H215.497Z",fill:"#36E0F8",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M284.219 219.607L283.978 219.84C281.275 222.482 256.583 215.986 253.172 218.418C222.389 240.36 182.779 269.061 146.099 219.397C146.099 219.397 140.761 217.641 138.609 216.686C139.425 217.96 140.279 219.226 141.165 220.469C170.425 261.516 227.423 271.073 268.47 241.813C276.97 235.752 284.118 228.503 289.852 220.454L292.424 216.841L288.252 218.302C287.086 218.713 285.851 219.11 284.553 219.498L284.227 219.599L284.219 219.607Z",fill:"black"}),o("path",{d:"M215.496 241.4C262.183 241.4 300.03 226.557 300.03 208.248C300.03 189.938 262.183 175.095 215.496 175.095C168.81 175.095 130.963 189.938 130.963 208.248C130.963 226.557 168.81 241.4 215.496 241.4Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M300.705 210.659C300.705 210.659 300.705 210.65 300.705 210.641C300.705 210.641 300.705 210.65 300.705 210.659Z",fill:"#EBE9E9",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 204.511C208.952 204.511 221.377 199.638 221.377 193.626C221.377 187.614 208.952 182.741 193.624 182.741C178.297 182.741 165.871 187.614 165.871 193.626C165.871 199.638 178.297 204.511 193.624 204.511Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 204.511C208.954 204.511 221.377 199.64 221.377 193.626V201.349C221.377 207.363 208.954 212.234 193.624 212.234C178.295 212.234 165.871 207.363 165.871 201.349V193.626C165.871 199.64 178.295 204.511 193.624 204.511Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 204.41C199.49 204.294 201.573 204.084 203.546 203.789V211.512C201.573 211.807 199.49 212.017 197.33 212.133V204.41Z",fill:"#D0F500"}),o("path",{d:"M206.398 203.291C211.246 202.304 215.255 200.774 217.905 198.901V206.624C215.255 208.497 211.246 210.027 206.398 211.014V203.291Z",fill:"black"}),o("path",{d:"M193.624 204.511C208.954 204.511 221.377 199.64 221.377 193.626V201.349C221.377 207.363 208.954 212.234 193.624 212.234C178.295 212.234 165.871 207.363 165.871 201.349V193.626C165.871 199.64 178.295 204.511 193.624 204.511Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 211.015C211.246 210.028 215.255 208.497 217.905 206.625",stroke:"#A66CFF",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 196.788C208.952 196.788 221.377 191.914 221.377 185.903C221.377 179.891 208.952 175.017 193.624 175.017C178.297 175.017 165.871 179.891 165.871 185.903C165.871 191.914 178.297 196.788 193.624 196.788Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 196.788C208.954 196.788 221.377 191.917 221.377 185.903V193.626C221.377 199.639 208.954 204.511 193.624 204.511C178.295 204.511 165.871 199.639 165.871 193.626V185.903C165.871 191.917 178.295 196.788 193.624 196.788Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 196.687C199.49 196.57 201.573 196.361 203.546 196.065V203.788C201.573 204.084 199.49 204.293 197.33 204.41V196.687Z",fill:"#36E0F8"}),o("path",{d:"M206.398 195.568C211.246 194.581 215.255 193.051 217.905 191.178V198.901C215.255 200.774 211.246 202.304 206.398 203.291V195.568Z",fill:"black"}),o("path",{d:"M193.624 196.788C208.954 196.788 221.377 191.917 221.377 185.903V193.626C221.377 199.639 208.954 204.511 193.624 204.511C178.295 204.511 165.871 199.639 165.871 193.626V185.903C165.871 191.917 178.295 196.788 193.624 196.788Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 203.291C211.246 202.304 215.255 200.774 217.905 198.901",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 189.065C208.952 189.065 221.377 184.192 221.377 178.18C221.377 172.168 208.952 167.294 193.624 167.294C178.297 167.294 165.871 172.168 165.871 178.18C165.871 184.192 178.297 189.065 193.624 189.065Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 189.065C208.954 189.065 221.377 184.194 221.377 178.18V185.903C221.377 191.917 208.954 196.788 193.624 196.788C178.295 196.788 165.871 191.917 165.871 185.903V178.18C165.871 184.194 178.295 189.065 193.624 189.065Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 188.965C199.49 188.849 201.573 188.639 203.546 188.343V196.067C201.573 196.362 199.49 196.571 197.33 196.688V188.965Z",fill:"#F191FA"}),o("path",{d:"M206.398 187.845C211.246 186.858 215.255 185.327 217.905 183.455V191.178C215.255 193.05 211.246 194.581 206.398 195.568V187.845Z",fill:"black"}),o("path",{d:"M193.624 189.065C208.954 189.065 221.377 184.194 221.377 178.18V185.903C221.377 191.917 208.954 196.788 193.624 196.788C178.295 196.788 165.871 191.917 165.871 185.903V178.18C165.871 184.194 178.295 189.065 193.624 189.065Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 195.569C211.246 194.582 215.255 193.052 217.905 191.179",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 212.934C253.929 212.934 266.354 208.06 266.354 202.049C266.354 196.037 253.929 191.164 238.601 191.164C223.274 191.164 210.848 196.037 210.848 202.049C210.848 208.06 223.274 212.934 238.601 212.934Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 212.935C253.931 212.935 266.354 208.063 266.354 202.049V209.772C266.354 215.786 253.931 220.658 238.601 220.658C223.272 220.658 210.848 215.786 210.848 209.772V202.049C210.848 208.063 223.272 212.935 238.601 212.935Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 212.833C244.467 212.717 246.55 212.507 248.523 212.212V219.935C246.55 220.23 244.467 220.44 242.307 220.556V212.833Z",fill:"#F191FA"}),o("path",{d:"M251.375 211.713C256.223 210.727 260.232 209.196 262.882 207.324V215.047C260.232 216.919 256.223 218.45 251.375 219.436V211.713Z",fill:"black"}),o("path",{d:"M238.601 212.935C253.931 212.935 266.354 208.063 266.354 202.049V209.772C266.354 215.786 253.931 220.658 238.601 220.658C223.272 220.658 210.848 215.786 210.848 209.772V202.049C210.848 208.063 223.272 212.935 238.601 212.935Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 219.437C256.223 218.45 260.232 216.919 262.882 215.047",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 205.21C253.929 205.21 266.354 200.336 266.354 194.324C266.354 188.313 253.929 183.439 238.601 183.439C223.274 183.439 210.848 188.313 210.848 194.324C210.848 200.336 223.274 205.21 238.601 205.21Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 205.21C253.931 205.21 266.354 200.339 266.354 194.325V202.048C266.354 208.062 253.931 212.934 238.601 212.934C223.272 212.934 210.848 208.062 210.848 202.048V194.325C210.848 200.339 223.272 205.21 238.601 205.21Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 205.109C244.467 204.993 246.55 204.783 248.523 204.488V212.211C246.55 212.506 244.467 212.716 242.307 212.832V205.109Z",fill:"#36E0F8"}),o("path",{d:"M251.375 203.989C256.223 203.003 260.232 201.472 262.882 199.6V207.323C260.232 209.195 256.223 210.726 251.375 211.712V203.989Z",fill:"black"}),o("path",{d:"M238.601 205.21C253.931 205.21 266.354 200.339 266.354 194.325V202.048C266.354 208.062 253.931 212.934 238.601 212.934C223.272 212.934 210.848 208.062 210.848 202.048V194.325C210.848 200.339 223.272 205.21 238.601 205.21Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 211.713C256.223 210.726 260.232 209.195 262.882 207.323",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 197.487C253.929 197.487 266.354 192.613 266.354 186.602C266.354 180.59 253.929 175.716 238.601 175.716C223.274 175.716 210.848 180.59 210.848 186.602C210.848 192.613 223.274 197.487 238.601 197.487Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 197.487C253.931 197.487 266.354 192.616 266.354 186.602V194.325C266.354 200.339 253.931 205.21 238.601 205.21C223.272 205.21 210.848 200.339 210.848 194.325V186.602C210.848 192.616 223.272 197.487 238.601 197.487Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 197.386C244.467 197.27 246.55 197.06 248.523 196.765V204.488C246.55 204.783 244.467 204.992 242.307 205.109V197.386Z",fill:"#F191FA"}),o("path",{d:"M251.375 196.267C256.223 195.28 260.232 193.75 262.882 191.877V199.6C260.232 201.473 256.223 203.003 251.375 203.99V196.267Z",fill:"#9AEFFB"}),o("path",{d:"M238.601 197.487C253.931 197.487 266.354 192.616 266.354 186.602V194.325C266.354 200.339 253.931 205.21 238.601 205.21C223.272 205.21 210.848 200.339 210.848 194.325V186.602C210.848 192.616 223.272 197.487 238.601 197.487Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 203.99C256.223 203.004 260.232 201.473 262.882 199.601",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M232.652 189.678C247.979 189.678 260.405 184.804 260.405 178.793C260.405 172.781 247.979 167.908 232.652 167.908C217.324 167.908 204.899 172.781 204.899 178.793C204.899 184.804 217.324 189.678 232.652 189.678Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M232.652 189.678C247.981 189.678 260.405 184.807 260.405 178.793V186.516C260.405 192.53 247.981 197.401 232.652 197.401C217.323 197.401 204.899 192.53 204.899 186.516V178.793C204.899 184.807 217.323 189.678 232.652 189.678Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M236.358 189.578C238.518 189.461 240.6 189.251 242.574 188.956V196.679C240.6 196.974 238.518 197.184 236.358 197.301V189.578Z",fill:"#F191FA"}),o("path",{d:"M245.426 188.458C250.274 187.471 254.283 185.94 256.932 184.067V191.791C254.283 193.663 250.274 195.194 245.426 196.18V188.458Z",fill:"black"}),o("path",{d:"M232.652 189.678C247.981 189.678 260.405 184.807 260.405 178.793V186.516C260.405 192.53 247.981 197.401 232.652 197.401C217.323 197.401 204.899 192.53 204.899 186.516V178.793C204.899 184.807 217.323 189.678 232.652 189.678Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M245.426 196.182C250.274 195.195 254.283 193.664 256.932 191.792",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M240.99 180.021C256.317 180.021 268.743 175.148 268.743 169.136C268.743 163.124 256.317 158.25 240.99 158.25C225.662 158.25 213.237 163.124 213.237 169.136C213.237 175.148 225.662 180.021 240.99 180.021Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M240.99 180.021C256.319 180.021 268.743 175.15 268.743 169.136V176.859C268.743 182.873 256.319 187.744 240.99 187.744C225.66 187.744 213.237 182.873 213.237 176.859V169.136C213.237 175.15 225.66 180.021 240.99 180.021Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M244.696 179.92C246.856 179.804 248.938 179.594 250.911 179.299V187.022C248.938 187.317 246.856 187.527 244.696 187.643V179.92Z",fill:"#9AEFFB"}),o("path",{d:"M253.763 178.801C258.612 177.815 262.621 176.284 265.27 174.412V182.135C262.621 184.007 258.612 185.538 253.763 186.524V178.801Z",fill:"black"}),o("path",{d:"M240.99 180.021C256.319 180.021 268.743 175.15 268.743 169.136V176.859C268.743 182.873 256.319 187.744 240.99 187.744C225.66 187.744 213.237 182.873 213.237 176.859V169.136C213.237 175.15 225.66 180.021 240.99 180.021Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M253.763 186.525C258.612 185.538 262.621 184.007 265.27 182.135",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M189.911 223.803C205.238 223.803 217.664 218.929 217.664 212.918C217.664 206.906 205.238 202.032 189.911 202.032C174.583 202.032 162.158 206.906 162.158 212.918C162.158 218.929 174.583 223.803 189.911 223.803Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M189.911 223.803C205.24 223.803 217.664 218.932 217.664 212.918V220.641C217.664 226.655 205.24 231.526 189.911 231.526C174.581 231.526 162.158 226.655 162.158 220.641V212.918C162.158 218.932 174.581 223.803 189.911 223.803Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.625 223.71C195.785 223.593 197.867 223.384 199.84 223.088V230.811C197.867 231.107 195.785 231.316 193.625 231.433V223.71Z",fill:"#F191FA"}),o("path",{d:"M202.685 222.583C207.533 221.596 211.542 220.066 214.191 218.193V225.916C211.542 227.789 207.533 229.319 202.685 230.306V222.583Z",fill:"#9AEFFB"}),o("path",{d:"M189.911 223.803C205.24 223.803 217.664 218.932 217.664 212.918V220.641C217.664 226.655 205.24 231.526 189.911 231.526C174.581 231.526 162.158 226.655 162.158 220.641V212.918C162.158 218.932 174.581 223.803 189.911 223.803Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M202.685 230.306C207.533 229.32 211.542 227.789 214.191 225.917",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M300.705 210.658C300.705 210.658 300.705 210.649 300.705 210.641C300.705 210.641 300.705 210.649 300.705 210.658Z",fill:"#A66CFF",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"})]})})})}export{C as S};
@@ -1 +1 @@
1
- import{u as e,aA as t,aB as o,j as a,aC as n,B as s,aD as r,a as i,b as d,aE as c,r as l,a4 as p,V as u,C as m,e as w,p as f,U as T,g as y,d as A,m as E,S,aF as v,ao as g,aG as x,H as h,aH as I,aI as b,k as C,l as k,aJ as P,t as R,f as _,y as F,aK as O,aL as W,a2 as D,av as N,aM as L,aN as V,aO as B,E as U,z as M,aP as j,J as G,aQ as $,a0 as H,i as z,W as J,aR as q,_ as K,$ as X,T as Q,D as Z,aS as Y,aT as ee,ax as te,aU as oe,aw as ae,aV as ne,aW as se,a1 as re,I as ie}from"./index-a91d7cc6.js";import{S as de,T as ce,a as le,F as pe,N as ue,W as me,g as we}from"./balance-c7e007a8.js";import{p as fe,S as Te,C as ye,a as Ae,c as Ee,f as Se,T as ve,b as ge}from"./TopUpView-de3745a8.js";import{u as xe}from"./retry-3b633bcd.js";import{S as he}from"./SpendingCapHero-df9b9edf.js";function Ie({theme:l,environment:p}){const{t:u}=e(),m=l===t.DARK?o(p,"/quickswapdark.webp"):o(p,"/quickswaplight.webp");return a(s,{testId:"quickswap-footer-container",sx:n,children:[a(s,{testId:"quickswap-logo",sx:r,children:[i(d,{size:"xSmall",sx:{paddingRight:"base.spacing.x1"},children:"By"}),i("img",{style:{height:"26px"},alt:"Quickswap logo",src:m})]}),i(d,{testId:"quickswap-footer-disclaimer-text",size:"xSmall",sx:c,children:u("footers.quickswapFooter.disclaimerText")})]})}const be={exchange:null,walletProviderName:null,network:null,tokenBalances:[],supportedTopUps:null,allowedTokens:[]};var Ce;!function(e){e.SET_EXCHANGE="SET_EXCHANGE",e.SET_WALLET_PROVIDER_NAME="SET_WALLET_PROVIDER_NAME",e.SET_NETWORK="SET_NETWORK",e.SET_SUPPORTED_TOP_UPS="SET_SUPPORTED_TOP_UPS",e.SET_TOKEN_BALANCES="SET_TOKEN_BALANCES",e.SET_ALLOWED_TOKENS="SET_ALLOWED_TOKENS"}(Ce||(Ce={}));const ke=l.createContext({swapState:be,swapDispatch:()=>{}});ke.displayName="SwapContext";const Pe=(e,t)=>{switch(t.payload.type){case Ce.SET_EXCHANGE:return{...e,exchange:t.payload.exchange};case Ce.SET_WALLET_PROVIDER_NAME:return{...e,walletProviderName:t.payload.walletProviderName};case Ce.SET_NETWORK:return{...e,network:t.payload.network};case Ce.SET_SUPPORTED_TOP_UPS:return{...e,supportedTopUps:{isSwapEnabled:t.payload.supportedTopUps.isSwapEnabled??!0,isOnRampEnabled:t.payload.supportedTopUps.isOnRampEnabled??!0,isBridgeEnabled:t.payload.supportedTopUps.isBridgeEnabled??!0}};case Ce.SET_TOKEN_BALANCES:return{...e,tokenBalances:t.payload.tokenBalances};case Ce.SET_ALLOWED_TOKENS:return{...e,allowedTokens:t.payload.allowedTokens};default:return e}},Re={fromAmountIn:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountIn(s,o.address,n.address,p.from(fe(a,o.decimals)))},fromAmountOut:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountOut(s,n.address,o.address,p.from(fe(a,o.decimals)))}},_e={display:"flex",flexDirection:"row",justifyContent:"space-between",columnGap:"base.spacing.x1"},Fe={flex:1},Oe={flex:2};function We({testId:e,options:t,textInputValue:o,textInputPlaceholder:n,textInputValidator:r,textInputType:d,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,textInputTextAlign:u,textInputSubtext:m,textInputErrorMessage:w,selectTextAlign:f,selectSubtext:T,selectErrorMessage:y,textInputMaxButtonClick:A,onSelectChange:E,textInputDisabled:S,selectInputDisabled:v,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h}){return a(s,{sx:_e,children:[i(s,{sx:Fe,children:i(de,{testId:`${e}-select-form`,options:t,subtext:T,textAlign:f,errorMessage:y,onSelectChange:E,disabled:v,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h})}),i(s,{sx:Oe,children:i(ce,{type:d,testId:`${e}-text-form`,value:o,placeholder:n,subtext:m,textAlign:u,errorMessage:w,validator:r,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,maxButtonClick:A,disabled:S})})]})}const De={display:"flex",flexDirection:"column",paddingY:"base.spacing.x6",paddingX:"base.spacing.x4"},Ne={width:"base.icon.size.400"};function Le({loading:t,updateLoading:o,validator:n,transaction:r,data:d,insufficientFundsForGas:c,openNotEnoughImxDrawer:p,openNetworkSwitchDrawer:v}){const{t:g}=e(),[x,h]=l.useState(!1),{viewDispatch:I}=l.useContext(u),{connectLoaderState:b}=l.useContext(m),{checkout:C,provider:k}=b,{track:P}=w(),R=async()=>{const e=n();if(P({userJourney:T.SWAP,screen:"SwapCoins",control:"Swap",controlType:"Button",extras:{swapFromAddress:d?.fromTokenAddress,swapFromAmount:d?.fromAmount,swapFromTokenSymbol:d?.fromTokenSymbol,swapToAddress:d?.toTokenAddress,swapToAmount:d?.toAmount,swapToTokenSymbol:d?.toTokenSymbol,isSwapFormValid:e,hasFundsForGas:!c}}),e&&C&&k&&r)if(c)p();else{try{const e=await k.provider.request({method:"eth_chainId",params:[]});if(parseInt(e.toString())!==y(C.config))return void v()}catch(e){console.error("Current network check failed",e)}if(r)try{o(!0);const e={fromAmount:d?.fromAmount||"",fromTokenAddress:d?.fromTokenAddress||"",toTokenAddress:d?.toTokenAddress||"",toAmount:d?.toAmount||""};if(r.approval)return void I({payload:{type:A.UPDATE_VIEW,view:{type:Te.APPROVE_ERC20,data:{approveTransaction:r.approval.transaction,transaction:r.swap.transaction,info:r.quote,swapFormInfo:e}}}});const t=await C.sendTransaction({provider:k,transaction:r.swap.transaction});I({payload:{type:A.UPDATE_VIEW,view:{type:Te.IN_PROGRESS,data:{transactionResponse:t.transactionResponse,swapForm:e}}}})}catch(e){if(console.error(e),o(!1),e.type===E.USER_REJECTED_REQUEST_ERROR)return void h(!0);if(e.type===E.UNPREDICTABLE_GAS_LIMIT)return void I({payload:{type:A.UPDATE_VIEW,view:{type:Te.PRICE_SURGE,data:d}}});if(e.type===E.TRANSACTION_FAILED||e.type===E.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status)return void I({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,reason:"Transaction failed",data:d}}});I({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,error:e}}})}}};return a(s,{sx:De,children:[i(f,{testId:"swap-button",disabled:t,variant:"primary",onClick:R,size:"large",children:t?i(f.Icon,{icon:"Loading",sx:Ne}):g("views.SWAP.swapForm.buttonText")}),i(le,{visible:x,showHeaderBar:!1,onCloseDrawer:()=>h(!1),onRetry:()=>{R(),h(!1)}})]})}const Ve={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x1",height:"100%"},Be={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},Ue={display:"flex",flexDirection:"column",justifyContent:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},Me={width:"100%",height:"base.spacing.x16"},je={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"};function Ge({environment:t,visible:o,showAdjustAmount:n,hasZeroImx:r,onCloseDrawer:c,onAddCoinsClick:l}){const{t:p}=e(),u=v(t);return i(g,{size:"full",onCloseDrawer:c,visible:o,showHeaderBar:!1,children:i(g.Content,{children:a(s,{testId:"not-enough-gas-bottom-sheet",sx:Ve,children:[i(x,{imageUrl:u,sx:{w:"base.icon.size.600",h:"base.icon.size.600"}}),i(h,{size:"small",sx:Be,testId:"not-enough-gas-heading",children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.heading`)}),i(d,{sx:Be,children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.body`)}),a(s,{sx:Ue,children:[n&&i(f,{testId:"not-enough-gas-adjust-amount-button",sx:Me,variant:"tertiary",onClick:c,children:p("drawers.notEnoughImx.buttons.adjustAmount")}),i(f,{testId:"not-enough-gas-add-imx-button",sx:Me,variant:"tertiary",onClick:l,children:p("drawers.notEnoughImx.buttons.addMoreImx")}),i(f,{sx:Me,variant:"tertiary",onClick:c,testId:"not-enough-gas-cancel-button",children:p("drawers.notEnoughImx.buttons.cancel")})]}),i(s,{sx:je,children:i(I,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const $e={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x4",paddingX:"base.spacing.x4",height:"100%"},He={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},ze={display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},Je={width:"100%",height:"base.spacing.x16",marginBottom:"base.spacing.x16"},qe={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"},Ke={width:"base.icon.size.600",fill:"base.color.status.fatal.bright"};function Xe({visible:t,onCloseDrawer:o}){const{t:n}=e();return i(g,{size:"full",onCloseDrawer:o,visible:t,showHeaderBar:!1,children:i(g.Content,{children:a(s,{testId:"unable-to-swap-bottom-sheet",sx:$e,children:[i(b,{icon:"Alert",testId:"unable-to-swap-icon",variant:"bold",sx:Ke}),i(h,{size:"small",sx:He,testId:"unable-to-swap-heading",children:n("drawers.unableToSwap.heading")}),i(d,{sx:He,children:n("drawers.unableToSwap.body")}),i(s,{sx:ze,children:i(f,{sx:Je,variant:"tertiary",onClick:o,testId:"unable-to-swap-cancel-button",children:n("drawers.unableToSwap.buttons.cancel")})}),i(s,{sx:qe,children:i(I,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const Qe=(e,t=500)=>{const[o,a]=l.useState(e);return l.useEffect((()=>{const o=setTimeout((()=>{a(e)}),t);return()=>{clearTimeout(o)}}),[e,t]),o};class Ze{static id=0;promiseId=0;promise;isCancelled=!1;onCancel=null;rejectPromise=()=>{};constructor(e){Ze.id+=1,this.promiseId=Ze.id,this.promise=new Promise(((t,o)=>{this.rejectPromise=o,e((e=>{this.isCancelled?o({cancelled:!0}):t(e)}),(e=>{this.isCancelled?o({cancelled:!0}):o(e)}))}))}static all(e){return new Ze(((t,o)=>{Promise.all(e.map((e=>e instanceof Ze?e.promise:e))).then(t,o)}))}then(e,t){return new Ze(((o,a)=>{this.promise.then((t=>o(e?e(t):t)),(e=>t?o(t(e)):a(e)))}))}catch(e){return this.then(void 0,e)}finally(e){return new Ze(((t,o)=>{this.promise.then(t,o).finally((()=>{e&&e()}))}))}cancel(){this.isCancelled||(this.isCancelled=!0,this.onCancel&&this.onCancel(),this.rejectPromise({cancelled:!0}))}onCancelled(e){this.onCancel=e}get cancelled(){return this.isCancelled}}var Ye;!function(e){e.FROM="FROM",e.TO="TO"}(Ye||(Ye={}));const et=({swapFromToken:e,swapToToken:t,swapFromAmount:o,swapToAmount:a,conversion:n})=>{const s={fromToConversion:"",swapToAmount:""};if(!a)return s;if(s.swapToAmount=R(a),o&&e&&t){const o=_(R(Se(n,t.decimals)),!0);s.fromToConversion=`1 ${e.symbol} ≈ ${o} ${t.symbol}`}return s},tt=(e,t)=>void 0!==e&&(""!==e&&t!==e);let ot;function at({data:t,theme:o}){const{t:n}=e(),{swapState:{allowedTokens:r,exchange:c,tokenBalances:f,network:E}}=l.useContext(ke),{connectLoaderState:v}=l.useContext(m),{checkout:g,provider:x}=v,I=C(g?.config.environment,o),b=l.useCallback(((e,t)=>k(t)?`${e.toLowerCase()}-${P}`:`${e.toLowerCase()}-${t.toLowerCase()}`),[]),{cryptoFiatState:U,cryptoFiatDispatch:M}=l.useContext(ye),{viewDispatch:j}=l.useContext(u),[G,$]=l.useState(Ye.FROM),[H,z]=l.useState(!1),[J,q]=l.useState(p.from(0)),[K,X]=l.useState(""),Q=l.useRef(!1),{track:Z}=w(),[Y,ee]=l.useState(t?.fromAmount||""),[te,oe]=l.useState(""),ae=Qe(Y,L),[ne,se]=l.useState(),[re,ie]=l.useState(""),[de,ce]=l.useState(""),[le,me]=l.useState(0),[we,Te]=l.useState(t?.toAmount||""),[ve,ge]=l.useState(""),he=Qe(we,L),[Ie,be]=l.useState(),[Ce,Pe]=l.useState(""),[_e,Fe]=l.useState(""),[Oe,De]=l.useState(null),[Ne,Ve]=l.useState(""),[Be,Ue]=l.useState(void 0),[Me,je]=l.useState(""),[$e,He]=l.useState([]),[ze,Je]=l.useState(!1),[qe,Ke]=l.useState(!1),[at,nt]=l.useState(!1);l.useEffect((()=>{if(0===f.length)return;if(!E)return;const e=f.filter((e=>e.balance.gt(0))).map((e=>({id:b(e.token.symbol,e.token.address),name:e.token.name,symbol:e.token.symbol,icon:e.token.icon,balance:{formattedAmount:R(e.formattedBalance),formattedFiatAmount:0===U.conversions.size?_(""):F(e.formattedBalance,e.token.symbol||"",U.conversions)}})));He(e),Q.current||(Q.current=!0,t?.fromTokenAddress&&(se(r.find((e=>k(e.address)&&t?.fromTokenAddress?.toLowerCase()===P||e.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))),ie(f.find((e=>k(e.token.address)&&t?.fromTokenAddress?.toLowerCase()===P||e.token.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))?.formattedBalance??"")),tt(t?.toTokenAddress,t?.fromTokenAddress)&&be(r.find((e=>k(e.address)&&t?.toTokenAddress?.toLowerCase()===P||e.address?.toLowerCase()===t?.toTokenAddress?.toLowerCase()))))}),[f,r,U.conversions,t?.fromTokenAddress,t?.toTokenAddress,Q.current,se,ie,be,He,b,_,E]);const st=l.useMemo((()=>r.map((e=>({id:b(e.symbol,e.address),name:e.name,symbol:e.symbol,icon:e.icon})))),[r,ne]);l.useEffect((()=>{M({payload:{type:Ae.SET_TOKEN_SYMBOLS,tokenSymbols:r.map((e=>e.symbol))}})}),[M,r]);const rt=()=>{oe(""),ce(""),ge(""),Pe("")},it=()=>{ot&&ot.cancel(),X(""),je(""),De(null)},dt=(e,t)=>!Number.isNaN(parseFloat(e))&&(!(parseFloat(e)<=0)&&(!!ne&&(!!Ie&&(!t||!H)))),ct=async(e=!1)=>{dt(Y,e)&&(ot&&ot.cancel(),e||z(!0),await(async(e=!1)=>{if(x&&c&&ne&&Ie){try{e||X("");const t=Re.fromAmountIn(c,x,ne,Y,Ie),o=Re.fromAmountIn(c,x,ne,"1",Ie),a=Ze.all([t,o]);ot=a;const n=await a,s=n[0],i=n[1];q(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=Se(l,B),m=d?.token,w=r.find((e=>e.address?.toLocaleLowerCase()===m?.address?.toLocaleLowerCase()));De(s),Ve(u),Ue({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),je(F(u,w?.symbol||"",U.conversions)),Te(_(R(Se(s.quote.amount.value,s.quote.amount.token.decimals),s.quote.amount.token.decimals))),rt()}catch(e){e.cancelled||(it(),Je(!1),Ke(!0))}e||z(!1)}})(e))},lt=(e,t)=>!Number.isNaN(parseFloat(e))&&(!(parseFloat(e)<=0)&&(!!ne&&(!!Ie&&(!t||!H)))),pt=async(e=!1)=>{lt(we,e)&&(ot&&ot.cancel(),e||z(!0),await(async(e=!1)=>{if(x&&c&&ne&&Ie){try{e||X("");const t=Re.fromAmountOut(c,x,Ie,we,ne),o=Re.fromAmountIn(c,x,ne,"1",Ie),a=Ze.all([t,o]);ot=a;const n=await a,s=n[0],i=n[1];q(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=Se(l,B),m=d?.token,w=r.find((e=>e.symbol===m?.symbol));De(s),Ve(u),Ue({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),je(F(u,w?.symbol||"",U.conversions)),ee(_(R(Se(s.quote.amount.value,s.quote.amount.token.decimals)))),rt()}catch(e){e.cancelled||(it(),Je(!1),Ke(!0))}e||z(!1)}})(e))},ut=async(e=!1)=>{G===Ye.FROM?await ct(e):await pt(e)};xe((()=>ut(!0)),O),l.useEffect((()=>{if(G===Ye.FROM){if(ae<=0)return z(!1),void it();(async()=>{await ut()})()}}),[ae,ne,Ie,le]),l.useEffect((()=>{if(G===Ye.TO){if(he<=0)return z(!1),void it();(async()=>{await ut()})()}}),[he,Ie,ne]);const mt=l.useMemo((()=>{const e=f.find((e=>e.token.address?.toLowerCase()===P));if(!e)return!0;const t=ne?.address?.toLowerCase()===P,o=Ee(0!==Ne.length?Ne:"0"),a=t&&!Number.isNaN(parseFloat(Y))?fe(Y,ne?.decimals||18):p.from("0");return o.add(a).gt(e.balance)}),[Ne,f,ne,Y]);l.useEffect((()=>{Y&&ne&&Fe(F(Y,ne.symbol,U.conversions))}),[Y,ne]);const wt=l.useCallback((e=>{const t=f.find((t=>e===b(t.token.symbol,t.token.address)));t&&(Ie&&e===b(Ie.symbol,Ie?.address)&&be(void 0),se(t.token),ie(t.formattedBalance),ce(""))}),[Ie]),ft=l.useCallback((e=>{const t=r.find((t=>e===b(t.symbol,t.address)));t&&(ne&&e===b(ne.symbol,ne?.address)&&se(void 0),be(t),Pe(""))}),[ne]);return l.useEffect((()=>{Oe&&J&&X(et({swapFromToken:ne,swapFromAmount:Y,swapToToken:Ie,swapToAmount:we,conversion:J}).fromToConversion)}),[Oe,J]),a(N,{children:[a(s,{sx:{paddingX:"base.spacing.x4",marginBottom:"base.spacing.x2"},children:[i(h,{size:"small",weight:"regular",sx:{paddingBottom:"base.spacing.x4"},children:n("views.SWAP.content.title")}),a(s,{sx:{display:"flex",flexDirection:"column",rowGap:"base.spacing.x6",paddingBottom:"base.spacing.x2"},children:[a(s,{children:[i(h,{size:"xSmall",sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:n("views.SWAP.swapForm.from.label")}),i(We,{testId:"fromTokenInputs",options:$e,selectSubtext:ne?`${n("views.SWAP.content.availableBalancePrefix")} ${R(re)}`:"",selectTextAlign:"left",textInputType:"number",textInputValue:Y,textInputPlaceholder:n("views.SWAP.swapForm.from.inputPlaceholder"),textInputSubtext:`${n("views.SWAP.content.fiatPricePrefix")} \n $${_(_e,!0)}`,textInputTextAlign:"right",textInputValidator:W,onTextInputChange:e=>{return t=e,rt(),it(),Te(""),dt(t,!1)&&z(!0),void ee(t);var t},onTextInputFocus:()=>{$(Ye.FROM)},textInputMaxButtonClick:()=>{if(!re)return;const e=re.slice(0,re.indexOf(".")+V+1);rt(),it(),$(Ye.FROM),Te(""),dt(e,!1)&&z(!0),Y===e?me(le+1):ee(e),Z({userJourney:T.SWAP,screen:"SwapCoins",control:"MaxFrom",controlType:"Button",extras:{fromBalance:re,fromBalanceTruncated:e}})},onSelectChange:wt,textInputErrorMessage:n(te),selectErrorMessage:n(de),selectedOption:ne?b(ne.symbol,ne.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.from.selectorTitle"),defaultTokenImage:I})]}),a(s,{children:[a(s,{sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:[i(h,{size:"xSmall",children:n("views.SWAP.swapForm.to.label")}),i(d,{sx:{color:"base.color.brand.4"},size:"small",children:K})]}),i(We,{testId:"toTokenInputs",options:st,selectTextAlign:"left",textInputType:"number",textInputValue:we,textInputPlaceholder:n("views.SWAP.swapForm.to.inputPlaceholder"),textInputTextAlign:"right",textInputValidator:W,onTextInputChange:e=>{return t=e,rt(),it(),Fe(""),ee(""),lt(t,!1)&&z(!0),void Te(t);var t},onTextInputFocus:()=>{$(Ye.TO)},onSelectChange:ft,textInputErrorMessage:n(ve),selectErrorMessage:n(Ce),selectedOption:Ie?b(Ie.symbol,Ie.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.to.selectorTitle"),defaultTokenImage:I})]})]}),i(pe,{gasFeeFiatValue:Me,gasFeeToken:Be,gasFeeValue:Ne,fees:[{label:n("drawers.feesBreakdown.fees.gasFeeSwap.label"),fiatAmount:`~ ${n("drawers.feesBreakdown.fees.fiatPricePrefix")}${Me}`,amount:R(Ne),prefix:"~"}],onFeesClick:()=>{Z({userJourney:T.SWAP,screen:"SwapCoins",control:"ViewFees",controlType:"Button"})},sx:{paddingBottom:"0"},loading:H})]}),i(Le,{validator:()=>{const e=function(e){return e?"":"views.SWAP.validation.noFromTokenSelected"}(ne),t=(a=re,(o=Y)&&0!==parseFloat(o)?a&&Number(o)>Number(a)?"views.SWAP.validation.insufficientBalance":"":"views.SWAP.validation.noAmountInputted");var o,a;const n=function(e){return e?"":"views.SWAP.validation.noToTokenSelected"}(Ie),s=function(e){return e&&0!==parseFloat(e)?"":"views.SWAP.validation.noAmountInputted"}(we);G===Ye.FROM?(ge(""),t&&oe(t)):G===Ye.TO&&(oe(""),s&&ge(s)),e&&ce(e),n&&Pe(n);let r=!0;return(e||n||t&&G===Ye.FROM||s&&G===Ye.TO)&&(r=!1),Z({userJourney:T.SWAP,screen:"SwapCoins",control:"FormValid",controlType:"Button",extras:{isSwapFormValid:r,swapFromAddress:ne?.address,swapFromAmount:Y,swapFromTokenSymbol:ne?.symbol,swapToAddress:Ie?.address,swapToAmount:we,swapToTokenSymbol:Ie?.symbol}}),r},updateLoading:e=>{z(e)},loading:H,transaction:Oe,data:{fromAmount:Y,toAmount:we,fromTokenSymbol:ne?.symbol,fromTokenAddress:ne?.address,toTokenSymbol:Ie?.symbol,toTokenAddress:Ie?.address},insufficientFundsForGas:mt,openNotEnoughImxDrawer:()=>{Ke(!1),Je(!0)},openNetworkSwitchDrawer:()=>nt(!0)}),i(Ge,{environment:g?.config.environment??D.PRODUCTION,visible:ze,showAdjustAmount:ne?.address===P,hasZeroImx:!1,onAddCoinsClick:()=>{j({payload:{type:A.UPDATE_VIEW,view:{type:S.TOP_UP_VIEW},currentViewData:{fromTokenAddress:ne?.address??"",fromAmount:Y,toTokenAddress:Ie?.address??""}}})},onCloseDrawer:()=>Je(!1)}),i(Xe,{visible:qe,onCloseDrawer:()=>{Ke(!1),se(void 0),ee(""),be(void 0),Te("")}}),i(ue,{visible:at,targetChainId:y(g?.config),provider:x,checkout:g,onCloseDrawer:()=>nt(!1)})]})}const nt=(e,t)=>{if(0===e.length)return!0;let o=!1;return e.forEach((e=>{e.token.symbol===t&&e.balance.eq(0)&&(o=!0)})),o};function st({theme:t,fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}){const{t:c}=e(),{viewDispatch:p}=l.useContext(u),{eventTargetState:{eventTarget:f}}=l.useContext(U),{swapState:{tokenBalances:y}}=l.useContext(ke),{connectLoaderState:{checkout:E}}=l.useContext(m),[v,g]=l.useState(!1),{page:x}=w();return l.useEffect((()=>{x({userJourney:T.SWAP,screen:"SwapCoins",extras:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}})}),[]),l.useEffect((()=>{nt(y,$)&&g(!0)}),[y]),i(G,{header:i(M,{title:c("views.SWAP.header.title"),onCloseButtonClick:()=>j(f)}),footer:i(Ie,{environment:E?.config.environment,theme:t}),children:a(s,{sx:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[i(at,{data:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d},theme:t}),i(Ge,{environment:E?.config.environment??D.PRODUCTION,visible:v,showAdjustAmount:!1,hasZeroImx:!0,onAddCoinsClick:()=>{p({payload:{type:A.UPDATE_VIEW,view:{type:S.TOP_UP_VIEW}}})},onCloseDrawer:()=>{g(!1)}})]})})}function rt({transactionResponse:t,swapForm:o}){const{t:a}=e(),{viewDispatch:n}=l.useContext(u),{page:s}=w();return l.useEffect((()=>{s({userJourney:T.SWAP,screen:"SwapInProgress",extras:{swapFormInfo:o}})}),[]),l.useEffect((()=>{(async()=>{try{const e=await t.wait();if(1===e.status)return void n({payload:{type:A.UPDATE_VIEW,view:{type:Te.SUCCESS,data:{fromTokenAddress:o.fromTokenAddress,fromAmount:o.fromAmount,toTokenAddress:o.toTokenAddress,toAmount:o.toAmount||"",transactionHash:e.transactionHash}}}});n({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,data:o,reason:"Transaction failed"}}})}catch{n({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,data:o,reason:"Transaction failed"}}})}})()}),[t]),i(H,{loadingText:a("views.SWAP.IN_PROGRESS.loading.text")})}function it({data:t}){const{t:o}=e(),{swapState:{allowedTokens:n}}=l.useContext(ke),{connectLoaderState:r}=l.useContext(m),{checkout:d,provider:c}=r,{viewDispatch:p}=l.useContext(u),{eventTargetState:{eventTarget:f}}=l.useContext(U),y=z(c),[v,g]=l.useState(!1),[x,h]=l.useState(!1),[I,b]=l.useState(!1),[C,k]=l.useState(!1),[P,R]=l.useState(!1),[_,F]=l.useState(!1),{page:O,track:W}=w();l.useEffect((()=>{O({userJourney:T.SWAP,screen:"ApproveERC20",extras:{swapFormInfo:t.swapFormInfo}})}),[]);const D=l.useMemo((()=>n.find((e=>e.address===t.swapFormInfo.fromTokenAddress))),[n,t.swapFormInfo.fromTokenAddress]),L=l.useCallback((()=>{p({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,error:new Error("No checkout object or no provider object found")}}})}),[p]),V=l.useCallback((()=>{p({payload:{type:A.UPDATE_VIEW,view:{type:Te.SWAP,data:t.swapFormInfo}}})}),[p]),B=(e,t)=>{e.type!==E.UNPREDICTABLE_GAS_LIMIT?e.type===E.TRANSACTION_FAILED||e.type===E.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status?p({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,reason:"Transaction failed",data:t}}}):p({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,error:e}}}):p({payload:{type:A.UPDATE_VIEW,view:{type:Te.PRICE_SURGE,data:t}}})},$=l.useCallback((async()=>{if(!C)if(W({userJourney:T.SWAP,screen:"ApproveERC20",control:"ApproveSpending",controlType:"Button"}),k(!0),d&&c){if(!v){g(!0);try{const e=await d.sendTransaction({provider:c,transaction:t.approveTransaction});h(!0);if(1!==(await e.transactionResponse.wait()).status)return void p({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,data:t.swapFormInfo}}});h(!1),g(!1),b(!0)}catch(e){if(h(!1),g(!1),e.type===E.USER_REJECTED_REQUEST_ERROR)return void R(!0);B(e,t.swapFormInfo)}finally{k(!1)}}}else L()}),[d,c,L,p,F,t.approveTransaction,t.swapFormInfo,v,g,h]),K=l.useMemo((()=>a(J,{heading:o(`views.APPROVE_ERC20.approveSpending.content.${y?"passport":"metamask"}.heading`),children:[y&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.passport.body")}),!y&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.metamask.body",{amount:`${t.swapFormInfo.fromAmount} ${D?.symbol||""}`})})]})),[t.swapFormInfo,D,y]),X=l.useMemo((()=>i(q,{loading:C,actionText:o(P?"views.APPROVE_ERC20.approveSpending.footer.retryText":"views.APPROVE_ERC20.approveSpending.footer.buttonText"),onActionClick:$})),[P,$,C]),Q=l.useCallback((async()=>{if(!C)if(W({userJourney:T.SWAP,screen:"ApproveERC20",control:"ApproveSwap",controlType:"Button"}),k(!0),d&&c){if(!v){g(!0);try{const e=await d.sendTransaction({provider:c,transaction:t.transaction});g(!1),p({payload:{type:A.UPDATE_VIEW,view:{type:Te.IN_PROGRESS,data:{transactionResponse:e.transactionResponse,swapForm:t.swapFormInfo}}}})}catch(e){if(g(!1),e.type===E.USER_REJECTED_REQUEST_ERROR)return void F(!0);B(e,t.swapFormInfo)}finally{k(!1)}}}else L()}),[d,c,L,p,F,t.transaction,t.swapFormInfo,v,g]),Z=i(J,{heading:o("views.APPROVE_ERC20.approveSwap.content.heading"),children:i(s,{children:o("views.APPROVE_ERC20.approveSwap.content.body")})}),Y=l.useMemo((()=>i(q,{loading:C,actionText:o(_?"views.APPROVE_ERC20.approveSwap.footer.retryText":"views.APPROVE_ERC20.approveSwap.footer.buttonText"),onActionClick:Q})),[_,Q,C]);return a(N,{children:[x&&i(H,{loadingText:o("views.APPROVE_ERC20.approveSpending.loading.text")}),!x&&i(G,{header:i(M,{transparent:!0,showBack:!0,onCloseButtonClick:()=>j(f),onBackButtonClick:V}),floatHeader:!0,heroContent:i(I?me:he,{}),footer:I?Y:X,children:I?Z:K})]})}function dt({amount:t,fromTokenAddress:o,toTokenAddress:n,config:s}){const{t:r}=e(),{eventTargetState:{eventTarget:d}}=l.useContext(U),{environment:c,theme:p,isOnRampEnabled:f,isSwapEnabled:E,isBridgeEnabled:v}=s,{connectLoaderState:{checkout:g,provider:x}}=l.useContext(m),[h,I]=l.useReducer(K,{...X,history:[]}),[b,C]=l.useReducer(Pe,be),{page:k}=w(),[P,R]=l.useState(!1),_=l.useMemo((()=>({swapState:b,swapDispatch:C})),[b,C]),F=l.useMemo((()=>({viewState:h,viewDispatch:I})),[h,I]),O=l.useCallback(((e,t)=>{I({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,tryAgain:t,error:e}}})}),[I]),W=l.useCallback((()=>{I({payload:{type:A.UPDATE_VIEW,view:{type:Te.SWAP}}})}),[I]),D=l.useCallback((async()=>{if(!g)throw new Error("loadBalances: missing checkout");if(!x)throw new Error("loadBalances: missing provider");try{const e=await we({checkout:g,provider:x,allowTokenListType:Q.SWAP});if(void 0===e)return!1;C({payload:{type:Ce.SET_ALLOWED_TOKENS,allowedTokens:e.allowList.tokens}}),C({payload:{type:Ce.SET_TOKEN_BALANCES,tokenBalances:e.allowedBalances}})}catch(e){if(Z.nonRetryable(e))return O(e,D),!1}return!0}),[g,x]);return l.useEffect((()=>{(async()=>{if(!g||!x)return;const e=await g.getNetworkInfo({provider:x});if(e.chainId!==y(g.config))return;let t;try{t=await g.config.remote.getConfig("dex")}catch(e){return void O(e)}const o=new Y({chainId:e.chainId,baseConfig:new ee({environment:c}),secondaryFees:t.secondaryFees,overrides:t.overrides});C({payload:{type:Ce.SET_EXCHANGE,exchange:o}}),C({payload:{type:Ce.SET_NETWORK,network:e}}),await D()&&h.view.type===S.LOADING_VIEW&&W()})()}),[g,x]),i(u.Provider,{value:F,children:i(ke.Provider,{value:_,children:a(ge,{environment:c,children:[h.view.type===S.LOADING_VIEW&&i(H,{loadingText:r("views.LOADING_VIEW.text")}),h.view.type===Te.SWAP&&i(st,{theme:p,fromAmount:h.view.data?.fromAmount??t,fromTokenAddress:h.view.data?.fromTokenAddress??o,toTokenAddress:h.view.data?.toTokenAddress??n}),h.view.type===Te.IN_PROGRESS&&i(rt,{transactionResponse:h.view.data.transactionResponse,swapForm:h.view.data.swapForm}),h.view.type===Te.APPROVE_ERC20&&i(it,{data:h.view.data}),h.view.type===Te.SUCCESS&&i(te,{statusText:r("views.SWAP.success.text"),actionText:r("views.SWAP.success.actionText"),onRenderEvent:()=>{k({userJourney:T.SWAP,screen:"SwapSuccess",extras:{fromTokenAddress:h.view.data?.fromTokenAddress,fromAmount:h.view.data?.fromAmount,toTokenAddress:h.view.data?.toTokenAddress,toAmount:h.view.data?.toAmount}}),oe(d,h.view.data.transactionHash)},onActionClick:()=>j(d),statusType:ae.SUCCESS,testId:"success-view"}),h.view.type===Te.FAIL&&i(te,{statusText:r("views.SWAP.failed.text"),actionText:r("views.SWAP.failed.actionText"),onRenderEvent:()=>{k({userJourney:T.SWAP,screen:"SwapFailed"}),ne(d,"Transaction failed")},onActionClick:()=>{h.view.type===Te.FAIL&&I({payload:{type:A.UPDATE_VIEW,view:{type:Te.SWAP,data:h.view.data}}})},statusType:ae.FAILURE,onCloseClick:()=>j(d),testId:"fail-view"}),h.view.type===Te.PRICE_SURGE&&i(te,{statusText:r("views.SWAP.rejected.text"),actionText:r("views.SWAP.rejected.actionText"),onRenderEvent:()=>{k({userJourney:T.SWAP,screen:"PriceSurge"}),se(d,"Price surge")},onActionClick:()=>{h.view.type===Te.PRICE_SURGE&&I({payload:{type:A.UPDATE_VIEW,view:{type:Te.SWAP,data:h.view.data}}})},statusType:ae.WARNING,onCloseClick:()=>j(d),testId:"price-surge-view"}),h.view.type===S.ERROR_VIEW&&i(re,{actionText:r("views.ERROR_VIEW.actionText"),onActionClick:async()=>{R(!0);const e=h.view;if(!e.tryAgain)return W(),void R(!1);await e.tryAgain()&&W(),R(!1)},onCloseClick:()=>j(d),errorEventActionLoading:P}),h.view.type===S.TOP_UP_VIEW&&i(ve,{analytics:{userJourney:T.SWAP},checkout:g,provider:x,widgetEvent:ie.IMTBL_SWAP_WIDGET_EVENT,showOnrampOption:f,showSwapOption:E,showBridgeOption:v,onCloseButtonClick:()=>j(d)})]})})})}export{dt as default};
1
+ import{u as e,aA as t,aB as o,j as a,aC as n,B as s,aD as r,a as i,b as d,aE as c,r as l,a4 as p,V as u,C as m,e as w,p as f,U as T,g as y,d as A,m as E,S,aF as v,ao as g,aG as x,H as h,aH as I,aI as b,k as C,l as k,aJ as P,t as R,f as _,y as F,aK as O,aL as W,a2 as D,av as N,aM as L,aN as V,aO as B,E as U,z as M,aP as j,J as G,aQ as $,a0 as H,i as z,W as J,aR as q,_ as K,$ as X,T as Q,D as Z,aS as Y,aT as ee,ax as te,aU as oe,aw as ae,aV as ne,aW as se,a1 as re,I as ie}from"./index-ab70a8f3.js";import{S as de,T as ce,a as le,F as pe,N as ue,W as me,g as we}from"./balance-a74e7655.js";import{p as fe,S as Te,C as ye,a as Ae,c as Ee,f as Se,T as ve,b as ge}from"./TopUpView-d04120e3.js";import{u as xe}from"./retry-3b188035.js";import{S as he}from"./SpendingCapHero-84219118.js";function Ie({theme:l,environment:p}){const{t:u}=e(),m=l===t.DARK?o(p,"/quickswapdark.webp"):o(p,"/quickswaplight.webp");return a(s,{testId:"quickswap-footer-container",sx:n,children:[a(s,{testId:"quickswap-logo",sx:r,children:[i(d,{size:"xSmall",sx:{paddingRight:"base.spacing.x1"},children:"By"}),i("img",{style:{height:"26px"},alt:"Quickswap logo",src:m})]}),i(d,{testId:"quickswap-footer-disclaimer-text",size:"xSmall",sx:c,children:u("footers.quickswapFooter.disclaimerText")})]})}const be={exchange:null,walletProviderName:null,network:null,tokenBalances:[],supportedTopUps:null,allowedTokens:[]};var Ce;!function(e){e.SET_EXCHANGE="SET_EXCHANGE",e.SET_WALLET_PROVIDER_NAME="SET_WALLET_PROVIDER_NAME",e.SET_NETWORK="SET_NETWORK",e.SET_SUPPORTED_TOP_UPS="SET_SUPPORTED_TOP_UPS",e.SET_TOKEN_BALANCES="SET_TOKEN_BALANCES",e.SET_ALLOWED_TOKENS="SET_ALLOWED_TOKENS"}(Ce||(Ce={}));const ke=l.createContext({swapState:be,swapDispatch:()=>{}});ke.displayName="SwapContext";const Pe=(e,t)=>{switch(t.payload.type){case Ce.SET_EXCHANGE:return{...e,exchange:t.payload.exchange};case Ce.SET_WALLET_PROVIDER_NAME:return{...e,walletProviderName:t.payload.walletProviderName};case Ce.SET_NETWORK:return{...e,network:t.payload.network};case Ce.SET_SUPPORTED_TOP_UPS:return{...e,supportedTopUps:{isSwapEnabled:t.payload.supportedTopUps.isSwapEnabled??!0,isOnRampEnabled:t.payload.supportedTopUps.isOnRampEnabled??!0,isBridgeEnabled:t.payload.supportedTopUps.isBridgeEnabled??!0}};case Ce.SET_TOKEN_BALANCES:return{...e,tokenBalances:t.payload.tokenBalances};case Ce.SET_ALLOWED_TOKENS:return{...e,allowedTokens:t.payload.allowedTokens};default:return e}},Re={fromAmountIn:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountIn(s,o.address,n.address,p.from(fe(a,o.decimals)))},fromAmountOut:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountOut(s,n.address,o.address,p.from(fe(a,o.decimals)))}},_e={display:"flex",flexDirection:"row",justifyContent:"space-between",columnGap:"base.spacing.x1"},Fe={flex:1},Oe={flex:2};function We({testId:e,options:t,textInputValue:o,textInputPlaceholder:n,textInputValidator:r,textInputType:d,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,textInputTextAlign:u,textInputSubtext:m,textInputErrorMessage:w,selectTextAlign:f,selectSubtext:T,selectErrorMessage:y,textInputMaxButtonClick:A,onSelectChange:E,textInputDisabled:S,selectInputDisabled:v,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h}){return a(s,{sx:_e,children:[i(s,{sx:Fe,children:i(de,{testId:`${e}-select-form`,options:t,subtext:T,textAlign:f,errorMessage:y,onSelectChange:E,disabled:v,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h})}),i(s,{sx:Oe,children:i(ce,{type:d,testId:`${e}-text-form`,value:o,placeholder:n,subtext:m,textAlign:u,errorMessage:w,validator:r,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,maxButtonClick:A,disabled:S})})]})}const De={display:"flex",flexDirection:"column",paddingY:"base.spacing.x6",paddingX:"base.spacing.x4"},Ne={width:"base.icon.size.400"};function Le({loading:t,updateLoading:o,validator:n,transaction:r,data:d,insufficientFundsForGas:c,openNotEnoughImxDrawer:p,openNetworkSwitchDrawer:v}){const{t:g}=e(),[x,h]=l.useState(!1),{viewDispatch:I}=l.useContext(u),{connectLoaderState:b}=l.useContext(m),{checkout:C,provider:k}=b,{track:P}=w(),R=async()=>{const e=n();if(P({userJourney:T.SWAP,screen:"SwapCoins",control:"Swap",controlType:"Button",extras:{swapFromAddress:d?.fromTokenAddress,swapFromAmount:d?.fromAmount,swapFromTokenSymbol:d?.fromTokenSymbol,swapToAddress:d?.toTokenAddress,swapToAmount:d?.toAmount,swapToTokenSymbol:d?.toTokenSymbol,isSwapFormValid:e,hasFundsForGas:!c}}),e&&C&&k&&r)if(c)p();else{try{const e=await k.provider.request({method:"eth_chainId",params:[]});if(parseInt(e.toString())!==y(C.config))return void v()}catch(e){console.error("Current network check failed",e)}if(r)try{o(!0);const e={fromAmount:d?.fromAmount||"",fromTokenAddress:d?.fromTokenAddress||"",toTokenAddress:d?.toTokenAddress||"",toAmount:d?.toAmount||""};if(r.approval)return void I({payload:{type:A.UPDATE_VIEW,view:{type:Te.APPROVE_ERC20,data:{approveTransaction:r.approval.transaction,transaction:r.swap.transaction,info:r.quote,swapFormInfo:e}}}});const t=await C.sendTransaction({provider:k,transaction:r.swap.transaction});I({payload:{type:A.UPDATE_VIEW,view:{type:Te.IN_PROGRESS,data:{transactionResponse:t.transactionResponse,swapForm:e}}}})}catch(e){if(console.error(e),o(!1),e.type===E.USER_REJECTED_REQUEST_ERROR)return void h(!0);if(e.type===E.UNPREDICTABLE_GAS_LIMIT)return void I({payload:{type:A.UPDATE_VIEW,view:{type:Te.PRICE_SURGE,data:d}}});if(e.type===E.TRANSACTION_FAILED||e.type===E.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status)return void I({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,reason:"Transaction failed",data:d}}});I({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,error:e}}})}}};return a(s,{sx:De,children:[i(f,{testId:"swap-button",disabled:t,variant:"primary",onClick:R,size:"large",children:t?i(f.Icon,{icon:"Loading",sx:Ne}):g("views.SWAP.swapForm.buttonText")}),i(le,{visible:x,showHeaderBar:!1,onCloseDrawer:()=>h(!1),onRetry:()=>{R(),h(!1)}})]})}const Ve={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x1",height:"100%"},Be={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},Ue={display:"flex",flexDirection:"column",justifyContent:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},Me={width:"100%",height:"base.spacing.x16"},je={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"};function Ge({environment:t,visible:o,showAdjustAmount:n,hasZeroImx:r,onCloseDrawer:c,onAddCoinsClick:l}){const{t:p}=e(),u=v(t);return i(g,{size:"full",onCloseDrawer:c,visible:o,showHeaderBar:!1,children:i(g.Content,{children:a(s,{testId:"not-enough-gas-bottom-sheet",sx:Ve,children:[i(x,{imageUrl:u,sx:{w:"base.icon.size.600",h:"base.icon.size.600"}}),i(h,{size:"small",sx:Be,testId:"not-enough-gas-heading",children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.heading`)}),i(d,{sx:Be,children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.body`)}),a(s,{sx:Ue,children:[n&&i(f,{testId:"not-enough-gas-adjust-amount-button",sx:Me,variant:"tertiary",onClick:c,children:p("drawers.notEnoughImx.buttons.adjustAmount")}),i(f,{testId:"not-enough-gas-add-imx-button",sx:Me,variant:"tertiary",onClick:l,children:p("drawers.notEnoughImx.buttons.addMoreImx")}),i(f,{sx:Me,variant:"tertiary",onClick:c,testId:"not-enough-gas-cancel-button",children:p("drawers.notEnoughImx.buttons.cancel")})]}),i(s,{sx:je,children:i(I,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const $e={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x4",paddingX:"base.spacing.x4",height:"100%"},He={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},ze={display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},Je={width:"100%",height:"base.spacing.x16",marginBottom:"base.spacing.x16"},qe={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"},Ke={width:"base.icon.size.600",fill:"base.color.status.fatal.bright"};function Xe({visible:t,onCloseDrawer:o}){const{t:n}=e();return i(g,{size:"full",onCloseDrawer:o,visible:t,showHeaderBar:!1,children:i(g.Content,{children:a(s,{testId:"unable-to-swap-bottom-sheet",sx:$e,children:[i(b,{icon:"Alert",testId:"unable-to-swap-icon",variant:"bold",sx:Ke}),i(h,{size:"small",sx:He,testId:"unable-to-swap-heading",children:n("drawers.unableToSwap.heading")}),i(d,{sx:He,children:n("drawers.unableToSwap.body")}),i(s,{sx:ze,children:i(f,{sx:Je,variant:"tertiary",onClick:o,testId:"unable-to-swap-cancel-button",children:n("drawers.unableToSwap.buttons.cancel")})}),i(s,{sx:qe,children:i(I,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const Qe=(e,t=500)=>{const[o,a]=l.useState(e);return l.useEffect((()=>{const o=setTimeout((()=>{a(e)}),t);return()=>{clearTimeout(o)}}),[e,t]),o};class Ze{static id=0;promiseId=0;promise;isCancelled=!1;onCancel=null;rejectPromise=()=>{};constructor(e){Ze.id+=1,this.promiseId=Ze.id,this.promise=new Promise(((t,o)=>{this.rejectPromise=o,e((e=>{this.isCancelled?o({cancelled:!0}):t(e)}),(e=>{this.isCancelled?o({cancelled:!0}):o(e)}))}))}static all(e){return new Ze(((t,o)=>{Promise.all(e.map((e=>e instanceof Ze?e.promise:e))).then(t,o)}))}then(e,t){return new Ze(((o,a)=>{this.promise.then((t=>o(e?e(t):t)),(e=>t?o(t(e)):a(e)))}))}catch(e){return this.then(void 0,e)}finally(e){return new Ze(((t,o)=>{this.promise.then(t,o).finally((()=>{e&&e()}))}))}cancel(){this.isCancelled||(this.isCancelled=!0,this.onCancel&&this.onCancel(),this.rejectPromise({cancelled:!0}))}onCancelled(e){this.onCancel=e}get cancelled(){return this.isCancelled}}var Ye;!function(e){e.FROM="FROM",e.TO="TO"}(Ye||(Ye={}));const et=({swapFromToken:e,swapToToken:t,swapFromAmount:o,swapToAmount:a,conversion:n})=>{const s={fromToConversion:"",swapToAmount:""};if(!a)return s;if(s.swapToAmount=R(a),o&&e&&t){const o=_(R(Se(n,t.decimals)),!0);s.fromToConversion=`1 ${e.symbol} ≈ ${o} ${t.symbol}`}return s},tt=(e,t)=>void 0!==e&&(""!==e&&t!==e);let ot;function at({data:t,theme:o}){const{t:n}=e(),{swapState:{allowedTokens:r,exchange:c,tokenBalances:f,network:E}}=l.useContext(ke),{connectLoaderState:v}=l.useContext(m),{checkout:g,provider:x}=v,I=C(g?.config.environment,o),b=l.useCallback(((e,t)=>k(t)?`${e.toLowerCase()}-${P}`:`${e.toLowerCase()}-${t.toLowerCase()}`),[]),{cryptoFiatState:U,cryptoFiatDispatch:M}=l.useContext(ye),{viewDispatch:j}=l.useContext(u),[G,$]=l.useState(Ye.FROM),[H,z]=l.useState(!1),[J,q]=l.useState(p.from(0)),[K,X]=l.useState(""),Q=l.useRef(!1),{track:Z}=w(),[Y,ee]=l.useState(t?.fromAmount||""),[te,oe]=l.useState(""),ae=Qe(Y,L),[ne,se]=l.useState(),[re,ie]=l.useState(""),[de,ce]=l.useState(""),[le,me]=l.useState(0),[we,Te]=l.useState(t?.toAmount||""),[ve,ge]=l.useState(""),he=Qe(we,L),[Ie,be]=l.useState(),[Ce,Pe]=l.useState(""),[_e,Fe]=l.useState(""),[Oe,De]=l.useState(null),[Ne,Ve]=l.useState(""),[Be,Ue]=l.useState(void 0),[Me,je]=l.useState(""),[$e,He]=l.useState([]),[ze,Je]=l.useState(!1),[qe,Ke]=l.useState(!1),[at,nt]=l.useState(!1);l.useEffect((()=>{if(0===f.length)return;if(!E)return;const e=f.filter((e=>e.balance.gt(0))).map((e=>({id:b(e.token.symbol,e.token.address),name:e.token.name,symbol:e.token.symbol,icon:e.token.icon,balance:{formattedAmount:R(e.formattedBalance),formattedFiatAmount:0===U.conversions.size?_(""):F(e.formattedBalance,e.token.symbol||"",U.conversions)}})));He(e),Q.current||(Q.current=!0,t?.fromTokenAddress&&(se(r.find((e=>k(e.address)&&t?.fromTokenAddress?.toLowerCase()===P||e.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))),ie(f.find((e=>k(e.token.address)&&t?.fromTokenAddress?.toLowerCase()===P||e.token.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))?.formattedBalance??"")),tt(t?.toTokenAddress,t?.fromTokenAddress)&&be(r.find((e=>k(e.address)&&t?.toTokenAddress?.toLowerCase()===P||e.address?.toLowerCase()===t?.toTokenAddress?.toLowerCase()))))}),[f,r,U.conversions,t?.fromTokenAddress,t?.toTokenAddress,Q.current,se,ie,be,He,b,_,E]);const st=l.useMemo((()=>r.map((e=>({id:b(e.symbol,e.address),name:e.name,symbol:e.symbol,icon:e.icon})))),[r,ne]);l.useEffect((()=>{M({payload:{type:Ae.SET_TOKEN_SYMBOLS,tokenSymbols:r.map((e=>e.symbol))}})}),[M,r]);const rt=()=>{oe(""),ce(""),ge(""),Pe("")},it=()=>{ot&&ot.cancel(),X(""),je(""),De(null)},dt=(e,t)=>!Number.isNaN(parseFloat(e))&&(!(parseFloat(e)<=0)&&(!!ne&&(!!Ie&&(!t||!H)))),ct=async(e=!1)=>{dt(Y,e)&&(ot&&ot.cancel(),e||z(!0),await(async(e=!1)=>{if(x&&c&&ne&&Ie){try{e||X("");const t=Re.fromAmountIn(c,x,ne,Y,Ie),o=Re.fromAmountIn(c,x,ne,"1",Ie),a=Ze.all([t,o]);ot=a;const n=await a,s=n[0],i=n[1];q(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=Se(l,B),m=d?.token,w=r.find((e=>e.address?.toLocaleLowerCase()===m?.address?.toLocaleLowerCase()));De(s),Ve(u),Ue({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),je(F(u,w?.symbol||"",U.conversions)),Te(_(R(Se(s.quote.amount.value,s.quote.amount.token.decimals),s.quote.amount.token.decimals))),rt()}catch(e){e.cancelled||(it(),Je(!1),Ke(!0))}e||z(!1)}})(e))},lt=(e,t)=>!Number.isNaN(parseFloat(e))&&(!(parseFloat(e)<=0)&&(!!ne&&(!!Ie&&(!t||!H)))),pt=async(e=!1)=>{lt(we,e)&&(ot&&ot.cancel(),e||z(!0),await(async(e=!1)=>{if(x&&c&&ne&&Ie){try{e||X("");const t=Re.fromAmountOut(c,x,Ie,we,ne),o=Re.fromAmountIn(c,x,ne,"1",Ie),a=Ze.all([t,o]);ot=a;const n=await a,s=n[0],i=n[1];q(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=Se(l,B),m=d?.token,w=r.find((e=>e.symbol===m?.symbol));De(s),Ve(u),Ue({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),je(F(u,w?.symbol||"",U.conversions)),ee(_(R(Se(s.quote.amount.value,s.quote.amount.token.decimals)))),rt()}catch(e){e.cancelled||(it(),Je(!1),Ke(!0))}e||z(!1)}})(e))},ut=async(e=!1)=>{G===Ye.FROM?await ct(e):await pt(e)};xe((()=>ut(!0)),O),l.useEffect((()=>{if(G===Ye.FROM){if(ae<=0)return z(!1),void it();(async()=>{await ut()})()}}),[ae,ne,Ie,le]),l.useEffect((()=>{if(G===Ye.TO){if(he<=0)return z(!1),void it();(async()=>{await ut()})()}}),[he,Ie,ne]);const mt=l.useMemo((()=>{const e=f.find((e=>e.token.address?.toLowerCase()===P));if(!e)return!0;const t=ne?.address?.toLowerCase()===P,o=Ee(0!==Ne.length?Ne:"0"),a=t&&!Number.isNaN(parseFloat(Y))?fe(Y,ne?.decimals||18):p.from("0");return o.add(a).gt(e.balance)}),[Ne,f,ne,Y]);l.useEffect((()=>{Y&&ne&&Fe(F(Y,ne.symbol,U.conversions))}),[Y,ne]);const wt=l.useCallback((e=>{const t=f.find((t=>e===b(t.token.symbol,t.token.address)));t&&(Ie&&e===b(Ie.symbol,Ie?.address)&&be(void 0),se(t.token),ie(t.formattedBalance),ce(""))}),[Ie]),ft=l.useCallback((e=>{const t=r.find((t=>e===b(t.symbol,t.address)));t&&(ne&&e===b(ne.symbol,ne?.address)&&se(void 0),be(t),Pe(""))}),[ne]);return l.useEffect((()=>{Oe&&J&&X(et({swapFromToken:ne,swapFromAmount:Y,swapToToken:Ie,swapToAmount:we,conversion:J}).fromToConversion)}),[Oe,J]),a(N,{children:[a(s,{sx:{paddingX:"base.spacing.x4",marginBottom:"base.spacing.x2"},children:[i(h,{size:"small",weight:"regular",sx:{paddingBottom:"base.spacing.x4"},children:n("views.SWAP.content.title")}),a(s,{sx:{display:"flex",flexDirection:"column",rowGap:"base.spacing.x6",paddingBottom:"base.spacing.x2"},children:[a(s,{children:[i(h,{size:"xSmall",sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:n("views.SWAP.swapForm.from.label")}),i(We,{testId:"fromTokenInputs",options:$e,selectSubtext:ne?`${n("views.SWAP.content.availableBalancePrefix")} ${R(re)}`:"",selectTextAlign:"left",textInputType:"number",textInputValue:Y,textInputPlaceholder:n("views.SWAP.swapForm.from.inputPlaceholder"),textInputSubtext:`${n("views.SWAP.content.fiatPricePrefix")} \n $${_(_e,!0)}`,textInputTextAlign:"right",textInputValidator:W,onTextInputChange:e=>{return t=e,rt(),it(),Te(""),dt(t,!1)&&z(!0),void ee(t);var t},onTextInputFocus:()=>{$(Ye.FROM)},textInputMaxButtonClick:()=>{if(!re)return;const e=re.slice(0,re.indexOf(".")+V+1);rt(),it(),$(Ye.FROM),Te(""),dt(e,!1)&&z(!0),Y===e?me(le+1):ee(e),Z({userJourney:T.SWAP,screen:"SwapCoins",control:"MaxFrom",controlType:"Button",extras:{fromBalance:re,fromBalanceTruncated:e}})},onSelectChange:wt,textInputErrorMessage:n(te),selectErrorMessage:n(de),selectedOption:ne?b(ne.symbol,ne.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.from.selectorTitle"),defaultTokenImage:I})]}),a(s,{children:[a(s,{sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:[i(h,{size:"xSmall",children:n("views.SWAP.swapForm.to.label")}),i(d,{sx:{color:"base.color.brand.4"},size:"small",children:K})]}),i(We,{testId:"toTokenInputs",options:st,selectTextAlign:"left",textInputType:"number",textInputValue:we,textInputPlaceholder:n("views.SWAP.swapForm.to.inputPlaceholder"),textInputTextAlign:"right",textInputValidator:W,onTextInputChange:e=>{return t=e,rt(),it(),Fe(""),ee(""),lt(t,!1)&&z(!0),void Te(t);var t},onTextInputFocus:()=>{$(Ye.TO)},onSelectChange:ft,textInputErrorMessage:n(ve),selectErrorMessage:n(Ce),selectedOption:Ie?b(Ie.symbol,Ie.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.to.selectorTitle"),defaultTokenImage:I})]})]}),i(pe,{gasFeeFiatValue:Me,gasFeeToken:Be,gasFeeValue:Ne,fees:[{label:n("drawers.feesBreakdown.fees.gasFeeSwap.label"),fiatAmount:`~ ${n("drawers.feesBreakdown.fees.fiatPricePrefix")}${Me}`,amount:R(Ne),prefix:"~"}],onFeesClick:()=>{Z({userJourney:T.SWAP,screen:"SwapCoins",control:"ViewFees",controlType:"Button"})},sx:{paddingBottom:"0"},loading:H})]}),i(Le,{validator:()=>{const e=function(e){return e?"":"views.SWAP.validation.noFromTokenSelected"}(ne),t=(a=re,(o=Y)&&0!==parseFloat(o)?a&&Number(o)>Number(a)?"views.SWAP.validation.insufficientBalance":"":"views.SWAP.validation.noAmountInputted");var o,a;const n=function(e){return e?"":"views.SWAP.validation.noToTokenSelected"}(Ie),s=function(e){return e&&0!==parseFloat(e)?"":"views.SWAP.validation.noAmountInputted"}(we);G===Ye.FROM?(ge(""),t&&oe(t)):G===Ye.TO&&(oe(""),s&&ge(s)),e&&ce(e),n&&Pe(n);let r=!0;return(e||n||t&&G===Ye.FROM||s&&G===Ye.TO)&&(r=!1),Z({userJourney:T.SWAP,screen:"SwapCoins",control:"FormValid",controlType:"Button",extras:{isSwapFormValid:r,swapFromAddress:ne?.address,swapFromAmount:Y,swapFromTokenSymbol:ne?.symbol,swapToAddress:Ie?.address,swapToAmount:we,swapToTokenSymbol:Ie?.symbol}}),r},updateLoading:e=>{z(e)},loading:H,transaction:Oe,data:{fromAmount:Y,toAmount:we,fromTokenSymbol:ne?.symbol,fromTokenAddress:ne?.address,toTokenSymbol:Ie?.symbol,toTokenAddress:Ie?.address},insufficientFundsForGas:mt,openNotEnoughImxDrawer:()=>{Ke(!1),Je(!0)},openNetworkSwitchDrawer:()=>nt(!0)}),i(Ge,{environment:g?.config.environment??D.PRODUCTION,visible:ze,showAdjustAmount:ne?.address===P,hasZeroImx:!1,onAddCoinsClick:()=>{j({payload:{type:A.UPDATE_VIEW,view:{type:S.TOP_UP_VIEW},currentViewData:{fromTokenAddress:ne?.address??"",fromAmount:Y,toTokenAddress:Ie?.address??""}}})},onCloseDrawer:()=>Je(!1)}),i(Xe,{visible:qe,onCloseDrawer:()=>{Ke(!1),se(void 0),ee(""),be(void 0),Te("")}}),i(ue,{visible:at,targetChainId:y(g?.config),provider:x,checkout:g,onCloseDrawer:()=>nt(!1)})]})}const nt=(e,t)=>{if(0===e.length)return!0;let o=!1;return e.forEach((e=>{e.token.symbol===t&&e.balance.eq(0)&&(o=!0)})),o};function st({theme:t,fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}){const{t:c}=e(),{viewDispatch:p}=l.useContext(u),{eventTargetState:{eventTarget:f}}=l.useContext(U),{swapState:{tokenBalances:y}}=l.useContext(ke),{connectLoaderState:{checkout:E}}=l.useContext(m),[v,g]=l.useState(!1),{page:x}=w();return l.useEffect((()=>{x({userJourney:T.SWAP,screen:"SwapCoins",extras:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}})}),[]),l.useEffect((()=>{nt(y,$)&&g(!0)}),[y]),i(G,{header:i(M,{title:c("views.SWAP.header.title"),onCloseButtonClick:()=>j(f)}),footer:i(Ie,{environment:E?.config.environment,theme:t}),children:a(s,{sx:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[i(at,{data:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d},theme:t}),i(Ge,{environment:E?.config.environment??D.PRODUCTION,visible:v,showAdjustAmount:!1,hasZeroImx:!0,onAddCoinsClick:()=>{p({payload:{type:A.UPDATE_VIEW,view:{type:S.TOP_UP_VIEW}}})},onCloseDrawer:()=>{g(!1)}})]})})}function rt({transactionResponse:t,swapForm:o}){const{t:a}=e(),{viewDispatch:n}=l.useContext(u),{page:s}=w();return l.useEffect((()=>{s({userJourney:T.SWAP,screen:"SwapInProgress",extras:{swapFormInfo:o}})}),[]),l.useEffect((()=>{(async()=>{try{const e=await t.wait();if(1===e.status)return void n({payload:{type:A.UPDATE_VIEW,view:{type:Te.SUCCESS,data:{fromTokenAddress:o.fromTokenAddress,fromAmount:o.fromAmount,toTokenAddress:o.toTokenAddress,toAmount:o.toAmount||"",transactionHash:e.transactionHash}}}});n({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,data:o,reason:"Transaction failed"}}})}catch{n({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,data:o,reason:"Transaction failed"}}})}})()}),[t]),i(H,{loadingText:a("views.SWAP.IN_PROGRESS.loading.text")})}function it({data:t}){const{t:o}=e(),{swapState:{allowedTokens:n}}=l.useContext(ke),{connectLoaderState:r}=l.useContext(m),{checkout:d,provider:c}=r,{viewDispatch:p}=l.useContext(u),{eventTargetState:{eventTarget:f}}=l.useContext(U),y=z(c),[v,g]=l.useState(!1),[x,h]=l.useState(!1),[I,b]=l.useState(!1),[C,k]=l.useState(!1),[P,R]=l.useState(!1),[_,F]=l.useState(!1),{page:O,track:W}=w();l.useEffect((()=>{O({userJourney:T.SWAP,screen:"ApproveERC20",extras:{swapFormInfo:t.swapFormInfo}})}),[]);const D=l.useMemo((()=>n.find((e=>e.address===t.swapFormInfo.fromTokenAddress))),[n,t.swapFormInfo.fromTokenAddress]),L=l.useCallback((()=>{p({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,error:new Error("No checkout object or no provider object found")}}})}),[p]),V=l.useCallback((()=>{p({payload:{type:A.UPDATE_VIEW,view:{type:Te.SWAP,data:t.swapFormInfo}}})}),[p]),B=(e,t)=>{e.type!==E.UNPREDICTABLE_GAS_LIMIT?e.type===E.TRANSACTION_FAILED||e.type===E.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status?p({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,reason:"Transaction failed",data:t}}}):p({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,error:e}}}):p({payload:{type:A.UPDATE_VIEW,view:{type:Te.PRICE_SURGE,data:t}}})},$=l.useCallback((async()=>{if(!C)if(W({userJourney:T.SWAP,screen:"ApproveERC20",control:"ApproveSpending",controlType:"Button"}),k(!0),d&&c){if(!v){g(!0);try{const e=await d.sendTransaction({provider:c,transaction:t.approveTransaction});h(!0);if(1!==(await e.transactionResponse.wait()).status)return void p({payload:{type:A.UPDATE_VIEW,view:{type:Te.FAIL,data:t.swapFormInfo}}});h(!1),g(!1),b(!0)}catch(e){if(h(!1),g(!1),e.type===E.USER_REJECTED_REQUEST_ERROR)return void R(!0);B(e,t.swapFormInfo)}finally{k(!1)}}}else L()}),[d,c,L,p,F,t.approveTransaction,t.swapFormInfo,v,g,h]),K=l.useMemo((()=>a(J,{heading:o(`views.APPROVE_ERC20.approveSpending.content.${y?"passport":"metamask"}.heading`),children:[y&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.passport.body")}),!y&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.metamask.body",{amount:`${t.swapFormInfo.fromAmount} ${D?.symbol||""}`})})]})),[t.swapFormInfo,D,y]),X=l.useMemo((()=>i(q,{loading:C,actionText:o(P?"views.APPROVE_ERC20.approveSpending.footer.retryText":"views.APPROVE_ERC20.approveSpending.footer.buttonText"),onActionClick:$})),[P,$,C]),Q=l.useCallback((async()=>{if(!C)if(W({userJourney:T.SWAP,screen:"ApproveERC20",control:"ApproveSwap",controlType:"Button"}),k(!0),d&&c){if(!v){g(!0);try{const e=await d.sendTransaction({provider:c,transaction:t.transaction});g(!1),p({payload:{type:A.UPDATE_VIEW,view:{type:Te.IN_PROGRESS,data:{transactionResponse:e.transactionResponse,swapForm:t.swapFormInfo}}}})}catch(e){if(g(!1),e.type===E.USER_REJECTED_REQUEST_ERROR)return void F(!0);B(e,t.swapFormInfo)}finally{k(!1)}}}else L()}),[d,c,L,p,F,t.transaction,t.swapFormInfo,v,g]),Z=i(J,{heading:o("views.APPROVE_ERC20.approveSwap.content.heading"),children:i(s,{children:o("views.APPROVE_ERC20.approveSwap.content.body")})}),Y=l.useMemo((()=>i(q,{loading:C,actionText:o(_?"views.APPROVE_ERC20.approveSwap.footer.retryText":"views.APPROVE_ERC20.approveSwap.footer.buttonText"),onActionClick:Q})),[_,Q,C]);return a(N,{children:[x&&i(H,{loadingText:o("views.APPROVE_ERC20.approveSpending.loading.text")}),!x&&i(G,{header:i(M,{transparent:!0,showBack:!0,onCloseButtonClick:()=>j(f),onBackButtonClick:V}),floatHeader:!0,heroContent:i(I?me:he,{}),footer:I?Y:X,children:I?Z:K})]})}function dt({amount:t,fromTokenAddress:o,toTokenAddress:n,config:s}){const{t:r}=e(),{eventTargetState:{eventTarget:d}}=l.useContext(U),{environment:c,theme:p,isOnRampEnabled:f,isSwapEnabled:E,isBridgeEnabled:v}=s,{connectLoaderState:{checkout:g,provider:x}}=l.useContext(m),[h,I]=l.useReducer(K,{...X,history:[]}),[b,C]=l.useReducer(Pe,be),{page:k}=w(),[P,R]=l.useState(!1),_=l.useMemo((()=>({swapState:b,swapDispatch:C})),[b,C]),F=l.useMemo((()=>({viewState:h,viewDispatch:I})),[h,I]),O=l.useCallback(((e,t)=>{I({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,tryAgain:t,error:e}}})}),[I]),W=l.useCallback((()=>{I({payload:{type:A.UPDATE_VIEW,view:{type:Te.SWAP}}})}),[I]),D=l.useCallback((async()=>{if(!g)throw new Error("loadBalances: missing checkout");if(!x)throw new Error("loadBalances: missing provider");try{const e=await we({checkout:g,provider:x,allowTokenListType:Q.SWAP});if(void 0===e)return!1;C({payload:{type:Ce.SET_ALLOWED_TOKENS,allowedTokens:e.allowList.tokens}}),C({payload:{type:Ce.SET_TOKEN_BALANCES,tokenBalances:e.allowedBalances}})}catch(e){if(Z.nonRetryable(e))return O(e,D),!1}return!0}),[g,x]);return l.useEffect((()=>{(async()=>{if(!g||!x)return;const e=await g.getNetworkInfo({provider:x});if(e.chainId!==y(g.config))return;let t;try{t=await g.config.remote.getConfig("dex")}catch(e){return void O(e)}const o=new Y({chainId:e.chainId,baseConfig:new ee({environment:c}),secondaryFees:t.secondaryFees,overrides:t.overrides});C({payload:{type:Ce.SET_EXCHANGE,exchange:o}}),C({payload:{type:Ce.SET_NETWORK,network:e}}),await D()&&h.view.type===S.LOADING_VIEW&&W()})()}),[g,x]),i(u.Provider,{value:F,children:i(ke.Provider,{value:_,children:a(ge,{environment:c,children:[h.view.type===S.LOADING_VIEW&&i(H,{loadingText:r("views.LOADING_VIEW.text")}),h.view.type===Te.SWAP&&i(st,{theme:p,fromAmount:h.view.data?.fromAmount??t,fromTokenAddress:h.view.data?.fromTokenAddress??o,toTokenAddress:h.view.data?.toTokenAddress??n}),h.view.type===Te.IN_PROGRESS&&i(rt,{transactionResponse:h.view.data.transactionResponse,swapForm:h.view.data.swapForm}),h.view.type===Te.APPROVE_ERC20&&i(it,{data:h.view.data}),h.view.type===Te.SUCCESS&&i(te,{statusText:r("views.SWAP.success.text"),actionText:r("views.SWAP.success.actionText"),onRenderEvent:()=>{k({userJourney:T.SWAP,screen:"SwapSuccess",extras:{fromTokenAddress:h.view.data?.fromTokenAddress,fromAmount:h.view.data?.fromAmount,toTokenAddress:h.view.data?.toTokenAddress,toAmount:h.view.data?.toAmount}}),oe(d,h.view.data.transactionHash)},onActionClick:()=>j(d),statusType:ae.SUCCESS,testId:"success-view"}),h.view.type===Te.FAIL&&i(te,{statusText:r("views.SWAP.failed.text"),actionText:r("views.SWAP.failed.actionText"),onRenderEvent:()=>{k({userJourney:T.SWAP,screen:"SwapFailed"}),ne(d,"Transaction failed")},onActionClick:()=>{h.view.type===Te.FAIL&&I({payload:{type:A.UPDATE_VIEW,view:{type:Te.SWAP,data:h.view.data}}})},statusType:ae.FAILURE,onCloseClick:()=>j(d),testId:"fail-view"}),h.view.type===Te.PRICE_SURGE&&i(te,{statusText:r("views.SWAP.rejected.text"),actionText:r("views.SWAP.rejected.actionText"),onRenderEvent:()=>{k({userJourney:T.SWAP,screen:"PriceSurge"}),se(d,"Price surge")},onActionClick:()=>{h.view.type===Te.PRICE_SURGE&&I({payload:{type:A.UPDATE_VIEW,view:{type:Te.SWAP,data:h.view.data}}})},statusType:ae.WARNING,onCloseClick:()=>j(d),testId:"price-surge-view"}),h.view.type===S.ERROR_VIEW&&i(re,{actionText:r("views.ERROR_VIEW.actionText"),onActionClick:async()=>{R(!0);const e=h.view;if(!e.tryAgain)return W(),void R(!1);await e.tryAgain()&&W(),R(!1)},onCloseClick:()=>j(d),errorEventActionLoading:P}),h.view.type===S.TOP_UP_VIEW&&i(ve,{analytics:{userJourney:T.SWAP},checkout:g,provider:x,widgetEvent:ie.IMTBL_SWAP_WIDGET_EVENT,showOnrampOption:f,showSwapOption:E,showBridgeOption:v,onCloseButtonClick:()=>j(d)})]})})})}export{dt as default};
@@ -1 +1 @@
1
- import{a4 as t,bN as e,d2 as o,bR as n,d3 as r,bq as i,d4 as s,r as a,a2 as c,bl as l,a as u,j as f,M as d,B as m,u as h,V as E,E as g,e as p,cB as S,z as _,G as v,H as w,b as A,J as b,I,d as T,o as C}from"./index-a91d7cc6.js";const y=new e(o),O={},R=t.from(0),x=t.from(-1);function N(t,o,n,r){const i={fault:o,operation:n};return void 0!==r&&(i.value=r),y.throwError(t,e.errors.NUMERIC_FAULT,i)}let F="0";for(;F.length<256;)F+=F;function P(e){if("number"!=typeof e)try{e=t.from(e).toNumber()}catch(t){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+F.substring(0,e):y.throwArgumentError("invalid decimal size","decimals",e)}function L(e,o){null==o&&(o=0);const n=P(o),r=(e=t.from(e)).lt(R);r&&(e=e.mul(x));let i=e.mod(n).toString();for(;i.length<n.length-1;)i="0"+i;i=i.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=e.div(n).toString();return e=1===n.length?s:s+"."+i,r&&(e="-"+e),e}function U(e,o){null==o&&(o=0);const n=P(o);"string"==typeof e&&e.match(/^-?[0-9.]+$/)||y.throwArgumentError("invalid decimal value","value",e);const r="-"===e.substring(0,1);r&&(e=e.substring(1)),"."===e&&y.throwArgumentError("missing value","value",e);const i=e.split(".");i.length>2&&y.throwArgumentError("too many decimal points","value",e);let s=i[0],a=i[1];for(s||(s="0"),a||(a="0");"0"===a[a.length-1];)a=a.substring(0,a.length-1);for(a.length>n.length-1&&N("fractional component exceeds decimals","underflow","parseFixed"),""===a&&(a="0");a.length<n.length-1;)a+="0";const c=t.from(s),l=t.from(a);let u=c.mul(n).add(l);return r&&(u=u.mul(x)),u}class W{constructor(t,o,n,r){t!==O&&y.throwError("cannot use FixedFormat constructor; use FixedFormat.from",e.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=o,this.width=n,this.decimals=r,this.name=(o?"":"u")+"fixed"+String(n)+"x"+String(r),this._multiplier=P(r),Object.freeze(this)}static from(t){if(t instanceof W)return t;"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,o=128,n=18;if("string"==typeof t)if("fixed"===t);else if("ufixed"===t)e=!1;else{const r=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);r||y.throwArgumentError("invalid fixed format","format",t),e="u"!==r[1],o=parseInt(r[2]),n=parseInt(r[3])}else if(t){const r=(e,o,n)=>null==t[e]?n:(typeof t[e]!==o&&y.throwArgumentError("invalid fixed format ("+e+" not "+o+")","format."+e,t[e]),t[e]);e=r("signed","boolean",e),o=r("width","number",o),n=r("decimals","number",n)}return o%8&&y.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",o),n>80&&y.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new W(O,e,o,n)}}class k{constructor(t,o,n,r){t!==O&&y.throwError("cannot use FixedNumber constructor; use FixedNumber.from",e.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=r,this._hex=o,this._value=n,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&y.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const e=U(this._value,this.format.decimals),o=U(t._value,t.format.decimals);return k.fromValue(e.add(o),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const e=U(this._value,this.format.decimals),o=U(t._value,t.format.decimals);return k.fromValue(e.sub(o),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const e=U(this._value,this.format.decimals),o=U(t._value,t.format.decimals);return k.fromValue(e.mul(o).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const e=U(this._value,this.format.decimals),o=U(t._value,t.format.decimals);return k.fromValue(e.mul(this.format._multiplier).div(o),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=k.from(t[0],this.format);const o=!t[1].match(/^(0*)$/);return this.isNegative()&&o&&(e=e.subUnsafe(B.toFormat(e.format))),e}ceiling(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=k.from(t[0],this.format);const o=!t[1].match(/^(0*)$/);return!this.isNegative()&&o&&(e=e.addUnsafe(B.toFormat(e.format))),e}round(t){null==t&&(t=0);const e=this.toString().split(".");if(1===e.length&&e.push("0"),(t<0||t>80||t%1)&&y.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;const o=k.from("1"+F.substring(0,t),this.format),n=D.toFormat(this.format);return this.mulUnsafe(o).addUnsafe(n).floor().divUnsafe(o)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(e){if(null==e)return this._hex;e%8&&y.throwArgumentError("invalid byte width","width",e);const o=t.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return n(o,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return k.fromString(this._value,t)}static fromValue(t,e,o){return null!=o||null==e||r(e)||(o=e,e=null),null==e&&(e=0),null==o&&(o="fixed"),k.fromString(L(t,e),W.from(o))}static fromString(t,e){null==e&&(e="fixed");const o=W.from(e),r=U(t,o.decimals);!o.signed&&r.lt(R)&&N("unsigned value cannot be negative","overflow","value",t);let i=null;o.signed?i=r.toTwos(o.width).toHexString():(i=r.toHexString(),i=n(i,o.width/8));const s=L(r,o.decimals);return new k(O,i,s,o)}static fromBytes(e,o){null==o&&(o="fixed");const n=W.from(o);if(i(e).length>n.width/8)throw new Error("overflow");let r=t.from(e);n.signed&&(r=r.fromTwos(n.width));const s=r.toTwos((n.signed?0:1)+n.width).toHexString(),a=L(r,n.decimals);return new k(O,s,a,n)}static from(t,o){if("string"==typeof t)return k.fromString(t,o);if(s(t))return k.fromBytes(t,o);try{return k.fromValue(t,0,o)}catch(t){if(t.code!==e.errors.INVALID_ARGUMENT)throw t}return y.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const B=k.from(1),D=k.from("0.5"),M=new e("units/5.7.0"),$=["wei","kwei","mwei","gwei","szabo","finney","ether"];function V(t,e){if("string"==typeof e){const t=$.indexOf(e);-1!==t&&(e=3*t)}return L(t,null!=e?e:18)}function G(t,e){if("string"!=typeof t&&M.throwArgumentError("value must be a string","value",t),"string"==typeof e){const t=$.indexOf(e);-1!==t&&(e=3*t)}return U(t,null!=e?e:18)}function H(t){return G(t,18)}var K,Y=Object.freeze({__proto__:null,commify:function(t){const e=String(t).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||"."===t||"-."===t)&&M.throwArgumentError("invalid value","value",t);let o=e[0],n="";for("-"===o.substring(0,1)&&(n="-",o=o.substring(1));"0"===o.substring(0,1);)o=o.substring(1);""===o&&(o="0");let r="";for(2===e.length&&(r="."+(e[1]||"0"));r.length>2&&"0"===r[r.length-1];)r=r.substring(0,r.length-1);const i=[];for(;o.length;){if(o.length<=3){i.unshift(o);break}{const t=o.length-3;i.unshift(o.substring(t)),o=o.substring(0,t)}}return n+i.join(",")+r},formatEther:function(t){return V(t,18)},formatUnits:V,parseEther:H,parseUnits:G});!function(t){t.USD="usd"}(K||(K={}));const z={cryptoFiat:null,fiatSymbol:K.USD,tokenSymbols:[],conversions:new Map};var j;!function(t){t.SET_CRYPTO_FIAT="SET_CRYPTO_FIAT",t.SET_FIAT_SYMBOL="SET_FIAT_SYMBOL",t.SET_TOKEN_SYMBOLS="SET_TOKEN_SYMBOLS",t.SET_CONVERSIONS="SET_CONVERSIONS"}(j||(j={}));const q=a.createContext({cryptoFiatState:z,cryptoFiatDispatch:()=>{}}),J=(t,e)=>{switch(e.payload.type){case j.SET_CRYPTO_FIAT:return{...t,cryptoFiat:e.payload.cryptoFiat};case j.SET_FIAT_SYMBOL:return{...t,fiatSymbol:e.payload.fiatSymbol};case j.SET_TOKEN_SYMBOLS:return{...t,tokenSymbols:e.payload.tokenSymbols};case j.SET_CONVERSIONS:return{...t,conversions:e.payload.conversions};default:return t}};var X;!function(t){t.SWAP="SWAP",t.IN_PROGRESS="IN_PROGRESS",t.SUCCESS="SUCCESS",t.FAIL="FAIL",t.PRICE_SURGE="PRICE_SURGE",t.APPROVE_ERC20="APPROVE_ERC20_SWAP"}(X||(X={}));class Z{baseConfig;constructor({baseConfig:t}){this.baseConfig=t}}const Q={[c.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[c.PRODUCTION]:"https://checkout-api.immutable.com"};class tt{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig}urlWithPath(t){return Q[this.config.environment]+t}async fetchOverrides(){if(null!==this.overridesCache)return;const t=this.urlWithPath("/v1/fiat/coins/overrides"),e=await l.get(t);if(200!==e.status)throw new Error(`Error fetching coins overrides: ${e.status} ${e.statusText}`);this.overridesCache=new Map(Object.entries(e.data))}async fetchCoins(){if(null!==this.coinsCache)return;await this.fetchOverrides();const t=this.urlWithPath("/v1/fiat/coins/all"),e=await l.get(t);if(200!==e.status)throw new Error(`Error fetching coins list: ${e.status} ${e.statusText}`);const{data:o}=e;this.coinsCache=new Map;for(const t of o){const e=this.overridesCache.get(t.symbol.toLowerCase());this.coinsCache.set(t.symbol.toLowerCase(),e||t.id.toLowerCase())}}async convert({tokenSymbols:t,fiatSymbols:e=[]}){if(!t||0===t.length)throw new Error("Error missing token symbols to convert");const o=e.filter((t=>""!==t));0===o.length&&o.push("usd"),await this.fetchCoins();const n=t.map((t=>this.coinsCache.get(t.toLowerCase()))).filter((t=>""!==t&&void 0!==t)).join(","),r=o.join(",").toLowerCase(),i=this.urlWithPath(`/v1/fiat/conversion?ids=${n}&currencies=${r}`),s=await l.get(i);if(200!==s.status)throw new Error(`Error fetching prices: ${s.status} ${s.statusText}`);const{data:a}=s,c={};for(const e of t){const t=e.toLowerCase(),o=this.coinsCache.get(t);c[t]={},o&&(c[t]=a[o]||{})}return c}}const et=async(t,e,o)=>{try{if(0===o.length)return new Map;return((t,e)=>{const o=new Map;for(const n in t){const r=t[n][e];void 0!==r&&o.set(n,r)}return o})(await t.convert({tokenSymbols:o,fiatSymbol:e}),e)}catch(t){return new Map}},ot=["ETH","IMX"];function nt({environment:t,children:e}){const[o,n]=a.useReducer(J,z),{cryptoFiat:r,fiatSymbol:i,tokenSymbols:s}=o;return a.useEffect((()=>{n({payload:{type:j.SET_CRYPTO_FIAT,cryptoFiat:new tt(new Z({baseConfig:{environment:t}}))}})}),[]),a.useEffect((()=>{r&&i&&(async()=>{const t=await et(r,i,[...new Set([...s,...ot])]);n({payload:{type:j.SET_CONVERSIONS,conversions:t}})})()}),[r,s,i]),u(q.Provider,{value:{cryptoFiatState:o,cryptoFiatDispatch:n},children:e})}var rt;!function(t){t.WALLET_NETWORK_SELECTION="WALLET_NETWORK_SELECTION",t.BRIDGE_FORM="BRIDGE_FORM",t.BRIDGE_REVIEW="BRIDGE_REVIEW",t.IN_PROGRESS="IN_PROGRESS",t.BRIDGE_FAILURE="BRIDGE_FAILURE",t.APPROVE_TRANSACTION="APPROVE_TRANSACTION",t.TRANSACTIONS="TRANSACTIONS",t.CLAIM_WITHDRAWAL="CLAIM_WITHDRAWAL",t.CLAIM_WITHDRAWAL_IN_PROGRESS="CLAIM_WITHDRAWAL_IN_PROGRESS",t.CLAIM_WITHDRAWAL_SUCCESS="CLAIM_WITHDRAWAL_SUCCESS",t.CLAIM_WITHDRAWAL_FAILURE="CLAIM_WITHDRAWAL_FAILURE"}(rt||(rt={}));const it=(t,e)=>{const{fees:o,token:n}=t;if(void 0===o.totalFees)return"-.--";if(void 0===n)return"-.--";const r=((t,e,o)=>{let n=-1;if(t&&e){const r=V(t,e.decimals),i=o.get(e.symbol.toLocaleLowerCase());if(i){const t=parseFloat(r);if(Number.isNaN(t))return n;n=t*i}}return n})(o.totalFees,n,e);return r<0?"-.--":function(t){if(t<0)return"-.--";const e=t.toString();if(e.includes("e")||0===t)return"0.00";if(t<.01)for(let o=0;o<e.length;o++)if("0"!==e[o]&&"."!==e[o])return t.toFixed(o-1);return t.toFixed(2)}(r)};var st;function at({testId:t,icon:e,heading:o,caption:n,onClick:r,renderFeeFunction:i,isDisabled:s}){return u(m,{testId:"top-up-view",sx:{paddingY:"1px"},children:f(d,{testId:`menu-item-${t}`,size:"medium",emphasized:!0,onClick:s?void 0:r,sx:s?{opacity:"0.5",cursor:"not-allowed"}:{},children:[u(d.Icon,{icon:e}),u(d.Label,{size:"medium",children:o}),u(d.IntentIcon,{}),f(d.Caption,{testId:`menu-item-caption-${t}`,children:[n,u("br",{}),s?"":i("-.--",!1)]})]})})}function ct({widgetEvent:t,checkout:e,provider:o,showOnrampOption:n,showSwapOption:r,showBridgeOption:i,tokenAddress:s,amount:c,analytics:l,onCloseButtonClick:d,onBackButtonClick:y,heading:O,subheading:R}){const{t:x}=h(),{userJourney:N}=l,{viewDispatch:F}=a.useContext(E),{cryptoFiatState:P,cryptoFiatDispatch:L}=a.useContext(q),{conversions:U,fiatSymbol:W}=P,{eventTargetState:{eventTarget:k}}=a.useContext(g),[B,D]=a.useState("-.--"),[M,$]=a.useState("-.--"),[V,G]=a.useState(!0),H=O?x(...O):x("views.TOP_UP_VIEW.header.title"),K=R?x(...R):null,{page:Y,track:z}=p();a.useEffect((()=>{Y({userJourney:N,screen:"TopUp"})}),[]),a.useEffect((()=>{L&&L({payload:{type:j.SET_TOKEN_SYMBOLS,tokenSymbols:ot}})}),[L]),a.useEffect((()=>{e&&(async()=>{const t=await e.gasEstimate({gasEstimateType:S.BRIDGE_TO_L2}),o=await it(t,U);$(o)})()}),[void 0!==e]),a.useEffect((()=>{e&&(async()=>{const t=(t=>{const{minPercentage:e,maxPercentage:o}=t;return void 0===e||void 0===o?"-.--":`${e}% to ${o}`})(await e.getExchangeFeeEstimate());D(t)})()}),[void 0!==e]),a.useEffect((()=>{e&&(async()=>{G(await e.isSwapAvailable())})()}),[void 0!==e]);const J=(t,e,o="Button")=>{z({userJourney:N,screen:"TopUp",control:t,controlType:o,extras:e})},Z=t=>u(m,{sx:{fontSize:"base.text.caption.small.regular.fontSize",c:"base.color.translucent.standard.600"},children:t}),Q=[{testId:"onramp",icon:"BankCard",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.onramp",onClickEvent:()=>{if(t===I.IMTBL_ONRAMP_WIDGET_EVENT){const e={tokenAddress:"",amount:""};return F({payload:{type:T.UPDATE_VIEW,view:{type:st.ONRAMP,data:e}}}),void J("OnRamp",{...e,widgetEvent:t})}const e={tokenAddress:s??"",amount:c??""};C.sendRequestOnrampEvent(k,t,e),J("OnRamp",{...e,widgetEvent:t})},fee:()=>Z(`${x("views.TOP_UP_VIEW.topUpOptions.onramp.subcaption")} ≈ ${B}%`),isAvailable:!0,isEnabled:n},{testId:"swap",icon:"Swap",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.swap",onClickEvent:()=>{if(t===I.IMTBL_SWAP_WIDGET_EVENT){const e={toTokenAddress:"",fromAmount:"",fromTokenAddress:""};return F({payload:{type:T.UPDATE_VIEW,view:{type:X.SWAP,data:e}}}),void J("Swap",{...e,widgetEvent:t})}const e={fromTokenAddress:"",toTokenAddress:s??"",amount:""};C.sendRequestSwapEvent(k,t,e),J("Swap",{...e,widgetEvent:t})},fee:()=>Z(`${x("views.TOP_UP_VIEW.topUpOptions.swap.subcaption")} ≈ $0.05 ${W.toUpperCase()}`),isAvailable:V,isEnabled:r},{testId:"bridge",icon:"Minting",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.bridge",onClickEvent:()=>{if(t===I.IMTBL_BRIDGE_WIDGET_EVENT){const e={fromTokenAddress:"",fromAmount:""};return F({payload:{type:T.UPDATE_VIEW,view:{type:rt.WALLET_NETWORK_SELECTION,data:e}}}),void J("Bridge",{...e,widgetEvent:t})}const e={tokenAddress:"",amount:""};C.sendRequestBridgeEvent(k,t,e),J("Bridge",{...e,widgetEvent:t})},fee:()=>Z(`${x("views.TOP_UP_VIEW.topUpOptions.bridge.subcaption")} ≈ $${M} ${W.toUpperCase()}`),isAvailable:!0,isEnabled:i}];return u(b,{header:u(_,{onBackButtonClick:y,onCloseButtonClick:d,showBack:!0}),footer:u(v,{}),children:f(m,{sx:{paddingX:"base.spacing.x4",paddingY:"base.spacing.x4"},children:[u(w,{size:"small",children:H}),K&&u(A,{size:"small",sx:{color:"base.color.text.body.secondary"},children:K}),u(m,{sx:{paddingY:"base.spacing.x4"},children:Q.sort(((t,e)=>Number(e.isAvailable)-Number(t.isAvailable))).map((t=>t.isEnabled&&u(at,{testId:t.testId,icon:t.icon,heading:x(`${t.textConfigKey}.heading`),caption:t.isAvailable?x(`${t.textConfigKey}.caption`):x(`${t.textConfigKey}.disabledCaption`),onClick:t.onClickEvent,renderFeeFunction:t.fee,isDisabled:!t.isAvailable},x(`${t.textConfigKey}.heading`).toLowerCase())))})]})})}!function(t){t.ONRAMP="ONRAMP",t.IN_PROGRESS_LOADING="IN_PROGRESS_LOADING",t.IN_PROGRESS="IN_PROGRESS",t.SUCCESS="SUCCESS",t.FAIL="FAIL"}(st||(st={}));export{rt as B,q as C,st as O,X as S,ct as T,j as a,nt as b,H as c,V as f,Y as l,G as p};
1
+ import{a4 as t,bN as e,d2 as o,bR as n,d3 as r,bq as i,d4 as s,r as a,a2 as c,bl as l,a as u,j as f,M as d,B as m,u as h,V as E,E as g,e as p,cB as S,z as _,G as v,H as w,b as A,J as b,I,d as T,o as C}from"./index-ab70a8f3.js";const y=new e(o),O={},R=t.from(0),x=t.from(-1);function N(t,o,n,r){const i={fault:o,operation:n};return void 0!==r&&(i.value=r),y.throwError(t,e.errors.NUMERIC_FAULT,i)}let F="0";for(;F.length<256;)F+=F;function P(e){if("number"!=typeof e)try{e=t.from(e).toNumber()}catch(t){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+F.substring(0,e):y.throwArgumentError("invalid decimal size","decimals",e)}function L(e,o){null==o&&(o=0);const n=P(o),r=(e=t.from(e)).lt(R);r&&(e=e.mul(x));let i=e.mod(n).toString();for(;i.length<n.length-1;)i="0"+i;i=i.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=e.div(n).toString();return e=1===n.length?s:s+"."+i,r&&(e="-"+e),e}function U(e,o){null==o&&(o=0);const n=P(o);"string"==typeof e&&e.match(/^-?[0-9.]+$/)||y.throwArgumentError("invalid decimal value","value",e);const r="-"===e.substring(0,1);r&&(e=e.substring(1)),"."===e&&y.throwArgumentError("missing value","value",e);const i=e.split(".");i.length>2&&y.throwArgumentError("too many decimal points","value",e);let s=i[0],a=i[1];for(s||(s="0"),a||(a="0");"0"===a[a.length-1];)a=a.substring(0,a.length-1);for(a.length>n.length-1&&N("fractional component exceeds decimals","underflow","parseFixed"),""===a&&(a="0");a.length<n.length-1;)a+="0";const c=t.from(s),l=t.from(a);let u=c.mul(n).add(l);return r&&(u=u.mul(x)),u}class W{constructor(t,o,n,r){t!==O&&y.throwError("cannot use FixedFormat constructor; use FixedFormat.from",e.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=o,this.width=n,this.decimals=r,this.name=(o?"":"u")+"fixed"+String(n)+"x"+String(r),this._multiplier=P(r),Object.freeze(this)}static from(t){if(t instanceof W)return t;"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,o=128,n=18;if("string"==typeof t)if("fixed"===t);else if("ufixed"===t)e=!1;else{const r=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);r||y.throwArgumentError("invalid fixed format","format",t),e="u"!==r[1],o=parseInt(r[2]),n=parseInt(r[3])}else if(t){const r=(e,o,n)=>null==t[e]?n:(typeof t[e]!==o&&y.throwArgumentError("invalid fixed format ("+e+" not "+o+")","format."+e,t[e]),t[e]);e=r("signed","boolean",e),o=r("width","number",o),n=r("decimals","number",n)}return o%8&&y.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",o),n>80&&y.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new W(O,e,o,n)}}class k{constructor(t,o,n,r){t!==O&&y.throwError("cannot use FixedNumber constructor; use FixedNumber.from",e.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=r,this._hex=o,this._value=n,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&y.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const e=U(this._value,this.format.decimals),o=U(t._value,t.format.decimals);return k.fromValue(e.add(o),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const e=U(this._value,this.format.decimals),o=U(t._value,t.format.decimals);return k.fromValue(e.sub(o),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const e=U(this._value,this.format.decimals),o=U(t._value,t.format.decimals);return k.fromValue(e.mul(o).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const e=U(this._value,this.format.decimals),o=U(t._value,t.format.decimals);return k.fromValue(e.mul(this.format._multiplier).div(o),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=k.from(t[0],this.format);const o=!t[1].match(/^(0*)$/);return this.isNegative()&&o&&(e=e.subUnsafe(B.toFormat(e.format))),e}ceiling(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=k.from(t[0],this.format);const o=!t[1].match(/^(0*)$/);return!this.isNegative()&&o&&(e=e.addUnsafe(B.toFormat(e.format))),e}round(t){null==t&&(t=0);const e=this.toString().split(".");if(1===e.length&&e.push("0"),(t<0||t>80||t%1)&&y.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;const o=k.from("1"+F.substring(0,t),this.format),n=D.toFormat(this.format);return this.mulUnsafe(o).addUnsafe(n).floor().divUnsafe(o)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(e){if(null==e)return this._hex;e%8&&y.throwArgumentError("invalid byte width","width",e);const o=t.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return n(o,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return k.fromString(this._value,t)}static fromValue(t,e,o){return null!=o||null==e||r(e)||(o=e,e=null),null==e&&(e=0),null==o&&(o="fixed"),k.fromString(L(t,e),W.from(o))}static fromString(t,e){null==e&&(e="fixed");const o=W.from(e),r=U(t,o.decimals);!o.signed&&r.lt(R)&&N("unsigned value cannot be negative","overflow","value",t);let i=null;o.signed?i=r.toTwos(o.width).toHexString():(i=r.toHexString(),i=n(i,o.width/8));const s=L(r,o.decimals);return new k(O,i,s,o)}static fromBytes(e,o){null==o&&(o="fixed");const n=W.from(o);if(i(e).length>n.width/8)throw new Error("overflow");let r=t.from(e);n.signed&&(r=r.fromTwos(n.width));const s=r.toTwos((n.signed?0:1)+n.width).toHexString(),a=L(r,n.decimals);return new k(O,s,a,n)}static from(t,o){if("string"==typeof t)return k.fromString(t,o);if(s(t))return k.fromBytes(t,o);try{return k.fromValue(t,0,o)}catch(t){if(t.code!==e.errors.INVALID_ARGUMENT)throw t}return y.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const B=k.from(1),D=k.from("0.5"),M=new e("units/5.7.0"),$=["wei","kwei","mwei","gwei","szabo","finney","ether"];function V(t,e){if("string"==typeof e){const t=$.indexOf(e);-1!==t&&(e=3*t)}return L(t,null!=e?e:18)}function G(t,e){if("string"!=typeof t&&M.throwArgumentError("value must be a string","value",t),"string"==typeof e){const t=$.indexOf(e);-1!==t&&(e=3*t)}return U(t,null!=e?e:18)}function H(t){return G(t,18)}var K,Y=Object.freeze({__proto__:null,commify:function(t){const e=String(t).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||"."===t||"-."===t)&&M.throwArgumentError("invalid value","value",t);let o=e[0],n="";for("-"===o.substring(0,1)&&(n="-",o=o.substring(1));"0"===o.substring(0,1);)o=o.substring(1);""===o&&(o="0");let r="";for(2===e.length&&(r="."+(e[1]||"0"));r.length>2&&"0"===r[r.length-1];)r=r.substring(0,r.length-1);const i=[];for(;o.length;){if(o.length<=3){i.unshift(o);break}{const t=o.length-3;i.unshift(o.substring(t)),o=o.substring(0,t)}}return n+i.join(",")+r},formatEther:function(t){return V(t,18)},formatUnits:V,parseEther:H,parseUnits:G});!function(t){t.USD="usd"}(K||(K={}));const z={cryptoFiat:null,fiatSymbol:K.USD,tokenSymbols:[],conversions:new Map};var j;!function(t){t.SET_CRYPTO_FIAT="SET_CRYPTO_FIAT",t.SET_FIAT_SYMBOL="SET_FIAT_SYMBOL",t.SET_TOKEN_SYMBOLS="SET_TOKEN_SYMBOLS",t.SET_CONVERSIONS="SET_CONVERSIONS"}(j||(j={}));const q=a.createContext({cryptoFiatState:z,cryptoFiatDispatch:()=>{}}),J=(t,e)=>{switch(e.payload.type){case j.SET_CRYPTO_FIAT:return{...t,cryptoFiat:e.payload.cryptoFiat};case j.SET_FIAT_SYMBOL:return{...t,fiatSymbol:e.payload.fiatSymbol};case j.SET_TOKEN_SYMBOLS:return{...t,tokenSymbols:e.payload.tokenSymbols};case j.SET_CONVERSIONS:return{...t,conversions:e.payload.conversions};default:return t}};var X;!function(t){t.SWAP="SWAP",t.IN_PROGRESS="IN_PROGRESS",t.SUCCESS="SUCCESS",t.FAIL="FAIL",t.PRICE_SURGE="PRICE_SURGE",t.APPROVE_ERC20="APPROVE_ERC20_SWAP"}(X||(X={}));class Z{baseConfig;constructor({baseConfig:t}){this.baseConfig=t}}const Q={[c.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[c.PRODUCTION]:"https://checkout-api.immutable.com"};class tt{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig}urlWithPath(t){return Q[this.config.environment]+t}async fetchOverrides(){if(null!==this.overridesCache)return;const t=this.urlWithPath("/v1/fiat/coins/overrides"),e=await l.get(t);if(200!==e.status)throw new Error(`Error fetching coins overrides: ${e.status} ${e.statusText}`);this.overridesCache=new Map(Object.entries(e.data))}async fetchCoins(){if(null!==this.coinsCache)return;await this.fetchOverrides();const t=this.urlWithPath("/v1/fiat/coins/all"),e=await l.get(t);if(200!==e.status)throw new Error(`Error fetching coins list: ${e.status} ${e.statusText}`);const{data:o}=e;this.coinsCache=new Map;for(const t of o){const e=this.overridesCache.get(t.symbol.toLowerCase());this.coinsCache.set(t.symbol.toLowerCase(),e||t.id.toLowerCase())}}async convert({tokenSymbols:t,fiatSymbols:e=[]}){if(!t||0===t.length)throw new Error("Error missing token symbols to convert");const o=e.filter((t=>""!==t));0===o.length&&o.push("usd"),await this.fetchCoins();const n=t.map((t=>this.coinsCache.get(t.toLowerCase()))).filter((t=>""!==t&&void 0!==t)).join(","),r=o.join(",").toLowerCase(),i=this.urlWithPath(`/v1/fiat/conversion?ids=${n}&currencies=${r}`),s=await l.get(i);if(200!==s.status)throw new Error(`Error fetching prices: ${s.status} ${s.statusText}`);const{data:a}=s,c={};for(const e of t){const t=e.toLowerCase(),o=this.coinsCache.get(t);c[t]={},o&&(c[t]=a[o]||{})}return c}}const et=async(t,e,o)=>{try{if(0===o.length)return new Map;return((t,e)=>{const o=new Map;for(const n in t){const r=t[n][e];void 0!==r&&o.set(n,r)}return o})(await t.convert({tokenSymbols:o,fiatSymbol:e}),e)}catch(t){return new Map}},ot=["ETH","IMX"];function nt({environment:t,children:e}){const[o,n]=a.useReducer(J,z),{cryptoFiat:r,fiatSymbol:i,tokenSymbols:s}=o;return a.useEffect((()=>{n({payload:{type:j.SET_CRYPTO_FIAT,cryptoFiat:new tt(new Z({baseConfig:{environment:t}}))}})}),[]),a.useEffect((()=>{r&&i&&(async()=>{const t=await et(r,i,[...new Set([...s,...ot])]);n({payload:{type:j.SET_CONVERSIONS,conversions:t}})})()}),[r,s,i]),u(q.Provider,{value:{cryptoFiatState:o,cryptoFiatDispatch:n},children:e})}var rt;!function(t){t.WALLET_NETWORK_SELECTION="WALLET_NETWORK_SELECTION",t.BRIDGE_FORM="BRIDGE_FORM",t.BRIDGE_REVIEW="BRIDGE_REVIEW",t.IN_PROGRESS="IN_PROGRESS",t.BRIDGE_FAILURE="BRIDGE_FAILURE",t.APPROVE_TRANSACTION="APPROVE_TRANSACTION",t.TRANSACTIONS="TRANSACTIONS",t.CLAIM_WITHDRAWAL="CLAIM_WITHDRAWAL",t.CLAIM_WITHDRAWAL_IN_PROGRESS="CLAIM_WITHDRAWAL_IN_PROGRESS",t.CLAIM_WITHDRAWAL_SUCCESS="CLAIM_WITHDRAWAL_SUCCESS",t.CLAIM_WITHDRAWAL_FAILURE="CLAIM_WITHDRAWAL_FAILURE"}(rt||(rt={}));const it=(t,e)=>{const{fees:o,token:n}=t;if(void 0===o.totalFees)return"-.--";if(void 0===n)return"-.--";const r=((t,e,o)=>{let n=-1;if(t&&e){const r=V(t,e.decimals),i=o.get(e.symbol.toLocaleLowerCase());if(i){const t=parseFloat(r);if(Number.isNaN(t))return n;n=t*i}}return n})(o.totalFees,n,e);return r<0?"-.--":function(t){if(t<0)return"-.--";const e=t.toString();if(e.includes("e")||0===t)return"0.00";if(t<.01)for(let o=0;o<e.length;o++)if("0"!==e[o]&&"."!==e[o])return t.toFixed(o-1);return t.toFixed(2)}(r)};var st;function at({testId:t,icon:e,heading:o,caption:n,onClick:r,renderFeeFunction:i,isDisabled:s}){return u(m,{testId:"top-up-view",sx:{paddingY:"1px"},children:f(d,{testId:`menu-item-${t}`,size:"medium",emphasized:!0,onClick:s?void 0:r,sx:s?{opacity:"0.5",cursor:"not-allowed"}:{},children:[u(d.Icon,{icon:e}),u(d.Label,{size:"medium",children:o}),u(d.IntentIcon,{}),f(d.Caption,{testId:`menu-item-caption-${t}`,children:[n,u("br",{}),s?"":i("-.--",!1)]})]})})}function ct({widgetEvent:t,checkout:e,provider:o,showOnrampOption:n,showSwapOption:r,showBridgeOption:i,tokenAddress:s,amount:c,analytics:l,onCloseButtonClick:d,onBackButtonClick:y,heading:O,subheading:R}){const{t:x}=h(),{userJourney:N}=l,{viewDispatch:F}=a.useContext(E),{cryptoFiatState:P,cryptoFiatDispatch:L}=a.useContext(q),{conversions:U,fiatSymbol:W}=P,{eventTargetState:{eventTarget:k}}=a.useContext(g),[B,D]=a.useState("-.--"),[M,$]=a.useState("-.--"),[V,G]=a.useState(!0),H=O?x(...O):x("views.TOP_UP_VIEW.header.title"),K=R?x(...R):null,{page:Y,track:z}=p();a.useEffect((()=>{Y({userJourney:N,screen:"TopUp"})}),[]),a.useEffect((()=>{L&&L({payload:{type:j.SET_TOKEN_SYMBOLS,tokenSymbols:ot}})}),[L]),a.useEffect((()=>{e&&(async()=>{const t=await e.gasEstimate({gasEstimateType:S.BRIDGE_TO_L2}),o=await it(t,U);$(o)})()}),[void 0!==e]),a.useEffect((()=>{e&&(async()=>{const t=(t=>{const{minPercentage:e,maxPercentage:o}=t;return void 0===e||void 0===o?"-.--":`${e}% to ${o}`})(await e.getExchangeFeeEstimate());D(t)})()}),[void 0!==e]),a.useEffect((()=>{e&&(async()=>{G(await e.isSwapAvailable())})()}),[void 0!==e]);const J=(t,e,o="Button")=>{z({userJourney:N,screen:"TopUp",control:t,controlType:o,extras:e})},Z=t=>u(m,{sx:{fontSize:"base.text.caption.small.regular.fontSize",c:"base.color.translucent.standard.600"},children:t}),Q=[{testId:"onramp",icon:"BankCard",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.onramp",onClickEvent:()=>{if(t===I.IMTBL_ONRAMP_WIDGET_EVENT){const e={tokenAddress:"",amount:""};return F({payload:{type:T.UPDATE_VIEW,view:{type:st.ONRAMP,data:e}}}),void J("OnRamp",{...e,widgetEvent:t})}const e={tokenAddress:s??"",amount:c??""};C.sendRequestOnrampEvent(k,t,e),J("OnRamp",{...e,widgetEvent:t})},fee:()=>Z(`${x("views.TOP_UP_VIEW.topUpOptions.onramp.subcaption")} ≈ ${B}%`),isAvailable:!0,isEnabled:n},{testId:"swap",icon:"Swap",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.swap",onClickEvent:()=>{if(t===I.IMTBL_SWAP_WIDGET_EVENT){const e={toTokenAddress:"",fromAmount:"",fromTokenAddress:""};return F({payload:{type:T.UPDATE_VIEW,view:{type:X.SWAP,data:e}}}),void J("Swap",{...e,widgetEvent:t})}const e={fromTokenAddress:"",toTokenAddress:s??"",amount:""};C.sendRequestSwapEvent(k,t,e),J("Swap",{...e,widgetEvent:t})},fee:()=>Z(`${x("views.TOP_UP_VIEW.topUpOptions.swap.subcaption")} ≈ $0.05 ${W.toUpperCase()}`),isAvailable:V,isEnabled:r},{testId:"bridge",icon:"Minting",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.bridge",onClickEvent:()=>{if(t===I.IMTBL_BRIDGE_WIDGET_EVENT){const e={fromTokenAddress:"",fromAmount:""};return F({payload:{type:T.UPDATE_VIEW,view:{type:rt.WALLET_NETWORK_SELECTION,data:e}}}),void J("Bridge",{...e,widgetEvent:t})}const e={tokenAddress:"",amount:""};C.sendRequestBridgeEvent(k,t,e),J("Bridge",{...e,widgetEvent:t})},fee:()=>Z(`${x("views.TOP_UP_VIEW.topUpOptions.bridge.subcaption")} ≈ $${M} ${W.toUpperCase()}`),isAvailable:!0,isEnabled:i}];return u(b,{header:u(_,{onBackButtonClick:y,onCloseButtonClick:d,showBack:!0}),footer:u(v,{}),children:f(m,{sx:{paddingX:"base.spacing.x4",paddingY:"base.spacing.x4"},children:[u(w,{size:"small",children:H}),K&&u(A,{size:"small",sx:{color:"base.color.text.body.secondary"},children:K}),u(m,{sx:{paddingY:"base.spacing.x4"},children:Q.sort(((t,e)=>Number(e.isAvailable)-Number(t.isAvailable))).map((t=>t.isEnabled&&u(at,{testId:t.testId,icon:t.icon,heading:x(`${t.textConfigKey}.heading`),caption:t.isAvailable?x(`${t.textConfigKey}.caption`):x(`${t.textConfigKey}.disabledCaption`),onClick:t.onClickEvent,renderFeeFunction:t.fee,isDisabled:!t.isAvailable},x(`${t.textConfigKey}.heading`).toLowerCase())))})]})})}!function(t){t.ONRAMP="ONRAMP",t.IN_PROGRESS_LOADING="IN_PROGRESS_LOADING",t.IN_PROGRESS="IN_PROGRESS",t.SUCCESS="SUCCESS",t.FAIL="FAIL"}(st||(st={}));export{rt as B,q as C,st as O,X as S,ct as T,j as a,nt as b,H as c,V as f,Y as l,G as p};
@@ -1 +1 @@
1
- import{r as e,T as t,u as n,V as a,j as o,B as s,a as i,b as r,c as l,d as c,C as d,e as p,f as u,E as h,i as L,g as C,h as k,k as f,M as w,H as b,t as E,U as m,o as T,I as g,Z as y,l as S,s as x,m as I,S as A,N as v,n as _,p as N,q as B,v as O,D as W,w as M,x as D,y as F,z as R,A as P,F as Z,G as U,J as V,K as j,L as z,O as G,P as $,Q as J,R as K,W as H,X,Y,_ as q,$ as Q,a0 as ee,a1 as te}from"./index-a91d7cc6.js";import{C as ne,a as ae,b as oe,T as se}from"./TopUpView-de3745a8.js";import{H as ie}from"./HorizontalMenu-actual-ae4ab7e2.js";import{r as re,u as le}from"./retry-3b633bcd.js";const ce={walletProviderName:null,network:null,tokenBalances:[],supportedTopUps:null,walletConfig:{showDisconnectButton:!0,showNetworkMenu:!0}};var de;!function(e){e.SET_WALLET_PROVIDER_NAME="SET_WALLET_PROVIDER_NAME",e.SET_NETWORK="SET_NETWORK",e.SET_TOKEN_BALANCES="SET_TOKEN_BALANCES",e.SET_SUPPORTED_TOP_UPS="SUPPORTED_TOP_UPS"}(de||(de={}));const pe=e.createContext({walletState:ce,walletDispatch:()=>{}});pe.displayName="WalletContext";const ue=(e,t)=>{switch(t.payload.type){case de.SET_WALLET_PROVIDER_NAME:return{...e,walletProviderName:t.payload.walletProviderName};case de.SET_NETWORK:return{...e,network:t.payload.network};case de.SET_TOKEN_BALANCES:return{...e,tokenBalances:t.payload.tokenBalances};case de.SET_SUPPORTED_TOP_UPS:return{...e,supportedTopUps:{isSwapEnabled:t.payload.supportedTopUps.isSwapEnabled??!0,isOnRampEnabled:t.payload.supportedTopUps.isOnRampEnabled??!0,isBridgeEnabled:t.payload.supportedTopUps.isBridgeEnabled??!0,isSwapAvailable:t.payload.supportedTopUps.isSwapAvailable??!0}};default:return e}},he=async(e,n)=>{const a=await e.getTokenAllowList({type:t.ALL,chainId:n}),o=new Set;return a.tokens.forEach((e=>{o.add(e.symbol)})),Array.from(o)},Le={display:"flex",flexDirection:"row",justifyContent:"space-between",paddingX:"base.spacing.x3",paddingY:"base.spacing.x2"},Ce={display:"flex",direction:"row",columnGap:"base.spacing.x1",alignItems:"center"},ke={height:"base.icon.size.250",width:"base.icon.size.250",minWidth:"base.icon.size.250",fill:"base.color.accent.4",cursor:"pointer"};var fe;function we(t){const{t:d}=n(),{viewDispatch:p}=e.useContext(a),{totalBalance:u,loading:h}=t;return o(s,{sx:Le,children:[o(s,{sx:Ce,children:[i(r,{size:"medium",children:d("views.WALLET_BALANCES.totalTokenBalance.heading")}),i(s,{sx:{pl:"base.spacing.x1"},children:i(l,{testId:"coin-info-icon",variant:"tertiary",icon:"Information",sx:ke,onClick:()=>p({payload:{type:c.UPDATE_VIEW,view:{type:fe.COIN_INFO}}})})})]}),o(s,{sx:Ce,children:[i(r,{testId:"total-token-balance-value",weight:"bold",shimmer:h?1:0,shimmerSx:{minw:"100px"},children:d("views.WALLET_BALANCES.totalTokenBalance.totalHeading")}),!h&&o(r,{testId:"total-token-balance",weight:"bold",children:["≈ USD $",u.toFixed(2)]})]})]})}!function(e){e.WALLET_BALANCES="WALLET_BALANCES",e.SETTINGS="SETTINGS",e.COIN_INFO="COIN_INFO",e.SUCCESS="SUCCESS",e.FAIL="FAIL"}(fe||(fe={}));const be=e=>({display:e?"":"none"});function Ee({balanceInfo:n,theme:a,bridgeToL2OnClick:s}){const{connectLoaderState:r}=e.useContext(d),{track:l}=p(),{checkout:c,provider:y}=r,S=`≈ USD $${u(n.fiatAmount)}`,{walletState:x}=e.useContext(pe),{supportedTopUps:I,network:A}=x,[v,_]=e.useState(),[N,B]=e.useState(),[O,W]=e.useState(),{eventTargetState:{eventTarget:M}}=e.useContext(h),[D,F]=e.useState([]),R=L(y);e.useEffect((()=>{(async()=>{if(!c)return;const e=await c.getTokenAllowList({type:t.ONRAMP,chainId:C(c.config)});F(e.tokens)})()}),[c]),e.useEffect((()=>{if(!A||!I||!c)return;const e=A.chainId===C(c.config)&&(I?.isOnRampEnabled??!0);_(e);const t=(A.chainId===k(c.config)||A.chainId===C(c.config))&&(I?.isBridgeEnabled??!0);B(t);const n=A.chainId===C(c.config)&&(I?.isSwapEnabled??!0)&&(I?.isSwapAvailable??!0);W(n)}),[A,I,c,R]);const P=e.useMemo((()=>Boolean(v&&D.length>0&&D.find((e=>e.address?.toLowerCase()===n.address?.toLowerCase())))),[v,D]);return o(w,{testId:`balance-item-${n.symbol}`,emphasized:!0,children:[i(w.FramedImage,{imageUrl:n.icon,defaultImageUrl:f(c?.config.environment,a),circularFrame:!0}),i(w.Label,{children:n.symbol}),i(w.Caption,{children:n.description}),i(w.PriceDisplay,{testId:`balance-item-${n.symbol}`,use:i(b,{size:"xSmall"}),price:E(n.balance),fiatAmount:S}),(v||O||N)&&o(w.OverflowPopoverMenu,{size:"small",testId:"token-menu",onClick:()=>{l({userJourney:m.WALLET,screen:"WalletBalances",control:"BalanceItem",controlType:"Button",extras:{tokenSymbol:n.symbol,tokenAddress:n.address}})},children:[o(w,{testId:"balance-item-add-option",sx:be(P),onClick:()=>{l({userJourney:m.WALLET,screen:"WalletBalances",control:"AddTokens",controlType:"Button",extras:{tokenSymbol:n.symbol,tokenAddress:n.address}}),T.sendRequestOnrampEvent(M,g.IMTBL_WALLET_WIDGET_EVENT,{tokenAddress:n.address??"",amount:""})},children:[i(w.Icon,{icon:"Add"}),i(w.Label,{children:`Add ${n.symbol}`})]}),o(w,{testId:"balance-item-swap-option",sx:be(O),onClick:()=>{l({userJourney:m.WALLET,screen:"WalletBalances",control:"SwapTokens",controlType:"Button",extras:{tokenSymbol:n.symbol,tokenAddress:n.address}}),T.sendRequestSwapEvent(M,g.IMTBL_WALLET_WIDGET_EVENT,{fromTokenAddress:n.address??"",toTokenAddress:"",amount:""})},children:[i(w.Icon,{icon:"Exchange"}),i(w.Label,{children:`Swap ${n.symbol}`})]}),o(w,{testId:"balance-item-move-option",sx:be(N),onClick:()=>{l({userJourney:m.WALLET,screen:"WalletBalances",control:"MoveTokens",controlType:"Button",extras:{tokenSymbol:n.symbol,tokenAddress:n.address}}),s(n.address)},children:[i(w.Icon,{icon:"Minting"}),i(w.Label,{children:`Move ${n.symbol}`})]})]})]})}const me={width:"100%",height:"100%",display:"flex",flexDirection:"column",rowGap:"base.spacing.x2"},Te={width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},ge=e=>e.filter((e=>e.balance!==y||S(e.address)));function ye({balanceInfoItems:e,theme:t,bridgeToL2OnClick:a}){const{t:l}=n(),c=ge(e);return o(s,{sx:me,children:[0===c.length&&i(s,{sx:Te,children:i(r,{testId:"no-tokens-found",children:l("views.WALLET_BALANCES.tokenBalancesList.noTokensFound")})}),c.map((e=>i(Ee,{balanceInfo:e,bridgeToL2OnClick:a,theme:t},e.id)))]})}const Se={display:"flex",flexDirection:"column",alignItems:"flex-start",paddingTop:"base.spacing.x4"},xe={fontWeight:"base.text.caption.small.bold.fontWeight",borderColor:"base.color.translucent.emphasis.1000",borderStyle:"solid",borderWidth:"base.border.size.200"},Ie={fontWeight:"base.text.caption.small.bold.fontWeight"},Ae=(e,t)=>({paddingRight:"base.spacing.x1",width:"22px",fill:t?e:"base.color.brand.4"}),ve={paddingX:"base.spacing.x3",paddingY:"base.spacing.x2"};function _e(){const{t:t}=n(),{connectLoaderState:l}=e.useContext(d),{eventTargetState:{eventTarget:u}}=e.useContext(h),{checkout:L,provider:C}=l,{viewDispatch:k}=e.useContext(a),{walletState:f,walletDispatch:w}=e.useContext(pe),{network:b}=f,[E,T]=e.useState([]),{track:g}=p(),y=e.useCallback((async e=>{if(L&&C&&b&&b.chainId!==e){g({userJourney:m.WALLET,screen:"WalletBalances",control:"SwitchNetwork",controlType:"Button",extras:{chainId:e}});try{const t=await L.switchNetwork({provider:C,chainId:e});x(u,t.provider,t.network)}catch(e){e.type===I.USER_REJECTED_REQUEST_ERROR||k({payload:{type:c.UPDATE_VIEW,view:{type:A.ERROR_VIEW,error:e}}})}}}),[L,C,b,w,k]);return e.useEffect((()=>{(async()=>{if(L){const e=await L.getNetworkAllowList({type:v.ALL});T(e?.networks??[])}else T([])})()}),[L]),o(s,{testId:"network-menu",sx:Se,children:[i(r,{testId:"network-heading",size:"medium",sx:ve,children:t("views.WALLET_BALANCES.networkStatus.heading")}),i(ie,{children:L&&E?.sort(((e,t)=>_(e,t,L.config))).map((e=>o(ie.Button,{testId:`${e.name}-network-button`,sx:e.chainId===b?.chainId?xe:Ie,size:"small",onClick:()=>y(e.chainId),children:[i(N.Icon,{icon:B[e.chainId],iconVariant:"bold",sx:Ae(O[e.chainId],e.chainId===b?.chainId)}),e.name]},e.chainId)))})]})}const Ne={display:"flex",flexDirection:"column",rowGap:"base.spacing.x2",paddingX:"base.spacing.x2",flex:1},Be={backgroundColor:"base.color.neutral.800",paddingX:"base.spacing.x1",borderRadius:"base.borderRadius.x6",flex:1},Oe={display:"flex",flexDirection:"column",rowGap:"base.spacing.x2"},We=(e,t)=>{let n=460;e&&(n-=104),t&&(n-=98);return{height:`${n}px`,overflowY:"auto",borderRadius:"base.borderRadius.x6"}},Me=(e,t,n)=>n?`${e.toString()}-${t.toLowerCase()}-${n.toLowerCase()}`:`${e.toString()}-${t.toLowerCase()}`,De=(e,t,n)=>t.map((t=>({id:Me(e,t.token.symbol,t.token.address),balance:t.formattedBalance,fiatAmount:F(t.formattedBalance,t.token.symbol,n),symbol:t.token.symbol,address:t.token.address,description:t.token.name,icon:t.token.icon})));function Fe({balancesLoading:t,theme:r,showNetworkMenu:u}){const{t:k}=n(),{connectLoaderState:f}=e.useContext(d),{checkout:b,provider:E}=f,{cryptoFiatState:y,cryptoFiatDispatch:S}=e.useContext(ne),{walletState:x}=e.useContext(pe),{eventTargetState:{eventTarget:I}}=e.useContext(h),{viewDispatch:v}=e.useContext(a),[_,N]=e.useState(0),{network:B,supportedTopUps:O,tokenBalances:W}=x,{conversions:M}=y,D=!L(E)&&u,{track:F,page:j}=p(),z=e.useMemo((()=>De(B?.chainId,W,M)),[W,M,B?.chainId]);e.useEffect((()=>{j({userJourney:m.WALLET,screen:"WalletBalances"})}),[]),e.useEffect((()=>{(async()=>{if(!b)return;if(!S)return;if(!B)return;const e=await he(b,B.chainId);S({payload:{type:ae.SET_TOKEN_SYMBOLS,tokenSymbols:e}})})()}),[b,S,B?.chainId]),e.useEffect((()=>{let e=0;z.forEach((t=>{const n=parseFloat(t.fiatAmount);Number.isNaN(n)||(e+=n)})),N(e)}),[z]);const G=e.useMemo((()=>!(!b||!B)&&(B.chainId===C(b.config)&&Boolean(O?.isBridgeEnabled||O?.isSwapEnabled||O?.isOnRampEnabled))),[b,B,O]);return i(V,{testId:"wallet-balances",header:i(R,{title:k("views.WALLET_BALANCES.header.title"),rightActions:i(l,{icon:"SettingsCog",sx:P(),iconVariant:"bold",onClick:()=>{F({userJourney:m.WALLET,screen:"WalletBalances",control:"Settings",controlType:"Button"}),v({payload:{type:c.UPDATE_VIEW,view:{type:fe.SETTINGS}}})},testId:"settings-button"}),onCloseButtonClick:()=>Z(I)}),footer:i(U,{}),children:o(s,{sx:Ne,children:[o(s,{sx:Be,children:[D&&i(_e,{}),i(we,{totalBalance:_,loading:t}),o(s,{sx:We(D,G),children:[t&&o(s,{sx:Oe,children:[i(w,{shimmer:!0,emphasized:!0,testId:"balance-item-shimmer--1"}),i(w,{shimmer:!0,emphasized:!0,testId:"balance-item-shimmer--2"}),i(w,{shimmer:!0,emphasized:!0,testId:"balance-item-shimmer--3"})]}),!t&&i(ye,{balanceInfoItems:z,bridgeToL2OnClick:e=>{T.sendRequestBridgeEvent(I,g.IMTBL_WALLET_WIDGET_EVENT,{tokenAddress:e??"",amount:""})},theme:r})]})]}),G&&o(w,{testId:"add-coins",emphasized:!0,onClick:()=>{F({userJourney:m.WALLET,screen:"WalletBalances",control:"AddCoins",controlType:"Button"}),v({payload:{type:c.UPDATE_VIEW,view:{type:A.TOP_UP_VIEW}}})},children:[i(w.FramedIcon,{icon:"Add"}),i(w.Label,{children:k("views.WALLET_BALANCES.addCoins")})]})]})})}const Re={width:"100%",height:"88px",display:"flex",flexDirection:"row",justifyContent:"space-between",padding:"24px 11px 24px 32px",backgroundColor:"base.color.translucent.emphasis.400",borderRadius:"base.borderRadius.x6"},Pe={width:"100%",display:"flex"},Ze={width:"318px",display:"flex",flexDirection:"column"},Ue={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Ve={background:"base.color.status.success.bright",fill:"base.color.status.success.bright"};function je({textToCopy:t}){const[n,a]=e.useState(!1),{track:o}=p();return i(s,{children:t&&i(s,{sx:{cursor:"pointer"},children:i(l,{sx:n?Ve:{},onClick:()=>{null!=t&&(o({userJourney:m.WALLET,screen:"Settings",control:"CopyWalletAddress",controlType:"Button"}),navigator.clipboard.writeText(t)),a(!0),setTimeout((()=>{a(!1)}),3e3)},size:"small",icon:n?"Tick":"CopyText"})})})}function ze({provider:t}){const[n,a]=e.useState("");return e.useEffect((()=>{t&&(async()=>{const e=await t.getSigner().getAddress();a(e)})()}),[t]),i(s,{sx:Re,children:o(s,{sx:Pe,children:[o(s,{sx:Ze,children:[i(b,{size:"xSmall",children:"Wallet address"}),i(r,{testId:"wallet-address",size:"xSmall",sx:Ue,children:n})]}),i(je,{textToCopy:n})]})})}const Ge={display:"flex",flexDirection:"column",rowGap:"base.spacing.x2",paddingX:"base.spacing.x4"},$e={marginTop:"32px"};function Je({showDisconnectButton:t}){const{t:a}=n(),{connectLoaderState:r}=e.useContext(d),{provider:l}=r,{eventTargetState:{eventTarget:c}}=e.useContext(h),{ethereumProvider:u}=j(),{page:L}=p();e.useEffect((()=>{L({userJourney:m.WALLET,screen:"Settings"})}),[]);return i(V,{testId:"wallet-balances",header:i(R,{showBack:!0,title:a("views.SETTINGS.header.title"),onCloseButtonClick:()=>Z(c)}),footer:i(U,{}),children:o(s,{sx:Ge,children:[i(ze,{provider:l}),t&&i(N,{testId:"disconnect-button",variant:"secondary",sx:$e,onClick:()=>{(async()=>{if(G(l))try{if(l.provider?.session){const e=l.provider?.signer.client.core.pairing.getPairings();if(e&&e.length>0){const t=e.map((e=>u?.signer.client.core.pairing.disconnect({topic:e.topic})));await Promise.allSettled(t)}return void await l.provider.disconnect()}if(u){const e=u?.signer.client.core.pairing.getPairings();if(e&&e.length>0){const t=e.map((e=>u?.signer.client.core.pairing.disconnect({topic:e.topic})));await Promise.allSettled(t)}await u.disconnect()}}catch(e){console.error(e)}})().then((()=>{z(c)}))},children:a("views.SETTINGS.disconnectButton.label")})]})})}function Ke(){return i(s,{sx:{...$,background:"base.color.translucent.emphasis.100"},children:i(s,{sx:{...J,...K},children:o("svg",{width:"430",height:"211",viewBox:"0 0 430 211",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i("path",{d:"M213 120C132.857 120 65.7181 139.009 1 175.641V211H431V178.515C365.165 140.107 295.216 120 213 120Z",fill:"url(#paint0_linear_4525_125520)"}),i("path",{d:"M428.5 210.5H383C383 123 114 113.5 236 120.5C333.6 126.1 405 163.833 428.5 182V210.5Z",fill:"#2D0034",fillOpacity:"0.2"}),i("path",{d:"M131.005 34.0566L130.576 32.4244L128.944 32.8537L129.373 34.4858L131.005 34.0566Z",fill:"white"}),i("path",{d:"M77.1152 45.7678L76.5627 43.6667L74.4617 44.2193L75.0142 46.3203L77.1152 45.7678Z",fill:"white"}),i("path",{d:"M264.238 30.1945L262.093 29.8494L261.748 31.9942L263.893 32.3394L264.238 30.1945Z",fill:"white"}),i("path",{d:"M348.157 2.3323L348.776 1.04626L347.49 0.427149L346.871 1.71319L348.157 2.3323Z",fill:"white"}),i("path",{d:"M342.606 56.5062L342.054 54.4052L339.953 54.9577L340.505 57.0587L342.606 56.5062Z",fill:"white"}),i("path",{d:"M348.381 55.0847L349 53.7986L347.714 53.1795L347.095 54.4656L348.381 55.0847Z",fill:"white"}),i("path",{d:"M107.606 18.8096L106.681 17.7229L105.594 18.6483L106.52 19.735L107.606 18.8096Z",fill:"white"}),i("path",{d:"M233.14 2.3323L233.759 1.04626L232.473 0.427149L231.854 1.71319L233.14 2.3323Z",fill:"white"}),i("path",{d:"M2.97844e-07 176.149C62.5366 139.802 135.143 119 212.584 119C292.029 119 366.384 140.892 430 179",stroke:"black"}),i("path",{d:"M70.97 142.773C76.3142 146.15 87.6289 137.839 96.242 124.208C104.855 110.578 107.505 96.7911 102.161 93.414C96.8167 90.037 85.5021 98.3487 76.889 111.979C68.2758 125.609 65.6258 139.396 70.97 142.773Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M76.8602 112.001C79.353 108.055 82.0686 104.564 84.8088 101.664L94.3989 126.977C86.0698 138.949 75.925 145.933 70.9515 142.793C65.6033 139.413 68.2536 125.631 76.8692 111.994L76.8602 112.001Z",fill:"black"}),i("path",{d:"M96.2211 124.237C104.836 110.608 107.486 96.8249 102.138 93.4455L109.009 97.785C114.357 101.164 111.707 114.947 103.092 128.576C94.4778 142.205 83.1639 150.512 77.8146 147.141L70.9434 142.801C76.2916 146.181 87.6066 137.866 96.2211 124.237Z",fill:"#D8EFF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M98.2141 120.884C99.3274 118.901 100.309 116.925 101.153 115.003L108.025 119.342C107.181 121.264 106.2 123.233 105.085 125.224L98.2141 120.884Z",fill:"#F191FA"}),i("path",{d:"M102.311 112.191C104.156 107.325 105.052 102.898 104.877 99.4899L111.748 103.829C111.923 107.238 111.035 111.665 109.182 116.531L102.311 112.191Z",fill:"black"}),i("path",{d:"M96.2211 124.237C104.836 110.608 107.486 96.8249 102.138 93.4455L109.009 97.785C114.357 101.164 111.707 114.947 103.092 128.576C94.4778 142.205 83.1639 150.512 77.8146 147.141L70.9434 142.801C76.2916 146.181 87.6066 137.866 96.2211 124.237Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M341.833 142.899C353.278 131.542 356.039 115.768 348 107.668C339.962 99.5669 324.167 102.207 312.723 113.564C301.278 124.921 298.517 140.695 306.555 148.795C314.594 156.896 330.388 154.256 341.833 142.899Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M341.813 142.853C353.26 131.495 356.014 115.719 347.977 107.616L352.129 111.801C360.166 119.903 357.412 135.68 345.965 147.037C334.519 158.395 318.726 161.037 310.688 152.934L306.536 148.75C314.574 156.852 330.375 154.211 341.813 142.853Z",fill:"#96DAF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M344.451 139.969C345.913 138.216 347.189 136.39 348.264 134.524L352.416 138.709C351.341 140.575 350.065 142.4 348.603 144.153L344.451 139.969Z",fill:"#D8EFF4"}),i("path",{d:"M349.72 131.746C352.022 126.818 352.967 121.785 352.442 117.302L356.594 121.486C357.119 125.97 356.174 131.002 353.872 135.93L349.72 131.746Z",fill:"black"}),i("path",{d:"M341.813 142.853C353.26 131.495 356.014 115.719 347.977 107.616L352.129 111.801C360.166 119.903 357.412 135.68 345.965 147.037C334.519 158.395 318.726 161.037 310.688 152.934L306.536 148.75C314.574 156.852 330.375 154.211 341.813 142.853Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M155.769 157.057C169.703 165.169 185.654 163.751 191.396 153.888C197.138 144.026 190.497 129.454 176.563 121.342C162.629 113.229 146.679 114.648 140.937 124.51C135.195 134.373 141.836 148.944 155.769 157.057Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M155.809 157.026C169.744 165.14 185.695 163.714 191.439 153.852L188.473 158.946C182.729 168.808 166.778 170.234 152.843 162.12C138.908 154.006 132.266 139.436 138.01 129.574L140.976 124.48C135.232 134.342 141.876 148.919 155.809 157.026Z",fill:"#96DAF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M159.278 158.826C161.349 159.785 163.443 160.544 165.524 161.099L162.558 166.193C160.477 165.639 158.383 164.879 156.311 163.921L159.278 158.826Z",fill:"#D8EFF4"}),i("path",{d:"M168.585 161.786C173.941 162.733 179.047 162.342 183.241 160.674L180.275 165.768C176.08 167.436 170.975 167.827 165.619 166.88L168.585 161.786Z",fill:"black"}),i("path",{d:"M155.809 157.026C169.744 165.14 185.695 163.714 191.439 153.852L188.473 158.946C182.729 168.808 166.778 170.234 152.843 162.12C138.908 154.006 132.266 139.436 138.01 129.574L140.976 124.48C135.232 134.342 141.876 148.919 155.809 157.026Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M234.03 133.525C249.631 129.452 260.983 121.192 259.386 115.075C257.79 108.959 243.848 107.301 228.248 111.374C212.647 115.446 201.294 123.706 202.891 129.823C204.488 135.94 218.429 137.597 234.03 133.525Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M234.031 133.533C249.63 129.462 260.98 121.198 259.388 115.083L261.44 122.943C263.04 129.058 251.682 137.322 236.083 141.393C220.484 145.464 206.542 143.808 204.942 137.685L202.89 129.825C204.49 135.94 218.433 137.604 234.031 133.533Z",fill:"#D8EFF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M237.663 132.44C239.836 131.754 241.896 130.986 243.826 130.154L245.878 138.014C243.948 138.838 241.888 139.606 239.715 140.3L237.663 132.44Z",fill:"#F191FA"}),i("path",{d:"M246.588 128.896C251.257 126.601 254.941 123.976 257.13 121.367L259.182 129.227C256.985 131.836 253.309 134.461 248.64 136.756L246.588 128.896Z",fill:"black"}),i("path",{d:"M234.031 133.533C249.63 129.462 260.98 121.198 259.388 115.083L261.44 122.943C263.04 129.058 251.682 137.322 236.083 141.393C220.484 145.464 206.542 143.808 204.942 137.685L202.89 129.825C204.49 135.94 218.433 137.604 234.031 133.533Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M189.995 60.1335C175.063 54.0502 161.025 53.8648 158.64 59.7194C156.255 65.5739 166.426 75.2515 181.358 81.3348C196.29 87.418 210.328 87.6034 212.713 81.7488C215.098 75.8943 204.927 66.2167 189.995 60.1335Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M181.375 81.3031C196.307 87.3891 210.345 87.5729 212.731 81.7174L209.667 89.2437C207.281 95.0992 193.243 94.9154 178.311 88.8293C163.379 82.7433 153.208 73.0653 155.594 67.2098L158.658 59.6835C156.272 65.5391 166.443 75.217 181.375 81.3031Z",fill:"#D8EFF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M185.032 82.6694C187.186 83.4191 189.294 84.0389 191.339 84.5366L188.275 92.0629C186.23 91.5652 184.122 90.9454 181.968 90.1957L185.032 82.6694Z",fill:"#96DAF4"}),i("path",{d:"M194.301 85.1776C199.418 86.1391 203.932 86.2438 207.256 85.4671L204.192 92.9934C200.868 93.762 196.353 93.6654 191.237 92.7038L194.301 85.1776Z",fill:"black"}),i("path",{d:"M181.375 81.3031C196.307 87.3891 210.345 87.5729 212.731 81.7174L209.667 89.2437C207.281 95.0992 193.243 94.9154 178.311 88.8293C163.379 82.7433 153.208 73.0653 155.594 67.2098L158.658 59.6835C156.272 65.5391 166.443 75.217 181.375 81.3031Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M331.022 121.427C326.722 126.062 313.654 120.93 301.833 109.965C290.012 99 283.915 86.3538 288.214 81.719C292.513 77.0841 305.581 82.2158 317.402 93.1808C329.223 104.146 335.321 116.792 331.022 121.427Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M317.436 93.1948C314.014 90.0206 310.494 87.3431 307.102 85.2426L304.325 112.168C315.446 121.604 327.043 125.752 331.044 121.441C335.347 116.803 329.25 104.162 317.425 93.1905L317.436 93.1948Z",fill:"black"}),i("path",{d:"M301.861 109.987C290.039 99.0235 283.942 86.3817 288.244 81.7437L282.716 87.7004C278.413 92.3385 284.51 104.98 296.332 115.944C308.154 126.907 321.22 132.035 325.526 127.404L331.054 121.447C326.752 126.085 313.683 120.951 301.861 109.987Z",fill:"#D8EFF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M299.075 107.258C297.49 105.627 296.034 103.969 294.725 102.327L289.197 108.284C290.506 109.926 291.959 111.577 293.546 113.215L299.075 107.258Z",fill:"#F191FA"}),i("path",{d:"M292.885 99.9066C289.854 95.6761 287.853 91.6272 287.147 88.2883L281.619 94.2451C282.324 97.584 284.318 101.636 287.357 105.863L292.885 99.9066Z",fill:"black"}),i("path",{d:"M301.861 109.987C290.039 99.0235 283.942 86.3817 288.244 81.7437L282.716 87.7004C278.413 92.3385 284.51 104.98 296.332 115.944C308.154 126.907 321.22 132.035 325.526 127.404L331.054 121.447C326.752 126.085 313.683 120.951 301.861 109.987Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("defs",{children:o("linearGradient",{id:"paint0_linear_4525_125520",x1:"191",y1:"124.403",x2:"247.716",y2:"304.676",gradientUnits:"userSpaceOnUse",children:[i("stop",{stopColor:"#AD48BA"}),i("stop",{offset:"0.65625",stopColor:"#D178FF",stopOpacity:"0.24"})]})})]})})})}function He(){const{t:t}=n(),{connectLoaderState:{provider:a}}=e.useContext(d),s=L(a),{page:r}=p();return e.useEffect((()=>{r({userJourney:m.WALLET,screen:"CoinInfo"})}),[]),o(V,{testId:"coin-info",header:i(R,{showBack:!0,transparent:!0}),footer:i(U,{}),heroContent:i(Ke,{}),floatHeader:!0,children:[!s&&i(H,{heading:t("views.COIN_INFO.metamask.heading"),children:t("views.COIN_INFO.metamask.body")}),s&&o(H,{heading:t("views.COIN_INFO.passport.heading"),children:[t("views.COIN_INFO.passport.body1"),i(Y,{onClick:()=>window.open(X),children:t("views.COIN_INFO.passport.linkText")}),t("views.COIN_INFO.passport.body2")]})]})}const Xe=({checkout:t,provider:n,refreshCallback:a,errorCallback:o})=>{const[s,i]=e.useState(!0),r=e.useCallback((async(e=!1)=>{if(t&&n)try{const o=await t.getNetworkInfo({provider:n});if(!o.isSupported)return;e||i(!0);const s=await(async(e,t,n)=>{if(!e||!t||!n)return[];const a=await t.getSigner().getAddress(),o=await re((()=>e.getAllBalances({provider:t,walletAddress:a,chainId:n})),W);return o?M(e.config,o.balances,n).map((t=>({...t,token:{...t.token,icon:D(e.config.environment,S(t.token.address)?t.token.symbol:t.token.address??"")}}))):[]})(t,n,o.chainId);e||i(!1),a(s)}catch(t){W.nonRetryable(t)&&o(t),e||i(!1)}}),[t,n]);return le((()=>r(!0)),3e4),{balancesLoading:s,refreshBalances:r}};function Ye(t){const{t:s}=n(),r=s("views.ERROR_VIEW.actionText"),l=s("views.LOADING_VIEW.text"),{eventTargetState:{eventTarget:p}}=e.useContext(h),{config:{environment:u,isOnRampEnabled:L,isSwapEnabled:C,isBridgeEnabled:k,theme:f},walletConfig:{showDisconnectButton:w,showNetworkMenu:b}}=t,{connectLoaderState:{checkout:E,provider:T}}=e.useContext(d),[y,S]=e.useReducer(q,{...Q,history:[]}),[x,I]=e.useReducer(ue,{...ce,walletConfig:{showDisconnectButton:w,showNetworkMenu:b}}),v=e.useMemo((()=>({walletState:x,walletDispatch:I})),[x,I]),_=e.useMemo((()=>({viewState:y,viewDispatch:S})),[y,S]),{balancesLoading:N,refreshBalances:B}=Xe({checkout:E,provider:T,refreshCallback:e=>{I({payload:{type:de.SET_TOKEN_BALANCES,tokenBalances:e}})},errorCallback:e=>{console.error(e),S({payload:{type:c.UPDATE_VIEW,view:{type:A.ERROR_VIEW,error:new Error("Unable to fetch balances")}}})}});e.useEffect((()=>{(async()=>{if(!E)return;let e;try{e=await E.isSwapAvailable()}catch(t){e=!1}I({payload:{type:de.SET_SUPPORTED_TOP_UPS,supportedTopUps:{isBridgeEnabled:k,isSwapEnabled:C,isOnRampEnabled:L,isSwapAvailable:e}}})})()}),[k,C,L,u]);const O=async()=>{if(E&&T)try{const e=await E.getNetworkInfo({provider:T});if(!e.isSupported)return;B(),S({payload:{type:c.UPDATE_VIEW,view:{type:fe.WALLET_BALANCES}}}),I({payload:{type:de.SET_NETWORK,network:e}})}catch(e){console.error(e),S({payload:{type:c.UPDATE_VIEW,view:{type:A.ERROR_VIEW,error:e}}})}};e.useEffect((()=>{E&&T&&O()}),[E,T]);return i(a.Provider,{value:_,children:i(oe,{environment:u,children:o(pe.Provider,{value:v,children:[y.view.type===A.LOADING_VIEW&&i(ee,{loadingText:l}),y.view.type===fe.WALLET_BALANCES&&i(Fe,{balancesLoading:N,theme:f,showNetworkMenu:b}),y.view.type===fe.SETTINGS&&i(Je,{showDisconnectButton:w}),y.view.type===fe.COIN_INFO&&i(He,{}),y.view.type===A.ERROR_VIEW&&i(te,{actionText:r,onActionClick:async()=>{S({payload:{type:c.UPDATE_VIEW,view:{type:fe.WALLET_BALANCES}}}),await O()},onCloseClick:()=>Z(p)}),y.view.type===A.TOP_UP_VIEW&&i(se,{analytics:{userJourney:m.WALLET},widgetEvent:g.IMTBL_WALLET_WIDGET_EVENT,checkout:E,provider:T,showOnrampOption:L,showSwapOption:C,showBridgeOption:k,onCloseButtonClick:()=>Z(p)})]})})})}export{Ye as default};
1
+ import{r as e,T as t,u as n,V as a,j as o,B as s,a as i,b as r,c as l,d as c,C as d,e as p,f as u,E as h,i as L,g as C,h as k,k as f,M as w,H as b,t as E,U as m,o as T,I as g,Z as y,l as S,s as x,m as I,S as A,N as v,n as _,p as N,q as B,v as O,D as W,w as M,x as D,y as F,z as R,A as P,F as Z,G as U,J as V,K as j,L as z,O as G,P as $,Q as J,R as K,W as H,X,Y,_ as q,$ as Q,a0 as ee,a1 as te}from"./index-ab70a8f3.js";import{C as ne,a as ae,b as oe,T as se}from"./TopUpView-d04120e3.js";import{H as ie}from"./HorizontalMenu-actual-91b73081.js";import{r as re,u as le}from"./retry-3b188035.js";const ce={walletProviderName:null,network:null,tokenBalances:[],supportedTopUps:null,walletConfig:{showDisconnectButton:!0,showNetworkMenu:!0}};var de;!function(e){e.SET_WALLET_PROVIDER_NAME="SET_WALLET_PROVIDER_NAME",e.SET_NETWORK="SET_NETWORK",e.SET_TOKEN_BALANCES="SET_TOKEN_BALANCES",e.SET_SUPPORTED_TOP_UPS="SUPPORTED_TOP_UPS"}(de||(de={}));const pe=e.createContext({walletState:ce,walletDispatch:()=>{}});pe.displayName="WalletContext";const ue=(e,t)=>{switch(t.payload.type){case de.SET_WALLET_PROVIDER_NAME:return{...e,walletProviderName:t.payload.walletProviderName};case de.SET_NETWORK:return{...e,network:t.payload.network};case de.SET_TOKEN_BALANCES:return{...e,tokenBalances:t.payload.tokenBalances};case de.SET_SUPPORTED_TOP_UPS:return{...e,supportedTopUps:{isSwapEnabled:t.payload.supportedTopUps.isSwapEnabled??!0,isOnRampEnabled:t.payload.supportedTopUps.isOnRampEnabled??!0,isBridgeEnabled:t.payload.supportedTopUps.isBridgeEnabled??!0,isSwapAvailable:t.payload.supportedTopUps.isSwapAvailable??!0}};default:return e}},he=async(e,n)=>{const a=await e.getTokenAllowList({type:t.ALL,chainId:n}),o=new Set;return a.tokens.forEach((e=>{o.add(e.symbol)})),Array.from(o)},Le={display:"flex",flexDirection:"row",justifyContent:"space-between",paddingX:"base.spacing.x3",paddingY:"base.spacing.x2"},Ce={display:"flex",direction:"row",columnGap:"base.spacing.x1",alignItems:"center"},ke={height:"base.icon.size.250",width:"base.icon.size.250",minWidth:"base.icon.size.250",fill:"base.color.accent.4",cursor:"pointer"};var fe;function we(t){const{t:d}=n(),{viewDispatch:p}=e.useContext(a),{totalBalance:u,loading:h}=t;return o(s,{sx:Le,children:[o(s,{sx:Ce,children:[i(r,{size:"medium",children:d("views.WALLET_BALANCES.totalTokenBalance.heading")}),i(s,{sx:{pl:"base.spacing.x1"},children:i(l,{testId:"coin-info-icon",variant:"tertiary",icon:"Information",sx:ke,onClick:()=>p({payload:{type:c.UPDATE_VIEW,view:{type:fe.COIN_INFO}}})})})]}),o(s,{sx:Ce,children:[i(r,{testId:"total-token-balance-value",weight:"bold",shimmer:h?1:0,shimmerSx:{minw:"100px"},children:d("views.WALLET_BALANCES.totalTokenBalance.totalHeading")}),!h&&o(r,{testId:"total-token-balance",weight:"bold",children:["≈ USD $",u.toFixed(2)]})]})]})}!function(e){e.WALLET_BALANCES="WALLET_BALANCES",e.SETTINGS="SETTINGS",e.COIN_INFO="COIN_INFO",e.SUCCESS="SUCCESS",e.FAIL="FAIL"}(fe||(fe={}));const be=e=>({display:e?"":"none"});function Ee({balanceInfo:n,theme:a,bridgeToL2OnClick:s}){const{connectLoaderState:r}=e.useContext(d),{track:l}=p(),{checkout:c,provider:y}=r,S=`≈ USD $${u(n.fiatAmount)}`,{walletState:x}=e.useContext(pe),{supportedTopUps:I,network:A}=x,[v,_]=e.useState(),[N,B]=e.useState(),[O,W]=e.useState(),{eventTargetState:{eventTarget:M}}=e.useContext(h),[D,F]=e.useState([]),R=L(y);e.useEffect((()=>{(async()=>{if(!c)return;const e=await c.getTokenAllowList({type:t.ONRAMP,chainId:C(c.config)});F(e.tokens)})()}),[c]),e.useEffect((()=>{if(!A||!I||!c)return;const e=A.chainId===C(c.config)&&(I?.isOnRampEnabled??!0);_(e);const t=(A.chainId===k(c.config)||A.chainId===C(c.config))&&(I?.isBridgeEnabled??!0);B(t);const n=A.chainId===C(c.config)&&(I?.isSwapEnabled??!0)&&(I?.isSwapAvailable??!0);W(n)}),[A,I,c,R]);const P=e.useMemo((()=>Boolean(v&&D.length>0&&D.find((e=>e.address?.toLowerCase()===n.address?.toLowerCase())))),[v,D]);return o(w,{testId:`balance-item-${n.symbol}`,emphasized:!0,children:[i(w.FramedImage,{imageUrl:n.icon,defaultImageUrl:f(c?.config.environment,a),circularFrame:!0}),i(w.Label,{children:n.symbol}),i(w.Caption,{children:n.description}),i(w.PriceDisplay,{testId:`balance-item-${n.symbol}`,use:i(b,{size:"xSmall"}),price:E(n.balance),fiatAmount:S}),(v||O||N)&&o(w.OverflowPopoverMenu,{size:"small",testId:"token-menu",onClick:()=>{l({userJourney:m.WALLET,screen:"WalletBalances",control:"BalanceItem",controlType:"Button",extras:{tokenSymbol:n.symbol,tokenAddress:n.address}})},children:[o(w,{testId:"balance-item-add-option",sx:be(P),onClick:()=>{l({userJourney:m.WALLET,screen:"WalletBalances",control:"AddTokens",controlType:"Button",extras:{tokenSymbol:n.symbol,tokenAddress:n.address}}),T.sendRequestOnrampEvent(M,g.IMTBL_WALLET_WIDGET_EVENT,{tokenAddress:n.address??"",amount:""})},children:[i(w.Icon,{icon:"Add"}),i(w.Label,{children:`Add ${n.symbol}`})]}),o(w,{testId:"balance-item-swap-option",sx:be(O),onClick:()=>{l({userJourney:m.WALLET,screen:"WalletBalances",control:"SwapTokens",controlType:"Button",extras:{tokenSymbol:n.symbol,tokenAddress:n.address}}),T.sendRequestSwapEvent(M,g.IMTBL_WALLET_WIDGET_EVENT,{fromTokenAddress:n.address??"",toTokenAddress:"",amount:""})},children:[i(w.Icon,{icon:"Exchange"}),i(w.Label,{children:`Swap ${n.symbol}`})]}),o(w,{testId:"balance-item-move-option",sx:be(N),onClick:()=>{l({userJourney:m.WALLET,screen:"WalletBalances",control:"MoveTokens",controlType:"Button",extras:{tokenSymbol:n.symbol,tokenAddress:n.address}}),s(n.address)},children:[i(w.Icon,{icon:"Minting"}),i(w.Label,{children:`Move ${n.symbol}`})]})]})]})}const me={width:"100%",height:"100%",display:"flex",flexDirection:"column",rowGap:"base.spacing.x2"},Te={width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},ge=e=>e.filter((e=>e.balance!==y||S(e.address)));function ye({balanceInfoItems:e,theme:t,bridgeToL2OnClick:a}){const{t:l}=n(),c=ge(e);return o(s,{sx:me,children:[0===c.length&&i(s,{sx:Te,children:i(r,{testId:"no-tokens-found",children:l("views.WALLET_BALANCES.tokenBalancesList.noTokensFound")})}),c.map((e=>i(Ee,{balanceInfo:e,bridgeToL2OnClick:a,theme:t},e.id)))]})}const Se={display:"flex",flexDirection:"column",alignItems:"flex-start",paddingTop:"base.spacing.x4"},xe={fontWeight:"base.text.caption.small.bold.fontWeight",borderColor:"base.color.translucent.emphasis.1000",borderStyle:"solid",borderWidth:"base.border.size.200"},Ie={fontWeight:"base.text.caption.small.bold.fontWeight"},Ae=(e,t)=>({paddingRight:"base.spacing.x1",width:"22px",fill:t?e:"base.color.brand.4"}),ve={paddingX:"base.spacing.x3",paddingY:"base.spacing.x2"};function _e(){const{t:t}=n(),{connectLoaderState:l}=e.useContext(d),{eventTargetState:{eventTarget:u}}=e.useContext(h),{checkout:L,provider:C}=l,{viewDispatch:k}=e.useContext(a),{walletState:f,walletDispatch:w}=e.useContext(pe),{network:b}=f,[E,T]=e.useState([]),{track:g}=p(),y=e.useCallback((async e=>{if(L&&C&&b&&b.chainId!==e){g({userJourney:m.WALLET,screen:"WalletBalances",control:"SwitchNetwork",controlType:"Button",extras:{chainId:e}});try{const t=await L.switchNetwork({provider:C,chainId:e});x(u,t.provider,t.network)}catch(e){e.type===I.USER_REJECTED_REQUEST_ERROR||k({payload:{type:c.UPDATE_VIEW,view:{type:A.ERROR_VIEW,error:e}}})}}}),[L,C,b,w,k]);return e.useEffect((()=>{(async()=>{if(L){const e=await L.getNetworkAllowList({type:v.ALL});T(e?.networks??[])}else T([])})()}),[L]),o(s,{testId:"network-menu",sx:Se,children:[i(r,{testId:"network-heading",size:"medium",sx:ve,children:t("views.WALLET_BALANCES.networkStatus.heading")}),i(ie,{children:L&&E?.sort(((e,t)=>_(e,t,L.config))).map((e=>o(ie.Button,{testId:`${e.name}-network-button`,sx:e.chainId===b?.chainId?xe:Ie,size:"small",onClick:()=>y(e.chainId),children:[i(N.Icon,{icon:B[e.chainId],iconVariant:"bold",sx:Ae(O[e.chainId],e.chainId===b?.chainId)}),e.name]},e.chainId)))})]})}const Ne={display:"flex",flexDirection:"column",rowGap:"base.spacing.x2",paddingX:"base.spacing.x2",flex:1},Be={backgroundColor:"base.color.neutral.800",paddingX:"base.spacing.x1",borderRadius:"base.borderRadius.x6",flex:1},Oe={display:"flex",flexDirection:"column",rowGap:"base.spacing.x2"},We=(e,t)=>{let n=460;e&&(n-=104),t&&(n-=98);return{height:`${n}px`,overflowY:"auto",borderRadius:"base.borderRadius.x6"}},Me=(e,t,n)=>n?`${e.toString()}-${t.toLowerCase()}-${n.toLowerCase()}`:`${e.toString()}-${t.toLowerCase()}`,De=(e,t,n)=>t.map((t=>({id:Me(e,t.token.symbol,t.token.address),balance:t.formattedBalance,fiatAmount:F(t.formattedBalance,t.token.symbol,n),symbol:t.token.symbol,address:t.token.address,description:t.token.name,icon:t.token.icon})));function Fe({balancesLoading:t,theme:r,showNetworkMenu:u}){const{t:k}=n(),{connectLoaderState:f}=e.useContext(d),{checkout:b,provider:E}=f,{cryptoFiatState:y,cryptoFiatDispatch:S}=e.useContext(ne),{walletState:x}=e.useContext(pe),{eventTargetState:{eventTarget:I}}=e.useContext(h),{viewDispatch:v}=e.useContext(a),[_,N]=e.useState(0),{network:B,supportedTopUps:O,tokenBalances:W}=x,{conversions:M}=y,D=!L(E)&&u,{track:F,page:j}=p(),z=e.useMemo((()=>De(B?.chainId,W,M)),[W,M,B?.chainId]);e.useEffect((()=>{j({userJourney:m.WALLET,screen:"WalletBalances"})}),[]),e.useEffect((()=>{(async()=>{if(!b)return;if(!S)return;if(!B)return;const e=await he(b,B.chainId);S({payload:{type:ae.SET_TOKEN_SYMBOLS,tokenSymbols:e}})})()}),[b,S,B?.chainId]),e.useEffect((()=>{let e=0;z.forEach((t=>{const n=parseFloat(t.fiatAmount);Number.isNaN(n)||(e+=n)})),N(e)}),[z]);const G=e.useMemo((()=>!(!b||!B)&&(B.chainId===C(b.config)&&Boolean(O?.isBridgeEnabled||O?.isSwapEnabled||O?.isOnRampEnabled))),[b,B,O]);return i(V,{testId:"wallet-balances",header:i(R,{title:k("views.WALLET_BALANCES.header.title"),rightActions:i(l,{icon:"SettingsCog",sx:P(),iconVariant:"bold",onClick:()=>{F({userJourney:m.WALLET,screen:"WalletBalances",control:"Settings",controlType:"Button"}),v({payload:{type:c.UPDATE_VIEW,view:{type:fe.SETTINGS}}})},testId:"settings-button"}),onCloseButtonClick:()=>Z(I)}),footer:i(U,{}),children:o(s,{sx:Ne,children:[o(s,{sx:Be,children:[D&&i(_e,{}),i(we,{totalBalance:_,loading:t}),o(s,{sx:We(D,G),children:[t&&o(s,{sx:Oe,children:[i(w,{shimmer:!0,emphasized:!0,testId:"balance-item-shimmer--1"}),i(w,{shimmer:!0,emphasized:!0,testId:"balance-item-shimmer--2"}),i(w,{shimmer:!0,emphasized:!0,testId:"balance-item-shimmer--3"})]}),!t&&i(ye,{balanceInfoItems:z,bridgeToL2OnClick:e=>{T.sendRequestBridgeEvent(I,g.IMTBL_WALLET_WIDGET_EVENT,{tokenAddress:e??"",amount:""})},theme:r})]})]}),G&&o(w,{testId:"add-coins",emphasized:!0,onClick:()=>{F({userJourney:m.WALLET,screen:"WalletBalances",control:"AddCoins",controlType:"Button"}),v({payload:{type:c.UPDATE_VIEW,view:{type:A.TOP_UP_VIEW}}})},children:[i(w.FramedIcon,{icon:"Add"}),i(w.Label,{children:k("views.WALLET_BALANCES.addCoins")})]})]})})}const Re={width:"100%",height:"88px",display:"flex",flexDirection:"row",justifyContent:"space-between",padding:"24px 11px 24px 32px",backgroundColor:"base.color.translucent.emphasis.400",borderRadius:"base.borderRadius.x6"},Pe={width:"100%",display:"flex"},Ze={width:"318px",display:"flex",flexDirection:"column"},Ue={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Ve={background:"base.color.status.success.bright",fill:"base.color.status.success.bright"};function je({textToCopy:t}){const[n,a]=e.useState(!1),{track:o}=p();return i(s,{children:t&&i(s,{sx:{cursor:"pointer"},children:i(l,{sx:n?Ve:{},onClick:()=>{null!=t&&(o({userJourney:m.WALLET,screen:"Settings",control:"CopyWalletAddress",controlType:"Button"}),navigator.clipboard.writeText(t)),a(!0),setTimeout((()=>{a(!1)}),3e3)},size:"small",icon:n?"Tick":"CopyText"})})})}function ze({provider:t}){const[n,a]=e.useState("");return e.useEffect((()=>{t&&(async()=>{const e=await t.getSigner().getAddress();a(e)})()}),[t]),i(s,{sx:Re,children:o(s,{sx:Pe,children:[o(s,{sx:Ze,children:[i(b,{size:"xSmall",children:"Wallet address"}),i(r,{testId:"wallet-address",size:"xSmall",sx:Ue,children:n})]}),i(je,{textToCopy:n})]})})}const Ge={display:"flex",flexDirection:"column",rowGap:"base.spacing.x2",paddingX:"base.spacing.x4"},$e={marginTop:"32px"};function Je({showDisconnectButton:t}){const{t:a}=n(),{connectLoaderState:r}=e.useContext(d),{provider:l}=r,{eventTargetState:{eventTarget:c}}=e.useContext(h),{ethereumProvider:u}=j(),{page:L}=p();e.useEffect((()=>{L({userJourney:m.WALLET,screen:"Settings"})}),[]);return i(V,{testId:"wallet-balances",header:i(R,{showBack:!0,title:a("views.SETTINGS.header.title"),onCloseButtonClick:()=>Z(c)}),footer:i(U,{}),children:o(s,{sx:Ge,children:[i(ze,{provider:l}),t&&i(N,{testId:"disconnect-button",variant:"secondary",sx:$e,onClick:()=>{(async()=>{if(G(l))try{if(l.provider?.session){const e=l.provider?.signer.client.core.pairing.getPairings();if(e&&e.length>0){const t=e.map((e=>u?.signer.client.core.pairing.disconnect({topic:e.topic})));await Promise.allSettled(t)}return void await l.provider.disconnect()}if(u){const e=u?.signer.client.core.pairing.getPairings();if(e&&e.length>0){const t=e.map((e=>u?.signer.client.core.pairing.disconnect({topic:e.topic})));await Promise.allSettled(t)}await u.disconnect()}}catch(e){console.error(e)}})().then((()=>{z(c)}))},children:a("views.SETTINGS.disconnectButton.label")})]})})}function Ke(){return i(s,{sx:{...$,background:"base.color.translucent.emphasis.100"},children:i(s,{sx:{...J,...K},children:o("svg",{width:"430",height:"211",viewBox:"0 0 430 211",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i("path",{d:"M213 120C132.857 120 65.7181 139.009 1 175.641V211H431V178.515C365.165 140.107 295.216 120 213 120Z",fill:"url(#paint0_linear_4525_125520)"}),i("path",{d:"M428.5 210.5H383C383 123 114 113.5 236 120.5C333.6 126.1 405 163.833 428.5 182V210.5Z",fill:"#2D0034",fillOpacity:"0.2"}),i("path",{d:"M131.005 34.0566L130.576 32.4244L128.944 32.8537L129.373 34.4858L131.005 34.0566Z",fill:"white"}),i("path",{d:"M77.1152 45.7678L76.5627 43.6667L74.4617 44.2193L75.0142 46.3203L77.1152 45.7678Z",fill:"white"}),i("path",{d:"M264.238 30.1945L262.093 29.8494L261.748 31.9942L263.893 32.3394L264.238 30.1945Z",fill:"white"}),i("path",{d:"M348.157 2.3323L348.776 1.04626L347.49 0.427149L346.871 1.71319L348.157 2.3323Z",fill:"white"}),i("path",{d:"M342.606 56.5062L342.054 54.4052L339.953 54.9577L340.505 57.0587L342.606 56.5062Z",fill:"white"}),i("path",{d:"M348.381 55.0847L349 53.7986L347.714 53.1795L347.095 54.4656L348.381 55.0847Z",fill:"white"}),i("path",{d:"M107.606 18.8096L106.681 17.7229L105.594 18.6483L106.52 19.735L107.606 18.8096Z",fill:"white"}),i("path",{d:"M233.14 2.3323L233.759 1.04626L232.473 0.427149L231.854 1.71319L233.14 2.3323Z",fill:"white"}),i("path",{d:"M2.97844e-07 176.149C62.5366 139.802 135.143 119 212.584 119C292.029 119 366.384 140.892 430 179",stroke:"black"}),i("path",{d:"M70.97 142.773C76.3142 146.15 87.6289 137.839 96.242 124.208C104.855 110.578 107.505 96.7911 102.161 93.414C96.8167 90.037 85.5021 98.3487 76.889 111.979C68.2758 125.609 65.6258 139.396 70.97 142.773Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M76.8602 112.001C79.353 108.055 82.0686 104.564 84.8088 101.664L94.3989 126.977C86.0698 138.949 75.925 145.933 70.9515 142.793C65.6033 139.413 68.2536 125.631 76.8692 111.994L76.8602 112.001Z",fill:"black"}),i("path",{d:"M96.2211 124.237C104.836 110.608 107.486 96.8249 102.138 93.4455L109.009 97.785C114.357 101.164 111.707 114.947 103.092 128.576C94.4778 142.205 83.1639 150.512 77.8146 147.141L70.9434 142.801C76.2916 146.181 87.6066 137.866 96.2211 124.237Z",fill:"#D8EFF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M98.2141 120.884C99.3274 118.901 100.309 116.925 101.153 115.003L108.025 119.342C107.181 121.264 106.2 123.233 105.085 125.224L98.2141 120.884Z",fill:"#F191FA"}),i("path",{d:"M102.311 112.191C104.156 107.325 105.052 102.898 104.877 99.4899L111.748 103.829C111.923 107.238 111.035 111.665 109.182 116.531L102.311 112.191Z",fill:"black"}),i("path",{d:"M96.2211 124.237C104.836 110.608 107.486 96.8249 102.138 93.4455L109.009 97.785C114.357 101.164 111.707 114.947 103.092 128.576C94.4778 142.205 83.1639 150.512 77.8146 147.141L70.9434 142.801C76.2916 146.181 87.6066 137.866 96.2211 124.237Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M341.833 142.899C353.278 131.542 356.039 115.768 348 107.668C339.962 99.5669 324.167 102.207 312.723 113.564C301.278 124.921 298.517 140.695 306.555 148.795C314.594 156.896 330.388 154.256 341.833 142.899Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M341.813 142.853C353.26 131.495 356.014 115.719 347.977 107.616L352.129 111.801C360.166 119.903 357.412 135.68 345.965 147.037C334.519 158.395 318.726 161.037 310.688 152.934L306.536 148.75C314.574 156.852 330.375 154.211 341.813 142.853Z",fill:"#96DAF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M344.451 139.969C345.913 138.216 347.189 136.39 348.264 134.524L352.416 138.709C351.341 140.575 350.065 142.4 348.603 144.153L344.451 139.969Z",fill:"#D8EFF4"}),i("path",{d:"M349.72 131.746C352.022 126.818 352.967 121.785 352.442 117.302L356.594 121.486C357.119 125.97 356.174 131.002 353.872 135.93L349.72 131.746Z",fill:"black"}),i("path",{d:"M341.813 142.853C353.26 131.495 356.014 115.719 347.977 107.616L352.129 111.801C360.166 119.903 357.412 135.68 345.965 147.037C334.519 158.395 318.726 161.037 310.688 152.934L306.536 148.75C314.574 156.852 330.375 154.211 341.813 142.853Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M155.769 157.057C169.703 165.169 185.654 163.751 191.396 153.888C197.138 144.026 190.497 129.454 176.563 121.342C162.629 113.229 146.679 114.648 140.937 124.51C135.195 134.373 141.836 148.944 155.769 157.057Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M155.809 157.026C169.744 165.14 185.695 163.714 191.439 153.852L188.473 158.946C182.729 168.808 166.778 170.234 152.843 162.12C138.908 154.006 132.266 139.436 138.01 129.574L140.976 124.48C135.232 134.342 141.876 148.919 155.809 157.026Z",fill:"#96DAF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M159.278 158.826C161.349 159.785 163.443 160.544 165.524 161.099L162.558 166.193C160.477 165.639 158.383 164.879 156.311 163.921L159.278 158.826Z",fill:"#D8EFF4"}),i("path",{d:"M168.585 161.786C173.941 162.733 179.047 162.342 183.241 160.674L180.275 165.768C176.08 167.436 170.975 167.827 165.619 166.88L168.585 161.786Z",fill:"black"}),i("path",{d:"M155.809 157.026C169.744 165.14 185.695 163.714 191.439 153.852L188.473 158.946C182.729 168.808 166.778 170.234 152.843 162.12C138.908 154.006 132.266 139.436 138.01 129.574L140.976 124.48C135.232 134.342 141.876 148.919 155.809 157.026Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M234.03 133.525C249.631 129.452 260.983 121.192 259.386 115.075C257.79 108.959 243.848 107.301 228.248 111.374C212.647 115.446 201.294 123.706 202.891 129.823C204.488 135.94 218.429 137.597 234.03 133.525Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M234.031 133.533C249.63 129.462 260.98 121.198 259.388 115.083L261.44 122.943C263.04 129.058 251.682 137.322 236.083 141.393C220.484 145.464 206.542 143.808 204.942 137.685L202.89 129.825C204.49 135.94 218.433 137.604 234.031 133.533Z",fill:"#D8EFF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M237.663 132.44C239.836 131.754 241.896 130.986 243.826 130.154L245.878 138.014C243.948 138.838 241.888 139.606 239.715 140.3L237.663 132.44Z",fill:"#F191FA"}),i("path",{d:"M246.588 128.896C251.257 126.601 254.941 123.976 257.13 121.367L259.182 129.227C256.985 131.836 253.309 134.461 248.64 136.756L246.588 128.896Z",fill:"black"}),i("path",{d:"M234.031 133.533C249.63 129.462 260.98 121.198 259.388 115.083L261.44 122.943C263.04 129.058 251.682 137.322 236.083 141.393C220.484 145.464 206.542 143.808 204.942 137.685L202.89 129.825C204.49 135.94 218.433 137.604 234.031 133.533Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M189.995 60.1335C175.063 54.0502 161.025 53.8648 158.64 59.7194C156.255 65.5739 166.426 75.2515 181.358 81.3348C196.29 87.418 210.328 87.6034 212.713 81.7488C215.098 75.8943 204.927 66.2167 189.995 60.1335Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M181.375 81.3031C196.307 87.3891 210.345 87.5729 212.731 81.7174L209.667 89.2437C207.281 95.0992 193.243 94.9154 178.311 88.8293C163.379 82.7433 153.208 73.0653 155.594 67.2098L158.658 59.6835C156.272 65.5391 166.443 75.217 181.375 81.3031Z",fill:"#D8EFF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M185.032 82.6694C187.186 83.4191 189.294 84.0389 191.339 84.5366L188.275 92.0629C186.23 91.5652 184.122 90.9454 181.968 90.1957L185.032 82.6694Z",fill:"#96DAF4"}),i("path",{d:"M194.301 85.1776C199.418 86.1391 203.932 86.2438 207.256 85.4671L204.192 92.9934C200.868 93.762 196.353 93.6654 191.237 92.7038L194.301 85.1776Z",fill:"black"}),i("path",{d:"M181.375 81.3031C196.307 87.3891 210.345 87.5729 212.731 81.7174L209.667 89.2437C207.281 95.0992 193.243 94.9154 178.311 88.8293C163.379 82.7433 153.208 73.0653 155.594 67.2098L158.658 59.6835C156.272 65.5391 166.443 75.217 181.375 81.3031Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M331.022 121.427C326.722 126.062 313.654 120.93 301.833 109.965C290.012 99 283.915 86.3538 288.214 81.719C292.513 77.0841 305.581 82.2158 317.402 93.1808C329.223 104.146 335.321 116.792 331.022 121.427Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M317.436 93.1948C314.014 90.0206 310.494 87.3431 307.102 85.2426L304.325 112.168C315.446 121.604 327.043 125.752 331.044 121.441C335.347 116.803 329.25 104.162 317.425 93.1905L317.436 93.1948Z",fill:"black"}),i("path",{d:"M301.861 109.987C290.039 99.0235 283.942 86.3817 288.244 81.7437L282.716 87.7004C278.413 92.3385 284.51 104.98 296.332 115.944C308.154 126.907 321.22 132.035 325.526 127.404L331.054 121.447C326.752 126.085 313.683 120.951 301.861 109.987Z",fill:"#D8EFF4",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M299.075 107.258C297.49 105.627 296.034 103.969 294.725 102.327L289.197 108.284C290.506 109.926 291.959 111.577 293.546 113.215L299.075 107.258Z",fill:"#F191FA"}),i("path",{d:"M292.885 99.9066C289.854 95.6761 287.853 91.6272 287.147 88.2883L281.619 94.2451C282.324 97.584 284.318 101.636 287.357 105.863L292.885 99.9066Z",fill:"black"}),i("path",{d:"M301.861 109.987C290.039 99.0235 283.942 86.3817 288.244 81.7437L282.716 87.7004C278.413 92.3385 284.51 104.98 296.332 115.944C308.154 126.907 321.22 132.035 325.526 127.404L331.054 121.447C326.752 126.085 313.683 120.951 301.861 109.987Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),i("defs",{children:o("linearGradient",{id:"paint0_linear_4525_125520",x1:"191",y1:"124.403",x2:"247.716",y2:"304.676",gradientUnits:"userSpaceOnUse",children:[i("stop",{stopColor:"#AD48BA"}),i("stop",{offset:"0.65625",stopColor:"#D178FF",stopOpacity:"0.24"})]})})]})})})}function He(){const{t:t}=n(),{connectLoaderState:{provider:a}}=e.useContext(d),s=L(a),{page:r}=p();return e.useEffect((()=>{r({userJourney:m.WALLET,screen:"CoinInfo"})}),[]),o(V,{testId:"coin-info",header:i(R,{showBack:!0,transparent:!0}),footer:i(U,{}),heroContent:i(Ke,{}),floatHeader:!0,children:[!s&&i(H,{heading:t("views.COIN_INFO.metamask.heading"),children:t("views.COIN_INFO.metamask.body")}),s&&o(H,{heading:t("views.COIN_INFO.passport.heading"),children:[t("views.COIN_INFO.passport.body1"),i(Y,{onClick:()=>window.open(X),children:t("views.COIN_INFO.passport.linkText")}),t("views.COIN_INFO.passport.body2")]})]})}const Xe=({checkout:t,provider:n,refreshCallback:a,errorCallback:o})=>{const[s,i]=e.useState(!0),r=e.useCallback((async(e=!1)=>{if(t&&n)try{const o=await t.getNetworkInfo({provider:n});if(!o.isSupported)return;e||i(!0);const s=await(async(e,t,n)=>{if(!e||!t||!n)return[];const a=await t.getSigner().getAddress(),o=await re((()=>e.getAllBalances({provider:t,walletAddress:a,chainId:n})),W);return o?M(e.config,o.balances,n).map((t=>({...t,token:{...t.token,icon:D(e.config.environment,S(t.token.address)?t.token.symbol:t.token.address??"")}}))):[]})(t,n,o.chainId);e||i(!1),a(s)}catch(t){W.nonRetryable(t)&&o(t),e||i(!1)}}),[t,n]);return le((()=>r(!0)),3e4),{balancesLoading:s,refreshBalances:r}};function Ye(t){const{t:s}=n(),r=s("views.ERROR_VIEW.actionText"),l=s("views.LOADING_VIEW.text"),{eventTargetState:{eventTarget:p}}=e.useContext(h),{config:{environment:u,isOnRampEnabled:L,isSwapEnabled:C,isBridgeEnabled:k,theme:f},walletConfig:{showDisconnectButton:w,showNetworkMenu:b}}=t,{connectLoaderState:{checkout:E,provider:T}}=e.useContext(d),[y,S]=e.useReducer(q,{...Q,history:[]}),[x,I]=e.useReducer(ue,{...ce,walletConfig:{showDisconnectButton:w,showNetworkMenu:b}}),v=e.useMemo((()=>({walletState:x,walletDispatch:I})),[x,I]),_=e.useMemo((()=>({viewState:y,viewDispatch:S})),[y,S]),{balancesLoading:N,refreshBalances:B}=Xe({checkout:E,provider:T,refreshCallback:e=>{I({payload:{type:de.SET_TOKEN_BALANCES,tokenBalances:e}})},errorCallback:e=>{console.error(e),S({payload:{type:c.UPDATE_VIEW,view:{type:A.ERROR_VIEW,error:new Error("Unable to fetch balances")}}})}});e.useEffect((()=>{(async()=>{if(!E)return;let e;try{e=await E.isSwapAvailable()}catch(t){e=!1}I({payload:{type:de.SET_SUPPORTED_TOP_UPS,supportedTopUps:{isBridgeEnabled:k,isSwapEnabled:C,isOnRampEnabled:L,isSwapAvailable:e}}})})()}),[k,C,L,u]);const O=async()=>{if(E&&T)try{const e=await E.getNetworkInfo({provider:T});if(!e.isSupported)return;B(),S({payload:{type:c.UPDATE_VIEW,view:{type:fe.WALLET_BALANCES}}}),I({payload:{type:de.SET_NETWORK,network:e}})}catch(e){console.error(e),S({payload:{type:c.UPDATE_VIEW,view:{type:A.ERROR_VIEW,error:e}}})}};e.useEffect((()=>{E&&T&&O()}),[E,T]);return i(a.Provider,{value:_,children:i(oe,{environment:u,children:o(pe.Provider,{value:v,children:[y.view.type===A.LOADING_VIEW&&i(ee,{loadingText:l}),y.view.type===fe.WALLET_BALANCES&&i(Fe,{balancesLoading:N,theme:f,showNetworkMenu:b}),y.view.type===fe.SETTINGS&&i(Je,{showDisconnectButton:w}),y.view.type===fe.COIN_INFO&&i(He,{}),y.view.type===A.ERROR_VIEW&&i(te,{actionText:r,onActionClick:async()=>{S({payload:{type:c.UPDATE_VIEW,view:{type:fe.WALLET_BALANCES}}}),await O()},onCloseClick:()=>Z(p)}),y.view.type===A.TOP_UP_VIEW&&i(se,{analytics:{userJourney:m.WALLET},widgetEvent:g.IMTBL_WALLET_WIDGET_EVENT,checkout:E,provider:T,showOnrampOption:L,showSwapOption:C,showBridgeOption:k,onCloseButtonClick:()=>Z(p)})]})})})}export{Ye as default};
@@ -1 +1 @@
1
- import{dz as t}from"./index-a91d7cc6.js";function n(n,e,r,o){var i=this;return n?((n instanceof Element?[n]:"toArray"in n?n.toArray():n).forEach((function(n){n.addEventListener("click",(function(u){var a,c,s=e instanceof Function?e(n):e,f=r instanceof Function?r(n):r,l=n.getAttribute("href")||n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("xlink:href")||(null===(a=n.getElementsByTagName("a")[0])||void 0===a?void 0:a.getAttribute("href")),h=t(i.track(s,f,null!=o?o:{}),null!==(c=i.settings.timeout)&&void 0!==c?c:500);(function(t,n){return!("_blank"!==t.target||!n)})(n,l)||function(t){var n=t;return!!(n.ctrlKey||n.shiftKey||n.metaKey||n.button&&1==n.button)}(u)||l&&(u.preventDefault?u.preventDefault():u.returnValue=!1,h.catch(console.error).then((function(){window.location.href=l})).catch(console.error))}),!1)})),this):this}function e(n,e,r,o){var i=this;return n?(n instanceof HTMLFormElement&&(n=[n]),n.forEach((function(n){if(!(n instanceof Element))throw new TypeError("Must pass HTMLElement to trackForm/trackSubmit.");var u=function(u){var a;u.preventDefault?u.preventDefault():u.returnValue=!1;var c=e instanceof Function?e(n):e,s=r instanceof Function?r(n):r;t(i.track(c,s,null!=o?o:{}),null!==(a=i.settings.timeout)&&void 0!==a?a:500).catch(console.error).then((function(){n.submit()})).catch(console.error)},a=window.jQuery||window.Zepto;a?a(n).submit(u):n.addEventListener("submit",u,!1)})),this):this}export{e as form,n as link};
1
+ import{dz as t}from"./index-ab70a8f3.js";function n(n,e,r,o){var i=this;return n?((n instanceof Element?[n]:"toArray"in n?n.toArray():n).forEach((function(n){n.addEventListener("click",(function(u){var a,c,s=e instanceof Function?e(n):e,f=r instanceof Function?r(n):r,l=n.getAttribute("href")||n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("xlink:href")||(null===(a=n.getElementsByTagName("a")[0])||void 0===a?void 0:a.getAttribute("href")),h=t(i.track(s,f,null!=o?o:{}),null!==(c=i.settings.timeout)&&void 0!==c?c:500);(function(t,n){return!("_blank"!==t.target||!n)})(n,l)||function(t){var n=t;return!!(n.ctrlKey||n.shiftKey||n.metaKey||n.button&&1==n.button)}(u)||l&&(u.preventDefault?u.preventDefault():u.returnValue=!1,h.catch(console.error).then((function(){window.location.href=l})).catch(console.error))}),!1)})),this):this}function e(n,e,r,o){var i=this;return n?(n instanceof HTMLFormElement&&(n=[n]),n.forEach((function(n){if(!(n instanceof Element))throw new TypeError("Must pass HTMLElement to trackForm/trackSubmit.");var u=function(u){var a;u.preventDefault?u.preventDefault():u.returnValue=!1;var c=e instanceof Function?e(n):e,s=r instanceof Function?r(n):r;t(i.track(c,s,null!=o?o:{}),null!==(a=i.settings.timeout)&&void 0!==a?a:500).catch(console.error).then((function(){n.submit()})).catch(console.error)},a=window.jQuery||window.Zepto;a?a(n).submit(u):n.addEventListener("submit",u,!1)})),this):this}export{e as form,n as link};