@rango-dev/widget-embedded 0.36.1-next.10 → 0.36.1-next.12

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 (33) hide show
  1. package/dist/QueueManager.d.ts.map +1 -1
  2. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  3. package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
  4. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  5. package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +1 -1
  6. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  7. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +2 -4
  8. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  9. package/dist/index.js +2 -2
  10. package/dist/index.js.map +4 -4
  11. package/dist/store/slices/wallets.d.ts +3 -1
  12. package/dist/store/slices/wallets.d.ts.map +1 -1
  13. package/dist/types/wallets.d.ts +1 -6
  14. package/dist/types/wallets.d.ts.map +1 -1
  15. package/dist/utils/providers.d.ts.map +1 -1
  16. package/dist/utils/wallets.d.ts.map +1 -1
  17. package/dist/widget-embedded.build.json +1 -1
  18. package/package.json +7 -7
  19. package/src/QueueManager.tsx +11 -10
  20. package/src/components/ConfirmWalletsModal/WalletList.tsx +1 -1
  21. package/src/components/SwapDetails/SwapDetails.tsx +10 -7
  22. package/src/components/WalletStatefulConnect/Namespaces.tsx +30 -37
  23. package/src/containers/Wallets/Wallets.tsx +63 -3
  24. package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +2 -2
  25. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +20 -22
  26. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +2 -4
  27. package/src/store/slices/wallets.ts +13 -2
  28. package/src/types/wallets.ts +1 -6
  29. package/src/utils/providers.ts +43 -36
  30. package/src/utils/wallets.ts +2 -4
  31. package/dist/utils/hub.d.ts +0 -4
  32. package/dist/utils/hub.d.ts.map +0 -1
  33. package/src/utils/hub.ts +0 -21
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var Hh=Object.defineProperty;var i=(t,e)=>Hh(t,"name",{value:e,configurable:!0});import{EventSeverity as rj,RouteEventType as ij,StepEventType as aj,StepExecutionBlockedEventStatus as sj,StepExecutionEventStatus as lj}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as cj}from"@rango-dev/wallets-core/legacy";import{useWallets as ei,Events as mj}from"@rango-dev/wallets-react";import{Networks as fj,WalletTypes as gj}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as yj}from"rango-types";import{Divider as OS}from"@rango-dev/ui";import co,{useEffect as US,useRef as zS,useState as $c}from"react";import{WalletState as Gh}from"@rango-dev/ui";import{useWallets as Vh}from"@rango-dev/wallets-react";import{useReducer as Kh}from"react";function cp(t){return t.map(e=>{switch(e){case"evm":return"EVM";case"solana":return"Solana";case"cosmos":return"Cosmos";default:throw new Error("Can not convert this common namespace key to a proper legacy key.")}})}i(cp,"convertCommonNamespacesKeysToLegacyNamespace");function up(t){return!!t.derivationPath}i(up,"isStateOnDerivationPathStep");function mp(t){return!!t.namespace}i(mp,"isStateOnNamespace");var nr={status:"init",namespace:null,derivationPath:null};function dp(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return nr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:nr;default:throw new Error("Action hasn't been defined.")}}i(dp,"reducer");function Ht(){let{state:t,disconnect:e,connect:o}=Vh(),[n,r]=Kh(dp,nr),a=i(async(c,m,h)=>{r({type:"reset"});try{let f=m?.map(d=>({...d,network:void 0}));return await o(c,f),{status:"connected"}}catch(f){let d=f?.message?`Error: ${f.message}`:"An unknown error happened during connecting wallet.";throw new Error(d,{cause:f})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Gh.DISCONNECTED){if(!!c.isHub){let C=c.properties?.find(T=>T.name==="detached");if(C&&c.state!=="connected"){let T=cp(C.value);return r({type:"needsNamespace",payload:{providerType:c.type,providerImage:c.image,availableNamespaces:T,singleNamespace:!1}}),{status:"namespace"}}}if(!c.namespaces)return await a(c.type,void 0,m);let d=c.namespaces.length>1,g=c.needsDerivationPath;return d?(r({type:"needsNamespace",payload:{providerType:c.type,providerImage:c.image,availableNamespaces:c.namespaces,singleNamespace:c.singleNamespace}}),{status:"namespace"}):g?(r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:c.namespaces[0]}}),{status:"derivation-path"}):await a(c.type,c.namespaces.map(C=>({namespace:C})),m)}return m?.disconnectIfConnected?(await u(c.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(c,m)=>{let h=c.singleNamespace,f=c.needsDerivationPath,d=m[0];if(!d)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&f)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:d}}),{status:"derivation-path"};if(!mp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let g=n.namespace.providerType,C=m.map(S=>({namespace:S}));return await a(g,C)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!up(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,f=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,f)},"handleDerivationPath"),u=i(async c=>{let m=t(c);return m.connected||m.connecting?(await e(c),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:p,getState:()=>n,resetState:c=>{r(c==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Ht,"useStatefulConnect");import{WalletState as ka}from"@rango-dev/ui";import{useWallets as tS}from"@rango-dev/wallets-react";import{detectMobileScreens as oS,KEPLR_COMPATIBLE_WALLETS as nS,WalletTypes as Po}from"@rango-dev/wallets-shared";import{useCallback as rS,useEffect as iS}from"react";import Xy,{createContext as Yy,useContext as Zy,useEffect as Jy,useRef as Ry}from"react";import{create as Ky}from"zustand";import{persist as jy}from"zustand/middleware";var ra=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},Ao=new ra;function rr(t,e){return e.find(o=>o.name===t)?.displayName}i(rr,"getBlockchainDisplayNameFor");function lt(t,e){return e.find(o=>o.name===t)?.shortName}i(lt,"getBlockchainShortNameFor");function fp(t,e){return e.find(o=>o.name===t)?.logo}i(fp,"getBlockchainImage");function an(t,e){return e.find(o=>o.id===t)?.title}i(an,"getSwapperDisplayName");function sn(t,e){return e.find(o=>o.name===t)??null}i(sn,"findBlockchain");function ia(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(ia,"isTokenNative");function pt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(pt,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");function ln(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=pt(p));let u=o.tokensMapByTokenHash.get(p);u&&(n[p]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(p=>{l.has(p)||a(o.tokensMapByBlockchainName[p])})}return s.forEach(l=>{let p=r[l];if(!p&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}p&&(p.isExcluded?(a(o.tokensMapByBlockchainName[l]),p.tokens.forEach(u=>{let c=pt(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(ln,"matchTokensFromConfigWithMeta");function ir(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(ir,"getSupportedBlockchainsFromConfig");var aa={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"},features:{experimentalWallet:"enabled"}},jh={clientUrl:void 0},Xh={liquiditySources:void 0},gp=i((t,e,o)=>({config:{...aa,...t},iframe:jh,campaignMode:Xh,getLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?r.liquiditySources:n.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:n,campaignMode:r}=o();return r.liquiditySources?.length?[]:n},excludeLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?!1:!!n.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:n}=o();return!!n.liquiditySources?.length},updateConfig:n=>{let r=o().config,{_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s}=o(),l=ln({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=ln({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});Ao.set("supportedSourceTokens",l),Ao.set("supportedDestinationTokens",p),e({config:{...r,...n}})},updateCampaignMode:(n,r)=>{let a=o().campaignMode;e({campaignMode:{...a,[n]:r}})},updateIframe:(n,r)=>{let a=o().iframe;e({iframe:{...a,[n]:r}})}}),"createConfigSlice");import{TransactionType as hp}from"rango-types";var yp=[hp.EVM,hp.SOLANA];import{RangoClient as cy}from"rango-sdk";import{UI_ID as Yh}from"@rango-dev/ui";var ar="c6381a79-2817-4602-83bf-6a641a409e32",Sp="https://api.rango.exchange",Cp="https://explorer.rango.exchange",Pe={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Yh};import{BlockchainCategories as ny,WalletState as xt}from"@rango-dev/ui";import{legacyReadAccountAddress as ry}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as iy,getCosmosExperimentalChainInfo as ay,isEvmAddress as sy,KEPLR_COMPATIBLE_WALLETS as rA,Networks as Mp}from"@rango-dev/wallets-shared";import io from"bignumber.js";import{isCosmosBlockchain as ly}from"rango-types";import Zh from"bignumber.js";var Ce=new Zh(0);import{WalletTypes as Jh}from"@rango-dev/wallets-shared";var Tp=[Jh.LEAP];import{BlockchainCategories as la,WalletState as oy}from"@rango-dev/ui";import{TransactionType as sr}from"rango-sdk";var kp="Roboto",sa=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function Wo(t){return Array.from(new Set(t))}i(Wo,"removeDuplicateFrom");function ua(t,e){return t.length===e.length&&t.every((o,n)=>o===e[n])}i(ua,"areEqual");function Ip(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Ip,"debounce");function Re(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Re,"containsText");function xp(t,e){return t.toLowerCase()===e.toLowerCase()}i(xp,"exactText");function bp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(bp,"startWithText");var N=i(()=>document.getElementById(Pe.SWAP_BOX_ID),"getContainer"),ro=i(()=>document.getElementById(Pe.EXPANDED_BOX_ID),"getExpanded");function Ep(t,e,o){let n=!!e&&xp(e,t),r=!!o&&xp(o,t);return n!==r?n?-1:1:0}i(Ep,"compareExactMatchText");function pa(t,e,o){let n=!!e&&Re(e,t),r=!!o&&Re(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(pa,"compareContainsText");function ca(t,e,o){let n=!!e&&bp(e,t),r=!!o&&bp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ca,"compareStartWithText");function Ap(t,e,o){if(!o)return 0;let n=Ep(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Ep(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=ca(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=pa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ca(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=pa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=ca(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=pa(o,t.address,e.address);if(r!==0)return r}return 0}i(Ap,"compareWithSearchFor");var lr=i((t,e)=>{switch(e){case la.ALL:return!0;case la.UTXO:return t===sr.TRANSFER;case la.OTHER:return t!==sr.TRANSFER&&t!==sr.COSMOS&&t!==sr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Np=i(t=>sa.find(o=>o.value===t)?.url,"getFontUrlByName");function Wp(t,e){let o=!!t.find(n=>n.state===oy.CONNECTED);return e===!1&&o}i(Wp,"isSingleWalletActive");import{BigNumber as Bp}from"bignumber.js";var pn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),B=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Bp(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Bp(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var pr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),cn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function un(t){switch(!0){case t.connected:return xt.CONNECTED;case t.connecting:return xt.CONNECTING;case!t.installed:return xt.NOT_INSTALLED;default:return xt.DISCONNECTED}}i(un,"mapStatusToWalletState");function Lp(t,e,o,n){return o.filter(r=>!Tp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,namespaces:u,singleNamespace:c,supportedChains:m,needsDerivationPath:h,properties:f,isHub:d}=e(r),g=Wo(m.map(S=>S.type)),C=un(t(r));return{title:a,image:s,link:iy(l),state:C,type:r,showOnMobile:p,namespaces:u,singleNamespace:c,blockchainTypes:g,needsDerivationPath:h,properties:f,isHub:d}})}i(Lp,"mapWalletTypesToWalletInfo");function mr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(mr,"walletAndSupportedChainsNames");function Pp(t,e,o,n,r){let a=[];function s(p,u){if(!!!a.find(m=>m.chain===p)){let m={address:u,chain:p,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(p=>{let{address:u,network:c}=ry(p),m=l.length>0,h=l.includes(c),f=c===Mp.Unknown;if(m&&!h&&!f)return;let g=c===Mp.Unknown&&sy(u);if(f&&!g)return;o.includes(c)||g?r?s(c,u.toLowerCase()):l.filter(T=>o.includes(T)).forEach(T=>{s(T,u.toLowerCase())}):s(c,u)}),a}i(Pp,"prepareAccountsForWalletStore");function ao(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,h=u.to.blockchain,f=a===o.swaps.length-1,d=c===p.length-1;(!f&&!d||f&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(ao,"getQuoteWallets");function Dp(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Dp,"isAccountAndWalletMatched");var _p=i(t=>{let e=Object.values(t).reduce((o,n)=>n.usdValue?o.plus(n.usdValue):o,new io(Ce));return py(e.toString())},"calculateWalletUsdValue");function py(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(py,"numberWithThousandSeparator");var dr=i((t,e)=>{let o=ay(Object.entries(t).map(([,n])=>n).filter(ly));return o&&o[e]?.experimental},"isExperimentalChain");function fr(t){if(!t)return null;let e=new io(t.amount).shiftedBy(-t.decimals).toFixed(),o=t.usdValue?new io(t.usdValue).shiftedBy(-t.decimals).toFixed():null,n=B(e,8,8),r=o?B(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(fr,"formatBalance");function $p(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new io(t.usdValue).shiftedBy(-t.decimals):Ce,n=e&&e.usdValue?new io(e.usdValue).shiftedBy(-e.decimals):Ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new io(t.amount).shiftedBy(-t.decimals):Ce,n=e&&e.amount?new io(e.amount).shiftedBy(-e.decimals):Ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i($p,"compareTokenBalance");function Mt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Mt,"areTokensEqual");function Fp(t){return t.sort((e,o)=>+(o.state===xt.CONNECTED)-+(e.state===xt.CONNECTED)||+(o.state===xt.DISCONNECTED||o.state===xt.CONNECTING)-+(e.state===xt.DISCONNECTED||e.state===xt.CONNECTING))}i(Fp,"sortWalletsBasedOnConnectionState");function gr(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(gr,"getConciseAddress");function Op({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Op,"getAddress");var Up=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function zp(t){return t.map(e=>e.state).join("-")}i(zp,"hashWalletsState");function Qp(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Qp,"filterBlockchainsByWalletTypes");function qp(t,e){return e===ny.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(lr(n,e))return!0;return!1})}i(qp,"filterWalletsByCategory");var ma={API_KEY:ar};function Lt(t){return ma[t]||""}i(Lt,"getConfig");function Hp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ma=e,ma}i(Hp,"initConfig");var Gp=20,Vp=25,da="theme-widget",fa=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Mt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Mt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),ga=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Kp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var hr,bt=i(()=>hr||(hr=new cy(Lt("API_KEY"),Lt("BASE_URL")),hr),"httpService");function yr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Wo(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(p=>p===s.swapperGroup)),l&&s.types.map(p=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:p,selected:!e.includes(s.swapperGroup)})})}}),n}i(yr,"getUniqueSwappersGroups");function jp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(jp,"sortLiquiditySourcesByGroupTitle");function je(t,e){return e?.[t]==="hidden"}i(je,"isFeatureHidden");function Xp(t,e){return e?.[t]==="enabled"}i(Xp,"isFeatureEnabled");function Bo(t,e){return e?.[t]==="enabled"}i(Bo,"isRoutingEnabled");var Yp=i((t,e,o)=>je("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Zp=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let p=ir({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>yp.includes(c.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(p=>!(s.length>0&&!s.includes(p.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),p=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",c=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=Ao.get(c);m?.length||(m=ln({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Ao.set(c,m)),m=Yp(m,s,a.features);let h=e().blockchains({type:o.type});return m.filter(d=>o.blockchain&&d.blockchain!==o.blockchain||!h.some(g=>g.name===d.blockchain)?!1:o.searchFor?!!(Re(d.symbol,o.searchFor)||Re(d.address||"",o.searchFor)||Re(d.name||"",o.searchFor)):!0).sort((d,g)=>{let C=e().isTokenPinned(d,o.type),S=e().isTokenPinned(g,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(d),L=o.getBalanceFor(g),b=$p(I,L);if(b!==0)return b}let T=p.get(d.blockchain),v=p.get(g.blockchain),k=ia(d,T),w=ia(g,v);if(k!==w)return k?-1:1;if(d.isPopular!==g.isPopular)return d.isPopular?-1:1;if(o.searchFor){let I=Ap(d,g,o.searchFor);if(I)return I}return d.isSecondaryCoin!==g.isSecondaryCoin?d.isSecondaryCoin?1:-1:T&&v?T.sort-v.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=pt(o),s=n.get(a);return s||(s=r.find(l=>pt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Mt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let c=a?.includes(u.swapperGroup);return s||!a||a.length===0?!c:c}).sort(jp)},fetch:async()=>{try{let{routing:o}=e().config,n=Bo("enableCentralizedSwappers",o),r=await bt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},p=[],u=r.popularTokens,c=r.swappers.filter(f=>f.enabled),m=new Set;r.tokens.forEach(f=>{m.add(f.blockchain),p.push(f)}),r.blockchains.sort((f,d)=>f.sort-d.sort).forEach(f=>{f.enabled&&m.has(f.name)&&a.set(f.name,f)}),p.forEach(f=>{let d=pt(f);l[f.blockchain]||(l[f.blockchain]=[]),s.set(d,f),l[f.blockchain].push(d)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:u,_swappers:c})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as uy,Catalonia as my,Chinese as Jp,Denmark as dy,English as fy,Finland as gy,French as hy,German as yy,Greece as Sy,Hungary as Cy,India as Ty,Indonesian as ky,Italian as vy,Japanese as wy,Korea as xy,Lithuania as by,Malay as Ey,Netherlands as Iy,Pakistan as Ay,Philippines as Ny,Poland as Wy,Portuguese as By,Russian as My,SaudiArabia as Ly,Serbia as Py,Slovakia as Dy,SouthAfrica as _y,Spanish as $y,Swahili as Fy,Swedish as Oy,Thai as Uy,Turkish as zy,Ukrainian as Qy,Vietnamese as qy}from"@rango-dev/ui";var Rp=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:_y},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ly},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:uy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:my},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Jp},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Jp},{title:"Danish",label:"Dansk",local:"da",SVGFlag:dy},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:Iy},{title:"English",label:"English",local:"en",SVGFlag:fy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:Ny},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:gy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:hy},{title:"German",label:"Deutsch",local:"de",SVGFlag:yy},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:Sy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:Ty},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:Cy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:ky},{title:"Italian",label:"Italiana",local:"it",SVGFlag:vy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:wy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:xy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:by},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Ey},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Wy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:By},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:My},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Py},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Dy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:$y},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Fy},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Oy},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:Uy},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:zy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Qy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:Ay},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:qy}],Mo="en";var ec=[.5,1,3],tc=1,oc=5,nc=100,rc=0;var ic=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:tc,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let p=s===o,u=l<=9;return p&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Wo(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=je("theme",n),s=je("language",n),l=je("liquiditySource",n),p=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...p&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Mo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Mo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=ir({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import cc from"bignumber.js";import Hy from"mitt";var ge=Hy(),Gy={on:ge.on,off:ge.off};import{WidgetEvents as ac}from"@rango-dev/queue-manager-rango-preset";var ya=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ya||{}),Sa=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Sa||{}),Ca=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Ca||{}),Lo=(a=>(a[a.RouteEvent=ac.RouteEvent]="RouteEvent",a[a.StepEvent=ac.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Lo||{});import Vy from"bignumber.js";function mn(t){return`${t.blockchain}-${t.address}-${t.symbol}`}i(mn,"createAssetKey");function Ta(t,e){return`${mn(e)}-${t}`}i(Ta,"createBalanceKey");function Sr(t){let[e,o,n]=t.split("-");return{address:o,blockchain:e,symbol:n}}i(Sr,"extractAssetFromBalanceKey");function sc(t,e){let o={};return t.balances?.forEach(n=>{let r=Ta(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,p=l?new Vy(l??Ce).multipliedBy(a).toString():"",u={amount:a,decimals:s,usdValue:p};o[r]=u}),o}i(sc,"createBalanceStateForNewAccount");function lc(t,e){for(let o in e){let n=Sr(o),r=mn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(lc,"updateAggregatedBalanceStateForNewAccount");function pc(t,e){let o=Sr(e),n=mn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(pc,"removeBalanceFromAggregatedBalance");var uc=i((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!1}:r)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:o=>{let n=e().connectedWallets,r=o.filter(a=>!n.some(s=>Dp(a,s)));if(r.length>0){let a=r.map(s=>{let l=!n.some(p=>p.chain===s.chain&&p.selected&&p.walletType!==s.walletType);return{address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!1,error:!1}});t(s=>({connectedWallets:[...s.connectedWallets.filter(p=>!a.some(u=>u.walletType===p.walletType&&u.chain===p.chain)),...a]}))}},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async o=>{ge.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o),e().fetchBalances(o)},removeBalancesForWallet:o=>{let n=e().connectedWallets.filter(p=>p.walletType===o);e().connectedWallets.forEach(p=>{p.walletType!==o&&(n=n.filter(u=>!(u.chain===p.chain&&u.address===p.address)))});let r={},a=e()._aggregatedBalances,s=e()._balances;Object.keys(s).forEach(p=>{let u=Sr(p),c=!!n.find(m=>Ta(m.address,{address:u.address,blockchain:m.chain,symbol:u.symbol})===p);c||(r[p]=s[p]),c&&(a=pc(a,p))}),t({_balances:r,_aggregatedBalances:a})},disconnectWallet:o=>{if(e().connectedWallets.find(r=>r.walletType===o)){ge.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),e().removeBalancesForWallet(o);let r=e().connectedWallets.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain),a=e().connectedWallets.filter(s=>s.walletType!==o);r.length>0&&(a=a.map(s=>r.includes(s.chain)?(r=r.filter(l=>l!==s.chain),{...s,selected:!0}):s)),t({connectedWallets:a})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(r);let a=o.map(p=>({address:p.address,blockchain:p.chain})),l=(await bt().getWalletsDetails(a)).wallets;if(l){let{retryOnFailedBalances:p=!0}=n||{};if(p){let m=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));m.length>0&&e().fetchBalances(m,{retryOnFailedBalances:!1})}let u={},c=e()._aggregatedBalances;l.forEach(m=>{if(m.failed)return;let h=sc(m,e);c=lc(c,h),u={...u,...h}}),t(m=>({_balances:{...m._balances,...u},_aggregatedBalances:c})),e().setConnectedWalletRetrievedData(r)}else throw e().setConnectedWalletHasError(r),new Error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=mn(o),a=e()._aggregatedBalances[r]||[];if(a.length===0)return null;if(a.length===1){let p=a[0];return n[p]}let l=n[a[0]];return a.forEach(p=>{let u=n[p],c=new cc(u.amount),m=new cc(l.amount);c.isGreaterThan(m)&&(l=u)}),l}}),"createWalletsSlice");function mc(t){return Ky()(jy((...e)=>({...uc(...e),...Zp(...e),...ic(...e),...gp(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(mc,"createAppStore");var dc=Yy(null);function y(){let t=Zy(dc);if(Jy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function fc(t){let e=Ry();return e.current||(e.current=mc(t.config)),Xy.createElement(dc.Provider,{value:e.current},t.children)}i(fc,"AppStoreProvider");import{allProviders as eS}from"@rango-dev/provider-all";import{defineVersions as Cr,pickVersion as gc,Provider as Tr}from"@rango-dev/wallets-core";function kr(t,e){let o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0},n=eS(o);if(t){let r=[];return t.forEach(a=>{if(typeof a=="string"){let s=hc(n,e).find(l=>l instanceof Tr?l.id===a:l.config.type===a);s?s instanceof Tr?r.push(Cr().version("1.0.0",s).build()):r.push(Cr().version("0.0.0",s).build()):console.warn(`Couldn't find ${a} provider. Please make sure you are passing the correct name.`)}else a instanceof Tr?r.push(Cr().version("1.0.0",a).build()):r.push(Cr().version("0.0.0",a).build())}),r}return n}i(kr,"matchAndGenerateProviders");function hc(t,e){let{experimentalWallet:o="enabled"}=e||{};return t.map(n=>{let r=o=="disabled"?"0.0.0":"1.0.0";try{return gc(n,r)[1]}catch{return gc(n,"0.0.0")[1]}})}i(hc,"pickVersionWithFallbackToLegacy");function yc(t,e){return hc(kr(t,e),e).map(r=>r instanceof Tr?r.id:r.config.type)}i(yc,"configWalletsToWalletName");var aS=Object.values(Po);function gt(t){let{chain:e}=t||{},{config:o,connectedWallets:n}=y(),{state:r,getWalletInfo:a}=tS(),s=y().blockchains(),{handleDisconnect:l}=Ht(),p=yc(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,tonConnect:o.tonConnect})||aS,u=Lp(r,a,p,e);u=oS()?u.filter(g=>g.showOnMobile!==!1&&r(g.type).installed):u;let c=Fp(u),m=i(g=>!n.find(C=>C.walletType===g&&C.chain===e),"isExperimentalChainNotAdded"),h=rS(()=>{let g=u?.filter(C=>C.state===ka.CONNECTING)||[];for(let C of g)l(C.type)},[zp(u)]);iS(()=>()=>{h()},[]);let f=i(g=>{let C=g.find(T=>T.type===Po.DEFAULT);return!C||C.state===ka.NOT_INSTALLED?!1:g.filter(T=>T.state!=ka.NOT_INSTALLED&&![Po.DEFAULT,Po.WALLET_CONNECT_2,Po.LEDGER].includes(T.type)&&a(T.type).supportedChains.filter(v=>v.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),d=i((g,C,S)=>dr(S,C)&&m(g)&&!nS.includes(g)||g==Po.DEFAULT&&!f(u),"shouldExcludeWallet");return{list:c.filter(g=>!d(g.type,e??"",s)),terminateConnectingWallets:h}}i(gt,"useWalletList");import{Modal as cS}from"@rango-dev/ui";import uS from"react";import{create as pS}from"zustand";var Sc="rango-widget";var dn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(Sc),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var lS=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),Do=lS;var le=Do(pS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})}}))),so=new dn({onInit:()=>le.setState({tabManagerInitiated:!0}),onClaim:()=>le.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>le.setState({isActiveTab:!1})});function R(t){let{watermark:e}=le();return uS.createElement(cS,{hasWatermark:e==="FULL",...t},t.children)}i(R,"WatermarkedModal");import{i18n as va}from"@lingui/core";import{Button as yS,Checkbox as SS,Divider as CS,Image as Ac,ListItemButton as TS,MessageBox as kS,Radio as vS,RadioRoot as wS}from"@rango-dev/ui";import{namespaces as Nc}from"@rango-dev/wallets-shared";import ke,{useMemo as xS,useState as bS}from"react";import{css as mS,darkTheme as Tc,IconButton as dS,styled as lo}from"@rango-dev/ui";var Et=lo(dS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Tc} &`]:{backgroundColor:"$neutral"}}}),kc=lo("div",{position:"absolute",background:"$secondary500",[`.${Tc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Gt=lo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),vc=lo("div",{position:"absolute",width:"14px",height:"14px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"7px",top:"$0",right:"$0",variants:{isSever:{true:{backgroundColor:"$error500"},false:{backgroundColor:"$secondary500"}}}}),wc=lo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),xc=lo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),bc=mS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),vr=lo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as fS,styled as wr}from"@rango-dev/ui";var cN=wr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),_o=wr("div",{position:"relative"}),gS=fS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),$o=wr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${gS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),xr=wr("div",{"& img":{borderRadius:"50%"}});function Ec(t,e){return t.find(o=>o.name===e)?.logo}i(Ec,"getBlockchainLogo");import{styled as hS}from"@rango-dev/ui";var Ic=hS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function fn(t){let{singleNamespace:e,availableNamespaces:o,providerImage:n}=t.value,[r,a]=bS([]),s=y().blockchains(),l=xS(()=>o?.map(c=>({name:c,logo:Ec(s,Nc[c].mainBlockchain),title:Nc[c].title})),[o]),p=i(c=>{a(e?[c]:m=>m.includes(c)?m.filter(h=>h!==c):m.concat(c))},"onSelect"),u=i(c=>e?ke.createElement(wS,{value:r?.[0]},c):ke.createElement(ke.Fragment,null,c),"wrapRadioRoot");return ke.createElement(ke.Fragment,null,ke.createElement(CS,{size:20}),ke.createElement(kS,{type:"info",title:va.t("Select chain types"),description:va.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:ke.createElement(_o,null,ke.createElement(vr,null,ke.createElement(Ac,{src:n,size:45})),ke.createElement($o,null))}),ke.createElement(Ic,null,u(ke.createElement(ke.Fragment,null,l?.map(c=>ke.createElement(TS,{key:c.name,id:c.name,title:c.title,hasDivider:!0,style:{height:60},onClick:()=>p(c.name),start:ke.createElement(Ac,{src:c.logo,size:22}),end:e?ke.createElement(vS,{value:c.name}):ke.createElement(SS,{checked:r.includes(c.name)})}))))),ke.createElement(yS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},va.t("Confirm")))}i(fn,"Namespaces");import{i18n as Fo}from"@lingui/core";import{Button as AS,Divider as Mc,Image as NS,MessageBox as WS,Select as BS,TextField as MS}from"@rango-dev/ui";import Fe,{useEffect as LS,useState as Lc}from"react";import{namespaces as ES}from"@rango-dev/wallets-shared";var br={id:"custom",label:"Custom",generateDerivationPath:t=>t};function wa(t){let e=t?ES[t].derivationPaths:null;return e?[...e,br]:[]}i(wa,"getDerivationPaths");import{styled as Wc,Typography as IS}from"@rango-dev/ui";var Bc=Wc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),xa=Wc(IS,{paddingLeft:"$10"}),ba={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Pc="0";function gn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Lc(null),[l,p]=Lc(Pc),u=a===br.id,c=wa(o),m=i(({value:f})=>{let d=c?.find(g=>g.id===f);d&&(a===br.id&&Number.isNaN(Number(l))&&p(Pc),s(d.id))},"handleDerivationPathItemClick"),h=i(()=>{let f=c.find(d=>d.id===a);if(f)e(f.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return LS(()=>{s(wa(o)[0]?.id||null)},[o]),Fe.createElement(Fe.Fragment,null,Fe.createElement(Mc,{size:20}),Fe.createElement(WS,{type:"info",title:Fo.t("Select Derivation Path"),description:Fo.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Fe.createElement(_o,null,Fe.createElement(xr,null,Fe.createElement(NS,{src:n,size:45})),Fe.createElement($o,null))}),Fe.createElement(Bc,null,Fe.createElement(xa,{variant:"body",size:"xsmall",color:"$neutral600"},Fo.t("Choose Derivation Path Template")),Fe.createElement(BS,{value:a||"",options:c.map(f=>({value:f.id,label:f.label})),variant:"filled",handleItemClick:m,styles:{trigger:ba}}),Fe.createElement(Mc,{size:20}),Fe.createElement(xa,{variant:"body",size:"xsmall",color:"$neutral600"},u?Fo.t("Enter Path"):Fo.t("Enter Index")),Fe.createElement(MS,{type:u?"text":"number",variant:"contained",value:l,onChange:f=>p(f.target.value),style:ba})),Fe.createElement(AS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!c||!a||!l},Fo.t("Confirm")))}i(gn,"DerivationPath");import{i18n as Oo}from"@lingui/core";import{Image as PS,MessageBox as Ea,WalletState as DS}from"@rango-dev/ui";import{useWallets as _S}from"@rango-dev/wallets-react";import po from"react";function Ia(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=_S();return un(a(n))===DS.CONNECTED?po.createElement(Ea,{type:"success",title:Oo.t("Wallet Connected"),description:Oo.t("Your wallet is connected, you can use it to swap.")}):o?po.createElement(Ea,{type:"error",title:Oo.t("Failed to Connect"),description:o||Oo.t("Your wallet is not connected. Please try again.")}):po.createElement(Ea,{type:"loading",title:Oo.t("Connecting to your wallet"),description:Oo.t("Click connect in your wallet popup."),icon:po.createElement(_o,null,po.createElement(xr,null,po.createElement(PS,{src:r,size:45})),po.createElement($o,null))})}i(Ia,"ConnectStatus");import{i18n as Aa}from"@lingui/core";import{Button as $S,Divider as Dc,MessageBox as FS}from"@rango-dev/ui";import Er from"react";function Na(t){let{displayName:e,onConfirm:o}=t;return Er.createElement(FS,{title:Aa.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Aa.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Er.createElement(Dc,{size:18}),Er.createElement(Dc,{size:32}),Er.createElement($S,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Aa.t("Confirm")))}i(Na,"ExperimentalChain");function _c(t,e){return t().status==="init"&&!!e}i(_c,"isOnStatus");function hn(t){return t().status==="namespace"}i(hn,"isOnNamespace");function yn(t){return t().status==="derivationPath"}i(yn,"isOnDerivationPath");var QS=3e3,qS=300;function uo(t){let e=zS(),[o,n]=$c(!1),[r,a]=$c(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=gt(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:h}=Ht(),f=i(S=>{c(t.wallet,S).catch(s)},"handleConfirmNamespaces"),d=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(S).catch(s)},"handleDerivationPathConfirm"),g=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return US(()=>{if(t.wallet){C();let S=!1,T=!0,v=i(()=>{setTimeout(()=>{T=!1,S||n(!0)},qS)},"beforeConnecting"),k=i(w=>{let I=w.status==="connected",L=["disconnected","disconnected-unhandled"].includes(w.status);["namespace","derivation-path"].includes(w.status)||(S=!0),I&&!T?e.current=setTimeout(g,QS):L&&g(),t.onConnect&&t.onConnect(w)},"afterConnected");v(),p(t.wallet,{disconnectIfConnected:!0}).then(k).catch(s)}},[t.wallet]),co.createElement(R,{open:o,onClose:g,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:N()},_c(m,t.wallet)&&co.createElement(co.Fragment,null,co.createElement(Ia,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),co.createElement(OS,{direction:"vertical",size:32})),hn(m)&&co.createElement(fn,{onConfirm:f,value:m().namespace}),yn(m)&&co.createElement(gn,{onConfirm:d,value:m().derivationPath}))}i(uo,"StatefulConnectModal");import{Events as Ir,Provider as GS}from"@rango-dev/wallets-react";import{isEvmBlockchain as VS}from"rango-sdk";import Ar,{createContext as KS,useEffect as Oc,useMemo as jS,useRef as Uc}from"react";import{useEffect as HS}from"react";function Fc(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Fc,"hashProviders");function Wa(t,e){let{clearConnectedWallet:o}=y(),n=kr(t,e);return HS(()=>{o(),n=kr(t,e)},[Fc(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(Wa,"useWalletProviders");var Nr=KS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function XS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),{newWalletConnected:s,disconnectWallet:l}=y(),p=y().config,u={walletConnectProjectId:p?.walletConnectProjectId,trezorManifest:p?.trezorManifest,tonConnect:p.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,experimentalWallet:t.config.features?.experimentalWallet},{providers:c}=Wa(p.wallets,u),m=Uc(),h=Uc();Oc(()=>{n().catch(console.log)},[]),Oc(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:p,dappConfig:t.config})},[t.config,r]);let f=a.filter(VS).map(S=>S.name),d=i((S,T,v,k,w)=>{if(T===Ir.ACCOUNTS)if(v){let I=mr(w.supportedBlockchains),L=Pp(S,v,f,I,w.isContractWallet);L.length&&s(L)}else l(S),h.current?h.current(S):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?");if(T===Ir.ACCOUNTS&&k.connected||T===Ir.ACCOUNTS&&w.isHub){let I=`${S}-${k.network}-${v}`;m.current?m.current(I):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(T===Ir.NETWORK&&k.network){let I=`${S}-${k.network}`;m.current?m.current(I):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(S,T,v,k,w)},"onUpdateState"),g=le.use.isActiveTab(),C=jS(()=>({onConnectWallet:S=>{m.current=S},onDisconnectWallet:S=>{h.current=S}}),[]);return Ar.createElement(Nr.Provider,{value:C},Ar.createElement(GS,{allBlockChains:a,providers:c,onUpdateState:d,autoConnect:!!g,configs:{isExperimentalEnabled:Xp("experimentalWallet",p.features)}},t.children))}i(XS,"Main");function Wr(t){let{config:e,...o}=t;return Ar.createElement(fc,{config:e},Ar.createElement(XS,{...o,config:e}))}i(Wr,"WidgetWallets");import oa from"react";import YS,{Fragment as ZS}from"react";import{MemoryRouter as JS,useInRouterContext as RS}from"react-router";function zc({children:t}){let o=RS()?ZS:JS;return YS.createElement(o,null,t)}i(zc,"AppRouter");import{I18nManager as LE}from"@rango-dev/ui";import sp from"react";import Le from"react";import{useRoutes as CE}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Qo,useRef as Or}from"react";import Xe from"bignumber.js";import{create as oC}from"zustand";import{subscribeWithSelector as nC}from"zustand/middleware";import{getLastSuccessfulStep as tC}from"@rango-dev/queue-manager-rango-preset";import SB from"bignumber.js";function Ba(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(Ba,"getFeeLabel");var Ma=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Qc=30,qc=15,Hc=60;import{i18n as ht}from"@lingui/core";import{RouteEventType as nB}from"@rango-dev/queue-manager-rango-preset";import Oe from"bignumber.js";import{PendingSwapNetworkStatus as Mr}from"rango-types";import{i18n as De}from"@lingui/core";var te=i(()=>({genericServerError:De.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:De.t("Please reset your liquidity sources."),description:De.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:De.t("No Routes Found."),description:De.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:De.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:De.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:De.t("High Price Impact"),title:De.t("Price impact is too high!"),description:De.t("The price impact is significantly higher than the allowed amount."),confirmMessage:De.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:De.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:De.t("USD Price Unknown"),title:De.t("USD Price Unknown, Cannot calculate Price Impact."),description:De.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:De.t("Confirm USD Price Unknown")}}),"errorMessages");function Gc(t){switch(t.type){case 0:return t.diagnosisMessage??te().noResultError.title;case 1:return te().genericServerError;default:return""}}i(Gc,"getQuoteErrorMessage");import{i18n as Br}from"@lingui/core";var mo=i(()=>({connectWallet:Br.t("Connect Wallet"),swap:Br.t("Swap"),swapAnyway:Br.t("Swap anyway"),ethWarning:Br.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Vc(t,e){return(parseInt(e.toFixed(2)||"0")<=-10&&t?.gte(new Oe(400))||parseInt(e.toFixed(2)||"0")<=-5&&t?.gte(new Oe(1e3)))??!1}i(Vc,"hasHighValueLoss");function Kc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Oe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Oe(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Kc,"hasLimitError");function jc(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new Oe(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Oe(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?p?.gte(l.fromAmount)||u?.lte(l.fromAmount):p?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Oe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Oe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=ht.t({id:"Required: >= {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=ht.t({id:"Required: > {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=ht.t({id:"Required: <= {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=ht.t({id:"Required: < {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(jc,"getLimitErrorMessage");function Xc(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:mo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:mo().swap,action:"confirm-swap",disabled:!0}:s?{title:mo().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:mo().ethWarning,action:"confirm-warning",disabled:!1}:{title:mo().swap,action:"confirm-swap",disabled:!1}:{title:mo().connectWallet,action:"connect-wallet",disabled:!1}}i(Xc,"getSwapButtonState");function La(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(Ce))&&e&&e!=="0"&&n!==0)}i(La,"canComputePriceImpact");function Pa(t,e){let o=Ce;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Oe(r.amount).multipliedBy(a||0))}return o}i(Pa,"getUsdFeeOfStep");function Lr(t,e){return t.reduce((o,n)=>o.plus(Pa(n,e)),Ce)}i(Lr,"getTotalFeeInUsd");function Da(t){let e=Ce;return e=e.plus(new Oe(t.amount).multipliedBy(t.price||0)),e}i(Da,"getUsdFee");function Yc(t){return t.reduce((e,o)=>e.plus(Da(o)),Ce)}i(Yc,"getTotalFeesInUsd");function Zc(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(Zc,"getFeesGroup");function Jc(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?e:null}i(Jc,"checkSlippageErrors");function Rc(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?o:null}i(Rc,"checkSlippageWarnings");function Pr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Pr,"getMinRequiredSlippage");function eu(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(eu,"hasProperSlippage");function tu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:h,destination:f}=t,d=a?.reduce((S,T)=>(S[T.chain]=T.address,S),{}),g=[];return r?.forEach(S=>{g.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:h??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:g,selectedWallets:d??{},slippage:u.toString(),...f&&{destination:f},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(tu,"createQuoteRequestBody");function ou(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(ou,"getWalletsForNewSwap");function Uo(t){return t?.outputAmount||null}i(Uo,"getQuoteOutputAmount");function nu(t,e){return new Oe(e).div(new Oe(t)).minus(1).multipliedBy(100).toNumber()}i(nu,"getPercentageChange");function ru(t,e){let o=Uo(t),n=Uo(e);if(!o||!n)return!1;let r=ct(o,n);return r?r<=-1:!0}i(ru,"isOutputAmountChangedALot");function iu(t,e,o){let n=t.validationStatus,r=ao({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>uu(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=B(new Oe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=B(new Oe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=ht.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=ht.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=ht.t(" for input and network fee")),ht.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:c,currentAmount:p,blockchain:lt(s.asset.blockchain,o)}})})}i(iu,"generateBalanceWarnings");function Kt(t,e){return(t?new Oe(t):Ce).multipliedBy(e||0)}i(Kt,"calcOutputUsdValue");function Sn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Mr.NetworkChanged}i(Sn,"isNetworkStatusInWarningState");function au(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),Sn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Mr.WaitingForConnectingWallet:n=n||ht.t("Waiting for connecting wallet");break;case Mr.WaitingForQueue:n=n||ht.t("Waiting for other running tasks to be finished");break;case Mr.WaitingForNetworkChange:n=n||ht.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(au,"getSwapMessages");function su(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(su,"getLastConvertedTokenInFailedSwap");function lu(t){return t.status==="failed"}i(lu,"shouldRetrySwap");function pu(t,e,o,n,r,a){if(!n||t)return!0;let s=ao({filter:"all",quote:n}),l=ao({filter:"required",quote:n}),p=s.every(m=>r.some(h=>h.chain===m)),u=l.every(m=>r.some(h=>h.chain===m)),c=o&&a?No(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(pu,"isConfirmSwapDisabled");function cu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(cu,"isTokensIdentical");function fo(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(fo,"getQuoteToTokenUsdPrice");function Cn(t){return(t?.swaps||[])[0].from.usdPrice}i(Cn,"getQuoteFromTokenUsdPrice");function _a(t,e){let o=t?.swaps||[],n=e?.swaps||[];return o.length!==n.length}i(_a,"isNumberOfSwapsChanged");function $a(t,e){let o=t?.swaps.map(r=>r.swapperId)||[],n=e?.swaps.map(r=>r.swapperId)||[];return!ua(o,n)}i($a,"isQuoteSwappersUpdated");function Fa(t,e){let o=t?.swaps.map(r=>r.to.symbol)||[],n=e?.swaps.map(r=>r.to.symbol)||[];return!ua(o,n)}i(Fa,"isQuoteInternalCoinsUpdated");function du(t,e){return _a(t,e)||$a(t,e)||Fa(t,e)}i(du,"isQuoteChanged");function uu(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(uu,"getRequiredBalanceOfWallet");function Pt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Pt,"getPriceImpactLevel");function _r(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=tC(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=sn(a?a.toBlockchain:n.fromBlockchain,e),p=sn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(_r,"createRetryQuote");function zo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=Kt(t.requestAmount,Cn(t)||o?.usdPrice),l=Kt(t.outputAmount,fo(t)||n?.usdPrice);if(t&&s&&l){let c=ct(s.toString(),l.toString());if(!!c&&Vc(s,c)){let h=Lr(t?.swaps,r),f=Pt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:h,warningLevel:f}}}else if(t&&(!s||!l))return{type:1};let p=Pr(t.swaps),u=a>oc;if(eu(e.userSlippage.toString(),p)){if(u&&parseFloat(p??"0")<a)return{type:3,slippage:a.toString()}}else return{type:2,recommendedSlippages:Rc(t,a),minRequiredSlippage:p};return null}i(zo,"generateQuoteWarnings");function ct(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:nu(t.toString(),e.toString());return n&&n<0?n:null}i(ct,"getPriceImpact");var fu=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),$r=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(c=>c.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),p=n.requestId.toLowerCase();return l.localeCompare(p)}),"sortQuotesBy"),gu=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,validationStatus:null,...e[0]};let n=new Set(t.swaps.map(a=>a.swapperId)),r=e.find(a=>{let s=new Set(a.swaps.map(l=>l.swapperId));return Array.from(n).every(l=>s.has(l))});return{requestAmount:o,validationStatus:null,...r||e[0]}},"getDefaultQuote"),hu=i(t=>{let e=i((o,n)=>{let r=Ma.indexOf(o.value),a=Ma.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");var Fr=i((t,e)=>t?.usdPrice?new Xe(e||Ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Do(oC()(nC(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Xe(0),outputUsdValue:new Xe(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=Ce,a=o.inputUsdValue;return cn(o.inputAmount)?(e&&(n=e?.outputAmount?new Xe(e?.outputAmount):null,a=Kt(o.inputAmount,Cn(e)||o.fromToken?.usdPrice),r=Kt(e.outputAmount,fo(e)||o.toToken?.usdPrice)),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Xe(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Xe(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:Fr(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Fr(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Fr(n??null,s),outputUsdValue:new Xe(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Fr(e.toToken,e.outputAmount?.toString()||""):new Xe(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Xe(0),inputUsdValue:new Xe(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),yu=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ge.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&ge.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function Su(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=O(),c=y().config,m=y().fetchStatus,h=y().blockchains(),f=y().tokens(),{findToken:d}=y(),{setAffiliateRef:g,setAffiliatePercent:C,setAffiliateWallets:S}=y(),T=c?.from?.tokens,v=c?.from?.blockchains,k=c?.to?.tokens,w=c?.to?.blockchains,I=Or(void 0),L=Or(void 0),b=Or(void 0),E=Or(void 0);Qo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Qo(()=>{if(m==="success"){r();let x=h.find(A=>A.name===c?.from?.blockchain),W=c?.from?.token,D=W&&d(W);(x||!x&&b.current)&&n(x??null),D?a({token:D,meta:{blockchains:h,tokens:f}}):!D&&I.current&&a({token:null}),b.current=c?.from?.blockchain,I.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Qo(()=>{fa(s,T)&&a({token:null}),ga(p,v)&&n(null)},[T,v]),Qo(()=>{fa(l,k)&&a({token:null}),ga(u,w)&&o(null)},[k,w]),Qo(()=>{if(m==="success"){r();let x=h.find(A=>A.name===c?.to?.blockchain),W=c?.to?.token,D=W&&d(W);(x||!x&&E.current)&&o(x??null),D?e({token:D,meta:{blockchains:h,tokens:f}}):!D&&L.current&&e({token:null}),E.current=c?.to?.blockchain,L.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Qo(()=>{g(c?.affiliate?.ref??null),C(c?.affiliate?.percent??null),S(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(Su,"useSyncStoresWithConfig");import{useEffect as za,useRef as rC}from"react";import{useInRouterContext as iC,useLocation as aC,useSearchParams as sC}from"react-router-dom";function Oa(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Oa,"convertTokenSearchParamToAsset");function Ua(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Ua,"tokenToSearchParam");function qa(){let t=aC(),[e,o]=sC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:h}=O(),f=y().fetchStatus,d=y().blockchains(),g=y().tokens(),C=iC(),{updateIframe:S,updateCampaignMode:T}=y(),v=y().isInCampaignMode(),k=rC(),{findToken:w}=y(),I=i(()=>{let b={};for(let[K,pe]of e.entries())K.startsWith("utm_")&&(b[K]=pe);let E=e.get("fromAmount"),x=e.get("fromBlockchain"),W=e.get("fromToken"),D=e.get("toBlockchain"),A=e.get("toToken"),X=e.get("autoConnect"),se=e.get("clientUrl"),J=e.get("liquiditySources"),M=e.get("blockchain");return{fromAmount:E,fromBlockchain:x,fromToken:W,toBlockchain:D,toToken:A,autoConnect:X,clientUrl:se,liquiditySources:J,utmQueryParams:b,blockchain:M}},"getUrlSearchParams"),L=i(b=>{for(let E in b)b[E]||delete b[E];o(b,{replace:!0})},"updateUrlSearchParams");za(()=>{let{autoConnect:b,clientUrl:E,utmQueryParams:x,blockchain:W}=I();C&&f==="success"&&L({fromBlockchain:n?.name,fromToken:Ua(a),toBlockchain:r?.name,toToken:Ua(s),fromAmount:l,autoConnect:b??void 0,clientUrl:E??void 0,blockchain:W??void 0,liquiditySources:v?k.current:void 0,...x})},[t.pathname,l,n,a,r,s,v]),za(()=>{if(!C)return;let b=I();if(!k.current&&b.liquiditySources&&(k.current=b.liquiditySources),b.fromAmount&&h(b.fromAmount),f==="success"){let E=d.find(A=>A.name===b.fromBlockchain),x=b.fromToken&&E?w(Oa(b.fromToken,E)):void 0,W=d.find(A=>A.name===b.toBlockchain),D=b.toToken&&W?w(Oa(b.toToken,W)):void 0;E&&(p(E),x&&c({token:x,meta:{blockchains:d,tokens:g}})),W&&(u(W),D&&m({token:D,meta:{blockchains:d,tokens:g}}))}},[f]),za(()=>{let{clientUrl:b,liquiditySources:E}=I();S("clientUrl",b||void 0),T("liquiditySources",E?.split(",")??void 0)},[])}i(qa,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as kT,Button as Ju,darkTheme as vT,Divider as vn,DoneIcon as wT,MessageBox as xT,styled as bT,TextField as ET,Typography as IT}from"@rango-dev/ui";import he,{useEffect as AT,useState as Vr}from"react";import{useNavigate as NT,useSearchParams as WT}from"react-router-dom";import{ChevronRightIcon as lC,Divider as wu,Image as pC,Typography as xu}from"@rango-dev/ui";import yt from"react";import{darkTheme as Cu,styled as Ha}from"@rango-dev/ui";var Tu=Ha("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${Cu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Cu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),ku=Ha("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),vu=Ha("div",{display:"flex"});function Ga(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return yt.createElement(ku,null,yt.createElement(xu,{size:"large",variant:"label"},n),yt.createElement(wu,{size:10}),yt.createElement(Tu,{onClick:s?void 0:e,disabled:s},yt.createElement(vu,null,r&&yt.createElement(yt.Fragment,null,yt.createElement(pC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),yt.createElement(wu,{size:4,direction:"horizontal"})),yt.createElement(xu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),yt.createElement(lC,{size:12,color:"black"})))}i(Ga,"BlockchainSelectorButton");import{i18n as Ka}from"@lingui/core";import{Button as cC,Divider as Tn,ExternalLinkIcon as uC,Image as mC,Typography as Ho}from"@rango-dev/ui";import Ae from"react";function bu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(bu,"generateExplorerLink");import{darkTheme as qo,styled as Eu}from"@rango-dev/ui";var Va=Eu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${qo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${qo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${qo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${qo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Iu=Eu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${qo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${qo} &`]:{color:"$colors$neutral900"}}});function ja(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=bu(n.address,a);return Ae.createElement(R,{open:e,dismissible:!0,onClose:o,container:N()},Ae.createElement(Iu,null,Ae.createElement(mC,{src:n.image,size:45,type:"circular"}),Ae.createElement(Ho,{variant:"title",size:"medium"},n.name),Ae.createElement(Ho,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ae.createElement(Tn,{size:4}),Ae.createElement(Ho,{variant:"body",size:"medium"},s?Ae.createElement(Va,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ae.createElement(uC,{size:12,color:"gray"})):Ae.createElement(Va,null,n.address)),Ae.createElement(Tn,{size:4}),n.coinSource&&Ae.createElement(Ho,{className:"_coin-source",variant:"body",size:"xsmall"},Ka.t("via")," ",Ae.createElement(Ho,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ae.createElement(Tn,{size:"32"}),Ae.createElement(Ho,{size:"medium",variant:"body",className:"_custom-token-description"},Ka.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ae.createElement(Tn,{size:40}),Ae.createElement(Tn,{size:10}),Ae.createElement(cC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ka.t("Import")))}i(ja,"CustomTokenModal");import{useManager as gT}from"@rango-dev/queue-manager-react";import{BottomLogo as hT,Divider as Ku,Header as yT}from"@rango-dev/ui";import We,{useEffect as hs,useRef as ju,useState as ST}from"react";import{useRef as dC}from"react";function Ur(){return window.self!==window.top}i(Ur,"isAppLoadedIntoIframe");function Xa(){let t=dC(null),{iframe:e}=y(),o=Ur()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let p of l)n({type:"widget_height",data:{height:p.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Xa,"useIframe");import{useNavigate as fC}from"react-router-dom";function Ye(){let t=fC();return()=>t(-1)}i(Ye,"useNavigateBack");import{createTheme as os,darkTheme as AC,lightTheme as NC}from"@rango-dev/ui";import{useEffect as WC,useState as BC}from"react";import{theme as EC,darkColors as IC}from"@rango-dev/ui";import es from"react";function gC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(gC,"expandShortHexColor");function hC(t){return/[0-9]+$/.test(t)}i(hC,"isOverridingColor");function yC(t,e){return t.padStart(e,"0")}i(yC,"pad");function Ya(t){let e=Math.min(Math.max(Math.round(t),0),255);return yC(e.toString(16),2)}i(Ya,"intToHex");function SC(t){return`#${Ya(t.red)}${Ya(t.green)}${Ya(t.blue)}`}i(SC,"rgbToHex");function CC(t){let e=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return{red:e,green:o,blue:n}}i(CC,"hexToRGB");function TC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(TC,"generateShade");function kC(t,e){let o=.11*e;return{red:t.red+(255-t.red)*o,green:t.green+(255-t.green)*o,blue:t.blue+(255-t.blue)*o}}i(kC,"generateTint");function vC(t){return Au(t,TC)}i(vC,"calculateShades");function wC(t){return Au(t,kC)}i(wC,"calculateTints");function Au(t,e){let o=CC(t),n=[];for(let r=1;r<9;r++)n.push(SC(e(o,r)));return n}i(Au,"calculateColors");function Za(t,e,o){let a=wC(t).reverse().concat(t),s=vC(t),l=a.concat(s),p={},u=l.length;for(let c=0;c<u;c++){let m=100+(o?u-1-c:c)*50;p[`${e}${m}`]=l[c]}return p}i(Za,"createTintsAndShades");function Ja(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!hC(r)){let p=gC(a);Object.assign(n,Za(p,r,s))}}return{...n,...e}}i(Ja,"expandToGenerateThemeColors");var Nu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),xC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Nu(o%52)+e;return Nu(o%52)+e},"toAlphabeticName"),bC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Ra=i(t=>xC(bC(5381,JSON.stringify(t))>>>0),"toHash");function ts(t){let e=EC.colors,o={...e,...IC},n,r;if(t?.light){let s={colors:Ja(e,t.light)};n={id:`${da}-light-${Ra(s)}`,tokens:s}}if(t?.dark){let s={colors:Ja(o,t.dark,{reverseNeutralRange:!0})};r={id:`${da}-dark-${Ra(s)}`,tokens:s}}return{light:n,dark:r}}i(ts,"customizedThemeTokens");function Wu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>es.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(es.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(es.cloneElement(e,{key:l}))}}),o}i(Wu,"joinList");function Bu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Bu,"doesWindowPreferDarkColorScheme");function Go(t){let{colors:e,fontFamily:o=kp,borderRadius:n=Gp,secondaryBorderRadius:r=Vp}=t,[a,s]=BC(Bu()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=ts(e),c=os({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,NC.className],h=[c.className,AC.className];if(u){let d=os(u.id,u.tokens);m.push(d.className)}if(p){let d=os(p.id,p.tokens);h.push(d.className)}return WC(()=>{let d=i(g=>{g.matches?s("dark"):s("light")},"switchThemeListener");return Bu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",d),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",d)}},[]),{activeTheme:i(()=>{let d=m.join(" "),g=h.join(" ");return l==="auto"?a==="dark"?g:d:l==="dark"?g:d},"getActiveTheme"),mode:l==="auto"?a:l}}i(Go,"useTheme");var ut=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Mu}from"@lingui/core";import{Alert as MC,Button as LC}from"@rango-dev/ui";import Lu from"react";function ns(t){return Lu.createElement(MC,{action:Lu.createElement(LC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Mu.t("Activate this tab")),type:"warning",variant:"alarm",title:Mu.t("Another tab is open and handles transactions.")})}i(ns,"ActivateTabAlert");import{i18n as rs}from"@lingui/core";import{Button as PC,Divider as DC,MessageBox as _C}from"@rango-dev/ui";import zr from"react";function is(t){let{open:e,onClose:o,onConfirm:n}=t;return zr.createElement(R,{open:e,dismissible:!0,onClose:o,container:N()},zr.createElement(_C,{title:rs.t("Activate current tab"),type:"warning",description:rs.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},zr.createElement(DC,{size:20}),zr.createElement(PC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},rs.t("Confirm"))))}i(is,"ActivateTabModal");import{ChevronLeftIcon as $C}from"@rango-dev/ui";import Pu from"react";function as(t){return Pu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Pu.createElement($C,{color:"black",size:16}))}i(as,"BackButton");import{i18n as FC}from"@lingui/core";import{Button as OC,Typography as UC}from"@rango-dev/ui";import ss from"react";function ls(t){return ss.createElement(Gt,null,ss.createElement(OC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},ss.createElement(UC,{variant:"label",size:"medium",color:"error500"},FC.t("Cancel"))))}i(ls,"CancelButton");import{i18n as zC}from"@lingui/core";import{Image as QC,Tooltip as qC,WalletIcon as HC}from"@rango-dev/ui";import go from"react";function ps(t){let{list:e}=gt(),o=e.filter(r=>r.state==="connected"),n=o.length?go.createElement("div",{className:bc()},o.map(r=>go.createElement(vr,{key:r.title},go.createElement(QC,{src:r.image,size:14})))):zC.t("Connect Wallet");return go.createElement(qC,{container:t.container,side:"bottom",content:n},go.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&go.createElement(kc,null),go.createElement(HC,{size:18,color:"black"})))}i(ps,"WalletButton");import{i18n as qr}from"@lingui/core";import{NotificationsIcon as aT,Popover as sT,SettingsIcon as lT,Tooltip as Hr,TransactionIcon as pT}from"@rango-dev/ui";import Ne from"react";import{Notifications as jC}from"@rango-dev/ui";import XC from"react";import{useNavigate as YC}from"react-router-dom";import{create as GC}from"zustand";import{persist as VC,subscribeWithSelector as KC}from"zustand/middleware";var ve=Do(GC()(VC(KC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(p=>p.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(p=>p.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function cs(){let t=YC(),{getNotifications:e,clearNotifications:o}=ve(),n=e(),r=y().blockchains(),{findToken:a}=y();return XC.createElement(jC,{list:n,getBlockchainImage:l=>fp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(cs,"NotificationContent");import{useManager as ZC}from"@rango-dev/queue-manager-react";import{InProgressIcon as JC}from"@rango-dev/ui";import Du from"react";var RC=i(()=>{let{manager:t}=ZC();return ut(t).map(({swap:o})=>o).find(o=>o.status==="running")?Du.createElement(xc,null,Du.createElement(JC,{color:"info",size:6})):null},"InProgressTransactionBadge"),_u=RC;import{EventSeverity as eT}from"@rango-dev/queue-manager-rango-preset";import{Typography as tT}from"@rango-dev/ui";import $u from"react";function Fu(){let{getNotifications:t}=ve(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===eT.WARNING);return o?$u.createElement(vc,{isSever:n},$u.createElement(tT,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Fu,"NotificationsBadge");import{RefreshProgressButton as oT}from"@rango-dev/ui";import us,{useEffect as nT,useState as Ou}from"react";var rT=1e3,Uu=60,iT=100;function Qr({onClick:t}){let[e,o]=Ou(0),[n,r]=Ou(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");nT(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Uu&&l()},rT):s(p),document.addEventListener("visibilitychange",()=>a(p)),()=>{document.removeEventListener("visibilitychange",()=>a(p)),p&&clearInterval(p)}},[e,t]);let s=i(p=>{p&&clearInterval(p),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return us.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},us.createElement(wc,{onTransitionEnd:()=>r(!1),isRefetched:n},us.createElement(oT,{size:22,color:t?"black":"gray",progress:e/Uu*iT})))}i(Qr,"RefreshButton");function ho(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=je("notification",s)||r.includes("notifications");return Ne.createElement(Ne.Fragment,null,!r.includes("refresh")&&Ne.createElement(Hr,{container:a||N(),side:"top",content:qr.t("Refresh")},Ne.createElement(Qr,{onClick:e})),!l&&Ne.createElement(sT,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:N(),content:Ne.createElement(cs,null)},Ne.createElement("div",null,Ne.createElement(Hr,{container:N(),side:"top",content:qr.t("Notifications")},Ne.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Ne.createElement(aT,{size:18,color:"black"}),Ne.createElement(Fu,null))))),!r.includes("settings")&&Ne.createElement(Hr,{container:N(),side:"top",content:qr.t("Settings")},Ne.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Ne.createElement(lT,{size:18,color:"black"}))),!r.includes("history")&&Ne.createElement(Hr,{container:N(),side:"top",content:qr.t("History")},Ne.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Ne.createElement(pT,{size:18,color:"black"}),Ne.createElement(_u,null))))}i(ho,"HeaderButtons");import{i18n as ms}from"@lingui/core";import{Divider as Qu,MessageBox as mT,RefreshIcon as dT}from"@rango-dev/ui";import Vo from"react";import{Button as cT,styled as uT}from"@rango-dev/ui";var zu=uT(cT,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function ds(t){let{open:e,onClose:o}=t;return Vo.createElement(R,{open:e,dismissible:!0,onClose:o,container:N()},Vo.createElement(mT,{title:ms.t("Something went wrong"),type:"error",description:ms.t("Something went wrong. Please refresh the app.")},Vo.createElement(Qu,{size:30}),Vo.createElement(zu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Vo.createElement(dT,{size:20,color:"primary"}),Vo.createElement(Qu,{size:4,direction:"horizontal"}),ms.t("Refresh"))))}i(ds,"RefreshModal");function fs(t){let e=t.target;if(e){let o=e.scrollTop,n=N();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(fs,"onScrollContentAttachStatusToContainer");import{css as fT,styled as gs}from"@rango-dev/ui";var qu="700px",Gr=fT({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Hu=gs("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:qu},fixed:{height:qu}}}}),Gu=gs("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Vu=gs("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Xa(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:p}=y(),[u,c]=ST(!1),{config:{features:m,theme:h}}=y(),{watermark:f}=le(),d=f==="FULL",{activeTheme:g}=Go(h||{}),C=je("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:T,showActivateTabModal:v,setShowActivateTabModal:k,activateCurrentTab:w}=le(),I=Ye(),{manager:L}=gT(),E=ut(L).map(({swap:se})=>se).some(se=>se.status==="running"),x=i(()=>w(so.forceClaim,E),"onActivateTab"),W=i(()=>{r.onWallet?.()},"onConnectWallet"),D=typeof r.hasBackButton>"u"||r.hasBackButton,A=ju(null),X=ju(null);return hs(()=>(Ur()&&X.current&&e(X.current),()=>{o()}),[]),hs(()=>(A.current?.addEventListener("scroll",fs),()=>{A.current?.removeEventListener("scroll",fs)}),[]),hs(()=>{c(l==="failed")},[l]),We.createElement(Hu,{height:s,id:Pe.SWAP_BOX_ID,className:`${g()} ${Gr()}`,ref:X},We.createElement(yT,{prefix:D?We.createElement(as,{onClick:()=>{I(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:We.createElement(We.Fragment,null,r.suffix,r.onWallet&&!C&&We.createElement(ps,{container:N(),onClick:W,isConnected:!!p?.length}),r.onCancel&&We.createElement(ls,{onClick:r.onCancel}))}),We.createElement(Gu,{ref:A},n),We.createElement(is,{open:v,onClose:()=>k(!1),onConfirm:x}),We.createElement(Vu,null,We.createElement("div",{className:"footer__content"},T&&!S&&We.createElement("div",{className:"footer__alert"},We.createElement(ns,{onActivateTab:x}),We.createElement(Ku,{size:10})),a),We.createElement(Ku,{size:12}),We.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},We.createElement(hT,null))),We.createElement(ds,{open:u,onClose:()=>c(!1)}))}i(oe,"Layout");import{styled as CT}from"@rango-dev/ui";var Xu="$20 $20 $10 $20",kn=CT("div",{padding:Xu,overflowY:"auto",flexGrow:1});import{styled as TT}from"@rango-dev/ui";var ie=TT("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as Ko}from"@lingui/core";import{useState as Yu}from"react";function Zu(){let[t,e]=Yu(!1),[o,n]=Yu(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Ko.t("Duplicate Token"),message:Ko.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Ko.t("Token Already Exists"),message:Ko.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Ko.t("Token Not Found"),message:Ko.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:u}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:p,tokenAddress:u})=>{e(!0);try{if(a.some(d=>d.address?.toLowerCase()===u.toLowerCase())){let d=s("duplicated");n(d);return}let m=await bt().getCustomToken({blockchain:p,address:u});if(!m||!m.token||m.error){let d=s("not-found",p);n(d);return}let h=m.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let d=s("token-exist");n(d);return}return h}catch(c){if(c?.code==="ERR_BAD_REQUEST"){let m=s("not-found",p);n(m);return}throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Zu,"useFetchCustomToken");var BT=bT("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${vT} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),MT=1e3;function Ru(){let t=NT(),[e]=WT(),o=Ye(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=sn(a,r),[l,p]=Vr(""),[u,c]=Vr(!1),[m,h]=Vr(),{fetchCustomToken:f,loading:d,error:g}=Zu(),[C,S]=Vr(""),T=!!s&&No(s,l),v=!s||!l||!T,k=i(async()=>{if(s)try{let L=await f({blockchain:a,tokenAddress:l});S(""),L&&h(L)}catch(L){L.message==="Failed to fetch"&&(S(It.t("Network Error")),c(!0))}},"getCustomToken"),w=i(()=>{g&&p(""),c(!1)},"closeErrorModal"),I=i(async()=>{C&&setTimeout(async()=>{await k()},MT),w()},"handleErrorModalButtonClick");return AT(()=>{g&&c(!0)},[g]),he.createElement(oe,{header:{title:It.t("Add Custom Token")}},he.createElement(ie,null,he.createElement(BT,null,he.createElement("div",null,he.createElement(Ga,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),he.createElement(vn,{size:"24"}),he.createElement(IT,{size:"large",variant:"label"},It.t("Enter Address")),he.createElement(vn,{size:10}),he.createElement(ET,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&T&&he.createElement(wT,{color:"success",size:12}),onChange:L=>p(L.target.value)}),!T&&!!l&&he.createElement(he.Fragment,null,he.createElement(vn,{size:4}),he.createElement(kT,{type:"error",variant:"alarm",title:"Invalid Address"}))),he.createElement(Ju,{id:"widget-add-custom-token-import-btn",disabled:v,type:"primary",variant:"contained",loading:d,size:"large",onClick:k},It.t("Import"))),he.createElement(R,{open:u,dismissible:!0,onClose:w,container:N()},he.createElement(xT,{title:g?.title||C,type:"error",description:g?.message||It.t("Failed Network, Please retry.")},he.createElement(vn,{size:40}),he.createElement(vn,{size:10}),he.createElement(Ju,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:I},C?It.t("Retry"):It.t("Add another custom token")))),s&&m&&he.createElement(ja,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!m})))}i(Ru,"AddCustomTokenPage");import{i18n as Vs}from"@lingui/core";import{useManager as gv}from"@rango-dev/queue-manager-react";import{Alert as jd,Button as hv,css as js,Divider as Ks,IconButton as Xd,styled as yv,Typography as Sv,WalletIcon as Cv}from"@rango-dev/ui";import be,{useEffect as vi,useLayoutEffect as Tv,useRef as kv,useState as Dn}from"react";import{useNavigate as vv}from"react-router-dom";import{i18n as yo}from"@lingui/core";import{Alert as Im,BalanceErrors as rk,Button as Am,ChevronLeftIcon as ik,Divider as ti,MessageBox as ak,Typography as xs}from"@rango-dev/ui";import Y,{useCallback as sk,useEffect as Nm,useMemo as lk,useState as So}from"react";import{useNavigate as pk}from"react-router-dom";import{i18n as Kr}from"@lingui/core";function jr(t){switch(t.type){case 0:return Kr.t("Route has been updated.");case 3:return Kr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Kr.t("Route swappers has been updated.");case 2:return Kr.t("Route internal coins has been updated.");default:return""}}i(jr,"getQuoteUpdateWarningMessage");import{i18n as Ts}from"@lingui/core";import{Alert as FT,ChevronDownIcon as OT,CloseIcon as UT,Divider as am,IconButton as sm,PasteIcon as zT,Typography as QT,WalletIcon as qT}from"@rango-dev/ui";import Be,{useEffect as HT,useRef as GT}from"react";import Jr,{useRef as _T}from"react";import*as jo from"@radix-ui/react-collapsible";import{keyframes as em,styled as Xr}from"@rango-dev/ui";var ys=300,PT=em({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),DT=em({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),tm=Xr(jo.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Ss=Xr(jo.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Yr=Xr(jo.Content,{overflow:"hidden",variants:{open:{true:{animation:`${PT} ${ys}ms ease-out`},false:{animation:`${DT} ${ys}ms ease-out`}}}}),Zr=Xr("div",{transition:`all ${ys}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Rr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=_T(null);return Jr.createElement(tm,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Jr.createElement(Ss,{className:"collapsible_trigger",onClick:a},s),Jr.createElement(Yr,{className:"collapsible_content",open:e},r),l==="bottom"&&Jr.createElement(Ss,{className:"collapsible_trigger",onClick:a},s))}i(Rr,"CustomCollapsible");import{darkTheme as om,styled as Cs,TextField as $T}from"@rango-dev/ui";var nm=Cs("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),rm=Cs($T,{backgroundColor:"$neutral100",padding:"$15"}),im=Cs("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${om} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${om} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function lm(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),p=rr(e.name,l),u=GT(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),f=n&&!!r&&e&&!No(e,r),d=i(()=>{a("")},"handleClear"),g=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let T=await navigator.clipboard.readText();a(T),u?.current?.focus()}},"handlePaste"),C=i(()=>r?Be.createElement(sm,{id:"widget-custom-destination-close-icon-btn",onClick:d,variant:"ghost"},Be.createElement(UT,{size:12,color:"gray"})):m?null:Be.createElement(sm,{id:"widget-custom-destination-paste-icon-btn",onClick:g,variant:"ghost"},Be.createElement(zT,{size:16})),"renderSuffix");return HT(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Be.createElement(nm,null,Be.createElement(Rr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Be.createElement(im,null,Be.createElement("div",{className:"button__content"},Be.createElement(qT,{size:18,color:"info"}),Be.createElement(am,{size:4,direction:"horizontal"}),Be.createElement(QT,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ts.t("Send to a different address"))),Be.createElement(Zr,{orientation:n?"up":"down"},Be.createElement(OT,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Be.createElement(rm,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ts.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:C(),onChange:S=>{let T=S.target.value;a(T)}})),f&&Be.createElement(Be.Fragment,null,Be.createElement(am,{size:4}),Be.createElement(FT,{variant:"alarm",type:"error",title:Ts.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(lm,"CustomDestination");import{css as VT,darkTheme as ks,IconButton as KT,styled as Dt}from"@rango-dev/ui";var pm=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),cm=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),jT=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${ks} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${ks} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${ks} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),um=Dt(jT,{alignSelf:"stretch",minHeight:"93px"}),mm=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),dm=Dt(KT,{position:"absolute",left:"$20"}),fm=Dt("div",{paddingTop:"$20"}),gm=VT({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),hm=Dt("div",{display:"flex"}),ym=Dt("div",{overflow:"visible",width:"100%"});import{i18n as wm}from"@lingui/core";import{warn as RT}from"@rango-dev/logging-core";import{Divider as ek,SelectableWallet as tk,Typography as xm,WalletState as bm}from"@rango-dev/ui";import Ze,{useEffect as Em,useState as xn}from"react";import{Image as ZT,MessageBox as JT}from"@rango-dev/ui";import wn from"react";import{keyframes as XT,styled as vs}from"@rango-dev/ui";var Sm=vs("div",{position:"relative"}),YT=XT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Cm=vs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${YT} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Tm=vs("div",{"& img":{borderRadius:"50%"}});import{i18n as Xo}from"@lingui/core";function km(t,e){switch(t){case"in-progress":return{type:"loading",title:Xo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Xo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Xo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Xo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Xo.t("Request Rejected"),description:Xo.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(km,"generateMessageByStatus");function vm(t){let{status:e,displayName:o,image:n}=t,r=km(e,o),a=e=="in-progress";return wn.createElement(JT,{type:r.type,title:r.title,description:r.description,icon:a?wn.createElement(Sm,null,wn.createElement(Tm,null,wn.createElement(ZT,{src:n,size:45})),wn.createElement(Cm,null)):void 0})}i(vm,"ExperimentalChainStatus");var ok=7,nk=3e3;function ws(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=le.use.isActiveTab(),{blockchains:l,connectedWallets:p}=y(),[u,c]=xn(),[m,h]=xn(null),[f,d]=xn(!1),[g,C]=xn(null),{suggestAndConnect:S}=ei(),{handleDisconnect:T}=Ht(),{list:v}=gt({chain:e}),[k,w]=xn(v),I=v.length,L=r&&I-r>0,b=i(async x=>{d(!1),C("in-progress");try{await S(x.walletType,x.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");Em(()=>{w(x=>{let W=v.findIndex(D=>o(D.type,e));return L&&W>1?[v[W]].concat(v.filter((D,A)=>A!==W)):x.map(D=>v.find(A=>A.type===D.type)??D)})},[JSON.stringify(v)]);let E=document.getElementById(Pe.SWAP_BOX_ID);return Em(()=>{let x=null;return(g==="completed"||g==="rejected")&&(x=setTimeout(()=>C(null),nk)),()=>{x&&clearTimeout(x)}},[g]),Ze.createElement(Ze.Fragment,null,k.slice(0,r).map(x=>{let W=Op({connectedWallets:p,walletType:x.type,chain:e}),D=W?gr(W,ok):"",A=dr(l(),e),X=!p.find(pe=>pe.walletType===x.type&&pe.chain===e),se=A&&X&&x.state===bm.CONNECTED,J=se?wm.t({id:"Add {chain} chain",values:{chain:e}}):D,M=i(async()=>{let pe=x.state===bm.DISCONNECTED,Q=(x.isHub||!!x.namespaces)&&!D;pe?c(x):Q?(await T(x.type),c(x)):se?(h({walletType:x.type,chain:e,address:W??""}),d(!0)):n({walletType:x.type,chain:e,address:W??""})},"onSelectableWalletClick"),K=m?.chain?rr(m.chain,l()):void 0;return Ze.createElement(Ze.Fragment,{key:`${x.title}_${K}`},!!m&&Ze.createElement(R,{open:!!m&&f,container:E,onClose:()=>{h(null)}},Ze.createElement(Na,{displayName:K,onConfirm:()=>{b(m)}})),g&&Ze.createElement(R,{open:!!g,onClose:C.bind(null,null),container:E},Ze.createElement(vm,{status:g,displayName:K,image:x.image}),Ze.createElement(ek,{direction:"vertical",size:32})),Ze.createElement(tk,{key:x.type,description:J,onClick:M,selected:o(x.type,e),disabled:!s,...x}))}),Ze.createElement(uo,{wallet:u,onClose:()=>{c(void 0)},onConnect:x=>{t.onConnect&&x.status==="connected"&&(u?.type?t.onConnect(u.type):RT(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),L&&Ze.createElement(um,{selected:!1,onClick:a},Ze.createElement(xm,{variant:"label",size:"medium"},wm.t("Show more wallets"),Ze.createElement(xm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(r??0)))))}i(ws,"WalletList");var ck=2;function Wm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=pk(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:h,setCustomDestination:f}=O(),{config:d,connectedWallets:g,setWalletsAsSelected:C}=y(),[S,T]=So(""),[v,k]=So([]),[w,I]=So(""),[L,b]=So(null),[E,x]=So(!!h),W=lk(()=>ao({filter:"all",quote:p}),[p]),D=ao({filter:"required",quote:p}),A=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),X=i(_=>D.includes(_),"isWalletRequiredFor"),se=sk(()=>g.filter(_=>_.selected&&W.includes(_.chain)),[g,W]),[J,M]=So(se()),[K,pe]=So([]),Q=i((_,G)=>pe(q=>q.concat({blockchain:_,walletType:G})),"addNextSelectedWallets"),me=v.length>0,Ge=i((_,G)=>!!J.find(q=>q.walletType===_&&q.chain===G&&q.selected&&(X(G)||!X(G)&&!h)),"isSelected"),st=i((_,G,q)=>{let ee=!1;return _.map(ne=>{if(ne.chain===G){let re=ne.selected;return!ee&&q?(ee=!0,re=!0):q||(re=!1),{...ne,selected:re}}return ne})},"updateSelectableWallets"),de=i(_=>{x(_),_?X(A?.name??"")||M(G=>st(G,A?.name||"",!1)):(f(""),M(G=>st(G,A?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ve=i(_=>{if(S&&T(""),Ge(_.walletType,_.chain))return;let q=g.find(ee=>ee.walletType===_.walletType&&ee.chain===_.chain);q&&(n(),_.chain===A?.name&&E&&!X(A.name)&&(x(!1),f(null)),M(ee=>ee.filter(ne=>ne.chain!==_.chain).concat({...q,selected:!0})))},"onChange"),V=i(()=>{let _=J.filter(G=>G.selected);C(_),u(_),m(!0),o()},"onConfirmBalance"),Ke=i(async()=>{k([]),I(""),b(null);let _=await r?.({selectedWallets:J.filter(q=>q.selected),customDestination:h}),G=_.warnings;G?.balance?.messages&&k(G.balance.messages),G?.quoteUpdate&&b(G.quoteUpdate),_.error&&I(Gc(_.error)),!_.error&&!G?.balance?.messages.length?V():k(G?.balance?.messages??[])},"onConfirmWallets");Nm(()=>{M(_=>{let G=[];return _.forEach(q=>{!g.some(ne=>ne.chain===q.chain&&ne.walletType===q.walletType&&ne.address===q.address)||G.push(q)}),G=G.concat(g.filter(q=>!!!G.find(ne=>ne.chain===q.chain)&&q.selected&&W.includes(q.chain))),G})},[g,W]),Nm(()=>{let _=[];K.length>0&&(K.forEach(G=>{let q=g.find(ee=>ee.chain===G.blockchain&&ee.walletType===G.walletType);q?Ve(q):_.push(G)}),pe(_))},[g,K]);let ft=document.getElementById(Pe.SWAP_BOX_ID);return Y.createElement(R,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:ft,...!S&&{styles:{container:{height:"100%"}},footer:Y.createElement(hm,null,Y.createElement(Am,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:pu(a,E,h,p,J,A),onClick:Ke,variant:"contained",type:"primary",fullWidth:!0,size:"large"},yo.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:Y.createElement(mm,null,Y.createElement(dm,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:T.bind(null,"")},Y.createElement(ik,{size:16})),Y.createElement(xs,{variant:"headline",size:"small"},yo.t({id:"Your {blockchainName} wallets",values:{blockchainName:lt(S,l)}})))},anchor:"center"},Y.createElement(R,{open:me,onClose:k.bind(null,[]),container:ft},Y.createElement(ak,{title:yo.t("Insufficient account balance"),type:"error",description:Y.createElement(rk,{messages:v??[]})},Y.createElement(Am,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:V},yo.t("Proceed anyway")))),S&&Y.createElement(fm,null,Y.createElement("div",{className:gm()},Y.createElement(ws,{chain:S,isSelected:Ge,selectWallet:Ve,onShowMore:()=>T(S),onConnect:_=>{Q(S,_)}}))),!S&&Y.createElement(Y.Fragment,null,w&&Y.createElement(Y.Fragment,null,Y.createElement(Im,{variant:"alarm",type:"error",title:yo.t(w)}),Y.createElement(ti,{size:12})),L&&Y.createElement(Y.Fragment,null,Y.createElement(Im,{variant:"alarm",type:"warning",title:jr(L)}),Y.createElement(ti,{size:12})),Y.createElement(ym,null,W.map((_,G)=>{let q=l.find($e=>$e.name===_),ee=`wallet-${G}`,ne=G===W.length-1,re=ne&&A&&d?.customDestination!==!1;return Y.createElement("div",{key:ee},Y.createElement(pm,null,Y.createElement(xs,{variant:"title",size:"xmedium"},yo.t({id:"Your {blockchainName} wallets",values:{blockchainName:q?.shortName}})),Y.createElement(xs,{variant:"label",color:"$neutral700",size:"medium"},yo.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:q?.shortName}}))),Y.createElement(ti,{size:24}),Y.createElement(cm,null,Y.createElement(ws,{chain:_,isSelected:Ge,selectWallet:Ve,limit:ck,onShowMore:()=>T(q?.name??""),onConnect:$e=>{Q(_,$e)}})),!ne&&Y.createElement(ti,{size:32}),re&&Y.createElement(lm,{blockchain:A,open:E,handleOpenChange:de}))}))))}i(Wm,"ConfirmWalletsModal");import{i18n as Nk}from"@lingui/core";import{Alert as Wk,Button as Bk,InfoIcon as Mk}from"@rango-dev/ui";import tt from"react";import{Alert as dk,Button as fk,Divider as Is,NoRouteIcon as gk,RefreshIcon as hk,Typography as $m}from"@rango-dev/ui";import et from"react";import{i18n as Bm}from"@lingui/core";var uk=24,mk=60;function Mm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:te().genericServerError,action:{onClick:n,title:Bm.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:te().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Bm.t("Reset")}},description:te().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:te().noResultError.description}}i(Mm,"makeInfo");var bs=(o=>(o[o.small=uk]="small",o[o.large=mk]="large",o))(bs||{}),Es=(o=>(o.small="small",o.large="medium",o))(Es||{});import{styled as oi}from"@rango-dev/ui";var Lm=oi("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Pm=oi("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Dm=oi("div",{variants:{size:{small:{width:"100%"},large:{}}}}),_m=oi("div",{padding:"$6 $0"});function bn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Mm(o,r,()=>a(s,!0),e);return et.createElement(Lm,null,et.createElement(gk,{size:bs[n],color:"gray"}),et.createElement(Is,{size:4}),et.createElement($m,{variant:"title",size:Es[n]},te().noResultError.title),n==="large"&&et.createElement(Is,{size:4}),!!l.description&&et.createElement(Pm,{size:n},et.createElement($m,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),et.createElement(Is,{size:n==="large"?"24":"4"}),!!l.alert&&et.createElement(Dm,{size:n},et.createElement(dk,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&et.createElement(fk,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:et.createElement(_m,null,et.createElement(hk,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(bn,"NoResult");import{i18n as En}from"@lingui/core";import{Button as Sk,Divider as Ck,MessageBox as Tk,Typography as kk,WarningIcon as vk}from"@rango-dev/ui";import _t from"react";import{Typography as zm}from"@rango-dev/ui";import Ns from"react";import{darkTheme as yk,styled as ni}from"@rango-dev/ui";var Fm=ni("div",{width:"100%"}),As=ni("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Om=ni("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${yk} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Um=ni("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Qm(t){let{title:e,value:o,valueColor:n}=t;return Ns.createElement(Om,null,Ns.createElement(zm,{size:"medium",variant:"label",className:"_title"},e),Ns.createElement(zm,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Qm,"QuoteErrorsModalItem");function qm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:En.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:En.t("Gas cost"),value:B(r.totalFee,2,2)},{title:En.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:En.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return _t.createElement(R,{footer:_t.createElement(Sk,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:_t.createElement(vk,null),fullWidth:!0,disabled:a,onClick:n},te().highValueLossError.confirmMessage),open:e,onClose:o,container:N()},_t.createElement(Tk,{type:s,title:te().highValueLossError.impactTitle,description:te().highValueLossError.description}),_t.createElement(As,null,_t.createElement(Ck,{size:"4"}),_t.createElement(kk,{size:"small",variant:"title"},En.t("Details")),_t.createElement(As,null,l.map((p,u)=>_t.createElement(Qm,{key:u,...p})))))}i(qm,"HighValueLossWarningModal");import{i18n as Ws}from"@lingui/core";function Hm(t,e){let o={alertType:"warning",title:"",action:null};return e?(o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Ws.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o):t?(t.type===0&&(Pt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=te().highValueLossError.title),t.type===1&&(o.title=te().unknownPriceError.title),t.type===2&&(o.title=Ws.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings"),t.type===3&&(o.title=Ws.t("Caution, your slippage is high."),o.action="change-settings"),o):null}i(Hm,"makeAlerts");import{i18n as Yo}from"@lingui/core";import{Button as Gm,Divider as Vm,MessageBox as wk,Typography as xk}from"@rango-dev/ui";import Co from"react";import{useNavigate as bk}from"react-router-dom";function Km(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=bk(),u=e??o;return Co.createElement(R,{anchor:"bottom",open:n,prefix:Co.createElement(Gm,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>p("../"+$.settings)},Co.createElement(xk,{variant:"label",size:"medium",color:"$neutral900"},Yo.t("Change settings"))),container:N(),onClose:r},Co.createElement(wk,{type:"warning",title:s.type===3?Yo.t("High slippage"):Yo.t("Low slippage"),description:s.type===3?Yo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Yo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},Co.createElement(Vm,{size:18}),Co.createElement(Vm,{size:32}),Co.createElement(Gm,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Yo.t("Confirm anyway"))))}i(Km,"SlippageWarningModal");import{Button as Ek,MessageBox as Ik,WarningIcon as Ak}from"@rango-dev/ui";import ri from"react";function jm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ri.createElement(R,{footer:ri.createElement(Ek,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ri.createElement(Ak,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:N()},ri.createElement(Ik,{type:"warning",title:te().unknownPriceError.impactTitle,description:te().unknownPriceError.description}))}i(jm,"UnknownPriceWarningModal");function In(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},h=o?.type===0||o?.type===1,f=Hm(e,o?.type===3||o?.type===4?o:null);return f&&!n&&(f.action=null),tt.createElement(tt.Fragment,null,h&&tt.createElement(bn,{error:o,fetch:s}),!!f&&tt.createElement(Fm,null,tt.createElement(Wk,{title:f.title,type:f.alertType,variant:"alarm",...f.action==="show-info"&&{action:tt.createElement(Um,{onClick:l},tt.createElement(Mk,{size:12,color:"gray"}))},...f.action==="change-settings"&&{action:tt.createElement(Bk,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:f.alertType,onClick:c},Nk.t("Change"))}})),e&&tt.createElement(tt.Fragment,null,e.type===0&&tt.createElement(qm,{...m,warning:e}),(e.type===3||e.type===2)&&tt.createElement(Km,{...m,warning:e}),e.type===1&&tt.createElement(jm,{...m,warning:e})))}i(In,"QuoteWarningsAndErrors");import pv from"bignumber.js";import Si from"react";import{i18n as To}from"@lingui/core";import{Alert as Yk,Divider as Jo,FullExpandedQuote as Zk,InfoIcon as Jk,NumericTooltip as Ed,QuoteTag as Rk,StepDetails as ev,TokenAmount as tv,Typography as Ro}from"@rango-dev/ui";import Os from"bignumber.js";import F,{useRef as ov,useState as nv}from"react";import{styled as Bs}from"@rango-dev/ui";var Ms=Bs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Xm=Bs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Ym=Bs("div",{width:"100%",display:"flex"});import*as ii from"@radix-ui/react-collapsible";import{Button as Lk,css as An,darkTheme as we,Image as Zm,styled as Ue,Typography as Pk}from"@rango-dev/ui";var Dk=300,Jm=Ue(ii.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${we} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Rm=An({padding:"$10 $15"}),ed=Ue(Lk,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${we} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${we} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${we} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),td=Ue("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${we} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${we} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${we} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${we} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${we} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${we} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${we} &`]:{backgroundColor:"$neutral400"}}}}]}),od=An({width:"100%",padding:"$15 $15 $10 $15"}),nd=An({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Zo=An({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),rd=An({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${we} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),id=Ue(ii.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${Zm}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Zm}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${we} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),ad=Ue("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),sd=Ue(Yr,{width:"100%",background:"inherit"}),Ls=Ue("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${Dk}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),HF=Ue("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),ld=Ue("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${we} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),pd=Ue("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Ps=Ue(Pk,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),cd=Ue("div",{display:"flex",flexWrap:"wrap"}),Ds=Ue("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),ud=Ue("div",{display:"flex"}),ai=Ue("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${we} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as $k,CloseIcon as Fk,Divider as pi,IconButton as Ok,NumericTooltip as Uk,QuoteCost as zk,Typography as St}from"@rango-dev/ui";import Z,{useState as gd}from"react";import{css as _k,styled as si}from"@rango-dev/ui";var li=si("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),_s=si("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),md=si("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),dd=si("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),fd=_k({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var Qk=i(t=>t.fee.isZero()?null:Z.createElement(li,null,Z.createElement(St,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(St,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function $s(t){let[e,o]=gd(!1),[n,r]=gd(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,timeWarning:c,showModalFee:m,fullExpandedMode:h=!1}=t,f=s?.swaps??[],d=h?ro():N(),g=Zc(f);return Z.createElement(Z.Fragment,null,Z.createElement(zk,{onClickFee:m?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,timeWarning:c,time:p,steps:a,tooltipGas:m?At.t("View more info"):void 0,tooltipContainer:d}),Z.createElement(R,{container:d,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Z.createElement(dd,{style:{textAlign:h?"left":"center"}},Z.createElement(St,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Z.createElement(Ok,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(Fk,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(md,null,Z.createElement(St,{variant:"title",size:"small"},At.t("Details")),Z.createElement(pi,{size:10}),Object.entries(g.payable).flatMap(([C,S])=>S.map((T,v)=>{let k=`payable-fee-${v}`,w=Da(T);return Z.createElement(li,{key:k},Z.createElement(St,{variant:"label",size:"medium",color:"neutral600"},Ba(C,At.t)),Z.createElement(Uk,{content:T.amount,container:d},Z.createElement(St,{variant:"label",size:"medium"},B(T.amount,2,2)," ",T.asset.symbol," ($",B(w,4,4),")")))})),Z.createElement(li,{className:"total_payable_fee"},Z.createElement(St,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Z.createElement(St,{variant:"label",size:"medium"},"$",B(l,4,4))),Z.createElement(_s,null),Object.keys(g.nonePayable).length&&Z.createElement(Rr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Z.createElement("div",{className:fd()},Z.createElement(St,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Z.createElement(pi,{size:4,direction:"horizontal"}),Z.createElement(Zr,{orientation:n?"up":"down"},Z.createElement($k,{size:12,color:"gray"}))),open:n},Z.createElement(St,{size:"small",variant:"title"},At.t("Description")),Z.createElement(pi,{size:4}),Z.createElement(St,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),Z.createElement(pi,{size:10}),Object.entries(g.nonePayable).map(([C,S],T)=>{let v=Yc(S),k=Ba(C,At.t),w=`non-payable-fee-${T}`;return Z.createElement(Qk,{key:w,fee:v,label:k})}),Z.createElement(_s,null)))))}i($s,"QuoteCostDetails");import{i18n as Sd}from"@lingui/core";import{TokenAmount as Cd}from"@rango-dev/ui";import ci from"react";import{css as qk,styled as Hk}from"@rango-dev/ui";var hd=Hk("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),yd=qk({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Nn(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ci.createElement(hd,null,ci.createElement(Cd,{direction:"horizontal",label:Sd.t("Swap input"),type:"input",tooltipContainer:N(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),ci.createElement("div",{className:yd()}),ci.createElement(Cd,{direction:"horizontal",tooltipContainer:N(),label:Sd.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(Nn,"QuoteSummary");import{i18n as xd}from"@lingui/core";import{ChevronDownIcon as Kk,ChevronRightIcon as jk,Divider as Fs,Image as Xk,Tooltip as gi,Typography as mi}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as Gk,useState as Wn}from"react";var Td=480,kd=768,vd=1024,wd=1200,Vk=i(()=>{let[t,e]=Wn(!1),[o,n]=Wn(!1),[r,a]=Wn(!1),[s,l]=Wn(!1),[p,u]=Wn(!1),c=i(()=>{e(window.innerWidth<=Td),n(window.innerWidth>Td&&window.innerWidth<=kd),a(window.innerWidth>kd&&window.innerWidth<=vd),l(window.innerWidth>vd&&window.innerWidth<=wd),u(window.innerWidth>wd)},"handleResize");return Gk(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),ui=Vk;var di=4,fi=6,Bn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||N();return U.createElement(gi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(ad,{className:n,state:a},U.createElement(Xk,{src:o,size:16})))},"ImageComponent");function bd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||N(),u=r.length,c=fu(r),{isTablet:m,isMobile:h}=ui();return U.createElement(id,{listItem:s==="list-item",ref:f=>e.current=f,selected:o,onClick:f=>{f.stopPropagation(),n(d=>!d)}},U.createElement("div",{className:Zo()},U.createElement(mi,{variant:"body",size:"xsmall"},xd.t("Via:")),U.createElement(Fs,{direction:"horizontal",size:4}),r.map((f,d)=>{let g=`item-${d}`,C=U.createElement(Ls,null,U.createElement(jk,{size:12,color:"black"}));return h||m?U.createElement(U.Fragment,{key:g},U.createElement(Bn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),d!==u-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:g},u<=di||u>di&&d<di-1?U.createElement(U.Fragment,null,U.createElement(Bn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),d!==u-1&&U.createElement(U.Fragment,null,C)):d===di-1&&U.createElement(gi,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Zo()},C,r.map((S,T)=>{let v=`image-${T}`;return T>=d&&U.createElement(U.Fragment,{key:v},U.createElement(Bn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),T!==u-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Ds,{state:r.find((S,T)=>T>=d&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(mi,{size:"xsmall",variant:"body"},"+",u-d))))})),U.createElement("div",{className:Zo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Zo()},U.createElement(mi,{variant:"body",size:"xsmall"},xd.t("Chains:")),U.createElement(Fs,{direction:"horizontal",size:4}),c.map((f,d)=>U.createElement(U.Fragment,{key:f.displayName},c.length<=fi||c.length>fi&&d<fi-1?U.createElement(gi,{container:p,side:"bottom",content:f.displayName,sideOffset:4},U.createElement(Bn,{content:"",src:f.image,open:!1,className:d!==0?"blockchainImage":""})):d===fi-1&&U.createElement(gi,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Zo()},c.map((g,C)=>C>=d&&U.createElement(Bn,{key:g.displayName,content:"",src:g.image,open:!1,className:C>d?"blockchainImage":"",container:l})))},U.createElement(Ds,{className:"blockchainImage"},U.createElement(mi,{size:"xsmall",variant:"body"},"+",c.length-d))))),U.createElement(Fs,{direction:"horizontal",size:32}))),U.createElement(Ls,{orientation:a?"up":"down"},U.createElement(Kk,{size:12,color:"black"}))))}i(bd,"QuoteTrigger");function Us(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:h}=t,f=y().blockchains(),{findToken:d}=y(),g=y().swappers(),{customSlippage:C,slippage:S}=y(),T=C||S,[v,k]=nv(t.expanded),w=ov(null),I=B(o.value,6,6),L=B(n.value,6,6),b=n.usdValue?B(n.usdValue,4,4):"",E=ct(o.usdValue,n.usdValue??null),x=B(E,2,2),W=Pt(E??0),D=i((de,Ve)=>de.map((V,Ke)=>{let ft,_=r?.type===3&&r.swap.swapperId===V.swapperId,G=r?.type===4&&r.recommendedSlippages?.has(Ke),q=a?.type===2&&a.recommendedSlippages?.has(Ke),ee=_||G,ne=q;ee?ft="error":ne&&(ft="warning");let re=ee?To.t("Slippage Error"):To.t("Slippage Warning");return _&&(re=To.t("Bridge Limit Error")),{swapper:{displayName:an(V.swapperId,g)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:lt(V.from.blockchain,f)??"",image:V.from.blockchainLogo},price:{value:Ke===0&&!Ve?B(o.value,6,6):B(V.fromAmount,6,6),usdValue:B((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:Ke===0?o.value:V.fromAmount,realUsdValue:new Os(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:lt(V.to.blockchain,f)||"",image:V.to.blockchainLogo},price:{value:B(V.toAmount,6,6),usdValue:B((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new Os(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:ft,alerts:ee||ne?F.createElement(Xm,{dense:m},F.createElement(Yk,{variant:"alarm",type:ee?"error":"warning",title:re,footer:F.createElement(Ym,null,_&&F.createElement("div",null,F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Jo,{direction:"vertical",size:2}),F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {amount} {symbol}",values:{amount:B(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(G||q)&&!_&&F.createElement("div",null,F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(Ke)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(Ke)}}})),F.createElement(Jo,{direction:"vertical",size:2}),F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {userSlippage}",values:{userSlippage:T}}))))})):void 0,time:pn(V.estimatedTimeInSeconds),fee:B(Pa(V,d),2,2),internalSwaps:V.internalSwaps?D(V.internalSwaps):void 0}}),"getQuoteSteps"),A=D(e?.swaps??[]),X=A.length,se=h||N(),J=hu(t.quote.tags||[]),M=!!c,K=pr(e?.swaps),pe=pn(K),Q=Lr(e?.swaps??[],d),me=B(Q,2,2),Ge=Q.gte(new Os(Qc)),st=K/Hc>=qc;return m?F.createElement(Zk,{selected:l,fee:me,time:pe,tooltipContainer:ro(),steps:A,tags:J,quoteCost:F.createElement($s,{quote:e,fullExpandedMode:!0,time:pe,fee:me,feeWarning:Ge,timeWarning:st,showModalFee:u,steps:X}),percentageChange:x,warningLevel:W,outputPrice:{value:L,usdValue:b,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(td,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:od()},!p&&J.length?F.createElement(F.Fragment,null,F.createElement(ud,null,J.map((de,Ve)=>{let V=`${de.value}_${Ve}`;return F.createElement(F.Fragment,{key:V},F.createElement(Rk,{label:de.label,value:de.value}),F.createElement(Jo,{size:4,direction:"horizontal"}))})),F.createElement(ai,null),!M&&F.createElement(Jo,{size:4})):null,F.createElement("div",{id:"portal-root",className:nd()},F.createElement($s,{quote:e,time:pe,fee:me,feeWarning:Ge,timeWarning:st,showModalFee:u,steps:X}),M&&F.createElement(ed,{onClick:de=>{de.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Ro,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},To.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:rd()},F.createElement(pd,null,F.createElement(Jk,{size:12,color:"gray"})),F.createElement(cd,null,F.createElement(Ps,{size:"small",variant:"body"},`${I} ${A[0].from.token.displayName} = `),F.createElement(Ed,{content:n.value,container:se,open:n.value?void 0:!1},F.createElement(Ps,{size:"small",variant:"body"},"\xA0",`${L} ${A[A.length-1].to.token.displayName}`))),F.createElement(Ed,{content:n.usdValue,container:se},F.createElement(Jo,{size:2,direction:"horizontal"}),F.createElement(Ro,{color:"$neutral600",size:"xsmall",variant:"body"},`($${b})`))),s==="list-item"&&F.createElement(tv,{tooltipContainer:se,type:"output",direction:"vertical",price:{value:L,usdValue:b,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:A[X-1].to.token.displayName,image:A[X-1].to.token.image},chain:{image:A[X-1].to.chain.image},percentageChange:x,warningLevel:W}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Nn,{from:A[0].from,to:A[X-1].to,percentageChange:x,warningLevel:W}),F.createElement(Jo,{size:4}))),F.createElement(Jm,{selected:l,listItem:s==="list-item",open:v,className:"quote_container",onOpenChange:k},F.createElement(bd,{type:s,quoteRef:w,selected:l,setExpanded:k,container:se,expanded:v,steps:A}),F.createElement(sd,{open:v},F.createElement(ld,null),F.createElement("div",{className:Rm()},A.map((de,Ve)=>{let V=`item-${Ve}`;return F.createElement(ev,{type:"quote-details",key:V,tooltipContainer:se,step:de,hasSeparator:Ve!==A.length-1,state:de.state})})))))}i(Us,"Quote");import{Divider as sv,Skeleton as lv}from"@rango-dev/ui";import Ft from"react";import{darkTheme as rv,styled as hi}from"@rango-dev/ui";var Id=hi("div",{$$color:"$colors$neutral100",[`.${rv} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Ad=hi("div",{paddingTop:"$2"}),Nd=hi("div",{paddingLeft:"$8"}),Wd=hi("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Ud,Divider as Ct,Skeleton as ot}from"@rango-dev/ui";import z from"react";import{css as iv,styled as $t}from"@rango-dev/ui";var zs=$t("div",{display:"flex"}),Bd=$t("div",{padding:"$10 $0 $20"}),Md=$t("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Ld=$t("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Pd=$t("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Dd=$t("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),_d=$t("div",{width:"65%",display:"flex",justifyContent:"start"}),$d=$t("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Fd=$t("div",{padding:"$15 $0 $15 $0"}),Od=iv({display:"flex",justifyContent:"space-between",alignItems:"center"});function Mn(t){let{type:e,tagHidden:o=!0}=t,n=z.createElement(Pd,null,z.createElement(_d,null,z.createElement(Ud,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),z.createElement(Ct,{size:8,direction:"horizontal"}),z.createElement($d,null,z.createElement(ot,{height:10,width:60,variant:"rounded"}),z.createElement(Ct,{size:4}),z.createElement(ot,{height:15,variant:"rounded"}))),z.createElement(ot,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return z.createElement("div",null,!o&&z.createElement(z.Fragment,null,z.createElement(zs,null,z.createElement(ot,{width:65,height:20,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(ot,{width:65,height:20,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(ot,{width:65,height:20,variant:"rounded"})),z.createElement(ai,null),!r&&z.createElement(Ct,{size:4})),z.createElement("div",{className:Od()},z.createElement(zs,null,z.createElement(ot,{width:60,height:10,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(ot,{width:60,height:10,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(ot,{width:60,height:10,variant:"rounded"})),r&&z.createElement(ot,{width:85,height:24,variant:"rounded"})),e==="basic"&&z.createElement(Bd,null,z.createElement(ot,{height:15,width:148,variant:"rounded"})),e==="list-item"&&z.createElement(Md,null,z.createElement(Ld,null,z.createElement(Ud,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),z.createElement(Ct,{direction:"horizontal",size:4}),z.createElement(ot,{height:15,width:150,variant:"rounded"})),z.createElement(Ct,{size:10}),z.createElement(ot,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&z.createElement(z.Fragment,null,z.createElement(Ct,{size:4}),z.createElement(Fd,null,n,z.createElement(Dd,null),n),z.createElement(Ct,{size:12})))}i(Mn,"QuoteSummarySkeleton");import{ChainToken as Gd,Divider as qs,NextIcon as av,Skeleton as yi}from"@rango-dev/ui";import xe from"react";import{styled as Ln}from"@rango-dev/ui";var zd=Ln("div",{display:"flex",alignItems:"start"}),Qd=Ln("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Qs=Ln("div",{display:"flex",alignItems:"center",flexGrow:1}),qd=Ln("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Hd=Ln("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return xe.createElement(xe.Fragment,null,xe.createElement(Hd,null,xe.createElement(yi,{height:22,width:22,variant:"circular"}),xe.createElement(qs,{direction:"horizontal",size:8}),xe.createElement(yi,{height:15,width:148,variant:"rounded"})),xe.createElement(zd,null,xe.createElement(Wd,{hideSeparator:!e}),xe.createElement(Qd,{extraSpace:e},xe.createElement(Qs,null,xe.createElement(Gd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),xe.createElement(qs,{direction:"horizontal",size:8}),xe.createElement(yi,{height:12,variant:"rounded"})),xe.createElement(qd,null,xe.createElement(av,{color:"gray",size:16})),xe.createElement(Qs,null,xe.createElement(Gd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),xe.createElement(qs,{direction:"horizontal",size:8}),xe.createElement(yi,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function Pn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ft.createElement(Id,{expanded:o,rounded:e!=="basic"},Ft.createElement(Mn,{type:e,tagHidden:n}),Ft.createElement(Ad,null,Ft.createElement(lv,{height:15,variant:"rounded"})),o&&Ft.createElement(Nd,null,Ft.createElement(sv,{size:24}),Ft.createElement(Nt,null),Ft.createElement(Nt,null),Ft.createElement(Nt,{separator:!1})))}i(Pn,"QuoteSkeleton");function ko(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:p,showModalFee:u,selected:c,onClickAllRoutes:m,fullExpandedMode:h=!1,container:f}=t,{inputAmount:d,inputUsdValue:g,toToken:C}=O(),S=e?.outputAmount?new pv(e?.outputAmount):null,T=e?.outputAmount?Kt(e?.outputAmount,fo(e)||C?.usdPrice):null,k=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?Si.createElement(Ms,null,Si.createElement(Pn,{tagHidden:l,type:o,expanded:s})):k?Si.createElement(Ms,{onClick:()=>p?.(e)},Si.createElement(Us,{quote:e,error:r,container:f,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:h,input:{value:d,usdValue:g?.toString()??""},output:{value:S?.toString()??"",usdValue:T?.toString()??""}})):null}i(ko,"QuoteInfo");import{calculatePendingSwap as dv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as fv}from"react";import{useRef as cv,useState as uv}from"react";var mv=2e3;function Ci({request:t}){let[e,o]=uv(!1),n=cv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,mv)),await s(l,!1)),"retryFetch"),s=i(async(l,p=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(p)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(Ci,"useFetch");function Vd(){let{fetch:t,loading:e,cancelFetch:o}=Ci({request:async(n,r)=>await bt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Vd,"useFetchConfirmQuote");function Ti(t){if(!t.swaps)throw new Error(te().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Hs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(Ti,"throwErrorIfResponseIsNotValid");function Hs(t){if(Kc(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=jc(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Jc(t);if(o){let n=Pr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Hs,"getQuoteError");function Kd(t,e,o){let n=!1;t&&(n=du(t,e));let r={quote:null,quoteUpdate:null,balance:null},a=zo(e,{fromToken:o.fromToken,toToken:o.toToken,findToken:o.findToken,userSlippage:o.userSlippage});a&&(r.quote=a),t&&n&&(ru(t,e)?r.quoteUpdate={type:3,newOutputAmount:B(Uo(e)),percentageChange:B(ct(Uo(t)??"",Uo(e)??""),null,2)}:_a(t,e)?r.quoteUpdate={type:0}:$a(t,e)?r.quoteUpdate={type:1}:Fa(t,e)&&(r.quoteUpdate={type:2}));let s=iu(e,o.selectedWallets,o.meta.blockchains);return s.length===0||(r.balance={messages:s}),r}i(Kd,"generateWarnings");function ki(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(ki,"handleQuoteErrors");function Gs(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=O(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),h=y().tokens(),{findToken:f}=y(),d=u||p,{fetch:g,cancelFetch:C,loading:S}=Vd();return fv(()=>C,[]),{loading:S,fetch:i(async v=>{let k=v.selectedWallets,w=v?.customDestination??a;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let I=k.reduce((b,E)=>(b[E.chain]=E.address,b),{}),L={requestId:r?.requestId||"",selectedWallets:I,destination:w||void 0};try{return await g(L,!0).then(b=>{let{result:E}=b;if(!E)throw new Error("Error fetching updated route");Ti({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let x={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};n(x);let W={slippage:d.toString(),disabledSwappersGroups:c},D=Kd(r??void 0,x,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:f,selectedWallets:k,userSlippage:d});D.quoteUpdate&&s(!1),l();let A=!!D.balance,X=dv(o.toString(),E,ou(k),W,!A,{blockchains:m,tokens:h});return{quote:x,swap:X,error:null,warnings:D}})}catch(b){return ki(b)}},"fetch"),cancelFetch:C}}i(Gs,"useConfirmSwap");var wv=yv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Xd}`]:{width:"$48",height:"$48"}}),xv=js({flexGrow:1,paddingRight:"$10"}),bv=js({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Ev=js({display:"flex",justifyContent:"space-between",alignItems:"center"});function Yd(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=vv(),[l,p]=Dn(""),u=!n,[c,m]=Dn(!1),[h,f]=Dn(!1),{isActiveTab:d}=le(),g=y().getDisabledLiquiditySources(),C=kv(g),{manager:S}=gv(),{fetch:T,loading:v,cancelFetch:k}=Gs(),[w,I]=Dn({swap:null,error:null,warnings:null}),[L,b]=Dn(!1),E=i(async({selectedWallets:M,customDestination:K})=>{let pe=await T?.({selectedWallets:M,customDestination:K});return I(pe),pe},"onConfirmSwap"),x=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let M=`../${$.swaps}/${w.swap.requestId}`;s(M,{replace:!0}),setTimeout(()=>{e("")},0)}catch(M){p("Error: "+M?.message)}},"addNewSwap"),W=i(async()=>{f(!0),await x(),f(!1)},"onConfirm"),D=i(async()=>{w?.warnings?.quote&&!a?b(!0):await W()},"onStartConfirmSwap"),A=i(async()=>{I({error:null,swap:null,warnings:null}),T({selectedWallets:o,customDestination:r}).then(M=>{I(M)}).catch(M=>console.error(M))},"onRefresh");vi(()=>{!!C.current.length&&!g.length&&A(),C.current=g},[g.length]),vi(()=>{u&&k()},[u]),vi(()=>{u&&m(u)},[u]),vi(()=>{u||T({selectedWallets:o,customDestination:r}).then(M=>I(M)).catch(M=>console.error(M))},[]),Tv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let X=w.warnings?.quote??null,se=w.error,J=[];if(l&&J.push(be.createElement(jd,{type:"error",variant:"alarm",title:l})),w.warnings?.quoteUpdate&&J.push(be.createElement(jd,{variant:"alarm",type:"warning",title:w.warnings.quoteUpdate&&jr(w.warnings.quoteUpdate)})),X||se){let M=`../${$.settings}`;J.push(be.createElement(In,{warning:X,error:se,couldChangeSettings:!1,refetchQuote:A,showWarningModal:L,confirmationDisabled:!d,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await x()},onChangeSettings:()=>s(M)}))}return be.createElement(oe,{header:{title:Vs.t("Confirm Swap"),onWallet:()=>{let M=`../${$.wallets}`;s(M)}},footer:be.createElement(wv,null,be.createElement("div",{className:xv()},be.createElement(hv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:v||h,disabled:!!w.error||!d,onClick:D},Vs.t("Start Swap"))),be.createElement(Xd,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:v||h,disabled:!d,onClick:m.bind(null,!0)},be.createElement(Cv,{size:24})))},c&&be.createElement(Wm,{open:c,onClose:()=>m(!1),onCancel:k,loading:v,onCheckBalance:E}),be.createElement(ie,null,be.createElement("div",{className:Ev()},be.createElement(Sv,{variant:"title",size:"small"},Vs.t("You get")),be.createElement("div",{className:bv()},be.createElement(Qr,{onClick:!v&&!c&&!L?A:void 0}))),be.createElement(Ks,{size:"12"}),Wu(J.map((M,K)=>({element:M,key:`alert-${K}`})),be.createElement(Ks,{size:10})),J.length>0?be.createElement(Ks,{size:10}):null,be.createElement(ko,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:v,warning:w.warnings?.quote??null})))}i(Yd,"ConfirmSwapPage");import{i18n as Ot}from"@lingui/core";import{Button as il,CustomTokensZeroStateDarkIcon as Qv,CustomTokensZeroStateIcon as qv,DeleteIcon as Hv,Divider as On,IconButton as Gv,MessageBox as Vv,NotFound as Kv,styled as sl}from"@rango-dev/ui";import fe,{useState as al}from"react";import{useNavigate as jv}from"react-router-dom";import{CloseIcon as Av,IconButton as Nv,SearchIcon as Wv,TextField as Bv}from"@rango-dev/ui";import _n from"react";import{styled as Iv}from"@rango-dev/ui";var Zd=Iv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Tt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return _n.createElement(Bv,{prefix:_n.createElement(Zd,null,_n.createElement(Wv,{color:"black"})),suffix:!!s.length&&_n.createElement(Nv,{variant:"ghost",onClick:()=>p?.(""),size:"small"},_n.createElement(Av,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Tt,"SearchInput");import{i18n as rl}from"@lingui/core";import{darkTheme as pf,Divider as tn,ExternalLinkIcon as Pv,Image as Dv,ListItemButton as _v,NotFound as $v,PinIcon as Fv,Skeleton as cf,Typography as bi,VirtualizedList as Ov}from"@rango-dev/ui";import H from"react";import{Divider as sf,ListItem as Lv,Skeleton as $n}from"@rango-dev/ui";import kt from"react";import{css as en,darkTheme as Jd,ImageContainer as Mv,styled as mt,Typography as Rd}from"@rango-dev/ui";var Xs=en({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),Ys=en({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Zs=en({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Js=en({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Jd} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Rs=en({}),el=en(),ef=mt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),tl=mt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),wi=mt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${Ys}`]:{[`& .${Js}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Rs}`]:{bottom:"-15px"},[`& .${Xs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Zs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),ol=mt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),nl=mt(Rd,{}),tf=mt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${el}`]:{$$color:"$colors$neutral600",[`.${Jd} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),xi=mt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),UU=mt("div",{display:"flex",alignItems:"center"}),of=mt("div",{position:"relative",[`& ${Mv}`]:{borderRadius:"$xm",overflow:"hidden"}}),nf=mt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),rf=mt(Rd,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),af=mt("a",{"& svg:hover":{color:"$colors$info"}});function lf(t){return kt.createElement(wi,null,Array.from(Array(t.size),e=>kt.createElement(Lv,{key:e,hasDivider:!0,start:kt.createElement($n,{variant:"circular",width:35,height:35}),end:kt.createElement(xi,null,kt.createElement($n,{variant:"text",size:"large",width:70}),kt.createElement(sf,{size:4}),kt.createElement($n,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement($n,{variant:"text",size:"large",width:90}),kt.createElement(sf,{size:4}),kt.createElement($n,{variant:"text",size:"medium",width:90}))})))}i(lf,"LoadingTokenList");var Uv=20,zv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:Ys()},o?H.createElement("div",{className:Xs()},o):H.createElement(tl,{className:Zs()},H.createElement(bi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(tn,{direction:"horizontal",size:4}),H.createElement(ol,{css:a},H.createElement(nl,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Js()} ${!o&&Rs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(tn,{size:4,direction:"horizontal"}),H.createElement(af,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},H.createElement(Pv,{size:12}))))},"renderDesc");function Fn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,p=y().blockchains(),{getBalanceFor:u,fetchingWallets:c}=y(),{isTokenPinned:m}=y(),h=i(d=>{let g=fr(u(d));return s?s(d):c?H.createElement(xi,null,H.createElement(cf,{variant:"text",size:"large",width:70}),H.createElement(tn,{size:4}),H.createElement(cf,{variant:"text",size:"medium",width:50})):g&&H.createElement(tf,null,H.createElement(rf,{variant:"title",size:"small"},g.amount),H.createElement("div",null),g.usdValue&&H.createElement(bi,{variant:"body",className:el(),size:"xsmall"},`$${g.usdValue}`))},"endRenderer"),f=i(()=>H.createElement(Ov,{itemContent:d=>{let g=e[d],C=g.address||"",S=p.find(w=>w.name===g.blockchain),T=Za(S.color,"main"),v={$$color:T.main150,[`.${pf} &`]:{$$color:T.main750},backgroundColor:"$$color"},k={$$color:T.main750,[`.${pf} &`]:{$$color:T.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(_v,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":d,key:`${g.symbol}${g.address}`,id:`${g.symbol}${g.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[d]),start:H.createElement(of,null,H.createElement(Dv,{src:g.image,size:30}),t.type!=="custom-token"&&m(g,t.type)&&H.createElement(nf,null,H.createElement(Fv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||g.name||!g.name&&!C?H.createElement(tl,null,H.createElement(bi,{variant:"title",size:"xmedium"},g.symbol),H.createElement(tn,{direction:"horizontal",size:4}),H.createElement(ol,{css:v},H.createElement(nl,{variant:"body",size:"xsmall",css:k},g.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?zv({address:C,token:e[d],customCssForTag:v,customCssForTagTitle:k,name:g.name,url:S.info.addressUrl.split("{wallet}").join(C)}):g.name||void 0,end:h(g)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(bi,{variant:"label",size:"large"},rl.t("Select Token")),H.createElement(tn,{size:4})),H.createElement(ef,null,H.createElement(tn,{size:4}),l==="loading"&&H.createElement(lf,{size:Uv}),l==="success"&&(e.length?H.createElement(wi,{as:"ul"},f()):!!o&&H.createElement($v,{title:rl.t("No results found"),description:rl.t("Try using different keywords")}))))}i(Fn,"TokenList");var Xv=sl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Yv=sl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Zv=sl(Gv,{"&:hover":{"& svg":{color:"$secondary550"}}});function uf(){let[t,e]=al(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:p}=Go({}),u=jv(),[c,m]=al(!1),[h,f]=al(),d=i(T=>{let v=T.target.value;e(v)},"handleSearch"),g=p==="dark",C=n.filter(T=>Re(T.symbol,t)||Re(T.address||"",t)||Re(T.name||"",t)),S=i(()=>{if(h){let T=a?pt(a):null,v=r?pt(r):null,k=pt(h);T===k?l({token:null}):v===k&&s({token:null}),o(h)}m(!1)},"handleDeleteCustomToken");return fe.createElement(oe,{header:{title:Ot.t("Custom Tokens")}},fe.createElement(ie,null,fe.createElement(Xv,null,n.length?fe.createElement(fe.Fragment,null,fe.createElement(Tt,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ot.t("Search Token"),onChange:d}),fe.createElement(On,{size:16}),fe.createElement(Fn,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:T=>fe.createElement(Zv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),f(T)}},fe.createElement(Hv,{size:12,color:"gray"}))})):fe.createElement(Yv,null,fe.createElement(Kv,{icon:g?fe.createElement(Qv,{size:200}):fe.createElement(qv,{size:200}),title:Ot.t("No custom tokens"),description:Ot.t("press the button to add your custom token")})),fe.createElement(On,{size:20}),fe.createElement(il,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u($.addCustomTokens)},Ot.t("Add Custom Token"))),fe.createElement(R,{open:c,dismissible:!0,onClose:()=>m(!1),container:N()},fe.createElement(Vv,{title:Ot.t("Delete Custom Token"),type:"error",description:Ot.t("Are you sure you want to Delete this Token?")},fe.createElement(On,{size:40}),fe.createElement(On,{size:10}),fe.createElement(il,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ot.t("Yes, Delete it")),fe.createElement(On,{size:12}),fe.createElement(il,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ot.t("No, Continue"))))))}i(uf,"CustomTokensPage");import{i18n as Qe}from"@lingui/core";import{useManager as hw}from"@rango-dev/queue-manager-react";import{Button as fl,darkTheme as yw,Divider as wo,MessageBox as Sw,NotFound as Cw,styled as gl,Typography as Ai}from"@rango-dev/ui";import{TransactionStatus as Qn}from"rango-types";import ae,{useMemo as Wf,useState as Ni}from"react";import{useNavigate as Tw}from"react-router-dom";import{FilterIcon as rw,Popover as iw}from"@rango-dev/ui";import vo from"react";import{css as Jv,darkTheme as Ei,IconButton as Rv,styled as Un}from"@rango-dev/ui";var ll=Un("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ei} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),mf=Un(Rv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ei} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ei} &`]:{backgroundColor:"$neutral"},[`& ${ll}::before`]:{backgroundColor:"$secondary100",[`.${Ei} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),df=Un("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),ff=Un("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),gf=Jv({display:"flex",justifyContent:"space-between",alignItems:"center"}),hf=Un("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as yf}from"@lingui/core";import{Button as ew,Divider as Sf,ListItemButton as tw,Radio as ow,RadioRoot as nw,Typography as Cf}from"@rango-dev/ui";import nt from"react";function Tf(t){let{filterBy:e,onClickItem:o}=t;return nt.createElement(ff,null,nt.createElement("div",{className:gf()},nt.createElement(Cf,{size:"small",variant:"body"},yf.t("Status")),nt.createElement(ew,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},yf.t("Reset"))),nt.createElement(Sf,{size:10}),nt.createElement(nw,{value:e},nt.createElement(hf,null,t.list.map((n,r)=>nt.createElement(tw,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:nt.createElement(nt.Fragment,null,nt.createElement(Sf,{direction:"horizontal",size:4}),nt.createElement(Cf,{size:"medium",variant:"body"},n.title)),start:nt.createElement(ow,{value:n.id}),onClick:o})))))}i(Tf,"FilterSelectorContent");function pl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return vo.createElement("div",null,vo.createElement(iw,{open:a,align:"end",onOpenChange:o,container:N(),content:vo.createElement(Tf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},vo.createElement(mf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},vo.createElement(ll,{isSelect:!!n},vo.createElement(rw,{size:16,color:"black"}),!!n&&vo.createElement(df,null)))))}i(pl,"FilterSelector");import{i18n as lw}from"@lingui/core";import{Divider as bf,GroupedVirtualizedList as pw,Skeleton as cw,SwapListItem as Ef,Typography as uw}from"@rango-dev/ui";import ze,{useCallback as If,useEffect as mw,useRef as dw,useState as fw}from"react";function kf(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(kf,"calculateGroupsSoFar");import{css as aw,darkTheme as sw,styled as zn}from"@rango-dev/ui";var cl=aw(),vf=zn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),ul=zn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${cl}`]:{$$color:"$colors$neutral600",[`.${sw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ml=zn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),wf=zn("div",{gap:"$10",display:"flex",flexDirection:"column"}),xf=zn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var gw=10;function dl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=fw([]),l=dw(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=If(kf,[]),h=If(()=>{let f=e.length-l.current;f&&(l.current+=Math.min(f,gw),s(m(u,l.current)))},[e.length]);if(mw(()=>{r||h()},[r,h]),r){let f=[1,2];return ze.createElement(ze.Fragment,null,[f,f].map((g,C)=>ze.createElement(ul,{key:C},ze.createElement(ml,null,ze.createElement(cw,{variant:"text",width:60,size:"small"}),ze.createElement(bf,{size:16})),ze.createElement(bf,{size:4}),ze.createElement(wf,null,g.map((T,v)=>ze.createElement(Ef,{isLoading:!0,key:v}))))))}return ze.createElement(pw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:f=>ze.createElement(ul,null,ze.createElement(ml,null,ze.createElement(uw,{variant:"label",size:"medium",className:cl()},c[f]))),itemContent:(f,d)=>{let g=p[f];if(!g)return null;let C=g.steps[0],S=g.steps[g.steps.length-1];return ze.createElement(vf,{key:g.requestId},ze.createElement(Ef,{requestId:g.requestId,creationTime:g.creationTime,status:g.status,onClick:o,tooltipContainer:N(),onlyShowTime:c[d]===lw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:B(g.inputAmount,6,6),realAmount:g.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:B(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(dl,"HistoryGroupedList");import{i18n as Ii}from"@lingui/core";import Af from"dayjs";var Nf=i(t=>{let e=new Map([["today",{title:Ii.t("Today"),swaps:[]}],["week",{title:Ii.t("This week"),swaps:[]}],["month",{title:Ii.t("This month"),swaps:[]}],["year",{title:Ii.t("This year"),swaps:[]}]]);function o(p,u){e.has(p)||e.set(p,{title:p,swaps:[]}),e.get(p)?.swaps.push(u)}i(o,"addYearsToOutput");let n=Af();t.forEach(p=>{let u=Number(p.creationTime),c=Af(u);if(n.isSame(c,"day"))e.get("today")?.swaps.push(p);else if(n.isSame(c,"week"))e.get("week")?.swaps.push(p);else if(n.isSame(c,"month"))e.get("month")?.swaps.push(p);else if(n.isSame(c,"year"))e.get("year")?.swaps.push(p);else{let m=new Date(u).getFullYear().toString();o(m,p)}});let r=Array.from(e.values()).filter(p=>p.swaps.length>0),a=r.flatMap(p=>p.swaps),s=r.map(p=>p.swaps.length),l=r.map(p=>p.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var kw=gl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),vw=gl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),ww=gl("div",{"._typography":{color:"$neutral700",[`.${yw}&`]:{color:"$neutral900"}}}),xw=[{id:Qn.SUCCESS,title:Qe.t("Complete")},{id:Qn.RUNNING,title:Qe.t("Running")},{id:Qn.FAILED,title:Qe.t("Failed")}],bw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Bf(){let t=Tw(),{manager:e,state:o}=hw(),n=ut(e).map(({swap:v})=>v),[r,a]=Ni(""),[s,l]=Ni(!1),p=!o.loadedFromPersistor,[u,c]=Ni(""),[m,h]=Ni(!1),f=i(v=>{let k=v.target.value;a(k)},"handleSearch"),d=Wf(()=>!r&&!u?n:n.filter(v=>{let{inputAmount:k,status:w,steps:I,requestId:L}=v;return(!r||wt(k,r)||wt(w,r)||bw(I,r)||wt(L,r))&&(!u||u===w)}),[n,r,u]),g=!d?.length&&!p,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(v){console.log(v)}},"onClear"),T=Wf(()=>!n.some(v=>v.status===Qn.SUCCESS||v.status===Qn.FAILED),[n]);return ae.createElement(oe,{header:{title:Qe.t("History"),suffix:ae.createElement(Gt,null,ae.createElement(fl,{id:"widget-history-clear-btn",disabled:T,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(Ai,{size:"medium",variant:"label",color:"error"},Qe.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(vw,null,ae.createElement(Tt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Qe.t("Search Transaction"),autoFocus:!0,onChange:f,style:{height:36},value:r}),ae.createElement(wo,{size:10,direction:"horizontal"}),ae.createElement(pl,{filterBy:u,open:s,onOpenChange:v=>l(v),onClickItem:v=>c(v),list:xw})),ae.createElement(wo,{size:"16"}),ae.createElement(kw,null,g&&ae.createElement(xf,null,ae.createElement(wo,{size:32}),ae.createElement(Cw,{title:r?Qe.t("No results found"):Qe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Qe.t("Try using different keywords"):Qe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!g&&ae.createElement(dl,{list:d,onSwapClick:t,groupBy:Nf,isLoading:p}))),ae.createElement(R,{open:m,onClose:C,container:N()},ae.createElement(wo,{size:20}),ae.createElement(Sw,{type:"warning",title:Qe.t("Clear Transaction History"),description:ae.createElement(ww,null,ae.createElement(Ai,{variant:"body",size:"medium"},Qe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(wo,{size:"24"}),ae.createElement(Ai,{variant:"body",size:"small"},Qe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(wo,{size:30}),ae.createElement(fl,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Qe.t("Yes, Clear the history")),ae.createElement(wo,{size:10}),ae.createElement(fl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(Ai,{variant:"title",size:"medium",color:"primary"},Qe.t("No, Cancel")))))}i(Bf,"HistoryPage");import{i18n as Xw}from"@lingui/core";import{Button as Yw,Divider as Jf,styled as Zw,WarningIcon as Jw}from"@rango-dev/ui";import Rw from"bignumber.js";import qe,{useEffect as Rf,useState as eg}from"react";import{useNavigate as ex}from"react-router-dom";import{i18n as Lf}from"@lingui/core";import{Alert as Iw,Divider as hl,NoRouteIcon as Aw,Typography as Nw}from"@rango-dev/ui";import xo from"react";import{styled as Ew}from"@rango-dev/ui";var Mf=Ew("div",{display:"flex",flexDirection:"column",alignItems:"center"});function yl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Mt(t,e)?xo.createElement(Mf,null,xo.createElement(hl,{size:10}),xo.createElement(Aw,{size:24,color:"gray"}),xo.createElement(hl,{size:4}),xo.createElement(Nw,{variant:"title",size:"small"},Lf.t("No Routes Found")),xo.createElement(hl,{size:4}),xo.createElement(Iw,{title:Lf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(yl,"SameTokensWarning");import{i18n as Dw}from"@lingui/core";import{Header as _w}from"@rango-dev/ui";import Jt,{useEffect as $w,useState as Fw}from"react";import{i18n as Bw}from"@lingui/core";import{Divider as Cl,FullExpandedQuote as Mw,Typography as Lw}from"@rango-dev/ui";import ye from"react";import{styled as Sl}from"@rango-dev/ui";var Pf=Sl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Df=Sl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),_f=Sl("div",{width:"146px"});import{i18n as qn}from"@lingui/core";import{Select as Ww}from"@rango-dev/ui";import $f from"react";function Wi(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:qn.t("Smart Routing")},{value:"FEE",label:qn.t("Lowest Fee")},{value:"SPEED",label:qn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:qn.t("Maximum Return")},{value:"PRICE",label:qn.t("Maximum Output")}];return $f.createElement(_f,null,$f.createElement(Ww,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Wi,"SelectStrategy");var Ff=3;function Hn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:h,sortStrategy:f,error:d}=O(),{slippage:g,customSlippage:C}=y(),{findToken:S}=y(),T=l||N(),v=!!u&&u.results.length,k=C??g,w=i(b=>{if(!m||!h||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...b};return zo(E,{fromToken:m,toToken:h,userSlippage:k,findToken:S})},"getQuoteWarning"),I=d?.type===0||d?.type===1,L=u?.results?$r(f,u?.results):[];return ye.createElement(ye.Fragment,null,a&&ye.createElement(ye.Fragment,null,ye.createElement(Df,null,ye.createElement(Lw,{size:"xmedium",variant:"title"},Bw.t("Sort by")),ye.createElement(Wi,{container:T})),ye.createElement(Cl,{size:"10"})),e&&Array.from({length:Ff},(b,E)=>ye.createElement(ye.Fragment,{key:E},s?ye.createElement(Mw,{loading:!0}):ye.createElement(Pn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Ff-1&&ye.createElement(Cl,{size:16}))),!e&&ye.createElement(ye.Fragment,null,v?L.map((b,E)=>{let x=w(b),W=Hs(b.swaps),D=L.length-1===E;return ye.createElement(ye.Fragment,{key:b.requestId},ye.createElement(ko,{showModalFee:r,container:T,selected:p?.requestId===b.requestId,tagHidden:!1,quote:{...b,requestAmount:u.requestAmount,validationStatus:null},loading:e,error:W?.options||null,warning:x,fullExpandedMode:s,onClick:A=>{W||c("warning",x),c("error",W?.options||null),o(A)},type:"list-item"}),!D&&ye.createElement(Cl,{size:16}))}):I&&ye.createElement(Pf,null,ye.createElement(bn,{size:s?"large":"small",error:d,fetch:n}))))}i(Hn,"Quotes");import{darkTheme as Pw,styled as Of}from"@rango-dev/ui";var Uf=Of("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Pw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),zf=Of("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Ow=100;function Tl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Fw(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=ro();return $w(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Ow):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Uf,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${Gr()}`,id:Pe.EXPANDED_BOX_ID},Jt.createElement(_w,{title:Dw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(Wi,{container:m}),Jt.createElement(ho,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(zf,null,Jt.createElement(Hn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:ro(),onClickOnQuote:n,fullExpandedMode:c})))}i(Tl,"ExpandedQuotes");import{i18n as jf}from"@lingui/core";import{SwapInput as Xf}from"@rango-dev/ui";import qw from"bignumber.js";import Gn from"react";import{ReverseIcon as Qw}from"@rango-dev/ui";import vl from"react";import{keyframes as Uw,styled as Qf}from"@rango-dev/ui";var kl=450,zw=Uw({"0%":{transform:"rotateX(0deg) rotateY(0deg) rotateZ(0deg)"},"33%":{transform:"rotateX(0deg) rotateZ(78deg) rotateY(66deg)"},"66%":{transform:"rotateX(0deg) rotateZ(163deg) rotateY(66deg)"},"100%":{transform:"rotateX(0deg) rotateZ(180deg) rotateY(0deg)"}}),qf=Qf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Hf=Qf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${zw} ${kl}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function wl(){let t=O.use.switchFromAndTo();return vl.createElement(qf,null,vl.createElement(Hf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},kl),t()}},vl.createElement(Qw,{size:12})))}i(wl,"SwitchFromAndToButton");import{styled as Gf}from"@rango-dev/ui";var Vf=Gf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Kf=Gf("div",{position:"relative"});function xl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:h,outputUsdValue:f,selectedQuote:d}=O(),{connectedWallets:g,getBalanceFor:C}=y(),S=a?C(a):null,T=fr(S)?.amount??"0",v=S?new qw(S.amount).shiftedBy(-S.decimals):Ce,k=!!s&&Up(g,s.name),w=!La(d,c,m),I=!La(d,c,f),L=!m||!f||!f.gt(0)?null:ct(m.toString(),f.toString());return Gn.createElement(Vf,null,Gn.createElement(Kf,null,Gn.createElement(Xf,{label:jf.t("From"),mode:"From",onInputChange:u,balance:T,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue:w?void 0:B(m,4,4),realUsdValue:w?void 0:m?.toString(),error:w?te().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:k,tooltipContainer:N(),onSelectMaxBalance:()=>{let b=B(v,S?.decimals),E=S?.amount?b:"";u(E)},anyWalletConnected:g.length>0}),Gn.createElement(wl,null)),Gn.createElement(Xf,{sharpBottomStyle:!r&&(!!d||e),label:jf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(ct(m,f),2,2),warningLevel:Pt(L??0),price:{value:B(h,6,6),usdValue:I?void 0:B(f,4,4),realValue:h?.toString(),realUsdValue:I?void 0:f?.toString(),error:I?te().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:N()}))}i(xl,"Inputs");import{useCallback as Hw,useEffect as Gw,useRef as Vw,useState as Kw}from"react";function Yf(){let{fetch:t,loading:e,cancelFetch:o}=Ci({request:async(n,r)=>await bt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Yf,"useFetchAllQuotes");var jw=600;function Bi({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Yf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:p,inputUsdValue:u,selectedQuote:c,sortStrategy:m,resetQuote:h,error:f,warning:d,setSelectedQuote:g,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:T,affiliatePercent:v,affiliateRef:k,affiliateWallets:w,fetchStatus:I}=y(),L=y().getLiquiditySources(),b=y().getDisabledLiquiditySources(),E=y().excludeLiquiditySources(),{findToken:x}=y(),[W,D]=Kw(!0),A=Vw(p),X=T??S,J=!s||!l||Mt(s,l)||!cn(p),M=i(Q=>{D(Q)},"resetState"),K=i(Q=>{let{fromToken:me,toToken:Ge,inputAmount:st,liquiditySources:de,excludeLiquiditySources:Ve,disabledLiquiditySources:V,slippage:Ke,affiliateRef:ft,affiliatePercent:_,affiliateWallets:G}=Q;if(W||M(!0),!J&&me&&Ge){h();let q=tu({fromToken:me,toToken:Ge,inputAmount:st,liquiditySources:de,excludeLiquiditySources:Ve,disabledLiquiditySources:V,wallets:a,slippage:Ke,affiliateRef:ft,affiliatePercent:_,affiliateWallets:G});Bo("experimental",r)&&(q.experimental=!0),Bo("avoidNativeFee",r)&&(q.avoidNativeFee=!0),Bo("enableCentralizedSwappers",r)&&(q.enableCentralizedSwappers=!0),r?.maxLength&&(q.maxLength=r.maxLength),e(q).then(ee=>{let ne=$r(m,ee.results),re=gu(c,ne,ee.requestAmount);D(!1),C("quotes",ee),g(re),Ti({diagnosisMessages:ee.diagnosisMessages,requestId:re?.requestId||"",swaps:re?.swaps});let $e=fo(re)||Ge?.usdPrice,or=Cn(re)||me?.usdPrice,no=re&&zo(re,{fromToken:{...me,usdPrice:or},toToken:{...Ge,usdPrice:$e},userSlippage:X,findToken:x});C("warning",no)}).catch(ee=>{let{error:ne}=ki(ee);(ne?.type===0||ne?.type===1)&&h(),ne?.type!==2&&(C("error",ne),D(!1))})}},"fetch"),pe=Hw(Ip(Q=>{K(Q)},jw),[J]);return Gw(()=>{if(!t){D(!1);return}if(I!=="success")return;if(J){D(!1),(c||f||d)&&h();return}if(!cn(p)||u?.eq(0)){M(!1),o();return}h(),M(!0);let Q=K;return A.current&&A.current!=p&&(Q=pe),A.current=p,Q({inputAmount:p,fromToken:s,toToken:l,liquiditySources:L,excludeLiquiditySources:E,disabledLiquiditySources:b,slippage:X,affiliateRef:k,affiliatePercent:v,affiliateWallets:w}),o},[I,p,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,L?.length,n,b.length,X,k,v,JSON.stringify(w)]),{fetch:()=>K({inputAmount:p,fromToken:s,toToken:l,liquiditySources:L,excludeLiquiditySources:E,disabledLiquiditySources:b,slippage:X,affiliateRef:k,affiliatePercent:v,affiliateWallets:w}),loading:W}}i(Bi,"useSwapInput");function Zf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ge.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Zf,"emitPreventableEvent");var tx=Zw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),ox=300;function tg(){let t=ex(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:h}=O(),[f,d]=eg(!1),{isLargeScreen:g,isExtraLargeScreen:C}=ui(),{fetch:S,loading:T}=Bi({refetchQuote:a}),{config:v,fetchStatus:k,connectedWallets:w}=y(),{isActiveTab:I}=le(),[L,b]=eg(!1),x=Xc({fetchMetaStatus:k,fetchingQuote:T,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),W=Kp(g,C,v?.variant),D=!!n&&!!e&&!!o&&new Rw(n).gt(0)&&!cu(e,o),A=D&&k==="success"&&T,J=(!W||W&&p?.results.length)&&(l||s);Rf(()=>{c(),h("refetchQuote",!0)},[]),Rf(()=>{d(D)},[D]);let M=(r||s)&&!L?S:void 0,K=i(Q=>{W&&f?(d(!1),setTimeout(()=>{t(Q)},ox)):t(Q)},"onHandleNavigation"),pe=i(Q=>{r?.requestId!==Q.requestId&&(b(!1),u(Q))},"onClickOnQuote");return qe.createElement(tx,null,qe.createElement(oe,{height:"auto",footer:qe.createElement(Yw,{id:`widget-swap-${x.action}-btn`,type:"primary",size:"large",disabled:x.disabled||!I,prefix:x.action==="confirm-warning"&&qe.createElement(Jw,null),fullWidth:!0,onClick:()=>{x.action==="connect-wallet"?Zf({type:"clickConnectWallet"},()=>K($.wallets)):x.action==="confirm-warning"?b(!0):K($.confirmSwap)}},x.title),header:{onWallet:()=>{K($.wallets)},hasBackButton:!1,title:v.title||Xw.t("Swap"),suffix:qe.createElement(ho,{hidden:W?["refresh"]:void 0,onClickRefresh:M,onClickHistory:()=>K($.swaps),onClickSettings:()=>{K($.settings)}})}},qe.createElement(ie,null,qe.createElement(xl,{fetchingQuote:A,fetchMetaStatus:k,isExpandable:W,onClickToken:Q=>{K(Q==="from"?$.fromSwap:$.toSwap)}}),qe.createElement(Jf,{size:"2"}),W?null:qe.createElement(ko,{quote:r,loading:A,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{h("refetchQuote",!1),K($.routes)}:void 0}),J?qe.createElement(qe.Fragment,null,qe.createElement(Jf,{size:"10"}),qe.createElement(In,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:L,confirmationDisabled:!I,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:()=>{b(!1),m(!0),K($.confirmSwap)},onChangeSettings:()=>K($.settings)})):null,qe.createElement(yl,null))),W?qe.createElement(Tl,{loading:A,onClickOnQuote:pe,fetch:S,onClickRefresh:M,isVisible:f}):null)}i(tg,"Home");import{i18n as og}from"@lingui/core";import{Alert as nx,Divider as rx,List as ix,ListItemButton as ax,Radio as sx,RadioRoot as lx,Typography as px}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Rp,r=o?.language||Mo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Mo),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function ng(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=Ye(),r=o.map(a=>{let{local:s,label:l,SVGFlag:p}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(px,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(sx,{value:s}),start:Wt.createElement(p,null)}});return Wt.createElement(oe,{header:{title:og.t("Language")}},Wt.createElement(ie,null,Wt.createElement(nx,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(rx,{size:"8"}),Wt.createElement(lx,{value:t},Wt.createElement(ix,{type:Wt.createElement(ax,{title:og.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(ng,"LanguagePage");import{i18n as Ut}from"@lingui/core";import{Button as fx,Checkbox as gx,Image as hx,ListItemButton as yx,NotFound as Sx,Typography as Cx}from"@rango-dev/ui";import He,{useState as Tx}from"react";import{Checkbox as mx,Skeleton as ig}from"@rango-dev/ui";import Kn from"react";import{styled as bl}from"@rango-dev/ui";var Vn=bl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),El=bl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Il=bl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as cx,styled as ux}from"@rango-dev/ui";var rg=ux(cx,{height:61});var dx=30;function Al(){return Kn.createElement(Vn,null,Array.from(Array(dx),(t,e)=>Kn.createElement(rg,{hasDivider:!0,key:e,start:Kn.createElement(ig,{variant:"circular",width:35,height:35}),title:Kn.createElement(ig,{variant:"text",size:"large",width:90}),end:Kn.createElement(mx,{checked:!1})})))}i(Al,"LoadingLiquiditySourceList");function Nl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=Tx(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=yr(o,n),u={Exchanges:Ut.t("Exchanges"),Bridges:Ut.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(S=>c.includes(S.type)),h=m.length===m.filter(S=>S.selected).length,f=i(()=>{m.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),d=m.map(S=>{let{selected:T,groupTitle:v,logo:k,id:w,...I}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:He.createElement(hx,{src:k,size:22,type:"circular"}),onClick:()=>{l||s(v)},end:He.createElement(gx,{checked:T,disabled:l}),title:He.createElement(Cx,{variant:"title",size:"xmedium"},Ut.t(v)),selected:T,groupTitle:v,logo:k,...I}}),g=i(S=>{let T=S.target.value;a(T)},"handleSearch"),C=d;return r&&(C=d.filter(S=>wt(S.groupTitle,r))),He.createElement(oe,{header:{title:Ut.t(t),suffix:He.createElement(El,null,He.createElement(fx,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:f},h?Ut.t("Deselect all"):Ut.t("Select all")))}},He.createElement(ie,{view:!0},He.createElement(Tt,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search {sourceType}",{sourceType:u[t]}),onChange:g}),e==="loading"&&He.createElement(Al,null),!C.length&&r?He.createElement(Il,null,He.createElement(Sx,{title:Ut.t("No results found"),description:Ut.t("Try using different keywords")})):e==="success"&&He.createElement(Vn,{disabled:l},C.map(S=>{let{groupTitle:T,...v}=S;return He.createElement(He.Fragment,{key:S.id},He.createElement(yx,{style:{height:"61px"},...v,selected:!1,hasDivider:!0}))}))))}i(Nl,"LiquiditySourcePage");import{i18n as kx}from"@lingui/core";import Mi from"react";import{useNavigate as vx}from"react-router-dom";function ag(){let t=vx(),e=Ye(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:p}=Bi({refetchQuote:n}),u=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${$.settings}`,m=`../${$.wallets}`;return Mi.createElement(oe,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:kx.t("Routes"),suffix:Mi.createElement(ho,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Mi.createElement(ie,null,Mi.createElement(Hn,{fetch:l,loading:p,onClickOnQuote:u})))}i(ag,"RoutesPage");import{i18n as dg}from"@lingui/core";import{Divider as fg,getCategoriesCount as Mx,SelectableCategoryList as Lx}from"@rango-dev/ui";import zt,{useState as gg}from"react";import{useNavigate as Px}from"react-router-dom";import{i18n as Wl}from"@lingui/core";import{Divider as Ex,Image as Ix,ListItemButton as Ax,NotFound as Nx,Typography as mg}from"@rango-dev/ui";import rt,{useEffect as Wx,useState as Bx}from"react";var sg=i((t,e,o)=>t.filter(n=>lr(n.type,o)).filter(n=>Re(n.name,e)||Re(n.displayName,e)),"filterBlockchains");import{ImageContainer as wx,styled as lg}from"@rango-dev/ui";var pg=lg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Li=lg(kn,{padding:0,margin:0,listStyle:"none",[`& ${wx}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as xx,Skeleton as cg}from"@rango-dev/ui";import Pi from"react";var bx=20;function ug(){return Pi.createElement(Li,null,Array.from(Array(bx),t=>Pi.createElement(xx,{key:t,hasDivider:!0,start:Pi.createElement(cg,{variant:"circular",width:35,height:35}),title:Pi.createElement(cg,{variant:"text",size:"large",width:90})})))}i(ug,"LoadingBlockchainList");function Bl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Bx(e),{fetchStatus:p}=y();Wx(()=>{l([...sg(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?rt.createElement(Nx,{title:Wl.t("No results found"),description:Wl.t("Try using different keywords")}):rt.createElement(Li,{as:"ul",key:`${r}-${o}`},s.map(c=>rt.createElement(Ax,{key:`${c.name}-${c.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(c),start:rt.createElement(Ix,{src:c.logo,size:30}),title:rt.createElement(mg,{variant:"title",size:"medium"},c.displayName),id:c.name}))),"renderList");return rt.createElement(rt.Fragment,null,a&&rt.createElement(rt.Fragment,null,rt.createElement(mg,{variant:"label",size:"large"},Wl.t("Select Chain")),rt.createElement(Ex,{size:4})),rt.createElement(pg,null,p==="loading"&&rt.createElement(ug,null),p==="success"&&u()))}i(Bl,"BlockchainList");function Di(t){let{type:e}=t,o=Ye(),[n,r]=gg(""),[a,s]=gg("ALL"),l=O.use.setToBlockchain(),p=O.use.setFromBlockchain(),{fetchStatus:u}=y(),c=Px(),m=y().blockchains({type:e}),h=Mx(m),f=!t.hideCategory&&h!==1;return zt.createElement(oe,{header:{title:dg.t("Select Chain")}},zt.createElement(ie,{view:!0},f&&zt.createElement(zt.Fragment,null,zt.createElement(Lx,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),zt.createElement(fg,{size:24})),zt.createElement(Tt,{value:n,autoFocus:!0,placeholder:dg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:d=>r(d.target.value)}),zt.createElement(fg,{size:16}),zt.createElement(Bl,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:d=>{e==="custom-token"?c(`..?blockchain=${d.name}`,{replace:!0}):(e==="source"?p(d):l(d),o())}})))}i(Di,"SelectBlockchainPage");import{i18n as $i}from"@lingui/core";import{Divider as kg}from"@rango-dev/ui";import bo,{useState as Qx}from"react";import{useNavigate as qx}from"react-router-dom";import{i18n as Pl}from"@lingui/core";import{BlockchainsChip as _i,Divider as Cg,Image as Tg,Skeleton as Ox,Tooltip as Ux,Typography as Dl}from"@rango-dev/ui";import Me from"react";import{useEffect as $x}from"react";var hg=["ETH","COSMOS","OSMOSIS"];function Ml(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Dx),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(_x(s)),r=n.splice(a)}return{list:n,more:r}}i(Ml,"prepare");function Dx(t,e){let o=hg,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(Dx,"sortByMostUsedBlockchains");function _x(t){return i(function(o,n){let r=t.findIndex(p=>p===o.name),a=t.findIndex(p=>p===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(_x,"generateSortByPreferredBlockchainsFor");function yg(t,e){return!!e.list.find(o=>o.name===t)}i(yg,"isInVisibleList");function Ll(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();$x(()=>{if(e?.selected){let a=Ml(t,o,e);yg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Ml(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Ll,"usePrepareBlockchainList");import{styled as Fx}from"@rango-dev/ui";var Sg=Fx("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var zx=12;function _l(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Ll(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=O.use.resetToBlockchain(),u=O.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,h=!m&&c;return Me.createElement(Me.Fragment,null,Me.createElement(Cg,{size:12}),Me.createElement(Dl,{variant:"label",size:"large"},Pl.t("Select Chain")),Me.createElement(Cg,{size:12}),Me.createElement(Sg,null,l==="loading"&&Array.from(Array(zx),f=>Me.createElement(Ox,{key:f,variant:"rounded",height:50})),l==="success"&&Me.createElement(Me.Fragment,null,Me.createElement(_i,{selected:!n,onClick:()=>{o==="from"?u():p()}},Me.createElement(Dl,{variant:"body",size:"xsmall",color:"secondary500"},Pl.t("All"))),s.list.map(f=>Me.createElement(Ux,{key:f.name,content:f.shortName,side:"bottom",sideOffset:2,container:N()},Me.createElement(_i,{key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},Me.createElement(Tg,{src:f.logo,size:30})))),m?Me.createElement(_i,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Me.createElement(Tg,{src:s.more[0].logo,size:30})):null,h?Me.createElement(_i,{onClick:a,key:"more-blockchains"},Me.createElement(Dl,{variant:"body",size:"xsmall",color:"secondary500"},Pl._("More +{count}",{count:s.more.length}))):null)))}i(_l,"BlockchainsSection");function $l(t){let{type:e}=t,o=qx(),n=Ye(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=O(),{getBalanceFor:c}=y(),[m,h]=Qx(""),d=(e==="source"?r:a)?.name??"",g=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:d,searchFor:m,getBalanceFor:c}),S=i(k=>{e==="source"?p(k):u(k)},"updateBlockchain"),T=i(k=>{e==="source"?s({token:k,meta:{blockchains:g,tokens:C}}):l({token:k,meta:{blockchains:g,tokens:C}})},"updateToken"),v={source:$i.t("Source"),destination:$i.t("Destination")};return bo.createElement(oe,{header:{title:$i.t("Swap {type}",{type:v[e]})}},bo.createElement(ie,null,bo.createElement(_l,{blockchains:g,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:k=>{S(k)}}),bo.createElement(kg,{size:24}),bo.createElement(Tt,{value:m,autoFocus:!0,placeholder:$i.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:k=>h(k.target.value)}),bo.createElement(kg,{size:16}),bo.createElement(Fn,{list:C,selectedBlockchain:d,searchedFor:m,type:e,onChange:k=>{T(k);let w=g.find(I=>k.blockchain===I.name);w&&S(w),n()}})))}i($l,"SelectSwapItemsPage");import{i18n as Ul}from"@lingui/core";import{Alert as gb,Button as hb,styled as yb}from"@rango-dev/ui";import Eo from"react";import{useInRouterContext as Sb,useSearchParams as Cb}from"react-router-dom";import{i18n as Ig}from"@lingui/core";import{Divider as Ag,InfoIcon as Kx,SlippageIcon as jx,TextField as Xx,Tooltip as Yx,Typography as Ng}from"@rango-dev/ui";import it from"react";import{Chip as Hx,styled as jn,TextField as Gx}from"@rango-dev/ui";var vg=jn("div",{paddingTop:"$5",padding:"$10 $5"}),wg=jn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Gx}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),xg=jn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Fi=jn("div",{maxWidth:"280px",padding:"$10"}),bg=jn(Hx,{width:"61px",flexShrink:0});import{i18n as Fl}from"@lingui/core";import{Typography as Vx}from"@rango-dev/ui";import Xn from"react";function Eg(){return Xn.createElement(Fi,null,Xn.createElement(Vx,{variant:"label",size:"medium",color:"neutral700"},Fl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Xn.createElement("br",null),Xn.createElement("br",null),Xn.createElement("b",null,Fl.t("Warning")),":\xA0",Fl.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(Eg,"SlippageTooltipContent");function Ol(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return it.createElement(vg,null,it.createElement(xg,null,it.createElement(jx,{size:16,color:"gray"}),it.createElement(Ag,{direction:"horizontal",size:4}),it.createElement(Ng,{variant:"title",size:"xmedium"},Ig.t("Slippage tolerance per swap")),it.createElement(Ag,{direction:"horizontal",size:4}),it.createElement(Yx,{container:N(),side:"top",sideOffset:4,content:it.createElement(Eg,null)},it.createElement(Kx,{color:"gray"}))),it.createElement(wg,null,ec.map((r,a)=>{let s=`slippage-${a}`;return it.createElement(bg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),it.createElement(Xx,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=rc&&s<=nc?n(s):n(null)},suffix:o&&it.createElement(Ng,{variant:"body",size:"small"},"%"),placeholder:Ig.t("Custom")})))}i(Ol,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as Wg,BridgesIcon as Zx,ChevronRightIcon as Oi,DarkModeIcon as Bg,Divider as Yn,ExchangeIcon as Jx,InfinityIcon as Rx,InfoIcon as eb,LanguageIcon as tb,LightModeIcon as Mg,List as ob,ListItem as nb,ListItemButton as rb,Skeleton as ib,styled as ab,Switch as sb,Tabs as lb,TargetIcon as pb,Tooltip as cb,Typography as Je}from"@rango-dev/ui";import P from"react";import{useNavigate as ub}from"react-router-dom";var mb=ab("div",{width:"202px",height:"$40"}),db=[{id:"light",icon:P.createElement(Mg,{color:"black",size:24}),tooltip:P.createElement(Je,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:P.createElement(Bg,{color:"black",size:24}),tooltip:P.createElement(Je,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:P.createElement(Wg,{color:"black",size:24}),tooltip:P.createElement(Je,{size:"xsmall",variant:"body"},dt.t("Auto"))}],fb=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return P.createElement(Wg,{...e});case"dark":return P.createElement(Bg,{...e});default:return P.createElement(Mg,{...e})}},"getThemeIcon");function Lg(){let t=ub(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(M=>M.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),h=je("theme",c),f=je("liquiditySource",c),d=je("language",c),g=je("customTokens",c),C=y().infiniteApprove,S=y().toggleInfiniteApprove,T=yr(p,u),v=T.filter(M=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(M.type)),k=v.length,w=v.filter(M=>M.selected).length,I=T.filter(M=>M.type==="DEX"),L=I.length,b=I.filter(M=>M.selected).length,E=i((M,K)=>{switch(l){case"loading":return P.createElement(ib,{variant:"text",size:"medium",width:50});case"failed":return P.createElement(Je,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return P.createElement(Je,{variant:"body",size:"medium"},`${M} / ${K}`)}},"handleSwapperEndItem"),x={id:"widget-setting-bridge-item-btn",title:P.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:P.createElement(P.Fragment,null,E(w,k),P.createElement(Yn,{direction:"horizontal",size:8}),P.createElement(Oi,{color:"black"})),onClick:()=>t($.bridges),start:P.createElement(Zx,{color:"gray",size:16})},W={id:"widget-setting-exchange-item-btn",title:P.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:P.createElement(P.Fragment,null,E(b,L),P.createElement(Yn,{direction:"horizontal",size:8}),P.createElement(Oi,{color:"black"})),start:P.createElement(Jx,{color:"gray",size:16}),onClick:()=>t($.exchanges)},D={id:"widget-setting-custom-tokens-item-btn",title:P.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:P.createElement(P.Fragment,null,P.createElement(Je,{variant:"body",size:"medium"},`${m.length}`),P.createElement(Yn,{direction:"horizontal",size:8}),P.createElement(Oi,{color:"black"})),start:P.createElement(pb,{color:"gray",size:16}),onClick:()=>t($.customTokens)},A={id:"widget-setting-language-item-btn",title:P.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Language")),start:P.createElement(tb,{color:"gray",size:16}),end:P.createElement(P.Fragment,null,P.createElement(Je,{variant:"body",size:"medium"},s),P.createElement(Yn,{direction:"horizontal",size:8}),P.createElement(Oi,{color:"black"})),onClick:()=>t($.languages)},X={id:"widget-setting-infinite-approval-item-btn",title:P.createElement(P.Fragment,null,P.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),P.createElement(Yn,{direction:"horizontal",size:4}),P.createElement(cb,{side:"top",sideOffset:4,container:N(),content:P.createElement(Fi,null,P.createElement(Je,{variant:"label",size:"medium",color:"neutral700"},P.createElement("b",null,dt.t("Warning")),":\xA0",dt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},P.createElement(eb,{color:"gray"}))),start:P.createElement(Rx,{color:"gray",size:16}),end:P.createElement(sb,{checked:C}),onClick:S},se={id:"widget-setting-theme-item-btn",type:P.createElement(nb,null),title:P.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Theme")),end:P.createElement(mb,null,P.createElement(lb,{container:N(),items:db,value:n,onChange:M=>o(M.id),type:"primary",borderRadius:"small"})),start:fb(n)},J=f?[]:[x,W];return g||J.push(D),d||J.push(A),J.push(X),!e?.singleTheme&&!h&&J.push(se),P.createElement(ob,{type:P.createElement(rb,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Lg,"SettingsLists");var Tb=yb("div",{paddingLeft:"$8"});function Pg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Cb(),r=Sb(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Eo.createElement(oe,{header:{title:Ul.t("Settings")}},Eo.createElement(ie,null,o&&Eo.createElement(gb,{type:"info",variant:"alarm",title:Ul.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Eo.createElement(Tb,null,Eo.createElement(hb,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Ul.t("Reset")))}),Eo.createElement(Ol,null),Eo.createElement(Lg,null)))}i(Pg,"SettingsPage");import{i18n as sE}from"@lingui/core";import{cancelSwap as lE}from"@rango-dev/queue-manager-rango-preset";import{useManager as pE}from"@rango-dev/queue-manager-react";import{Alert as cE}from"@rango-dev/ui";import np from"react";import{useParams as uE}from"react-router-dom";import{i18n as at}from"@lingui/core";import{getCurrentBlockchainOfOrNull as Qb,getCurrentStep as qb,getRelatedWalletOrNull as Hb}from"@rango-dev/queue-manager-rango-preset";import{Button as uh,CopyIcon as Gb,Divider as Vb,DoneIcon as Kb,IconButton as jb,QuoteCost as Xb,RangoExplorerIcon as Yb,StepDetails as Zb,Tooltip as mh,Typography as Io,useCopyToClipboard as Jb}from"@rango-dev/ui";import{useWallets as Rb}from"@rango-dev/wallets-react";import dh from"bignumber.js";import{PendingSwapNetworkStatus as ji}from"rango-types";import j,{useEffect as fh,useRef as eE,useState as gh}from"react";import{useNavigate as tE}from"react-router-dom";import{i18n as eo}from"@lingui/core";var kb=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function Dg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?eo.t("Today"):`${kb[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Dg,"timeSince");function _g(t){return t.finishTime?Dg(parseInt(t.finishTime)):Dg(parseInt(t.creationTime))}i(_g,"getSwapDate");import{PendingSwapNetworkStatus as Qi}from"rango-types";import qi from"react";import{i18n as Ui}from"@lingui/core";import{Button as $g,Divider as zl,MessageBox as vb}from"@rango-dev/ui";import to from"react";var Fg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(zl,{size:20}),to.createElement(vb,{type:"error",title:Ui.t("Cancel Swap"),description:Ui.t("Are you sure you want to cancel this swap?")}),to.createElement(zl,{size:32}),to.createElement($g,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Ui.t("Yes, Cancel it")),to.createElement(zl,{size:12}),to.createElement($g,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Ui.t("No, Continue"))),"CancelContent");import{i18n as zi}from"@lingui/core";import{Button as Og,Divider as Ql,MessageBox as wb,Typography as xb}from"@rango-dev/ui";import Qt from"react";var Ug=i(({onDelete:t,onClose:e})=>Qt.createElement(Qt.Fragment,null,Qt.createElement(Ql,{size:20}),Qt.createElement(wb,{type:"error",title:zi.t("Delete Transaction"),description:zi.t("Are you sure you want to delete this swap?")}),Qt.createElement(Ql,{size:32}),Qt.createElement(Og,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},zi.t("Yes, Delete it")),Qt.createElement(Ql,{size:12}),Qt.createElement(Og,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Qt.createElement(xb,{variant:"title",size:"medium",color:"primary"},zi.t("No, Cancel")))),"DeleteContent");import{i18n as ql}from"@lingui/core";import{PendingSwapNetworkStatus as Hl}from"rango-types";var Gl={[Hl.WaitingForNetworkChange]:{type:"loading",title:ql.t("Change Network")},[Hl.WaitingForConnectingWallet]:{type:"warning",title:ql.t("Connect Wallet")},[Hl.NetworkChanged]:{type:"success",title:ql.t("Network Changed")}};import{warn as bb}from"@rango-dev/logging-core";import{MessageBox as Eb,Wallet as Ib}from"@rango-dev/ui";import{useWallets as Ab}from"@rango-dev/wallets-react";import on,{useState as Nb}from"react";import{styled as zg}from"@rango-dev/ui";var Qg=zg("div",{display:"flex",justifyContent:"center"}),T5=zg("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var qg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=Nb(),{getWalletInfo:u,state:c}=Ab(),m=n?.walletType,h=m?un(c(m)):null,f=m?u(m):null,d=a&&!!m&&!!h&&!!f,{list:g}=gt(),C=i(()=>{if(m){let S=g.find(T=>T.type===m);S?p(S):bb(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return on.createElement(on.Fragment,null,on.createElement(Eb,{type:e,title:o,description:r}),d&&on.createElement(Qg,null,on.createElement(Ib,{container:N(),title:f.name,image:f.img,type:m,state:h,link:f.installLink,disabled:s,onClick:C})),on.createElement(uo,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function Vl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===Qi.WaitingForNetworkChange||e===Qi.WaitingForConnectingWallet||e===Qi.NetworkChanged;return qi.createElement(R,{open:!!e,onClose:o,container:document.getElementById(Pe.SWAP_BOX_ID)||document.body},p&&qi.createElement(qg,{type:Gl[e].type,title:Gl[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Qi.WaitingForNetworkChange}),e==="delete"&&qi.createElement(Ug,{onClose:o,onDelete:n}),e==="cancel"&&qi.createElement(Fg,{onClose:o,onCancel:r}))}i(Vl,"SwapDetailsModal");import{i18n as Zn}from"@lingui/core";import{Button as Kl,Divider as Hi,MessageBox as Hg,TokenAmount as Wb,Typography as jl}from"@rango-dev/ui";import _e from"react";import{useNavigate as Bb}from"react-router-dom";function Xl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:h}=t,f=Bb();return _e.createElement(R,{open:e,onClose:o,container:document.getElementById(Pe.SWAP_BOX_ID)||document.body},n==="success"?_e.createElement(Hg,{type:"success",title:Zn.t("Swap Successful")},_e.createElement(Wb,{direction:"vertical",tooltipContainer:N(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),_e.createElement(Hi,{size:12}),_e.createElement(jl,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):_e.createElement(Hg,{type:"error",title:Zn.t("Transaction Failed"),description:m}),_e.createElement(Hi,{size:32}),n==="success"&&_e.createElement(Kl,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{f("../../")}},_e.createElement(jl,{variant:"title",size:"medium",color:"neutral100"},Zn.t("Done"))),_e.createElement(Hi,{size:12}),h&&_e.createElement(_e.Fragment,null,_e.createElement(Kl,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},Zn.t("Diagnosis")),_e.createElement(Hi,{size:12})),_e.createElement(Kl,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},_e.createElement(jl,{variant:"title",size:"medium",color:"primary"},Zn.t("See Details"))))}i(Xl,"SwapDetailsCompleteModal");import zb from"react";import{i18n as $b}from"@lingui/core";import{Alert as sh,IconButton as Fb,LinkIcon as Ob}from"@rango-dev/ui";import oo,{Fragment as Ub}from"react";import{Alert as Lb,ChevronDownIcon as Pb,IconButton as Db}from"@rango-dev/ui";import rn,{useState as _b}from"react";import{css as Jn,darkTheme as Gg,styled as qt,Typography as Mb}from"@rango-dev/ui";var Vg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Gi=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Gg} &`]:{color:"$secondary500"}}}}}),Kg=qt(kn,{padding:"$0 $20 $20 $20"}),nK=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),jg=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),rK=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),nn=Jn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Gg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Xg=Jn({padding:"$5 0"}),Vi=Jn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Yg=Jn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Zg=Jn({width:"100%",padding:"0 $20 $10"}),Jg=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Rg=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ki=qt(Mb,{wordBreak:"break-word"});import{styled as Yl}from"@rango-dev/ui";var eh=Yl("div",{display:"flex",flexDirection:"column",gap:"$10"}),th=Yl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),oh=Yl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function nh(t){let{message:e}=t,[o,n]=_b(!1);return rn.createElement(Lb,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&rn.createElement(Db,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},rn.createElement(th,{rotated:o},rn.createElement(Pb,{size:12,color:"gray"}))),footer:rn.createElement(oh,{open:o},rn.createElement(Ki,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(nh,"FailedAlert");import{i18n as rh}from"@lingui/core";import{Alert as Zl,Button as ih}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Jl}from"rango-types";import Rn from"react";function ah(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Rn.createElement(Zl,{type:"warning",title:n.shortMessage,action:Rn.createElement(ih,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Jl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},rh.t("Change"))}):r===Jl.WaitingForConnectingWallet?Rn.createElement(Zl,{type:"warning",title:n.shortMessage,action:Rn.createElement(ih,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Jl.WaitingForConnectingWallet)}},rh.t("Connect"))}):Rn.createElement(Zl,{type:"warning",title:n.shortMessage})}i(ah,"WarningAlert");function Rl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=Sn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return oo.createElement(eh,null,a.explorerUrl?.map((m,h,f)=>{let d=h+m.url,g=h===f.length-1,C=(g&&u||p)&&!c,S=g&&a.status==="failed";return oo.createElement(Ub,{key:d},oo.createElement(sh,{type:g&&(C&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:$b.t("View transaction"),action:m.url&&oo.createElement(Fb,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},oo.createElement(Ob,{size:12}))}))}),c&&oo.createElement(sh,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(ah,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(nh,{message:r}))}i(Rl,"SwapDetailsAlerts");var lh=2e3;var ph=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:lt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:lt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:an(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(p=>({from:{chain:{displayName:lt(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:lt(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:an(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:zb.createElement(Rl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function ch(t){if(Sn(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(ch,"getStepState");function ep(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Rb(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=O.use.retry(),h=le.use.isActiveTab(),f=tE(),[d,g]=Jb(lh),C=eE(null),[S,T]=gh(null),[v,k]=gh(null),w=i(()=>{r(),T(null)},"onCancel"),I=ve.use.getNotifications(),L=ve.use.removeNotification(),b=I(),E=qb(e),x=E?.networkStatus;fh(()=>{b.find($e=>$e.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(k(e.status),L(e.requestId)):v&&k(null))},[e.status,e.requestId]),fh(()=>{M?T(ji.WaitingForNetworkChange):x===ji.WaitingForConnectingWallet||x===ji.NetworkChanged?T(x):T(null)},[x]);let W=su(e),D=E?Qb(e,E):null,A=E?Hb(e,E):null,X=_g(e),se=lu(e),J=i(re=>!!l(re)?.mobileWallet,"isMobileWallet"),M=x===ji.WaitingForNetworkChange&&!!D&&!!A?.walletType&&(J(A.walletType)||a(A.walletType,D)),K=M?s.bind(null,A.walletType,[{namespace:"DISCOVER_MODE",network:D}]):void 0,pe=au(e,E),Q=ph({swap:e,switchNetwork:K,showNetworkModal:x,setNetworkModal:T,message:pe,blockchains:p,swappers:u}),me=Q.length,[Ge,st]=[e.steps[0],e.steps[me-1]],de=st.outputAmount||st.expectedOutputAmountHumanReadable,Ve=e.steps.reduce((re,$e)=>re+parseFloat($e.feeInUsd||""),0),V=e.steps.find(re=>re.diagnosisUrl)?.diagnosisUrl,Ke=B(parseFloat(de||"0")*(st.toUsdPrice||0),4,4),ft=B(parseFloat(e.inputAmount)*(Ge.fromUsdPrice||0),4,4),_=de?new dh(de).multipliedBy(st.toUsdPrice||0).toString():"",G=new dh(e.inputAmount).multipliedBy(Ge.fromUsdPrice||0).toString(),q=ct(ft,Ke),ee=pe.detailedMessage.content||pe.shortMessage,ne=e.status==="success"?at.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:B(de,6,6),token:Q[me-1].to.token.displayName,conciseAddress:gr(e.wallets[Q[me-1].to.chain.displayName]?.address||""),chain:Q[me-1].to.chain.displayName}}):j.createElement(Rg,null,j.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},ee?"":at.t("Transaction was not sent."),W?`${at.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:W.outputAmount,symbol:W.symbol,blockchain:W.blockchain}})}`:""),ee&&j.createElement(Ki,{align:"center",variant:"body",size:"medium",color:"neutral700"},j.createElement("b",null,"Reason:")," ",ee));return j.createElement(oe,{header:{title:at.t("Swap Details"),onCancel:e.status==="running"?()=>T("cancel"):void 0,suffix:e.status!=="running"&&j.createElement(Gt,null,j.createElement(uh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>T("delete")},j.createElement(Io,{size:"medium",variant:"label",color:"error"},at.t("Delete"))))},footer:se&&!v&&j.createElement(uh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let re=_r(e,p,c);m(re),setTimeout(()=>{f("../../")},0)}},at.t("Try again"))},j.createElement(ie,{compact:!0,view:!0},j.createElement(Gi,null,j.createElement("div",{className:nn()},j.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${at.t("Request ID")}`),j.createElement("div",{className:Vi()},j.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),j.createElement(mh,{container:N(),content:d?at.t("Copied To Clipboard"):at.t("Copy Request ID"),open:d||void 0,side:"bottom",alignOffset:-16,align:"end"},j.createElement(jb,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:g.bind(null,o||"")},d?j.createElement(Kb,{size:16,color:"secondary"}):j.createElement(Gb,{size:16,color:"gray"}))),j.createElement(Jg,{target:"_blank",href:`${Cp}/swap/${o}`},j.createElement(mh,{container:N(),content:at.t("View on Rango Explorer"),side:"bottom"},j.createElement(Yb,{size:20}))))),j.createElement("div",{className:nn()},j.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?at.t("Finished at"):at.t("Created at")),j.createElement(Io,{variant:"label",size:"small",color:"neutral700"},X))),j.createElement("div",{className:Yg()},j.createElement(Xb,{fee:B(String(Ve),2,2),time:pn(pr(e.steps)),steps:me}),j.createElement(Nn,{from:{price:{value:B(e.inputAmount,6,6),usdValue:ft,realUsdValue:G,realValue:e.inputAmount},token:{displayName:Q[0].from.token.displayName,image:Q[0].from.token.image},chain:{image:Q[0].from.chain.image,displayName:Q[0].from.chain.displayName}},to:{price:{value:B(de,6,6),usdValue:Ke,realUsdValue:_,realValue:de||""},token:{displayName:Q[me-1].to.token.displayName,image:Q[me-1].to.token.image},chain:{image:Q[me-1].to.chain.image,displayName:Q[me-1].to.chain.displayName}},percentageChange:B(q,2,2),warningLevel:Pt(q??0)})),j.createElement("div",{className:Zg()},j.createElement(Io,{variant:"title",size:"small"},at.t("Swaps steps"))),j.createElement(Vb,{size:8}),j.createElement(Kg,{ref:C},Q.map((re,$e)=>{let or=$e,no=ch(e.steps[$e]),qh=no==="error"||no==="in-progress"||no==="warning"||no==="completed"&&$e===Q.length-1;return j.createElement(Zb,{key:or,step:re,type:"swap-progress",ref:C,state:no,hasSeparator:$e!==0,tabIndex:or,isFocused:qh,tooltipContainer:N()})}))),j.createElement(Vl,{state:S,onClose:()=>T(null),onCancel:w,onDelete:n,message:pe.detailedMessage.content,currentStepWallet:A,walletButtonDisabled:!h}),j.createElement(Xl,{open:!!v,diagnosisUrl:V,onClose:()=>k(null),status:e.status==="success"?"success":"failed",priceValue:B(de,6,6),usdValue:Ke,realUsdValue:_,realValue:de||"",percentageChange:B(q,2,2),token:{displayName:Q[me-1].to.token.displayName,image:Q[me-1].to.token.image},chain:{image:Q[me-1].to.chain.image},description:ne}))}i(ep,"SwapDetails");import{i18n as Yi}from"@lingui/core";import{Divider as Sh,NotFound as aE,Skeleton as tr,Typography as Zi}from"@rango-dev/ui";import Se from"react";import{i18n as oE}from"@lingui/core";import{Divider as nE,Skeleton as rE,Typography as iE}from"@rango-dev/ui";import Te from"react";import{css as vt,styled as tp}from"@rango-dev/ui";var hh=tp("div",{width:"100%",height:"100%",padding:"$10 $20"}),er=tp("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Xi=tp("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),h4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),y4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),S4=vt({paddingTop:"$15",display:"flex"}),C4=vt({padding:"$15 $0"}),T4=vt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),k4=vt({paddingBottom:"$10"}),v4=vt({display:"flex",justifyContent:"start",alignItems:"center"}),w4=vt({paddingTop:"$5",display:"flex",alignItems:"center"}),x4=vt({display:"flex",alignItems:"center"}),b4=vt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),yh=vt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function op(){return Te.createElement(hh,null,Te.createElement(Mn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(iE,{variant:"title",size:"small"},oE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(er,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:yh()},Te.createElement(nE,{direction:"horizontal",size:20}),Te.createElement(rE,{height:22,variant:"rectangular"}))),Te.createElement(Xi,null),Te.createElement(er,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Xi,null),Te.createElement(er,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Xi,null),Te.createElement(er,null,Te.createElement(Nt,{separator:!1}))))}i(op,"LoadingSwapDetails");function Ch(t){let{requestId:e,showSkeleton:o}=t;return Se.createElement(oe,{header:{title:Yi.t("Swap Details"),suffix:Se.createElement(Gt,null)}},o&&Se.createElement(Vg,null,Se.createElement(Gi,null,Se.createElement("div",{className:nn()},Se.createElement(Zi,{variant:"label",size:"large",color:"neutral700"},`${Yi.t("Request ID")}`),Se.createElement("div",{className:Vi()},Se.createElement(Zi,{variant:"label",size:"small",color:"neutral700"},Se.createElement(tr,{width:60,height:10,variant:"rounded"})),Se.createElement(Sh,{direction:"horizontal",size:4}),Se.createElement(tr,{width:16,height:16,variant:"rectangular"}),Se.createElement(Sh,{direction:"horizontal",size:4}),Se.createElement(tr,{width:16,height:16,variant:"rectangular"}))),Se.createElement("div",{className:nn()},Se.createElement(Zi,{className:Xg(),variant:"label",size:"large",color:"neutral700"},Se.createElement(tr,{width:60,height:10,variant:"rounded"})),Se.createElement(Zi,{variant:"label",size:"small",color:"neutral700"},Se.createElement(tr,{width:60,height:10,variant:"rounded"})))),Se.createElement(op,null)),!o&&Se.createElement(jg,null,Se.createElement(aE,{title:Yi.t("Not found"),description:Yi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(Ch,"SwapDetailsPlaceholder");function Th(){let{manager:t,state:e}=pE(),o=!e.loadedFromPersistor,n=ut(t),{requestId:r}=uE(),a=Ye(),{fetchStatus:s}=y();if(!r)return np.createElement(cE,{containerStyles:{margin:"20px"},type:"error",title:sE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:h})=>h.requestId===r):void 0,u=i(()=>{if(p?.id){let h=t?.get(p.id);h&&lE(h)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(h){console.log(h)}},"onDelete"),m=p?.swap;return!m||l?np.createElement(Ch,{requestId:r,showSkeleton:l}):np.createElement(ep,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(Th,"SwapDetailsPage");import{i18n as kh}from"@lingui/core";import{Divider as mE,getCategoriesCount as dE,SelectableCategoryList as fE,styled as wh,Typography as gE,Wallet as hE}from"@rango-dev/ui";import Bt,{useState as vh}from"react";var yE=wh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),SE=wh(ie,{textAlign:"center"});function xh(){let{fetchStatus:t}=y(),[e,o]=vh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=vh(),l=le.use.isActiveTab(),{list:p}=gt(),u=Qp(p,n),m=dE(u)!==1,h=qp(p,e),f=i(d=>{Wp(p,r.multiWallets)||s(d)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:kh.t("Connect Wallets")}},Bt.createElement(SE,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(fE,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(mE,{size:24})),Bt.createElement(gE,{variant:"title",size:"xmedium",align:"center"},kh.t("Choose a wallet to connect.")),Bt.createElement(yE,null,h.map((d,g)=>{let C=`wallet-${g}-${d.type}`;return Bt.createElement(hE,{key:C,...d,container:N(),onClick:()=>f(d),isLoading:t==="loading",disabled:!l})}),Bt.createElement(uo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(xh,"WalletsPage");function bh(){return Su(),qa(),CE([{path:$.home,element:Le.createElement(tg,null)},{path:$.routes,element:Le.createElement(ag,null)},{path:$.fromSwap,children:[{index:!0,element:Le.createElement($l,{type:"source"})},{path:$.blockchains,element:Le.createElement(Di,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:Le.createElement($l,{type:"destination"})},{path:$.blockchains,element:Le.createElement(Di,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:Le.createElement(Pg,null)},{path:$.languages,element:Le.createElement(ng,null)},{path:$.exchanges,element:Le.createElement(Nl,{sourceType:"Exchanges"})},{path:$.bridges,element:Le.createElement(Nl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:Le.createElement(uf,null)},{path:$.addCustomTokens,children:[{index:!0,element:Le.createElement(Ru,null)},{path:$.blockchains,element:Le.createElement(Di,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:Le.createElement(Bf,null)},{path:$.swapDetails,element:Le.createElement(Th,null)}]},{path:$.wallets,element:Le.createElement(xh,null)},{path:$.confirmSwap,element:Le.createElement(Yd,null)}])}i(bh,"AppRoutes");import{useQueueManager as AE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as NE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as WE}from"rango-sdk";import{useContext as BE,useEffect as Mh,useState as Lh}from"react";import{globalCss as TE}from"@rango-dev/ui";var Eh=i(()=>TE({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");function Ih(){let{setWatermark:t}=le();return{fetchApiConfig:i(async()=>{let o=await fetch(`${Lt("BASE_URL")}/meta/dapp/config?apiKey=${Lt("API_KEY")}`);if(!o.ok)throw new Error(`Request failed with status: ${o.status} `);let n=await o.json();t(n.config.watermark)},"fetchApiConfig")}}i(Ih,"useFetchApiConfig");import{useWallets as kE}from"@rango-dev/wallets-react";import{useEffect as vE,useRef as wE}from"react";function Ah(){let{connect:t,state:e}=kE(),o=wE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);vE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Ah,"useForceAutoConnect");import{isApprovalTX as xE,RouteEventType as Nh,StepEventType as Wh,StepExecutionEventStatus as bE,WidgetEvents as Ji}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Bh}from"react";function rp(){let t=ve.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Bh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===Wh.TX_EXECUTION&&a.status===bE.TX_SENT&&!xE(s)||a.type===Wh.SUCCEEDED){let u=e.find(m=>m.chain===s?.fromBlockchain),c=s?.fromBlockchain!==s?.toBlockchain&&e.find(m=>m.chain===s?.toBlockchain);u&&o([u]),c&&o([c])}t(a,l)},"handleStepEvent");return ge.on(Ji.StepEvent,n),()=>ge.off(Ji.StepEvent,n)},[ge,e]),Bh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===Nh.FAILED||a.type===Nh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return ge.on(Ji.RouteEvent,n),()=>ge.off(Ji.RouteEvent,n)},[ge])}i(rp,"useSubscribeToWidgetEvents");import{useManager as EE}from"@rango-dev/queue-manager-react";import{useEffect as IE}from"react";function ip(){let{isSynced:t,syncNotifications:e}=ve(),{manager:o,state:n}=EE();IE(()=>{ve.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ut(o))},[ve.persist.hasHydrated(),n.loadedFromPersistor,t])}i(ip,"useSyncNotifications");function ap(){Ah(),Eh(),rp(),ip();let t=y().blockchains(),{canSwitchNetworkTo:e}=ei(),[o,n]=Lh(""),[r,a]=Lh(),s=BE(Nr),l=t.filter(WE),{fetchApiConfig:p}=Ih();Mh(()=>()=>yu(),[]),AE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Mh(()=>(so.init(),ve.persist.hasHydrated()||ve.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===NE(o)?.[0]&&n("")}),p().catch(console.log),so.destroy),[])}i(ap,"useBootstrap");import{styled as ME}from"@rango-dev/ui";var Ph=ME("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Ri(){ap();let{config:t}=y(),{activeTheme:e}=Go(t?.theme||{}),{activeLanguage:o}=Rt();return sp.createElement(LE,{language:o},sp.createElement(Ph,{id:"swap-container",className:e()},sp.createElement(bh,null)))}i(Ri,"Main");import{setSolanaSignerConfig as RE}from"@rango-dev/signer-solana";import pp,{useEffect as Uh,useMemo as eI}from"react";import{useState as PE}from"react";var DE=i(()=>{let[t,e]=PE(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=Np(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Dh=DE;import{checkWaitingForNetworkChange as _E,makeQueueDefinition as $E}from"@rango-dev/queue-manager-rango-preset";import{Provider as FE}from"@rango-dev/queue-manager-react";import{useWallets as OE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as UE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as zE}from"rango-types";import QE,{useMemo as qE}from"react";function HE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=OE(),l=qE(()=>$E({API_KEY:t.apiKey||Lt("API_KEY"),BASE_URL:Lt("BASE_URL"),emitter:{emit:ge.emit}}),[t.apiKey]),{blockchains:p,connectedWallets:u}=y(),c=p(),m={blockchains:u.map(k=>({accounts:[k],name:k.chain}))},h=i(async(k,w)=>a(k,w)?await r(k,[{namespace:"DISCOVER_MODE",network:w}]):void 0,"switchNetwork"),f=i(k=>!!s(k).mobileWallet,"isMobileWallet"),d=c.filter(k=>k.enabled).reduce((k,w)=>(k[w.name]=w,k),{}),g=c.filter(zE),C=i(k=>{let{supportedChains:w}=s(k);return mr(w)},"getSupportedChainNames"),S=e(),T={meta:{blockchains:d,evmBasedChains:g,evmNetworkChainInfo:UE(g),getSupportedChainNames:C},getSigners:o,wallets:m,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:f},v=le.use.isActiveTab();return QE.createElement(FE,{queuesDefs:[l],context:T,onPersistedDataLoaded:k=>{_E(k)},isPaused:!v},t.children)}i(HE,"QueueManager");var _h=HE;import{useManager as XE}from"@rango-dev/queue-manager-react";import YE,{createContext as ZE,useContext as JE}from"react";function $h(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:h,toToken:f,requestAmount:d}=u,g={blockchains:e,tokens:o};if(c!==void 0){let C=e.find(S=>S.name===c)??null;n(C)}if(m!==void 0){let C=m?t(m)??null:null;r({meta:g,token:C})}if(h!==void 0){let C=e.find(S=>S.name===h)??null;a(C)}if(f!==void 0){let C=f?t(f)??null:null;s({meta:g,token:C})}d!==void 0&&l(d)},"updateQuoteInputs")}i($h,"useUpdateQuoteInputs");import{cancelSwap as GE,getCurrentBlockchainOfOrNull as VE,getCurrentStep as KE,getRelatedWalletOrNull as jE}from"@rango-dev/queue-manager-rango-preset";var ea=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return ut(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=_r(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&GE(o)}getCurrentStepInfo(e){let o=KE(e);return{step:o,wallet:o?jE(e,o):null,network:o?VE(e,o):null}}};var Fh=ZE(void 0);function lp(t){let{manager:e}=XE(),o=le.use.isActiveTab(),n=O.use.retry(),{findToken:r,connectedWallets:a,getBalances:s,fetchBalances:l}=y(),p=new ea(e,{retrySwap:n,findToken:r}),{fetchingWallets:u}=y(),c=_p(s()),m=y().blockchains(),h=y().tokens(),f=y().swappers(),d=y().fetchStatus,g=Rt().resetLanguage,C=ve().getNotifications(),S=ve().clearNotifications,T=$h(),{fromBlockchain:v,toBlockchain:k,fromToken:w,toToken:I,inputAmount:L}=O(),b={isActiveTab:o,setCurrentTabAsActive:so.forceClaim,history:p,wallets:{isLoading:u,details:a,totalBalance:c,refetch:async E=>l(E)},meta:{blockchains:m,tokens:h,swappers:f,loadingStatus:d,findToken:r},resetLanguage:g,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:v?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:k?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:L},updateQuoteInputs:T}};return YE.createElement(Fh.Provider,{value:b},t.children)}i(lp,"WidgetInfo");function Oh(){let t=JE(Fh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Oh,"useWidget");function ta(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Dh();return Uh(()=>{n&&r(n)},[n]),eI(()=>{Hp({API_KEY:o?.apiKey||ar,BASE_URL:o?.apiUrl||Sp})},[o.apiKey,o.apiUrl]),Uh(()=>{t.config?.signers?.customSolanaRPC&&RE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),pp.createElement(Wr,{config:o,onUpdateState:e},pp.createElement(_h,{apiKey:o.apiKey},pp.createElement(lp,null,t.children)))}i(ta,"WidgetProvider");function zh(t){let e=t.config?.externalWallets;return oa.createElement(zc,null,e?oa.createElement(Ri,null):oa.createElement(ta,{config:t.config??aa},oa.createElement(Ri,null)))}i(zh,"Widget");function Qh(){let{on:t,off:e}=ge;return{on:t,off:e}}i(Qh,"useWidgetEvents");var Mj={DerivationPath:gn,Namespaces:fn,isOnDerivationPath:yn,isOnNamespace:hn};export{rj as EventSeverity,Lo as MainEvents,fj as Networks,yj as PendingSwapNetworkStatus,ya as QuoteEventTypes,ij as RouteEventType,sa as SUPPORTED_FONTS,Mj as StatefulConnect,aj as StepEventType,sj as StepExecutionBlockedEventStatus,lj as StepExecutionEventStatus,Pe as UI_ID,Ca as UiEventTypes,Sa as WalletEventTypes,mj as WalletEvents,gj as WalletTypes,zh as Widget,Lo as WidgetEvents,ta as WidgetProvider,Wr as WidgetWallets,ts as customizedThemeTokens,cj as readAccountAddress,Ht as useStatefulConnect,gt as useWalletList,ei as useWallets,Oh as useWidget,Qh as useWidgetEvents,Gy as widgetEventEmitter};
1
+ var qh=Object.defineProperty;var i=(t,e)=>qh(t,"name",{value:e,configurable:!0});import{EventSeverity as ej,RouteEventType as tj,StepEventType as oj,StepExecutionBlockedEventStatus as nj,StepExecutionEventStatus as rj}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as aj}from"@rango-dev/wallets-core/legacy";import{useWallets as Jr,Events as lj}from"@rango-dev/wallets-react";import{Networks as cj,WalletTypes as uj}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as dj}from"rango-types";import{Divider as $S}from"@rango-dev/ui";import co,{useEffect as FS,useRef as OS,useState as Dc}from"react";import{WalletState as Hh}from"@rango-dev/ui";import{useWallets as Gh}from"@rango-dev/wallets-react";import{useReducer as Vh}from"react";function cp(t){return!!t.derivationPath}i(cp,"isStateOnDerivationPathStep");function up(t){return!!t.namespace}i(up,"isStateOnNamespace");var nr={status:"init",namespace:null,derivationPath:null};function mp(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return nr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:nr;default:throw new Error("Action hasn't been defined.")}}i(mp,"reducer");function Ht(){let{state:t,disconnect:e,connect:o}=Gh(),[n,r]=Vh(mp,nr),a=i(async(c,m,h)=>{r({type:"reset"});try{let d=m?.map(f=>({...f,network:void 0}));return await o(c,d),{status:"connected"}}catch(d){let f=d?.message?`Error: ${d.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:d})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Hh.DISCONNECTED){if(!!c.isHub&&c.properties?.find(T=>T.name==="detached")&&c.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:c}}),{status:"namespace"};if(!c.needsNamespace)return await a(c.type,void 0,m);let f=c.needsNamespace.data.length>1,g=c.needsDerivationPath;if(f)return r({type:"needsNamespace",payload:{targetWallet:c}}),{status:"namespace"};if(g){let C=c.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:C.value}}),{status:"derivation-path"}}return await a(c.type,c.needsNamespace?.data.map(C=>({namespace:C.value})),m)}return m?.disconnectIfConnected?(await u(c.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(c,m)=>{let h=c.needsNamespace?.selection==="single",d=c.needsDerivationPath,f=m[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&d)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:f}}),{status:"derivation-path"};if(!up(n))throw new Error("Something went wrong on handling namespace. Please retry.");let g=n.namespace.targetWallet.type,C=m.map(S=>({namespace:S}));return await a(g,C)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!cp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,d)},"handleDerivationPath"),u=i(async c=>{let m=t(c);return m.connected||m.connecting?(await e(c),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:p,getState:()=>n,resetState:c=>{r(c==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Ht,"useStatefulConnect");import{WalletState as ka}from"@rango-dev/ui";import{useWallets as eS}from"@rango-dev/wallets-react";import{detectMobileScreens as tS,KEPLR_COMPATIBLE_WALLETS as oS,WalletTypes as Po}from"@rango-dev/wallets-shared";import{useCallback as nS,useEffect as rS}from"react";import jy,{createContext as Xy,useContext as Yy,useEffect as Zy,useRef as Jy}from"react";import{create as Vy}from"zustand";import{persist as Ky}from"zustand/middleware";var oa=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},Ao=new oa;function rr(t,e){return e.find(o=>o.name===t)?.displayName}i(rr,"getBlockchainDisplayNameFor");function lt(t,e){return e.find(o=>o.name===t)?.shortName}i(lt,"getBlockchainShortNameFor");function dp(t,e){return e.find(o=>o.name===t)?.logo}i(dp,"getBlockchainImage");function an(t,e){return e.find(o=>o.id===t)?.title}i(an,"getSwapperDisplayName");function sn(t,e){return e.find(o=>o.name===t)??null}i(sn,"findBlockchain");function na(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(na,"isTokenNative");function pt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(pt,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");function ln(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=pt(p));let u=o.tokensMapByTokenHash.get(p);u&&(n[p]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(p=>{l.has(p)||a(o.tokensMapByBlockchainName[p])})}return s.forEach(l=>{let p=r[l];if(!p&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}p&&(p.isExcluded?(a(o.tokensMapByBlockchainName[l]),p.tokens.forEach(u=>{let c=pt(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(ln,"matchTokensFromConfigWithMeta");function ir(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(ir,"getSupportedBlockchainsFromConfig");var ra={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"},features:{experimentalWallet:"enabled"}},Kh={clientUrl:void 0},jh={liquiditySources:void 0},fp=i((t,e,o)=>({config:{...ra,...t},iframe:Kh,campaignMode:jh,getLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?r.liquiditySources:n.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:n,campaignMode:r}=o();return r.liquiditySources?.length?[]:n},excludeLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?!1:!!n.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:n}=o();return!!n.liquiditySources?.length},updateConfig:n=>{let r=o().config,{_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s}=o(),l=ln({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=ln({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});Ao.set("supportedSourceTokens",l),Ao.set("supportedDestinationTokens",p),e({config:{...r,...n}})},updateCampaignMode:(n,r)=>{let a=o().campaignMode;e({campaignMode:{...a,[n]:r}})},updateIframe:(n,r)=>{let a=o().iframe;e({iframe:{...a,[n]:r}})}}),"createConfigSlice");import{TransactionType as gp}from"rango-types";var hp=[gp.EVM,gp.SOLANA];import{RangoClient as py}from"rango-sdk";import{UI_ID as Xh}from"@rango-dev/ui";var ar="c6381a79-2817-4602-83bf-6a641a409e32",yp="https://api.rango.exchange",Sp="https://explorer.rango.exchange",Pe={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Xh};import{BlockchainCategories as oy,WalletState as xt}from"@rango-dev/ui";import{legacyReadAccountAddress as ny}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as ry,getCosmosExperimentalChainInfo as iy,isEvmAddress as ay,KEPLR_COMPATIBLE_WALLETS as eA,Networks as Bp}from"@rango-dev/wallets-shared";import io from"bignumber.js";import{isCosmosBlockchain as sy}from"rango-types";import Yh from"bignumber.js";var Ce=new Yh(0);import{WalletTypes as Zh}from"@rango-dev/wallets-shared";var Cp=[Zh.LEAP];import{BlockchainCategories as aa,WalletState as ty}from"@rango-dev/ui";import{TransactionType as sr}from"rango-sdk";var Tp="Roboto",ia=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function Wo(t){return Array.from(new Set(t))}i(Wo,"removeDuplicateFrom");function pa(t,e){return t.length===e.length&&t.every((o,n)=>o===e[n])}i(pa,"areEqual");function Ep(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Ep,"debounce");function Re(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Re,"containsText");function wp(t,e){return t.toLowerCase()===e.toLowerCase()}i(wp,"exactText");function xp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(xp,"startWithText");var W=i(()=>document.getElementById(Pe.SWAP_BOX_ID),"getContainer"),ro=i(()=>document.getElementById(Pe.EXPANDED_BOX_ID),"getExpanded");function bp(t,e,o){let n=!!e&&wp(e,t),r=!!o&&wp(o,t);return n!==r?n?-1:1:0}i(bp,"compareExactMatchText");function sa(t,e,o){let n=!!e&&Re(e,t),r=!!o&&Re(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(sa,"compareContainsText");function la(t,e,o){let n=!!e&&xp(e,t),r=!!o&&xp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(la,"compareStartWithText");function Ip(t,e,o){if(!o)return 0;let n=bp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=bp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=la(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=sa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=la(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=sa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=la(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=sa(o,t.address,e.address);if(r!==0)return r}return 0}i(Ip,"compareWithSearchFor");var lr=i((t,e)=>{switch(e){case aa.ALL:return!0;case aa.UTXO:return t===sr.TRANSFER;case aa.OTHER:return t!==sr.TRANSFER&&t!==sr.COSMOS&&t!==sr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Ap=i(t=>ia.find(o=>o.value===t)?.url,"getFontUrlByName");function Np(t,e){let o=!!t.find(n=>n.state===ty.CONNECTED);return e===!1&&o}i(Np,"isSingleWalletActive");import{BigNumber as Wp}from"bignumber.js";var pn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),L=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Wp(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Wp(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var pr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),cn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function un(t){switch(!0){case t.connected:return xt.CONNECTED;case t.connecting:return xt.CONNECTING;case!t.installed:return xt.NOT_INSTALLED;default:return xt.DISCONNECTED}}i(un,"mapStatusToWalletState");function Mp(t,e,o,n){return o.filter(r=>!Cp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,needsNamespace:u,supportedChains:c,needsDerivationPath:m,properties:h,isHub:d}=e(r),f=Wo(c.map(C=>C.type)),g=un(t(r));return{title:a,image:s,link:ry(l),state:g,type:r,showOnMobile:p,needsNamespace:u,blockchainTypes:f,needsDerivationPath:m,properties:h,isHub:d}})}i(Mp,"mapWalletTypesToWalletInfo");function mr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(mr,"walletAndSupportedChainsNames");function ca(t,e,o,n,r){let a=[];function s(p,u){if(!!!a.find(m=>m.chain===p)){let m={address:u,chain:p,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(p=>{let{address:u,network:c}=ny(p),m=l.length>0,h=l.includes(c),d=c===Bp.Unknown;if(m&&!h&&!d)return;let g=c===Bp.Unknown&&ay(u);if(d&&!g)return;o.includes(c)||g?r?s(c,u.toLowerCase()):l.filter(T=>o.includes(T)).forEach(T=>{s(T,u.toLowerCase())}):s(c,u)}),a}i(ca,"prepareAccountsForWalletStore");function ao(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,h=u.to.blockchain,d=a===o.swaps.length-1,f=c===p.length-1;(!d&&!f||d&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(ao,"getQuoteWallets");function Lp(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Lp,"isAccountAndWalletMatched");var Pp=i(t=>{let e=Object.values(t).reduce((o,n)=>n.usdValue?o.plus(n.usdValue):o,new io(Ce));return ly(e.toString())},"calculateWalletUsdValue");function ly(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(ly,"numberWithThousandSeparator");var dr=i((t,e)=>{let o=iy(Object.entries(t).map(([,n])=>n).filter(sy));return o&&o[e]?.experimental},"isExperimentalChain");function fr(t){if(!t)return null;let e=new io(t.amount).shiftedBy(-t.decimals).toFixed(),o=t.usdValue?new io(t.usdValue).shiftedBy(-t.decimals).toFixed():null,n=L(e,8,8),r=o?L(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(fr,"formatBalance");function Dp(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new io(t.usdValue).shiftedBy(-t.decimals):Ce,n=e&&e.usdValue?new io(e.usdValue).shiftedBy(-e.decimals):Ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new io(t.amount).shiftedBy(-t.decimals):Ce,n=e&&e.amount?new io(e.amount).shiftedBy(-e.decimals):Ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Dp,"compareTokenBalance");function Mt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Mt,"areTokensEqual");function _p(t){return t.sort((e,o)=>+(o.state===xt.CONNECTED)-+(e.state===xt.CONNECTED)||+(o.state===xt.DISCONNECTED||o.state===xt.CONNECTING)-+(e.state===xt.DISCONNECTED||e.state===xt.CONNECTING))}i(_p,"sortWalletsBasedOnConnectionState");function gr(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(gr,"getConciseAddress");function $p({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i($p,"getAddress");var Fp=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Op(t){return t.map(e=>e.state).join("-")}i(Op,"hashWalletsState");function Up(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Up,"filterBlockchainsByWalletTypes");function zp(t,e){return e===oy.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(lr(n,e))return!0;return!1})}i(zp,"filterWalletsByCategory");var ua={API_KEY:ar};function Lt(t){return ua[t]||""}i(Lt,"getConfig");function Qp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ua=e,ua}i(Qp,"initConfig");var qp=20,Hp=25,ma="theme-widget",da=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Mt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Mt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),fa=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Gp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var hr,bt=i(()=>hr||(hr=new py(Lt("API_KEY"),Lt("BASE_URL")),hr),"httpService");function yr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Wo(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(p=>p===s.swapperGroup)),l&&s.types.map(p=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:p,selected:!e.includes(s.swapperGroup)})})}}),n}i(yr,"getUniqueSwappersGroups");function Vp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Vp,"sortLiquiditySourcesByGroupTitle");function je(t,e){return e?.[t]==="hidden"}i(je,"isFeatureHidden");function Kp(t,e){return e?.[t]==="enabled"}i(Kp,"isFeatureEnabled");function Bo(t,e){return e?.[t]==="enabled"}i(Bo,"isRoutingEnabled");var jp=i((t,e,o)=>je("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Xp=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let p=ir({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>hp.includes(c.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(p=>!(s.length>0&&!s.includes(p.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),p=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",c=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=Ao.get(c);m?.length||(m=ln({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Ao.set(c,m)),m=jp(m,s,a.features);let h=e().blockchains({type:o.type});return m.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!h.some(g=>g.name===f.blockchain)?!1:o.searchFor?!!(Re(f.symbol,o.searchFor)||Re(f.address||"",o.searchFor)||Re(f.name||"",o.searchFor)):!0).sort((f,g)=>{let C=e().isTokenPinned(f,o.type),S=e().isTokenPinned(g,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let N=o.getBalanceFor(f),M=o.getBalanceFor(g),x=Dp(N,M);if(x!==0)return x}let T=p.get(f.blockchain),k=p.get(g.blockchain),v=na(f,T),w=na(g,k);if(v!==w)return v?-1:1;if(f.isPopular!==g.isPopular)return f.isPopular?-1:1;if(o.searchFor){let N=Ip(f,g,o.searchFor);if(N)return N}return f.isSecondaryCoin!==g.isSecondaryCoin?f.isSecondaryCoin?1:-1:T&&k?T.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=pt(o),s=n.get(a);return s||(s=r.find(l=>pt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Mt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let c=a?.includes(u.swapperGroup);return s||!a||a.length===0?!c:c}).sort(Vp)},fetch:async()=>{try{let{routing:o}=e().config,n=Bo("enableCentralizedSwappers",o),r=await bt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},p=[],u=r.popularTokens,c=r.swappers.filter(d=>d.enabled),m=new Set;r.tokens.forEach(d=>{m.add(d.blockchain),p.push(d)}),r.blockchains.sort((d,f)=>d.sort-f.sort).forEach(d=>{d.enabled&&m.has(d.name)&&a.set(d.name,d)}),p.forEach(d=>{let f=pt(d);l[d.blockchain]||(l[d.blockchain]=[]),s.set(f,d),l[d.blockchain].push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:u,_swappers:c})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as cy,Catalonia as uy,Chinese as Yp,Denmark as my,English as dy,Finland as fy,French as gy,German as hy,Greece as yy,Hungary as Sy,India as Cy,Indonesian as Ty,Italian as ky,Japanese as vy,Korea as wy,Lithuania as xy,Malay as by,Netherlands as Ey,Pakistan as Iy,Philippines as Ay,Poland as Ny,Portuguese as Wy,Russian as By,SaudiArabia as My,Serbia as Ly,Slovakia as Py,SouthAfrica as Dy,Spanish as _y,Swahili as $y,Swedish as Fy,Thai as Oy,Turkish as Uy,Ukrainian as zy,Vietnamese as Qy}from"@rango-dev/ui";var Zp=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:Dy},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:My},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:cy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:uy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Yp},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Yp},{title:"Danish",label:"Dansk",local:"da",SVGFlag:my},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:Ey},{title:"English",label:"English",local:"en",SVGFlag:dy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:Ay},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:fy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:gy},{title:"German",label:"Deutsch",local:"de",SVGFlag:hy},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:yy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:Cy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:Sy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:Ty},{title:"Italian",label:"Italiana",local:"it",SVGFlag:ky},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:vy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:wy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:xy},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:by},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Ny},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Wy},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:By},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Ly},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Py},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:_y},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:$y},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Fy},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:Oy},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Uy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:zy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:Iy},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Qy}],Mo="en";var Jp=[.5,1,3],Rp=1,ec=5,tc=100,oc=0;var nc=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Rp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let p=s===o,u=l<=9;return p&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Wo(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=je("theme",n),s=je("language",n),l=je("liquiditySource",n),p=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...p&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Mo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Mo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=ir({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import lc from"bignumber.js";import qy from"mitt";var ge=qy(),Hy={on:ge.on,off:ge.off};import{WidgetEvents as rc}from"@rango-dev/queue-manager-rango-preset";var ha=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ha||{}),ya=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ya||{}),Sa=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Sa||{}),Lo=(a=>(a[a.RouteEvent=rc.RouteEvent]="RouteEvent",a[a.StepEvent=rc.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Lo||{});import Gy from"bignumber.js";function mn(t){return`${t.blockchain}-${t.address}-${t.symbol}`}i(mn,"createAssetKey");function Ca(t,e){return`${mn(e)}-${t}`}i(Ca,"createBalanceKey");function Sr(t){let[e,o,n]=t.split("-");return{address:o,blockchain:e,symbol:n}}i(Sr,"extractAssetFromBalanceKey");function ic(t,e){let o={};return t.balances?.forEach(n=>{let r=Ca(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,p=l?new Gy(l??Ce).multipliedBy(a).toString():"",u={amount:a,decimals:s,usdValue:p};o[r]=u}),o}i(ic,"createBalanceStateForNewAccount");function ac(t,e){for(let o in e){let n=Sr(o),r=mn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(ac,"updateAggregatedBalanceStateForNewAccount");function sc(t,e){let o=Sr(e),n=mn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(sc,"removeBalanceFromAggregatedBalance");var pc=i((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!1}:r)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:o=>{let n=e().connectedWallets,r=o.filter(a=>!n.some(s=>Lp(a,s)));if(r.length>0){let a=r.map(s=>{let l=!n.some(p=>p.chain===s.chain&&p.selected&&p.walletType!==s.walletType);return{address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!1,error:!1}});t(s=>({connectedWallets:[...s.connectedWallets.filter(p=>!a.some(u=>u.walletType===p.walletType&&u.chain===p.chain)),...a]}))}},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async o=>{ge.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(u=>u.walletType===o);e().connectedWallets.forEach(u=>{u.walletType!==o&&(r=r.filter(c=>!(c.chain===u.chain&&c.address===u.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(u=>n.chains?.includes(u.chain)));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(u=>{let c=Sr(u),m=!!r.find(h=>Ca(h.address,{address:c.address,blockchain:h.chain,symbol:c.symbol})===u);m||(a[u]=l[u]),m&&(s=sc(s,u))}),t({_balances:a,_aggregatedBalances:s})},disconnectWallet:o=>{if(e().connectedWallets.find(r=>r.walletType===o)){ge.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),e().removeBalancesForWallet(o);let r=e().connectedWallets.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain),a=e().connectedWallets.filter(s=>s.walletType!==o);r.length>0&&(a=a.map(s=>r.includes(s.chain)?(r=r.filter(l=>l!==s.chain),{...s,selected:!0}):s)),t({connectedWallets:a})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(r);let a=o.map(p=>({address:p.address,blockchain:p.chain})),l=(await bt().getWalletsDetails(a)).wallets;if(l){let{retryOnFailedBalances:p=!0}=n||{};if(p){let m=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));m.length>0&&e().fetchBalances(m,{retryOnFailedBalances:!1})}let u={},c=e()._aggregatedBalances;l.forEach(m=>{if(m.failed)return;let h=ic(m,e);c=ac(c,h),u={...u,...h}}),t(m=>({_balances:{...m._balances,...u},_aggregatedBalances:c})),e().setConnectedWalletRetrievedData(r)}else throw e().setConnectedWalletHasError(r),new Error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=mn(o),a=e()._aggregatedBalances[r]||[];if(a.length===0)return null;if(a.length===1){let p=a[0];return n[p]}let l=n[a[0]];return a.forEach(p=>{let u=n[p],c=new lc(u.amount),m=new lc(l.amount);c.isGreaterThan(m)&&(l=u)}),l}}),"createWalletsSlice");function cc(t){return Vy()(Ky((...e)=>({...pc(...e),...Xp(...e),...nc(...e),...fp(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(cc,"createAppStore");var uc=Xy(null);function y(){let t=Yy(uc);if(Zy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function mc(t){let e=Jy();return e.current||(e.current=cc(t.config)),jy.createElement(uc.Provider,{value:e.current},t.children)}i(mc,"AppStoreProvider");import{allProviders as Ry}from"@rango-dev/provider-all";import{defineVersions as dc,pickVersion as fc,Provider as Ta}from"@rango-dev/wallets-core";function Cr(t,e){let o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0},n=Ry(o);if(t){let r=[];return t.forEach(a=>{if(typeof a=="string"){let s=n.find(l=>{let p=gc(l,e);return p instanceof Ta?p.id===a:p.config.type===a});s&&r.push(s),console.warn(`Couldn't find ${a} provider. Please make sure you are passing the correct name.`)}else a instanceof Ta?r.push(dc().version("1.0.0",a).build()):r.push(dc().version("0.0.0",a).build())}),r}return n}i(Cr,"matchAndGenerateProviders");function gc(t,e){let{experimentalWallet:o="enabled"}=e||{},n=o=="disabled"?"0.0.0":"1.0.0";try{return fc(t,n)[1]}catch{return fc(t,"0.0.0")[1]}}i(gc,"pickProviderVersionWithFallbackToLegacy");function hc(t,e){return Cr(t,e).map(r=>gc(r,e)).map(r=>r instanceof Ta?r.id:r.config.type)}i(hc,"configWalletsToWalletName");var iS=Object.values(Po);function gt(t){let{chain:e}=t||{},{config:o,connectedWallets:n}=y(),{state:r,getWalletInfo:a}=eS(),s=y().blockchains(),{handleDisconnect:l}=Ht(),p=hc(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,tonConnect:o.tonConnect})||iS,u=Mp(r,a,p,e);u=tS()?u.filter(g=>g.showOnMobile!==!1&&r(g.type).installed):u;let c=_p(u),m=i(g=>!n.find(C=>C.walletType===g&&C.chain===e),"isExperimentalChainNotAdded"),h=nS(()=>{let g=u?.filter(C=>C.state===ka.CONNECTING)||[];for(let C of g)l(C.type)},[Op(u)]);rS(()=>()=>{h()},[]);let d=i(g=>{let C=g.find(T=>T.type===Po.DEFAULT);return!C||C.state===ka.NOT_INSTALLED?!1:g.filter(T=>T.state!=ka.NOT_INSTALLED&&![Po.DEFAULT,Po.WALLET_CONNECT_2,Po.LEDGER].includes(T.type)&&a(T.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((g,C,S)=>dr(S,C)&&m(g)&&!oS.includes(g)||g==Po.DEFAULT&&!d(u),"shouldExcludeWallet");return{list:c.filter(g=>!f(g.type,e??"",s)),terminateConnectingWallets:h}}i(gt,"useWalletList");import{Modal as pS}from"@rango-dev/ui";import cS from"react";import{create as lS}from"zustand";var yc="rango-widget";var dn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(yc),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var sS=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),Do=sS;var le=Do(lS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})}}))),so=new dn({onInit:()=>le.setState({tabManagerInitiated:!0}),onClaim:()=>le.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>le.setState({isActiveTab:!1})});function R(t){let{watermark:e}=le();return cS.createElement(pS,{hasWatermark:e==="FULL",...t},t.children)}i(R,"WatermarkedModal");import{i18n as va}from"@lingui/core";import{Button as hS,Checkbox as yS,Divider as SS,Image as Ic,ListItemButton as CS,MessageBox as TS,Radio as kS,RadioRoot as vS}from"@rango-dev/ui";import ke,{useState as wS}from"react";import{css as uS,darkTheme as Cc,IconButton as mS,styled as lo}from"@rango-dev/ui";var Et=lo(mS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Cc} &`]:{backgroundColor:"$neutral"}}}),Tc=lo("div",{position:"absolute",background:"$secondary500",[`.${Cc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Gt=lo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),kc=lo("div",{position:"absolute",width:"14px",height:"14px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"7px",top:"$0",right:"$0",variants:{isSever:{true:{backgroundColor:"$error500"},false:{backgroundColor:"$secondary500"}}}}),vc=lo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),wc=lo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),xc=uS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Tr=lo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as dS,styled as kr}from"@rango-dev/ui";var aN=kr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),_o=kr("div",{position:"relative"}),fS=dS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),$o=kr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${fS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vr=kr("div",{"& img":{borderRadius:"50%"}});function bc(t,e){return t.find(o=>o.name===e)?.logo}i(bc,"getBlockchainLogo");import{styled as gS}from"@rango-dev/ui";var Ec=gS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function fn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=wS([]),s=y().blockchains(),l=i(u=>{a(o?[u]:c=>c.includes(u)?c.filter(m=>m!==u):c.concat(u))},"onSelect"),p=i(u=>o?ke.createElement(vS,{value:r?.[0]},u):ke.createElement(ke.Fragment,null,u),"wrapRadioRoot");return ke.createElement(ke.Fragment,null,ke.createElement(SS,{size:20}),ke.createElement(TS,{type:"info",title:va.t("Select chain types"),description:va.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:ke.createElement(_o,null,ke.createElement(Tr,null,ke.createElement(Ic,{src:n,size:45})),ke.createElement($o,null))}),ke.createElement(Ec,null,p(ke.createElement(ke.Fragment,null,e.needsNamespace?.data.map(u=>ke.createElement(CS,{key:u.id,id:u.id,title:u.label,hasDivider:!0,style:{height:60},onClick:()=>l(u.value),start:ke.createElement(Ic,{src:bc(s,u.id),size:22}),end:o?ke.createElement(kS,{value:u.value}):ke.createElement(yS,{checked:r.includes(u.value)})}))))),ke.createElement(hS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},va.t("Confirm")))}i(fn,"Namespaces");import{i18n as Fo}from"@lingui/core";import{Button as ES,Divider as Wc,Image as IS,MessageBox as AS,Select as NS,TextField as WS}from"@rango-dev/ui";import Fe,{useEffect as BS,useState as Bc}from"react";import{namespaces as xS}from"@rango-dev/wallets-shared";var wr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function wa(t){let e=t?xS[t].derivationPaths:null;return e?[...e,wr]:[]}i(wa,"getDerivationPaths");import{styled as Ac,Typography as bS}from"@rango-dev/ui";var Nc=Ac("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),xa=Ac(bS,{paddingLeft:"$10"}),ba={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Mc="0";function gn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Bc(null),[l,p]=Bc(Mc),u=a===wr.id,c=wa(o),m=i(({value:d})=>{let f=c?.find(g=>g.id===d);f&&(a===wr.id&&Number.isNaN(Number(l))&&p(Mc),s(f.id))},"handleDerivationPathItemClick"),h=i(()=>{let d=c.find(f=>f.id===a);if(d)e(d.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return BS(()=>{s(wa(o)[0]?.id||null)},[o]),Fe.createElement(Fe.Fragment,null,Fe.createElement(Wc,{size:20}),Fe.createElement(AS,{type:"info",title:Fo.t("Select Derivation Path"),description:Fo.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Fe.createElement(_o,null,Fe.createElement(vr,null,Fe.createElement(IS,{src:n,size:45})),Fe.createElement($o,null))}),Fe.createElement(Nc,null,Fe.createElement(xa,{variant:"body",size:"xsmall",color:"$neutral600"},Fo.t("Choose Derivation Path Template")),Fe.createElement(NS,{value:a||"",options:c.map(d=>({value:d.id,label:d.label})),variant:"filled",handleItemClick:m,styles:{trigger:ba}}),Fe.createElement(Wc,{size:20}),Fe.createElement(xa,{variant:"body",size:"xsmall",color:"$neutral600"},u?Fo.t("Enter Path"):Fo.t("Enter Index")),Fe.createElement(WS,{type:u?"text":"number",variant:"contained",value:l,onChange:d=>p(d.target.value),style:ba})),Fe.createElement(ES,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!c||!a||!l},Fo.t("Confirm")))}i(gn,"DerivationPath");import{i18n as Oo}from"@lingui/core";import{Image as MS,MessageBox as Ea,WalletState as LS}from"@rango-dev/ui";import{useWallets as PS}from"@rango-dev/wallets-react";import po from"react";function Ia(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=PS();return un(a(n))===LS.CONNECTED?po.createElement(Ea,{type:"success",title:Oo.t("Wallet Connected"),description:Oo.t("Your wallet is connected, you can use it to swap.")}):o?po.createElement(Ea,{type:"error",title:Oo.t("Failed to Connect"),description:o||Oo.t("Your wallet is not connected. Please try again.")}):po.createElement(Ea,{type:"loading",title:Oo.t("Connecting to your wallet"),description:Oo.t("Click connect in your wallet popup."),icon:po.createElement(_o,null,po.createElement(vr,null,po.createElement(MS,{src:r,size:45})),po.createElement($o,null))})}i(Ia,"ConnectStatus");import{i18n as Aa}from"@lingui/core";import{Button as DS,Divider as Lc,MessageBox as _S}from"@rango-dev/ui";import xr from"react";function Na(t){let{displayName:e,onConfirm:o}=t;return xr.createElement(_S,{title:Aa.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Aa.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},xr.createElement(Lc,{size:18}),xr.createElement(Lc,{size:32}),xr.createElement(DS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Aa.t("Confirm")))}i(Na,"ExperimentalChain");function Pc(t,e){return t().status==="init"&&!!e}i(Pc,"isOnStatus");function hn(t){return t().status==="namespace"}i(hn,"isOnNamespace");function yn(t){return t().status==="derivationPath"}i(yn,"isOnDerivationPath");var US=3e3,zS=300;function uo(t){let e=OS(),[o,n]=Dc(!1),[r,a]=Dc(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=gt(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:h}=Ht(),d=i(S=>{c(t.wallet,S).catch(s)},"handleConfirmNamespaces"),f=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(S).catch(s)},"handleDerivationPathConfirm"),g=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return FS(()=>{if(t.wallet){C();let S=!1,T=!0,k=i(()=>{setTimeout(()=>{T=!1,S||n(!0)},zS)},"beforeConnecting"),v=i(w=>{let N=w.status==="connected",M=["disconnected","disconnected-unhandled"].includes(w.status);["namespace","derivation-path"].includes(w.status)||(S=!0),N&&!T?e.current=setTimeout(g,US):M&&g(),t.onConnect&&t.onConnect(w)},"afterConnected");k(),p(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),co.createElement(R,{open:o,onClose:g,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:W()},Pc(m,t.wallet)&&co.createElement(co.Fragment,null,co.createElement(Ia,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),co.createElement($S,{direction:"vertical",size:32})),hn(m)&&co.createElement(fn,{onConfirm:d,value:m().namespace}),yn(m)&&co.createElement(gn,{onConfirm:f,value:m().derivationPath}))}i(uo,"StatefulConnectModal");import{legacyFormatAddressWithNetwork as qS,legacyReadAccountAddress as $c}from"@rango-dev/wallets-core/legacy";import{Events as br,Provider as HS}from"@rango-dev/wallets-react";import{isEvmBlockchain as GS}from"rango-sdk";import Er,{createContext as VS,useEffect as Fc,useMemo as KS,useRef as Oc}from"react";import{useEffect as QS}from"react";function _c(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(_c,"hashProviders");function Wa(t,e){let{clearConnectedWallet:o}=y(),n=Cr(t,e);return QS(()=>{o(),n=Cr(t,e)},[_c(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(Wa,"useWalletProviders");var Ir=VS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function jS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r,removeBalancesForWallet:a}=y(),s=y().blockchains(),{newWalletConnected:l,disconnectWallet:p,connectedWallets:u}=y(),c=y().config,m={walletConnectProjectId:c?.walletConnectProjectId,trezorManifest:c?.trezorManifest,tonConnect:c.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,experimentalWallet:t.config.features?.experimentalWallet},{providers:h}=Wa(c.wallets,m),d=Oc(),f=Oc();Fc(()=>{n().catch(console.log)},[]),Fc(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:c,dappConfig:t.config})},[t.config,r]);let g=s.filter(GS).map(k=>k.name),C=i((k,v,w,N,M)=>{if(v===br.ACCOUNTS){let x=mr(M.supportedBlockchains),E=[],b=[];if(w?.forEach(A=>{let{network:I}=$c(A);g.includes(I)?E.push(A):b.push(A)}),u.filter(A=>A.walletType===k).map(A=>qS(A.address,A.chain)).length>0){if(E.length>0){let A=ca(k,E,g,x,M.isContractWallet);a(k,{chains:A.map(I=>I.chain)})}b.length>0&&a(k,{chains:b.map(A=>{let{network:I}=$c(A);return I})})}if(w){let A=ca(k,w,g,x,M.isContractWallet);A.length&&l(A)}else p(k),f.current?f.current(k):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")}if(v===br.ACCOUNTS&&N.connected||v===br.ACCOUNTS&&M.isHub){let x=`${k}-${N.network}-${w}`;d.current?d.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(v===br.NETWORK&&N.network){let x=`${k}-${N.network}`;d.current?d.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(k,v,w,N,M)},"onUpdateState"),S=le.use.isActiveTab(),T=KS(()=>({onConnectWallet:k=>{d.current=k},onDisconnectWallet:k=>{f.current=k}}),[]);return Er.createElement(Ir.Provider,{value:T},Er.createElement(HS,{allBlockChains:s,providers:h,onUpdateState:C,autoConnect:!!S,configs:{wallets:c.wallets,isExperimentalEnabled:Kp("experimentalWallet",c.features)}},t.children))}i(jS,"Main");function Ar(t){let{config:e,...o}=t;return Er.createElement(mc,{config:e},Er.createElement(jS,{...o,config:e}))}i(Ar,"WidgetWallets");import ea from"react";import XS,{Fragment as YS}from"react";import{MemoryRouter as ZS,useInRouterContext as JS}from"react-router";function Uc({children:t}){let o=JS()?YS:ZS;return XS.createElement(o,null,t)}i(Uc,"AppRouter");import{I18nManager as ME}from"@rango-dev/ui";import sp from"react";import Le from"react";import{useRoutes as SE}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Qo,useRef as $r}from"react";import Xe from"bignumber.js";import{create as tC}from"zustand";import{subscribeWithSelector as oC}from"zustand/middleware";import{getLastSuccessfulStep as eC}from"@rango-dev/queue-manager-rango-preset";import fB from"bignumber.js";function Ba(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(Ba,"getFeeLabel");var Ma=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],zc=30,Qc=15,qc=60;import{i18n as ht}from"@lingui/core";import{RouteEventType as RW}from"@rango-dev/queue-manager-rango-preset";import Oe from"bignumber.js";import{PendingSwapNetworkStatus as Wr}from"rango-types";import{i18n as De}from"@lingui/core";var te=i(()=>({genericServerError:De.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:De.t("Please reset your liquidity sources."),description:De.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:De.t("No Routes Found."),description:De.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:De.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:De.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:De.t("High Price Impact"),title:De.t("Price impact is too high!"),description:De.t("The price impact is significantly higher than the allowed amount."),confirmMessage:De.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:De.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:De.t("USD Price Unknown"),title:De.t("USD Price Unknown, Cannot calculate Price Impact."),description:De.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:De.t("Confirm USD Price Unknown")}}),"errorMessages");function Hc(t){switch(t.type){case 0:return t.diagnosisMessage??te().noResultError.title;case 1:return te().genericServerError;default:return""}}i(Hc,"getQuoteErrorMessage");import{i18n as Nr}from"@lingui/core";var mo=i(()=>({connectWallet:Nr.t("Connect Wallet"),swap:Nr.t("Swap"),swapAnyway:Nr.t("Swap anyway"),ethWarning:Nr.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Gc(t,e){return(parseInt(e.toFixed(2)||"0")<=-10&&t?.gte(new Oe(400))||parseInt(e.toFixed(2)||"0")<=-5&&t?.gte(new Oe(1e3)))??!1}i(Gc,"hasHighValueLoss");function Vc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Oe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Oe(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Vc,"hasLimitError");function Kc(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new Oe(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Oe(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?p?.gte(l.fromAmount)||u?.lte(l.fromAmount):p?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Oe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Oe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=ht.t({id:"Required: >= {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=ht.t({id:"Required: > {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=ht.t({id:"Required: <= {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=ht.t({id:"Required: < {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Kc,"getLimitErrorMessage");function jc(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:mo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:mo().swap,action:"confirm-swap",disabled:!0}:s?{title:mo().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:mo().ethWarning,action:"confirm-warning",disabled:!1}:{title:mo().swap,action:"confirm-swap",disabled:!1}:{title:mo().connectWallet,action:"connect-wallet",disabled:!1}}i(jc,"getSwapButtonState");function La(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(Ce))&&e&&e!=="0"&&n!==0)}i(La,"canComputePriceImpact");function Pa(t,e){let o=Ce;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Oe(r.amount).multipliedBy(a||0))}return o}i(Pa,"getUsdFeeOfStep");function Br(t,e){return t.reduce((o,n)=>o.plus(Pa(n,e)),Ce)}i(Br,"getTotalFeeInUsd");function Da(t){let e=Ce;return e=e.plus(new Oe(t.amount).multipliedBy(t.price||0)),e}i(Da,"getUsdFee");function Xc(t){return t.reduce((e,o)=>e.plus(Da(o)),Ce)}i(Xc,"getTotalFeesInUsd");function Yc(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(Yc,"getFeesGroup");function Zc(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?e:null}i(Zc,"checkSlippageErrors");function Jc(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?o:null}i(Jc,"checkSlippageWarnings");function Mr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Mr,"getMinRequiredSlippage");function Rc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Rc,"hasProperSlippage");function eu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:h,destination:d}=t,f=a?.reduce((S,T)=>(S[T.chain]=T.address,S),{}),g=[];return r?.forEach(S=>{g.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:h??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:g,selectedWallets:f??{},slippage:u.toString(),...d&&{destination:d},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(eu,"createQuoteRequestBody");function tu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(tu,"getWalletsForNewSwap");function Uo(t){return t?.outputAmount||null}i(Uo,"getQuoteOutputAmount");function ou(t,e){return new Oe(e).div(new Oe(t)).minus(1).multipliedBy(100).toNumber()}i(ou,"getPercentageChange");function nu(t,e){let o=Uo(t),n=Uo(e);if(!o||!n)return!1;let r=ct(o,n);return r?r<=-1:!0}i(nu,"isOutputAmountChangedALot");function ru(t,e,o){let n=t.validationStatus,r=ao({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>cu(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=L(new Oe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=L(new Oe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=ht.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=ht.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=ht.t(" for input and network fee")),ht.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:c,currentAmount:p,blockchain:lt(s.asset.blockchain,o)}})})}i(ru,"generateBalanceWarnings");function Kt(t,e){return(t?new Oe(t):Ce).multipliedBy(e||0)}i(Kt,"calcOutputUsdValue");function Sn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Wr.NetworkChanged}i(Sn,"isNetworkStatusInWarningState");function iu(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),Sn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Wr.WaitingForConnectingWallet:n=n||ht.t("Waiting for connecting wallet");break;case Wr.WaitingForQueue:n=n||ht.t("Waiting for other running tasks to be finished");break;case Wr.WaitingForNetworkChange:n=n||ht.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(iu,"getSwapMessages");function au(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(au,"getLastConvertedTokenInFailedSwap");function su(t){return t.status==="failed"}i(su,"shouldRetrySwap");function lu(t,e,o,n,r,a){if(!n||t)return!0;let s=ao({filter:"all",quote:n}),l=ao({filter:"required",quote:n}),p=s.every(m=>r.some(h=>h.chain===m)),u=l.every(m=>r.some(h=>h.chain===m)),c=o&&a?No(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(lu,"isConfirmSwapDisabled");function pu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(pu,"isTokensIdentical");function fo(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(fo,"getQuoteToTokenUsdPrice");function Cn(t){return(t?.swaps||[])[0].from.usdPrice}i(Cn,"getQuoteFromTokenUsdPrice");function _a(t,e){let o=t?.swaps||[],n=e?.swaps||[];return o.length!==n.length}i(_a,"isNumberOfSwapsChanged");function $a(t,e){let o=t?.swaps.map(r=>r.swapperId)||[],n=e?.swaps.map(r=>r.swapperId)||[];return!pa(o,n)}i($a,"isQuoteSwappersUpdated");function Fa(t,e){let o=t?.swaps.map(r=>r.to.symbol)||[],n=e?.swaps.map(r=>r.to.symbol)||[];return!pa(o,n)}i(Fa,"isQuoteInternalCoinsUpdated");function mu(t,e){return _a(t,e)||$a(t,e)||Fa(t,e)}i(mu,"isQuoteChanged");function cu(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(cu,"getRequiredBalanceOfWallet");function Pt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Pt,"getPriceImpactLevel");function Pr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=eC(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=sn(a?a.toBlockchain:n.fromBlockchain,e),p=sn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(Pr,"createRetryQuote");function zo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=Kt(t.requestAmount,Cn(t)||o?.usdPrice),l=Kt(t.outputAmount,fo(t)||n?.usdPrice);if(t&&s&&l){let c=ct(s.toString(),l.toString());if(!!c&&Gc(s,c)){let h=Br(t?.swaps,r),d=Pt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:h,warningLevel:d}}}else if(t&&(!s||!l))return{type:1};let p=Mr(t.swaps),u=a>ec;if(Rc(e.userSlippage.toString(),p)){if(u&&parseFloat(p??"0")<a)return{type:3,slippage:a.toString()}}else return{type:2,recommendedSlippages:Jc(t,a),minRequiredSlippage:p};return null}i(zo,"generateQuoteWarnings");function ct(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:ou(t.toString(),e.toString());return n&&n<0?n:null}i(ct,"getPriceImpact");var du=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Dr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(c=>c.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),p=n.requestId.toLowerCase();return l.localeCompare(p)}),"sortQuotesBy"),fu=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,validationStatus:null,...e[0]};let n=new Set(t.swaps.map(a=>a.swapperId)),r=e.find(a=>{let s=new Set(a.swaps.map(l=>l.swapperId));return Array.from(n).every(l=>s.has(l))});return{requestAmount:o,validationStatus:null,...r||e[0]}},"getDefaultQuote"),gu=i(t=>{let e=i((o,n)=>{let r=Ma.indexOf(o.value),a=Ma.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");var _r=i((t,e)=>t?.usdPrice?new Xe(e||Ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Do(tC()(oC(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Xe(0),outputUsdValue:new Xe(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=Ce,a=o.inputUsdValue;return cn(o.inputAmount)?(e&&(n=e?.outputAmount?new Xe(e?.outputAmount):null,a=Kt(o.inputAmount,Cn(e)||o.fromToken?.usdPrice),r=Kt(e.outputAmount,fo(e)||o.toToken?.usdPrice)),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Xe(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Xe(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:_r(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:_r(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:_r(n??null,s),outputUsdValue:new Xe(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?_r(e.toToken,e.outputAmount?.toString()||""):new Xe(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Xe(0),inputUsdValue:new Xe(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),hu=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ge.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&ge.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function yu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=O(),c=y().config,m=y().fetchStatus,h=y().blockchains(),d=y().tokens(),{findToken:f}=y(),{setAffiliateRef:g,setAffiliatePercent:C,setAffiliateWallets:S}=y(),T=c?.from?.tokens,k=c?.from?.blockchains,v=c?.to?.tokens,w=c?.to?.blockchains,N=$r(void 0),M=$r(void 0),x=$r(void 0),E=$r(void 0);Qo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Qo(()=>{if(m==="success"){r();let b=h.find(I=>I.name===c?.from?.blockchain),B=c?.from?.token,A=B&&f(B);(b||!b&&x.current)&&n(b??null),A?a({token:A,meta:{blockchains:h,tokens:d}}):!A&&N.current&&a({token:null}),x.current=c?.from?.blockchain,N.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Qo(()=>{da(s,T)&&a({token:null}),fa(p,k)&&n(null)},[T,k]),Qo(()=>{da(l,v)&&a({token:null}),fa(u,w)&&o(null)},[v,w]),Qo(()=>{if(m==="success"){r();let b=h.find(I=>I.name===c?.to?.blockchain),B=c?.to?.token,A=B&&f(B);(b||!b&&E.current)&&o(b??null),A?e({token:A,meta:{blockchains:h,tokens:d}}):!A&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Qo(()=>{g(c?.affiliate?.ref??null),C(c?.affiliate?.percent??null),S(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(yu,"useSyncStoresWithConfig");import{useEffect as za,useRef as nC}from"react";import{useInRouterContext as rC,useLocation as iC,useSearchParams as aC}from"react-router-dom";function Oa(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Oa,"convertTokenSearchParamToAsset");function Ua(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Ua,"tokenToSearchParam");function qa(){let t=iC(),[e,o]=aC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:h}=O(),d=y().fetchStatus,f=y().blockchains(),g=y().tokens(),C=rC(),{updateIframe:S,updateCampaignMode:T}=y(),k=y().isInCampaignMode(),v=nC(),{findToken:w}=y(),N=i(()=>{let x={};for(let[K,pe]of e.entries())K.startsWith("utm_")&&(x[K]=pe);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),B=e.get("fromToken"),A=e.get("toBlockchain"),I=e.get("toToken"),X=e.get("autoConnect"),se=e.get("clientUrl"),J=e.get("liquiditySources"),P=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:B,toBlockchain:A,toToken:I,autoConnect:X,clientUrl:se,liquiditySources:J,utmQueryParams:x,blockchain:P}},"getUrlSearchParams"),M=i(x=>{for(let E in x)x[E]||delete x[E];o(x,{replace:!0})},"updateUrlSearchParams");za(()=>{let{autoConnect:x,clientUrl:E,utmQueryParams:b,blockchain:B}=N();C&&d==="success"&&M({fromBlockchain:n?.name,fromToken:Ua(a),toBlockchain:r?.name,toToken:Ua(s),fromAmount:l,autoConnect:x??void 0,clientUrl:E??void 0,blockchain:B??void 0,liquiditySources:k?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,k]),za(()=>{if(!C)return;let x=N();if(!v.current&&x.liquiditySources&&(v.current=x.liquiditySources),x.fromAmount&&h(x.fromAmount),d==="success"){let E=f.find(I=>I.name===x.fromBlockchain),b=x.fromToken&&E?w(Oa(x.fromToken,E)):void 0,B=f.find(I=>I.name===x.toBlockchain),A=x.toToken&&B?w(Oa(x.toToken,B)):void 0;E&&(p(E),b&&c({token:b,meta:{blockchains:f,tokens:g}})),B&&(u(B),A&&m({token:A,meta:{blockchains:f,tokens:g}}))}},[d]),za(()=>{let{clientUrl:x,liquiditySources:E}=N();S("clientUrl",x||void 0),T("liquiditySources",E?.split(",")??void 0)},[])}i(qa,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as TT,Button as Zu,darkTheme as kT,Divider as vn,DoneIcon as vT,MessageBox as wT,styled as xT,TextField as bT,Typography as ET}from"@rango-dev/ui";import he,{useEffect as IT,useState as Hr}from"react";import{useNavigate as AT,useSearchParams as NT}from"react-router-dom";import{ChevronRightIcon as sC,Divider as vu,Image as lC,Typography as wu}from"@rango-dev/ui";import yt from"react";import{darkTheme as Su,styled as Ha}from"@rango-dev/ui";var Cu=Ha("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${Su} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Su} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),Tu=Ha("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),ku=Ha("div",{display:"flex"});function Ga(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return yt.createElement(Tu,null,yt.createElement(wu,{size:"large",variant:"label"},n),yt.createElement(vu,{size:10}),yt.createElement(Cu,{onClick:s?void 0:e,disabled:s},yt.createElement(ku,null,r&&yt.createElement(yt.Fragment,null,yt.createElement(lC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),yt.createElement(vu,{size:4,direction:"horizontal"})),yt.createElement(wu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),yt.createElement(sC,{size:12,color:"black"})))}i(Ga,"BlockchainSelectorButton");import{i18n as Ka}from"@lingui/core";import{Button as pC,Divider as Tn,ExternalLinkIcon as cC,Image as uC,Typography as Ho}from"@rango-dev/ui";import Ae from"react";function xu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(xu,"generateExplorerLink");import{darkTheme as qo,styled as bu}from"@rango-dev/ui";var Va=bu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${qo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${qo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${qo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${qo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Eu=bu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${qo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${qo} &`]:{color:"$colors$neutral900"}}});function ja(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=xu(n.address,a);return Ae.createElement(R,{open:e,dismissible:!0,onClose:o,container:W()},Ae.createElement(Eu,null,Ae.createElement(uC,{src:n.image,size:45,type:"circular"}),Ae.createElement(Ho,{variant:"title",size:"medium"},n.name),Ae.createElement(Ho,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ae.createElement(Tn,{size:4}),Ae.createElement(Ho,{variant:"body",size:"medium"},s?Ae.createElement(Va,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ae.createElement(cC,{size:12,color:"gray"})):Ae.createElement(Va,null,n.address)),Ae.createElement(Tn,{size:4}),n.coinSource&&Ae.createElement(Ho,{className:"_coin-source",variant:"body",size:"xsmall"},Ka.t("via")," ",Ae.createElement(Ho,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ae.createElement(Tn,{size:"32"}),Ae.createElement(Ho,{size:"medium",variant:"body",className:"_custom-token-description"},Ka.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ae.createElement(Tn,{size:40}),Ae.createElement(Tn,{size:10}),Ae.createElement(pC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ka.t("Import")))}i(ja,"CustomTokenModal");import{useManager as fT}from"@rango-dev/queue-manager-react";import{BottomLogo as gT,Divider as Vu,Header as hT}from"@rango-dev/ui";import We,{useEffect as hs,useRef as Ku,useState as yT}from"react";import{useRef as mC}from"react";function Fr(){return window.self!==window.top}i(Fr,"isAppLoadedIntoIframe");function Xa(){let t=mC(null),{iframe:e}=y(),o=Fr()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let p of l)n({type:"widget_height",data:{height:p.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Xa,"useIframe");import{useNavigate as dC}from"react-router-dom";function Ye(){let t=dC();return()=>t(-1)}i(Ye,"useNavigateBack");import{createTheme as os,darkTheme as IC,lightTheme as AC}from"@rango-dev/ui";import{useEffect as NC,useState as WC}from"react";import{theme as bC,darkColors as EC}from"@rango-dev/ui";import es from"react";function fC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(fC,"expandShortHexColor");function gC(t){return/[0-9]+$/.test(t)}i(gC,"isOverridingColor");function hC(t,e){return t.padStart(e,"0")}i(hC,"pad");function Ya(t){let e=Math.min(Math.max(Math.round(t),0),255);return hC(e.toString(16),2)}i(Ya,"intToHex");function yC(t){return`#${Ya(t.red)}${Ya(t.green)}${Ya(t.blue)}`}i(yC,"rgbToHex");function SC(t){let e=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return{red:e,green:o,blue:n}}i(SC,"hexToRGB");function CC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(CC,"generateShade");function TC(t,e){let o=.11*e;return{red:t.red+(255-t.red)*o,green:t.green+(255-t.green)*o,blue:t.blue+(255-t.blue)*o}}i(TC,"generateTint");function kC(t){return Iu(t,CC)}i(kC,"calculateShades");function vC(t){return Iu(t,TC)}i(vC,"calculateTints");function Iu(t,e){let o=SC(t),n=[];for(let r=1;r<9;r++)n.push(yC(e(o,r)));return n}i(Iu,"calculateColors");function Za(t,e,o){let a=vC(t).reverse().concat(t),s=kC(t),l=a.concat(s),p={},u=l.length;for(let c=0;c<u;c++){let m=100+(o?u-1-c:c)*50;p[`${e}${m}`]=l[c]}return p}i(Za,"createTintsAndShades");function Ja(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!gC(r)){let p=fC(a);Object.assign(n,Za(p,r,s))}}return{...n,...e}}i(Ja,"expandToGenerateThemeColors");var Au=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),wC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Au(o%52)+e;return Au(o%52)+e},"toAlphabeticName"),xC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Ra=i(t=>wC(xC(5381,JSON.stringify(t))>>>0),"toHash");function ts(t){let e=bC.colors,o={...e,...EC},n,r;if(t?.light){let s={colors:Ja(e,t.light)};n={id:`${ma}-light-${Ra(s)}`,tokens:s}}if(t?.dark){let s={colors:Ja(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ma}-dark-${Ra(s)}`,tokens:s}}return{light:n,dark:r}}i(ts,"customizedThemeTokens");function Nu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>es.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(es.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(es.cloneElement(e,{key:l}))}}),o}i(Nu,"joinList");function Wu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Wu,"doesWindowPreferDarkColorScheme");function Go(t){let{colors:e,fontFamily:o=Tp,borderRadius:n=qp,secondaryBorderRadius:r=Hp}=t,[a,s]=WC(Wu()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=ts(e),c=os({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,AC.className],h=[c.className,IC.className];if(u){let f=os(u.id,u.tokens);m.push(f.className)}if(p){let f=os(p.id,p.tokens);h.push(f.className)}return NC(()=>{let f=i(g=>{g.matches?s("dark"):s("light")},"switchThemeListener");return Wu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=m.join(" "),g=h.join(" ");return l==="auto"?a==="dark"?g:f:l==="dark"?g:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(Go,"useTheme");var ut=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Bu}from"@lingui/core";import{Alert as BC,Button as MC}from"@rango-dev/ui";import Mu from"react";function ns(t){return Mu.createElement(BC,{action:Mu.createElement(MC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Bu.t("Activate this tab")),type:"warning",variant:"alarm",title:Bu.t("Another tab is open and handles transactions.")})}i(ns,"ActivateTabAlert");import{i18n as rs}from"@lingui/core";import{Button as LC,Divider as PC,MessageBox as DC}from"@rango-dev/ui";import Or from"react";function is(t){let{open:e,onClose:o,onConfirm:n}=t;return Or.createElement(R,{open:e,dismissible:!0,onClose:o,container:W()},Or.createElement(DC,{title:rs.t("Activate current tab"),type:"warning",description:rs.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},Or.createElement(PC,{size:20}),Or.createElement(LC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},rs.t("Confirm"))))}i(is,"ActivateTabModal");import{ChevronLeftIcon as _C}from"@rango-dev/ui";import Lu from"react";function as(t){return Lu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Lu.createElement(_C,{color:"black",size:16}))}i(as,"BackButton");import{i18n as $C}from"@lingui/core";import{Button as FC,Typography as OC}from"@rango-dev/ui";import ss from"react";function ls(t){return ss.createElement(Gt,null,ss.createElement(FC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},ss.createElement(OC,{variant:"label",size:"medium",color:"error500"},$C.t("Cancel"))))}i(ls,"CancelButton");import{i18n as UC}from"@lingui/core";import{Image as zC,Tooltip as QC,WalletIcon as qC}from"@rango-dev/ui";import go from"react";function ps(t){let{list:e}=gt(),o=e.filter(r=>r.state==="connected"),n=o.length?go.createElement("div",{className:xc()},o.map(r=>go.createElement(Tr,{key:r.title},go.createElement(zC,{src:r.image,size:14})))):UC.t("Connect Wallet");return go.createElement(QC,{container:t.container,side:"bottom",content:n},go.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&go.createElement(Tc,null),go.createElement(qC,{size:18,color:"black"})))}i(ps,"WalletButton");import{i18n as zr}from"@lingui/core";import{NotificationsIcon as iT,Popover as aT,SettingsIcon as sT,Tooltip as Qr,TransactionIcon as lT}from"@rango-dev/ui";import Ne from"react";import{Notifications as KC}from"@rango-dev/ui";import jC from"react";import{useNavigate as XC}from"react-router-dom";import{create as HC}from"zustand";import{persist as GC,subscribeWithSelector as VC}from"zustand/middleware";var ve=Do(HC()(GC(VC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(p=>p.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(p=>p.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function cs(){let t=XC(),{getNotifications:e,clearNotifications:o}=ve(),n=e(),r=y().blockchains(),{findToken:a}=y();return jC.createElement(KC,{list:n,getBlockchainImage:l=>dp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(cs,"NotificationContent");import{useManager as YC}from"@rango-dev/queue-manager-react";import{InProgressIcon as ZC}from"@rango-dev/ui";import Pu from"react";var JC=i(()=>{let{manager:t}=YC();return ut(t).map(({swap:o})=>o).find(o=>o.status==="running")?Pu.createElement(wc,null,Pu.createElement(ZC,{color:"info",size:6})):null},"InProgressTransactionBadge"),Du=JC;import{EventSeverity as RC}from"@rango-dev/queue-manager-rango-preset";import{Typography as eT}from"@rango-dev/ui";import _u from"react";function $u(){let{getNotifications:t}=ve(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===RC.WARNING);return o?_u.createElement(kc,{isSever:n},_u.createElement(eT,{variant:"body",size:"xsmall",color:"$background"},o)):null}i($u,"NotificationsBadge");import{RefreshProgressButton as tT}from"@rango-dev/ui";import us,{useEffect as oT,useState as Fu}from"react";var nT=1e3,Ou=60,rT=100;function Ur({onClick:t}){let[e,o]=Fu(0),[n,r]=Fu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");oT(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Ou&&l()},nT):s(p),document.addEventListener("visibilitychange",()=>a(p)),()=>{document.removeEventListener("visibilitychange",()=>a(p)),p&&clearInterval(p)}},[e,t]);let s=i(p=>{p&&clearInterval(p),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return us.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},us.createElement(vc,{onTransitionEnd:()=>r(!1),isRefetched:n},us.createElement(tT,{size:22,color:t?"black":"gray",progress:e/Ou*rT})))}i(Ur,"RefreshButton");function ho(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=je("notification",s)||r.includes("notifications");return Ne.createElement(Ne.Fragment,null,!r.includes("refresh")&&Ne.createElement(Qr,{container:a||W(),side:"top",content:zr.t("Refresh")},Ne.createElement(Ur,{onClick:e})),!l&&Ne.createElement(aT,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:W(),content:Ne.createElement(cs,null)},Ne.createElement("div",null,Ne.createElement(Qr,{container:W(),side:"top",content:zr.t("Notifications")},Ne.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Ne.createElement(iT,{size:18,color:"black"}),Ne.createElement($u,null))))),!r.includes("settings")&&Ne.createElement(Qr,{container:W(),side:"top",content:zr.t("Settings")},Ne.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Ne.createElement(sT,{size:18,color:"black"}))),!r.includes("history")&&Ne.createElement(Qr,{container:W(),side:"top",content:zr.t("History")},Ne.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Ne.createElement(lT,{size:18,color:"black"}),Ne.createElement(Du,null))))}i(ho,"HeaderButtons");import{i18n as ms}from"@lingui/core";import{Divider as zu,MessageBox as uT,RefreshIcon as mT}from"@rango-dev/ui";import Vo from"react";import{Button as pT,styled as cT}from"@rango-dev/ui";var Uu=cT(pT,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function ds(t){let{open:e,onClose:o}=t;return Vo.createElement(R,{open:e,dismissible:!0,onClose:o,container:W()},Vo.createElement(uT,{title:ms.t("Something went wrong"),type:"error",description:ms.t("Something went wrong. Please refresh the app.")},Vo.createElement(zu,{size:30}),Vo.createElement(Uu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Vo.createElement(mT,{size:20,color:"primary"}),Vo.createElement(zu,{size:4,direction:"horizontal"}),ms.t("Refresh"))))}i(ds,"RefreshModal");function fs(t){let e=t.target;if(e){let o=e.scrollTop,n=W();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(fs,"onScrollContentAttachStatusToContainer");import{css as dT,styled as gs}from"@rango-dev/ui";var Qu="700px",qr=dT({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),qu=gs("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Qu},fixed:{height:Qu}}}}),Hu=gs("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Gu=gs("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Xa(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:p}=y(),[u,c]=yT(!1),{config:{features:m,theme:h}}=y(),{watermark:d}=le(),f=d==="FULL",{activeTheme:g}=Go(h||{}),C=je("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:T,showActivateTabModal:k,setShowActivateTabModal:v,activateCurrentTab:w}=le(),N=Ye(),{manager:M}=fT(),E=ut(M).map(({swap:se})=>se).some(se=>se.status==="running"),b=i(()=>w(so.forceClaim,E),"onActivateTab"),B=i(()=>{r.onWallet?.()},"onConnectWallet"),A=typeof r.hasBackButton>"u"||r.hasBackButton,I=Ku(null),X=Ku(null);return hs(()=>(Fr()&&X.current&&e(X.current),()=>{o()}),[]),hs(()=>(I.current?.addEventListener("scroll",fs),()=>{I.current?.removeEventListener("scroll",fs)}),[]),hs(()=>{c(l==="failed")},[l]),We.createElement(qu,{height:s,id:Pe.SWAP_BOX_ID,className:`${g()} ${qr()}`,ref:X},We.createElement(hT,{prefix:A?We.createElement(as,{onClick:()=>{N(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:We.createElement(We.Fragment,null,r.suffix,r.onWallet&&!C&&We.createElement(ps,{container:W(),onClick:B,isConnected:!!p?.length}),r.onCancel&&We.createElement(ls,{onClick:r.onCancel}))}),We.createElement(Hu,{ref:I},n),We.createElement(is,{open:k,onClose:()=>v(!1),onConfirm:b}),We.createElement(Gu,null,We.createElement("div",{className:"footer__content"},T&&!S&&We.createElement("div",{className:"footer__alert"},We.createElement(ns,{onActivateTab:b}),We.createElement(Vu,{size:10})),a),We.createElement(Vu,{size:12}),We.createElement("div",{className:`footer__logo ${f?"logo__show":"logo__hidden"}`},We.createElement(gT,null))),We.createElement(ds,{open:u,onClose:()=>c(!1)}))}i(oe,"Layout");import{styled as ST}from"@rango-dev/ui";var ju="$20 $20 $10 $20",kn=ST("div",{padding:ju,overflowY:"auto",flexGrow:1});import{styled as CT}from"@rango-dev/ui";var ie=CT("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as Ko}from"@lingui/core";import{useState as Xu}from"react";function Yu(){let[t,e]=Xu(!1),[o,n]=Xu(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Ko.t("Duplicate Token"),message:Ko.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Ko.t("Token Already Exists"),message:Ko.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Ko.t("Token Not Found"),message:Ko.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:u}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:p,tokenAddress:u})=>{e(!0);try{if(a.some(f=>f.address?.toLowerCase()===u.toLowerCase())){let f=s("duplicated");n(f);return}let m=await bt().getCustomToken({blockchain:p,address:u});if(!m||!m.token||m.error){let f=s("not-found",p);n(f);return}let h=m.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let f=s("token-exist");n(f);return}return h}catch(c){if(c?.code==="ERR_BAD_REQUEST"){let m=s("not-found",p);n(m);return}throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Yu,"useFetchCustomToken");var WT=xT("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${kT} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),BT=1e3;function Ju(){let t=AT(),[e]=NT(),o=Ye(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=sn(a,r),[l,p]=Hr(""),[u,c]=Hr(!1),[m,h]=Hr(),{fetchCustomToken:d,loading:f,error:g}=Yu(),[C,S]=Hr(""),T=!!s&&No(s,l),k=!s||!l||!T,v=i(async()=>{if(s)try{let M=await d({blockchain:a,tokenAddress:l});S(""),M&&h(M)}catch(M){M.message==="Failed to fetch"&&(S(It.t("Network Error")),c(!0))}},"getCustomToken"),w=i(()=>{g&&p(""),c(!1)},"closeErrorModal"),N=i(async()=>{C&&setTimeout(async()=>{await v()},BT),w()},"handleErrorModalButtonClick");return IT(()=>{g&&c(!0)},[g]),he.createElement(oe,{header:{title:It.t("Add Custom Token")}},he.createElement(ie,null,he.createElement(WT,null,he.createElement("div",null,he.createElement(Ga,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),he.createElement(vn,{size:"24"}),he.createElement(ET,{size:"large",variant:"label"},It.t("Enter Address")),he.createElement(vn,{size:10}),he.createElement(bT,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&T&&he.createElement(vT,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!T&&!!l&&he.createElement(he.Fragment,null,he.createElement(vn,{size:4}),he.createElement(TT,{type:"error",variant:"alarm",title:"Invalid Address"}))),he.createElement(Zu,{id:"widget-add-custom-token-import-btn",disabled:k,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},It.t("Import"))),he.createElement(R,{open:u,dismissible:!0,onClose:w,container:W()},he.createElement(wT,{title:g?.title||C,type:"error",description:g?.message||It.t("Failed Network, Please retry.")},he.createElement(vn,{size:40}),he.createElement(vn,{size:10}),he.createElement(Zu,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:N},C?It.t("Retry"):It.t("Add another custom token")))),s&&m&&he.createElement(ja,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!m})))}i(Ju,"AddCustomTokenPage");import{i18n as Vs}from"@lingui/core";import{useManager as fv}from"@rango-dev/queue-manager-react";import{Alert as Kd,Button as gv,css as js,Divider as Ks,IconButton as jd,styled as hv,Typography as yv,WalletIcon as Sv}from"@rango-dev/ui";import be,{useEffect as Ti,useLayoutEffect as Cv,useRef as Tv,useState as Dn}from"react";import{useNavigate as kv}from"react-router-dom";import{i18n as yo}from"@lingui/core";import{Alert as Em,BalanceErrors as nk,Button as Im,ChevronLeftIcon as rk,Divider as Rr,MessageBox as ik,Typography as xs}from"@rango-dev/ui";import Y,{useCallback as ak,useEffect as Am,useMemo as sk,useState as So}from"react";import{useNavigate as lk}from"react-router-dom";import{i18n as Gr}from"@lingui/core";function Vr(t){switch(t.type){case 0:return Gr.t("Route has been updated.");case 3:return Gr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Gr.t("Route swappers has been updated.");case 2:return Gr.t("Route internal coins has been updated.");default:return""}}i(Vr,"getQuoteUpdateWarningMessage");import{i18n as Ts}from"@lingui/core";import{Alert as $T,ChevronDownIcon as FT,CloseIcon as OT,Divider as im,IconButton as am,PasteIcon as UT,Typography as zT,WalletIcon as QT}from"@rango-dev/ui";import Be,{useEffect as qT,useRef as HT}from"react";import Yr,{useRef as DT}from"react";import*as jo from"@radix-ui/react-collapsible";import{keyframes as Ru,styled as Kr}from"@rango-dev/ui";var ys=300,LT=Ru({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),PT=Ru({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),em=Kr(jo.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Ss=Kr(jo.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),jr=Kr(jo.Content,{overflow:"hidden",variants:{open:{true:{animation:`${LT} ${ys}ms ease-out`},false:{animation:`${PT} ${ys}ms ease-out`}}}}),Xr=Kr("div",{transition:`all ${ys}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Zr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=DT(null);return Yr.createElement(em,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Yr.createElement(Ss,{className:"collapsible_trigger",onClick:a},s),Yr.createElement(jr,{className:"collapsible_content",open:e},r),l==="bottom"&&Yr.createElement(Ss,{className:"collapsible_trigger",onClick:a},s))}i(Zr,"CustomCollapsible");import{darkTheme as tm,styled as Cs,TextField as _T}from"@rango-dev/ui";var om=Cs("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),nm=Cs(_T,{backgroundColor:"$neutral100",padding:"$15"}),rm=Cs("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${tm} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${tm} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function sm(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),p=rr(e.name,l),u=HT(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),d=n&&!!r&&e&&!No(e,r),f=i(()=>{a("")},"handleClear"),g=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let T=await navigator.clipboard.readText();a(T),u?.current?.focus()}},"handlePaste"),C=i(()=>r?Be.createElement(am,{id:"widget-custom-destination-close-icon-btn",onClick:f,variant:"ghost"},Be.createElement(OT,{size:12,color:"gray"})):m?null:Be.createElement(am,{id:"widget-custom-destination-paste-icon-btn",onClick:g,variant:"ghost"},Be.createElement(UT,{size:16})),"renderSuffix");return qT(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Be.createElement(om,null,Be.createElement(Zr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Be.createElement(rm,null,Be.createElement("div",{className:"button__content"},Be.createElement(QT,{size:18,color:"info"}),Be.createElement(im,{size:4,direction:"horizontal"}),Be.createElement(zT,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ts.t("Send to a different address"))),Be.createElement(Xr,{orientation:n?"up":"down"},Be.createElement(FT,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Be.createElement(nm,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ts.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:C(),onChange:S=>{let T=S.target.value;a(T)}})),d&&Be.createElement(Be.Fragment,null,Be.createElement(im,{size:4}),Be.createElement($T,{variant:"alarm",type:"error",title:Ts.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(sm,"CustomDestination");import{css as GT,darkTheme as ks,IconButton as VT,styled as Dt}from"@rango-dev/ui";var lm=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),pm=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),KT=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${ks} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${ks} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${ks} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),cm=Dt(KT,{alignSelf:"stretch",minHeight:"93px"}),um=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),mm=Dt(VT,{position:"absolute",left:"$20"}),dm=Dt("div",{paddingTop:"$20"}),fm=GT({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),gm=Dt("div",{display:"flex"}),hm=Dt("div",{overflow:"visible",width:"100%"});import{i18n as vm}from"@lingui/core";import{warn as JT}from"@rango-dev/logging-core";import{Divider as RT,SelectableWallet as ek,Typography as wm,WalletState as xm}from"@rango-dev/ui";import Ze,{useEffect as bm,useState as xn}from"react";import{Image as YT,MessageBox as ZT}from"@rango-dev/ui";import wn from"react";import{keyframes as jT,styled as vs}from"@rango-dev/ui";var ym=vs("div",{position:"relative"}),XT=jT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Sm=vs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${XT} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Cm=vs("div",{"& img":{borderRadius:"50%"}});import{i18n as Xo}from"@lingui/core";function Tm(t,e){switch(t){case"in-progress":return{type:"loading",title:Xo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Xo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Xo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Xo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Xo.t("Request Rejected"),description:Xo.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(Tm,"generateMessageByStatus");function km(t){let{status:e,displayName:o,image:n}=t,r=Tm(e,o),a=e=="in-progress";return wn.createElement(ZT,{type:r.type,title:r.title,description:r.description,icon:a?wn.createElement(ym,null,wn.createElement(Cm,null,wn.createElement(YT,{src:n,size:45})),wn.createElement(Sm,null)):void 0})}i(km,"ExperimentalChainStatus");var tk=7,ok=3e3;function ws(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=le.use.isActiveTab(),{blockchains:l,connectedWallets:p}=y(),[u,c]=xn(),[m,h]=xn(null),[d,f]=xn(!1),[g,C]=xn(null),{suggestAndConnect:S}=Jr(),{handleDisconnect:T}=Ht(),{list:k}=gt({chain:e}),[v,w]=xn(k),N=k.length,M=r&&N-r>0,x=i(async b=>{f(!1),C("in-progress");try{await S(b.walletType,b.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");bm(()=>{w(b=>{let B=k.findIndex(A=>o(A.type,e));return M&&B>1?[k[B]].concat(k.filter((A,I)=>I!==B)):b.map(A=>k.find(I=>I.type===A.type)??A)})},[JSON.stringify(k)]);let E=document.getElementById(Pe.SWAP_BOX_ID);return bm(()=>{let b=null;return(g==="completed"||g==="rejected")&&(b=setTimeout(()=>C(null),ok)),()=>{b&&clearTimeout(b)}},[g]),Ze.createElement(Ze.Fragment,null,v.slice(0,r).map(b=>{let B=$p({connectedWallets:p,walletType:b.type,chain:e}),A=B?gr(B,tk):"",I=dr(l(),e),X=!p.find(pe=>pe.walletType===b.type&&pe.chain===e),se=I&&X&&b.state===xm.CONNECTED,J=se?vm.t({id:"Add {chain} chain",values:{chain:e}}):A,P=i(async()=>{let pe=b.state===xm.DISCONNECTED,Q=(b.isHub||!!b.needsNamespace)&&!A;pe?c(b):Q?(await T(b.type),c(b)):se?(h({walletType:b.type,chain:e,address:B??""}),f(!0)):n({walletType:b.type,chain:e,address:B??""})},"onSelectableWalletClick"),K=m?.chain?rr(m.chain,l()):void 0;return Ze.createElement(Ze.Fragment,{key:`${b.title}_${K}`},!!m&&Ze.createElement(R,{open:!!m&&d,container:E,onClose:()=>{h(null)}},Ze.createElement(Na,{displayName:K,onConfirm:()=>{x(m)}})),g&&Ze.createElement(R,{open:!!g,onClose:C.bind(null,null),container:E},Ze.createElement(km,{status:g,displayName:K,image:b.image}),Ze.createElement(RT,{direction:"vertical",size:32})),Ze.createElement(ek,{key:b.type,description:J,onClick:P,selected:o(b.type,e),disabled:!s,...b}))}),Ze.createElement(uo,{wallet:u,onClose:()=>{c(void 0)},onConnect:b=>{t.onConnect&&b.status==="connected"&&(u?.type?t.onConnect(u.type):JT(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Ze.createElement(cm,{selected:!1,onClick:a},Ze.createElement(wm,{variant:"label",size:"medium"},vm.t("Show more wallets"),Ze.createElement(wm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",N-(r??0)))))}i(ws,"WalletList");var pk=2;function Nm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=lk(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:h,setCustomDestination:d}=O(),{config:f,connectedWallets:g,setWalletsAsSelected:C}=y(),[S,T]=So(""),[k,v]=So([]),[w,N]=So(""),[M,x]=So(null),[E,b]=So(!!h),B=sk(()=>ao({filter:"all",quote:p}),[p]),A=ao({filter:"required",quote:p}),I=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),X=i(_=>A.includes(_),"isWalletRequiredFor"),se=ak(()=>g.filter(_=>_.selected&&B.includes(_.chain)),[g,B]),[J,P]=So(se()),[K,pe]=So([]),Q=i((_,G)=>pe(q=>q.concat({blockchain:_,walletType:G})),"addNextSelectedWallets"),me=k.length>0,Ge=i((_,G)=>!!J.find(q=>q.walletType===_&&q.chain===G&&q.selected&&(X(G)||!X(G)&&!h)),"isSelected"),st=i((_,G,q)=>{let ee=!1;return _.map(ne=>{if(ne.chain===G){let re=ne.selected;return!ee&&q?(ee=!0,re=!0):q||(re=!1),{...ne,selected:re}}return ne})},"updateSelectableWallets"),de=i(_=>{b(_),_?X(I?.name??"")||P(G=>st(G,I?.name||"",!1)):(d(""),P(G=>st(G,I?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ve=i(_=>{if(S&&T(""),Ge(_.walletType,_.chain))return;let q=g.find(ee=>ee.walletType===_.walletType&&ee.chain===_.chain);q&&(n(),_.chain===I?.name&&E&&!X(I.name)&&(b(!1),d(null)),P(ee=>ee.filter(ne=>ne.chain!==_.chain).concat({...q,selected:!0})))},"onChange"),V=i(()=>{let _=J.filter(G=>G.selected);C(_),u(_),m(!0),o()},"onConfirmBalance"),Ke=i(async()=>{v([]),N(""),x(null);let _=await r?.({selectedWallets:J.filter(q=>q.selected),customDestination:h}),G=_.warnings;G?.balance?.messages&&v(G.balance.messages),G?.quoteUpdate&&x(G.quoteUpdate),_.error&&N(Hc(_.error)),!_.error&&!G?.balance?.messages.length?V():v(G?.balance?.messages??[])},"onConfirmWallets");Am(()=>{P(_=>{let G=[];return _.forEach(q=>{!g.some(ne=>ne.chain===q.chain&&ne.walletType===q.walletType&&ne.address===q.address)||G.push(q)}),G=G.concat(g.filter(q=>!!!G.find(ne=>ne.chain===q.chain)&&q.selected&&B.includes(q.chain))),G})},[g,B]),Am(()=>{let _=[];K.length>0&&(K.forEach(G=>{let q=g.find(ee=>ee.chain===G.blockchain&&ee.walletType===G.walletType);q?Ve(q):_.push(G)}),pe(_))},[g,K]);let ft=document.getElementById(Pe.SWAP_BOX_ID);return Y.createElement(R,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:ft,...!S&&{styles:{container:{height:"100%"}},footer:Y.createElement(gm,null,Y.createElement(Im,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:lu(a,E,h,p,J,I),onClick:Ke,variant:"contained",type:"primary",fullWidth:!0,size:"large"},yo.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:Y.createElement(um,null,Y.createElement(mm,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:T.bind(null,"")},Y.createElement(rk,{size:16})),Y.createElement(xs,{variant:"headline",size:"small"},yo.t({id:"Your {blockchainName} wallets",values:{blockchainName:lt(S,l)}})))},anchor:"center"},Y.createElement(R,{open:me,onClose:v.bind(null,[]),container:ft},Y.createElement(ik,{title:yo.t("Insufficient account balance"),type:"error",description:Y.createElement(nk,{messages:k??[]})},Y.createElement(Im,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:V},yo.t("Proceed anyway")))),S&&Y.createElement(dm,null,Y.createElement("div",{className:fm()},Y.createElement(ws,{chain:S,isSelected:Ge,selectWallet:Ve,onShowMore:()=>T(S),onConnect:_=>{Q(S,_)}}))),!S&&Y.createElement(Y.Fragment,null,w&&Y.createElement(Y.Fragment,null,Y.createElement(Em,{variant:"alarm",type:"error",title:yo.t(w)}),Y.createElement(Rr,{size:12})),M&&Y.createElement(Y.Fragment,null,Y.createElement(Em,{variant:"alarm",type:"warning",title:Vr(M)}),Y.createElement(Rr,{size:12})),Y.createElement(hm,null,B.map((_,G)=>{let q=l.find($e=>$e.name===_),ee=`wallet-${G}`,ne=G===B.length-1,re=ne&&I&&f?.customDestination!==!1;return Y.createElement("div",{key:ee},Y.createElement(lm,null,Y.createElement(xs,{variant:"title",size:"xmedium"},yo.t({id:"Your {blockchainName} wallets",values:{blockchainName:q?.shortName}})),Y.createElement(xs,{variant:"label",color:"$neutral700",size:"medium"},yo.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:q?.shortName}}))),Y.createElement(Rr,{size:24}),Y.createElement(pm,null,Y.createElement(ws,{chain:_,isSelected:Ge,selectWallet:Ve,limit:pk,onShowMore:()=>T(q?.name??""),onConnect:$e=>{Q(_,$e)}})),!ne&&Y.createElement(Rr,{size:32}),re&&Y.createElement(sm,{blockchain:I,open:E,handleOpenChange:de}))}))))}i(Nm,"ConfirmWalletsModal");import{i18n as Ak}from"@lingui/core";import{Alert as Nk,Button as Wk,InfoIcon as Bk}from"@rango-dev/ui";import tt from"react";import{Alert as mk,Button as dk,Divider as Is,NoRouteIcon as fk,RefreshIcon as gk,Typography as _m}from"@rango-dev/ui";import et from"react";import{i18n as Wm}from"@lingui/core";var ck=24,uk=60;function Bm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:te().genericServerError,action:{onClick:n,title:Wm.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:te().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Wm.t("Reset")}},description:te().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:te().noResultError.description}}i(Bm,"makeInfo");var bs=(o=>(o[o.small=ck]="small",o[o.large=uk]="large",o))(bs||{}),Es=(o=>(o.small="small",o.large="medium",o))(Es||{});import{styled as ei}from"@rango-dev/ui";var Mm=ei("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Lm=ei("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Pm=ei("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Dm=ei("div",{padding:"$6 $0"});function bn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Bm(o,r,()=>a(s,!0),e);return et.createElement(Mm,null,et.createElement(fk,{size:bs[n],color:"gray"}),et.createElement(Is,{size:4}),et.createElement(_m,{variant:"title",size:Es[n]},te().noResultError.title),n==="large"&&et.createElement(Is,{size:4}),!!l.description&&et.createElement(Lm,{size:n},et.createElement(_m,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),et.createElement(Is,{size:n==="large"?"24":"4"}),!!l.alert&&et.createElement(Pm,{size:n},et.createElement(mk,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&et.createElement(dk,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:et.createElement(Dm,null,et.createElement(gk,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(bn,"NoResult");import{i18n as En}from"@lingui/core";import{Button as yk,Divider as Sk,MessageBox as Ck,Typography as Tk,WarningIcon as kk}from"@rango-dev/ui";import _t from"react";import{Typography as Um}from"@rango-dev/ui";import Ns from"react";import{darkTheme as hk,styled as ti}from"@rango-dev/ui";var $m=ti("div",{width:"100%"}),As=ti("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Fm=ti("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${hk} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Om=ti("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function zm(t){let{title:e,value:o,valueColor:n}=t;return Ns.createElement(Fm,null,Ns.createElement(Um,{size:"medium",variant:"label",className:"_title"},e),Ns.createElement(Um,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(zm,"QuoteErrorsModalItem");function Qm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:En.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:En.t("Gas cost"),value:L(r.totalFee,2,2)},{title:En.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:En.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return _t.createElement(R,{footer:_t.createElement(yk,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:_t.createElement(kk,null),fullWidth:!0,disabled:a,onClick:n},te().highValueLossError.confirmMessage),open:e,onClose:o,container:W()},_t.createElement(Ck,{type:s,title:te().highValueLossError.impactTitle,description:te().highValueLossError.description}),_t.createElement(As,null,_t.createElement(Sk,{size:"4"}),_t.createElement(Tk,{size:"small",variant:"title"},En.t("Details")),_t.createElement(As,null,l.map((p,u)=>_t.createElement(zm,{key:u,...p})))))}i(Qm,"HighValueLossWarningModal");import{i18n as Ws}from"@lingui/core";function qm(t,e){let o={alertType:"warning",title:"",action:null};return e?(o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Ws.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o):t?(t.type===0&&(Pt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=te().highValueLossError.title),t.type===1&&(o.title=te().unknownPriceError.title),t.type===2&&(o.title=Ws.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings"),t.type===3&&(o.title=Ws.t("Caution, your slippage is high."),o.action="change-settings"),o):null}i(qm,"makeAlerts");import{i18n as Yo}from"@lingui/core";import{Button as Hm,Divider as Gm,MessageBox as vk,Typography as wk}from"@rango-dev/ui";import Co from"react";import{useNavigate as xk}from"react-router-dom";function Vm(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=xk(),u=e??o;return Co.createElement(R,{anchor:"bottom",open:n,prefix:Co.createElement(Hm,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>p("../"+$.settings)},Co.createElement(wk,{variant:"label",size:"medium",color:"$neutral900"},Yo.t("Change settings"))),container:W(),onClose:r},Co.createElement(vk,{type:"warning",title:s.type===3?Yo.t("High slippage"):Yo.t("Low slippage"),description:s.type===3?Yo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Yo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},Co.createElement(Gm,{size:18}),Co.createElement(Gm,{size:32}),Co.createElement(Hm,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Yo.t("Confirm anyway"))))}i(Vm,"SlippageWarningModal");import{Button as bk,MessageBox as Ek,WarningIcon as Ik}from"@rango-dev/ui";import oi from"react";function Km(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return oi.createElement(R,{footer:oi.createElement(bk,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:oi.createElement(Ik,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:W()},oi.createElement(Ek,{type:"warning",title:te().unknownPriceError.impactTitle,description:te().unknownPriceError.description}))}i(Km,"UnknownPriceWarningModal");function In(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},h=o?.type===0||o?.type===1,d=qm(e,o?.type===3||o?.type===4?o:null);return d&&!n&&(d.action=null),tt.createElement(tt.Fragment,null,h&&tt.createElement(bn,{error:o,fetch:s}),!!d&&tt.createElement($m,null,tt.createElement(Nk,{title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:tt.createElement(Om,{onClick:l},tt.createElement(Bk,{size:12,color:"gray"}))},...d.action==="change-settings"&&{action:tt.createElement(Wk,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:d.alertType,onClick:c},Ak.t("Change"))}})),e&&tt.createElement(tt.Fragment,null,e.type===0&&tt.createElement(Qm,{...m,warning:e}),(e.type===3||e.type===2)&&tt.createElement(Vm,{...m,warning:e}),e.type===1&&tt.createElement(Km,{...m,warning:e})))}i(In,"QuoteWarningsAndErrors");import lv from"bignumber.js";import hi from"react";import{i18n as To}from"@lingui/core";import{Alert as Xk,Divider as Jo,FullExpandedQuote as Yk,InfoIcon as Zk,NumericTooltip as bd,QuoteTag as Jk,StepDetails as Rk,TokenAmount as ev,Typography as Ro}from"@rango-dev/ui";import Os from"bignumber.js";import F,{useRef as tv,useState as ov}from"react";import{styled as Bs}from"@rango-dev/ui";var Ms=Bs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),jm=Bs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Xm=Bs("div",{width:"100%",display:"flex"});import*as ni from"@radix-ui/react-collapsible";import{Button as Mk,css as An,darkTheme as we,Image as Ym,styled as Ue,Typography as Lk}from"@rango-dev/ui";var Pk=300,Zm=Ue(ni.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${we} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Jm=An({padding:"$10 $15"}),Rm=Ue(Mk,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${we} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${we} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${we} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),ed=Ue("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${we} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${we} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${we} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${we} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${we} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${we} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${we} &`]:{backgroundColor:"$neutral400"}}}}]}),td=An({width:"100%",padding:"$15 $15 $10 $15"}),od=An({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Zo=An({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),nd=An({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${we} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),rd=Ue(ni.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${Ym}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Ym}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${we} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),id=Ue("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),ad=Ue(jr,{width:"100%",background:"inherit"}),Ls=Ue("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${Pk}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),UF=Ue("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),sd=Ue("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${we} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),ld=Ue("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Ps=Ue(Lk,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),pd=Ue("div",{display:"flex",flexWrap:"wrap"}),Ds=Ue("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),cd=Ue("div",{display:"flex"}),ri=Ue("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${we} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as _k,CloseIcon as $k,Divider as si,IconButton as Fk,NumericTooltip as Ok,QuoteCost as Uk,Typography as St}from"@rango-dev/ui";import Z,{useState as fd}from"react";import{css as Dk,styled as ii}from"@rango-dev/ui";var ai=ii("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),_s=ii("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),ud=ii("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),md=ii("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),dd=Dk({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var zk=i(t=>t.fee.isZero()?null:Z.createElement(ai,null,Z.createElement(St,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(St,{variant:"label",size:"medium"},"$",L(t.fee,4,4))),"NonPayableFee");function $s(t){let[e,o]=fd(!1),[n,r]=fd(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,timeWarning:c,showModalFee:m,fullExpandedMode:h=!1}=t,d=s?.swaps??[],f=h?ro():W(),g=Yc(d);return Z.createElement(Z.Fragment,null,Z.createElement(Uk,{onClickFee:m?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,timeWarning:c,time:p,steps:a,tooltipGas:m?At.t("View more info"):void 0,tooltipContainer:f}),Z.createElement(R,{container:f,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Z.createElement(md,{style:{textAlign:h?"left":"center"}},Z.createElement(St,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Z.createElement(Fk,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement($k,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(ud,null,Z.createElement(St,{variant:"title",size:"small"},At.t("Details")),Z.createElement(si,{size:10}),Object.entries(g.payable).flatMap(([C,S])=>S.map((T,k)=>{let v=`payable-fee-${k}`,w=Da(T);return Z.createElement(ai,{key:v},Z.createElement(St,{variant:"label",size:"medium",color:"neutral600"},Ba(C,At.t)),Z.createElement(Ok,{content:T.amount,container:f},Z.createElement(St,{variant:"label",size:"medium"},L(T.amount,2,2)," ",T.asset.symbol," ($",L(w,4,4),")")))})),Z.createElement(ai,{className:"total_payable_fee"},Z.createElement(St,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Z.createElement(St,{variant:"label",size:"medium"},"$",L(l,4,4))),Z.createElement(_s,null),Object.keys(g.nonePayable).length&&Z.createElement(Zr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Z.createElement("div",{className:dd()},Z.createElement(St,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Z.createElement(si,{size:4,direction:"horizontal"}),Z.createElement(Xr,{orientation:n?"up":"down"},Z.createElement(_k,{size:12,color:"gray"}))),open:n},Z.createElement(St,{size:"small",variant:"title"},At.t("Description")),Z.createElement(si,{size:4}),Z.createElement(St,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),Z.createElement(si,{size:10}),Object.entries(g.nonePayable).map(([C,S],T)=>{let k=Xc(S),v=Ba(C,At.t),w=`non-payable-fee-${T}`;return Z.createElement(zk,{key:w,fee:k,label:v})}),Z.createElement(_s,null)))))}i($s,"QuoteCostDetails");import{i18n as yd}from"@lingui/core";import{TokenAmount as Sd}from"@rango-dev/ui";import li from"react";import{css as Qk,styled as qk}from"@rango-dev/ui";var gd=qk("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),hd=Qk({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Nn(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return li.createElement(gd,null,li.createElement(Sd,{direction:"horizontal",label:yd.t("Swap input"),type:"input",tooltipContainer:W(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),li.createElement("div",{className:hd()}),li.createElement(Sd,{direction:"horizontal",tooltipContainer:W(),label:yd.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(Nn,"QuoteSummary");import{i18n as wd}from"@lingui/core";import{ChevronDownIcon as Vk,ChevronRightIcon as Kk,Divider as Fs,Image as jk,Tooltip as di,Typography as ci}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as Hk,useState as Wn}from"react";var Cd=480,Td=768,kd=1024,vd=1200,Gk=i(()=>{let[t,e]=Wn(!1),[o,n]=Wn(!1),[r,a]=Wn(!1),[s,l]=Wn(!1),[p,u]=Wn(!1),c=i(()=>{e(window.innerWidth<=Cd),n(window.innerWidth>Cd&&window.innerWidth<=Td),a(window.innerWidth>Td&&window.innerWidth<=kd),l(window.innerWidth>kd&&window.innerWidth<=vd),u(window.innerWidth>vd)},"handleResize");return Hk(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),pi=Gk;var ui=4,mi=6,Bn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||W();return U.createElement(di,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(id,{className:n,state:a},U.createElement(jk,{src:o,size:16})))},"ImageComponent");function xd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||W(),u=r.length,c=du(r),{isTablet:m,isMobile:h}=pi();return U.createElement(rd,{listItem:s==="list-item",ref:d=>e.current=d,selected:o,onClick:d=>{d.stopPropagation(),n(f=>!f)}},U.createElement("div",{className:Zo()},U.createElement(ci,{variant:"body",size:"xsmall"},wd.t("Via:")),U.createElement(Fs,{direction:"horizontal",size:4}),r.map((d,f)=>{let g=`item-${f}`,C=U.createElement(Ls,null,U.createElement(Kk,{size:12,color:"black"}));return h||m?U.createElement(U.Fragment,{key:g},U.createElement(Bn,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:g},u<=ui||u>ui&&f<ui-1?U.createElement(U.Fragment,null,U.createElement(Bn,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&U.createElement(U.Fragment,null,C)):f===ui-1&&U.createElement(di,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Zo()},C,r.map((S,T)=>{let k=`image-${T}`;return T>=f&&U.createElement(U.Fragment,{key:k},U.createElement(Bn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),T!==u-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Ds,{state:r.find((S,T)=>T>=f&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(ci,{size:"xsmall",variant:"body"},"+",u-f))))})),U.createElement("div",{className:Zo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Zo()},U.createElement(ci,{variant:"body",size:"xsmall"},wd.t("Chains:")),U.createElement(Fs,{direction:"horizontal",size:4}),c.map((d,f)=>U.createElement(U.Fragment,{key:d.displayName},c.length<=mi||c.length>mi&&f<mi-1?U.createElement(di,{container:p,side:"bottom",content:d.displayName,sideOffset:4},U.createElement(Bn,{content:"",src:d.image,open:!1,className:f!==0?"blockchainImage":""})):f===mi-1&&U.createElement(di,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Zo()},c.map((g,C)=>C>=f&&U.createElement(Bn,{key:g.displayName,content:"",src:g.image,open:!1,className:C>f?"blockchainImage":"",container:l})))},U.createElement(Ds,{className:"blockchainImage"},U.createElement(ci,{size:"xsmall",variant:"body"},"+",c.length-f))))),U.createElement(Fs,{direction:"horizontal",size:32}))),U.createElement(Ls,{orientation:a?"up":"down"},U.createElement(Vk,{size:12,color:"black"}))))}i(xd,"QuoteTrigger");function Us(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:h}=t,d=y().blockchains(),{findToken:f}=y(),g=y().swappers(),{customSlippage:C,slippage:S}=y(),T=C||S,[k,v]=ov(t.expanded),w=tv(null),N=L(o.value,6,6),M=L(n.value,6,6),x=n.usdValue?L(n.usdValue,4,4):"",E=ct(o.usdValue,n.usdValue??null),b=L(E,2,2),B=Pt(E??0),A=i((de,Ve)=>de.map((V,Ke)=>{let ft,_=r?.type===3&&r.swap.swapperId===V.swapperId,G=r?.type===4&&r.recommendedSlippages?.has(Ke),q=a?.type===2&&a.recommendedSlippages?.has(Ke),ee=_||G,ne=q;ee?ft="error":ne&&(ft="warning");let re=ee?To.t("Slippage Error"):To.t("Slippage Warning");return _&&(re=To.t("Bridge Limit Error")),{swapper:{displayName:an(V.swapperId,g)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:lt(V.from.blockchain,d)??"",image:V.from.blockchainLogo},price:{value:Ke===0&&!Ve?L(o.value,6,6):L(V.fromAmount,6,6),usdValue:L((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:Ke===0?o.value:V.fromAmount,realUsdValue:new Os(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:lt(V.to.blockchain,d)||"",image:V.to.blockchainLogo},price:{value:L(V.toAmount,6,6),usdValue:L((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new Os(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:ft,alerts:ee||ne?F.createElement(jm,{dense:m},F.createElement(Xk,{variant:"alarm",type:ee?"error":"warning",title:re,footer:F.createElement(Xm,null,_&&F.createElement("div",null,F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Jo,{direction:"vertical",size:2}),F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {amount} {symbol}",values:{amount:L(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(G||q)&&!_&&F.createElement("div",null,F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(Ke)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(Ke)}}})),F.createElement(Jo,{direction:"vertical",size:2}),F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {userSlippage}",values:{userSlippage:T}}))))})):void 0,time:pn(V.estimatedTimeInSeconds),fee:L(Pa(V,f),2,2),internalSwaps:V.internalSwaps?A(V.internalSwaps):void 0}}),"getQuoteSteps"),I=A(e?.swaps??[]),X=I.length,se=h||W(),J=gu(t.quote.tags||[]),P=!!c,K=pr(e?.swaps),pe=pn(K),Q=Br(e?.swaps??[],f),me=L(Q,2,2),Ge=Q.gte(new Os(zc)),st=K/qc>=Qc;return m?F.createElement(Yk,{selected:l,fee:me,time:pe,tooltipContainer:ro(),steps:I,tags:J,quoteCost:F.createElement($s,{quote:e,fullExpandedMode:!0,time:pe,fee:me,feeWarning:Ge,timeWarning:st,showModalFee:u,steps:X}),percentageChange:b,warningLevel:B,outputPrice:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(ed,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:td()},!p&&J.length?F.createElement(F.Fragment,null,F.createElement(cd,null,J.map((de,Ve)=>{let V=`${de.value}_${Ve}`;return F.createElement(F.Fragment,{key:V},F.createElement(Jk,{label:de.label,value:de.value}),F.createElement(Jo,{size:4,direction:"horizontal"}))})),F.createElement(ri,null),!P&&F.createElement(Jo,{size:4})):null,F.createElement("div",{id:"portal-root",className:od()},F.createElement($s,{quote:e,time:pe,fee:me,feeWarning:Ge,timeWarning:st,showModalFee:u,steps:X}),P&&F.createElement(Rm,{onClick:de=>{de.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Ro,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},To.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:nd()},F.createElement(ld,null,F.createElement(Zk,{size:12,color:"gray"})),F.createElement(pd,null,F.createElement(Ps,{size:"small",variant:"body"},`${N} ${I[0].from.token.displayName} = `),F.createElement(bd,{content:n.value,container:se,open:n.value?void 0:!1},F.createElement(Ps,{size:"small",variant:"body"},"\xA0",`${M} ${I[I.length-1].to.token.displayName}`))),F.createElement(bd,{content:n.usdValue,container:se},F.createElement(Jo,{size:2,direction:"horizontal"}),F.createElement(Ro,{color:"$neutral600",size:"xsmall",variant:"body"},`($${x})`))),s==="list-item"&&F.createElement(ev,{tooltipContainer:se,type:"output",direction:"vertical",price:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:I[X-1].to.token.displayName,image:I[X-1].to.token.image},chain:{image:I[X-1].to.chain.image},percentageChange:b,warningLevel:B}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Nn,{from:I[0].from,to:I[X-1].to,percentageChange:b,warningLevel:B}),F.createElement(Jo,{size:4}))),F.createElement(Zm,{selected:l,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:v},F.createElement(xd,{type:s,quoteRef:w,selected:l,setExpanded:v,container:se,expanded:k,steps:I}),F.createElement(ad,{open:k},F.createElement(sd,null),F.createElement("div",{className:Jm()},I.map((de,Ve)=>{let V=`item-${Ve}`;return F.createElement(Rk,{type:"quote-details",key:V,tooltipContainer:se,step:de,hasSeparator:Ve!==I.length-1,state:de.state})})))))}i(Us,"Quote");import{Divider as av,Skeleton as sv}from"@rango-dev/ui";import Ft from"react";import{darkTheme as nv,styled as fi}from"@rango-dev/ui";var Ed=fi("div",{$$color:"$colors$neutral100",[`.${nv} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Id=fi("div",{paddingTop:"$2"}),Ad=fi("div",{paddingLeft:"$8"}),Nd=fi("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Od,Divider as Ct,Skeleton as ot}from"@rango-dev/ui";import z from"react";import{css as rv,styled as $t}from"@rango-dev/ui";var zs=$t("div",{display:"flex"}),Wd=$t("div",{padding:"$10 $0 $20"}),Bd=$t("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Md=$t("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Ld=$t("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Pd=$t("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Dd=$t("div",{width:"65%",display:"flex",justifyContent:"start"}),_d=$t("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),$d=$t("div",{padding:"$15 $0 $15 $0"}),Fd=rv({display:"flex",justifyContent:"space-between",alignItems:"center"});function Mn(t){let{type:e,tagHidden:o=!0}=t,n=z.createElement(Ld,null,z.createElement(Dd,null,z.createElement(Od,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),z.createElement(Ct,{size:8,direction:"horizontal"}),z.createElement(_d,null,z.createElement(ot,{height:10,width:60,variant:"rounded"}),z.createElement(Ct,{size:4}),z.createElement(ot,{height:15,variant:"rounded"}))),z.createElement(ot,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return z.createElement("div",null,!o&&z.createElement(z.Fragment,null,z.createElement(zs,null,z.createElement(ot,{width:65,height:20,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(ot,{width:65,height:20,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(ot,{width:65,height:20,variant:"rounded"})),z.createElement(ri,null),!r&&z.createElement(Ct,{size:4})),z.createElement("div",{className:Fd()},z.createElement(zs,null,z.createElement(ot,{width:60,height:10,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(ot,{width:60,height:10,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(ot,{width:60,height:10,variant:"rounded"})),r&&z.createElement(ot,{width:85,height:24,variant:"rounded"})),e==="basic"&&z.createElement(Wd,null,z.createElement(ot,{height:15,width:148,variant:"rounded"})),e==="list-item"&&z.createElement(Bd,null,z.createElement(Md,null,z.createElement(Od,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),z.createElement(Ct,{direction:"horizontal",size:4}),z.createElement(ot,{height:15,width:150,variant:"rounded"})),z.createElement(Ct,{size:10}),z.createElement(ot,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&z.createElement(z.Fragment,null,z.createElement(Ct,{size:4}),z.createElement($d,null,n,z.createElement(Pd,null),n),z.createElement(Ct,{size:12})))}i(Mn,"QuoteSummarySkeleton");import{ChainToken as Hd,Divider as qs,NextIcon as iv,Skeleton as gi}from"@rango-dev/ui";import xe from"react";import{styled as Ln}from"@rango-dev/ui";var Ud=Ln("div",{display:"flex",alignItems:"start"}),zd=Ln("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Qs=Ln("div",{display:"flex",alignItems:"center",flexGrow:1}),Qd=Ln("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),qd=Ln("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return xe.createElement(xe.Fragment,null,xe.createElement(qd,null,xe.createElement(gi,{height:22,width:22,variant:"circular"}),xe.createElement(qs,{direction:"horizontal",size:8}),xe.createElement(gi,{height:15,width:148,variant:"rounded"})),xe.createElement(Ud,null,xe.createElement(Nd,{hideSeparator:!e}),xe.createElement(zd,{extraSpace:e},xe.createElement(Qs,null,xe.createElement(Hd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),xe.createElement(qs,{direction:"horizontal",size:8}),xe.createElement(gi,{height:12,variant:"rounded"})),xe.createElement(Qd,null,xe.createElement(iv,{color:"gray",size:16})),xe.createElement(Qs,null,xe.createElement(Hd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),xe.createElement(qs,{direction:"horizontal",size:8}),xe.createElement(gi,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function Pn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ft.createElement(Ed,{expanded:o,rounded:e!=="basic"},Ft.createElement(Mn,{type:e,tagHidden:n}),Ft.createElement(Id,null,Ft.createElement(sv,{height:15,variant:"rounded"})),o&&Ft.createElement(Ad,null,Ft.createElement(av,{size:24}),Ft.createElement(Nt,null),Ft.createElement(Nt,null),Ft.createElement(Nt,{separator:!1})))}i(Pn,"QuoteSkeleton");function ko(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:p,showModalFee:u,selected:c,onClickAllRoutes:m,fullExpandedMode:h=!1,container:d}=t,{inputAmount:f,inputUsdValue:g,toToken:C}=O(),S=e?.outputAmount?new lv(e?.outputAmount):null,T=e?.outputAmount?Kt(e?.outputAmount,fo(e)||C?.usdPrice):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?hi.createElement(Ms,null,hi.createElement(Pn,{tagHidden:l,type:o,expanded:s})):v?hi.createElement(Ms,{onClick:()=>p?.(e)},hi.createElement(Us,{quote:e,error:r,container:d,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:h,input:{value:f,usdValue:g?.toString()??""},output:{value:S?.toString()??"",usdValue:T?.toString()??""}})):null}i(ko,"QuoteInfo");import{calculatePendingSwap as mv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as dv}from"react";import{useRef as pv,useState as cv}from"react";var uv=2e3;function yi({request:t}){let[e,o]=cv(!1),n=pv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,uv)),await s(l,!1)),"retryFetch"),s=i(async(l,p=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(p)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(yi,"useFetch");function Gd(){let{fetch:t,loading:e,cancelFetch:o}=yi({request:async(n,r)=>await bt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Gd,"useFetchConfirmQuote");function Si(t){if(!t.swaps)throw new Error(te().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Hs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(Si,"throwErrorIfResponseIsNotValid");function Hs(t){if(Vc(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=Kc(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Zc(t);if(o){let n=Mr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Hs,"getQuoteError");function Vd(t,e,o){let n=!1;t&&(n=mu(t,e));let r={quote:null,quoteUpdate:null,balance:null},a=zo(e,{fromToken:o.fromToken,toToken:o.toToken,findToken:o.findToken,userSlippage:o.userSlippage});a&&(r.quote=a),t&&n&&(nu(t,e)?r.quoteUpdate={type:3,newOutputAmount:L(Uo(e)),percentageChange:L(ct(Uo(t)??"",Uo(e)??""),null,2)}:_a(t,e)?r.quoteUpdate={type:0}:$a(t,e)?r.quoteUpdate={type:1}:Fa(t,e)&&(r.quoteUpdate={type:2}));let s=ru(e,o.selectedWallets,o.meta.blockchains);return s.length===0||(r.balance={messages:s}),r}i(Vd,"generateWarnings");function Ci(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(Ci,"handleQuoteErrors");function Gs(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=O(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),h=y().tokens(),{findToken:d}=y(),f=u||p,{fetch:g,cancelFetch:C,loading:S}=Gd();return dv(()=>C,[]),{loading:S,fetch:i(async k=>{let v=k.selectedWallets,w=k?.customDestination??a;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=v.reduce((x,E)=>(x[E.chain]=E.address,x),{}),M={requestId:r?.requestId||"",selectedWallets:N,destination:w||void 0};try{return await g(M,!0).then(x=>{let{result:E}=x;if(!E)throw new Error("Error fetching updated route");Si({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let b={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};n(b);let B={slippage:f.toString(),disabledSwappersGroups:c},A=Vd(r??void 0,b,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:d,selectedWallets:v,userSlippage:f});A.quoteUpdate&&s(!1),l();let I=!!A.balance,X=mv(o.toString(),E,tu(v),B,!I,{blockchains:m,tokens:h});return{quote:b,swap:X,error:null,warnings:A}})}catch(x){return Ci(x)}},"fetch"),cancelFetch:C}}i(Gs,"useConfirmSwap");var vv=hv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${jd}`]:{width:"$48",height:"$48"}}),wv=js({flexGrow:1,paddingRight:"$10"}),xv=js({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),bv=js({display:"flex",justifyContent:"space-between",alignItems:"center"});function Xd(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=kv(),[l,p]=Dn(""),u=!n,[c,m]=Dn(!1),[h,d]=Dn(!1),{isActiveTab:f}=le(),g=y().getDisabledLiquiditySources(),C=Tv(g),{manager:S}=fv(),{fetch:T,loading:k,cancelFetch:v}=Gs(),[w,N]=Dn({swap:null,error:null,warnings:null}),[M,x]=Dn(!1),E=i(async({selectedWallets:P,customDestination:K})=>{let pe=await T?.({selectedWallets:P,customDestination:K});return N(pe),pe},"onConfirmSwap"),b=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let P=`../${$.swaps}/${w.swap.requestId}`;s(P,{replace:!0}),setTimeout(()=>{e("")},0)}catch(P){p("Error: "+P?.message)}},"addNewSwap"),B=i(async()=>{d(!0),await b(),d(!1)},"onConfirm"),A=i(async()=>{w?.warnings?.quote&&!a?x(!0):await B()},"onStartConfirmSwap"),I=i(async()=>{N({error:null,swap:null,warnings:null}),T({selectedWallets:o,customDestination:r}).then(P=>{N(P)}).catch(P=>console.error(P))},"onRefresh");Ti(()=>{!!C.current.length&&!g.length&&I(),C.current=g},[g.length]),Ti(()=>{u&&v()},[u]),Ti(()=>{u&&m(u)},[u]),Ti(()=>{u||T({selectedWallets:o,customDestination:r}).then(P=>N(P)).catch(P=>console.error(P))},[]),Cv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let X=w.warnings?.quote??null,se=w.error,J=[];if(l&&J.push(be.createElement(Kd,{type:"error",variant:"alarm",title:l})),w.warnings?.quoteUpdate&&J.push(be.createElement(Kd,{variant:"alarm",type:"warning",title:w.warnings.quoteUpdate&&Vr(w.warnings.quoteUpdate)})),X||se){let P=`../${$.settings}`;J.push(be.createElement(In,{warning:X,error:se,couldChangeSettings:!1,refetchQuote:I,showWarningModal:M,confirmationDisabled:!f,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await b()},onChangeSettings:()=>s(P)}))}return be.createElement(oe,{header:{title:Vs.t("Confirm Swap"),onWallet:()=>{let P=`../${$.wallets}`;s(P)}},footer:be.createElement(vv,null,be.createElement("div",{className:wv()},be.createElement(gv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||h,disabled:!!w.error||!f,onClick:A},Vs.t("Start Swap"))),be.createElement(jd,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||h,disabled:!f,onClick:m.bind(null,!0)},be.createElement(Sv,{size:24})))},c&&be.createElement(Nm,{open:c,onClose:()=>m(!1),onCancel:v,loading:k,onCheckBalance:E}),be.createElement(ie,null,be.createElement("div",{className:bv()},be.createElement(yv,{variant:"title",size:"small"},Vs.t("You get")),be.createElement("div",{className:xv()},be.createElement(Ur,{onClick:!k&&!c&&!M?I:void 0}))),be.createElement(Ks,{size:"12"}),Nu(J.map((P,K)=>({element:P,key:`alert-${K}`})),be.createElement(Ks,{size:10})),J.length>0?be.createElement(Ks,{size:10}):null,be.createElement(ko,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:k,warning:w.warnings?.quote??null})))}i(Xd,"ConfirmSwapPage");import{i18n as Ot}from"@lingui/core";import{Button as il,CustomTokensZeroStateDarkIcon as zv,CustomTokensZeroStateIcon as Qv,DeleteIcon as qv,Divider as On,IconButton as Hv,MessageBox as Gv,NotFound as Vv,styled as sl}from"@rango-dev/ui";import fe,{useState as al}from"react";import{useNavigate as Kv}from"react-router-dom";import{CloseIcon as Iv,IconButton as Av,SearchIcon as Nv,TextField as Wv}from"@rango-dev/ui";import _n from"react";import{styled as Ev}from"@rango-dev/ui";var Yd=Ev("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Tt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return _n.createElement(Wv,{prefix:_n.createElement(Yd,null,_n.createElement(Nv,{color:"black"})),suffix:!!s.length&&_n.createElement(Av,{variant:"ghost",onClick:()=>p?.(""),size:"small"},_n.createElement(Iv,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Tt,"SearchInput");import{i18n as rl}from"@lingui/core";import{darkTheme as lf,Divider as tn,ExternalLinkIcon as Lv,Image as Pv,ListItemButton as Dv,NotFound as _v,PinIcon as $v,Skeleton as pf,Typography as wi,VirtualizedList as Fv}from"@rango-dev/ui";import H from"react";import{Divider as af,ListItem as Mv,Skeleton as $n}from"@rango-dev/ui";import kt from"react";import{css as en,darkTheme as Zd,ImageContainer as Bv,styled as mt,Typography as Jd}from"@rango-dev/ui";var Xs=en({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),Ys=en({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Zs=en({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Js=en({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Zd} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Rs=en({}),el=en(),Rd=mt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),tl=mt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),ki=mt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${Ys}`]:{[`& .${Js}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Rs}`]:{bottom:"-15px"},[`& .${Xs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Zs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),ol=mt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),nl=mt(Jd,{}),ef=mt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${el}`]:{$$color:"$colors$neutral600",[`.${Zd} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),vi=mt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),_U=mt("div",{display:"flex",alignItems:"center"}),tf=mt("div",{position:"relative",[`& ${Bv}`]:{borderRadius:"$xm",overflow:"hidden"}}),of=mt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),nf=mt(Jd,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),rf=mt("a",{"& svg:hover":{color:"$colors$info"}});function sf(t){return kt.createElement(ki,null,Array.from(Array(t.size),e=>kt.createElement(Mv,{key:e,hasDivider:!0,start:kt.createElement($n,{variant:"circular",width:35,height:35}),end:kt.createElement(vi,null,kt.createElement($n,{variant:"text",size:"large",width:70}),kt.createElement(af,{size:4}),kt.createElement($n,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement($n,{variant:"text",size:"large",width:90}),kt.createElement(af,{size:4}),kt.createElement($n,{variant:"text",size:"medium",width:90}))})))}i(sf,"LoadingTokenList");var Ov=20,Uv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:Ys()},o?H.createElement("div",{className:Xs()},o):H.createElement(tl,{className:Zs()},H.createElement(wi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(tn,{direction:"horizontal",size:4}),H.createElement(ol,{css:a},H.createElement(nl,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Js()} ${!o&&Rs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(tn,{size:4,direction:"horizontal"}),H.createElement(rf,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},H.createElement(Lv,{size:12}))))},"renderDesc");function Fn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,p=y().blockchains(),{getBalanceFor:u,fetchingWallets:c}=y(),{isTokenPinned:m}=y(),h=i(f=>{let g=fr(u(f));return s?s(f):c?H.createElement(vi,null,H.createElement(pf,{variant:"text",size:"large",width:70}),H.createElement(tn,{size:4}),H.createElement(pf,{variant:"text",size:"medium",width:50})):g&&H.createElement(ef,null,H.createElement(nf,{variant:"title",size:"small"},g.amount),H.createElement("div",null),g.usdValue&&H.createElement(wi,{variant:"body",className:el(),size:"xsmall"},`$${g.usdValue}`))},"endRenderer"),d=i(()=>H.createElement(Fv,{itemContent:f=>{let g=e[f],C=g.address||"",S=p.find(w=>w.name===g.blockchain),T=Za(S.color,"main"),k={$$color:T.main150,[`.${lf} &`]:{$$color:T.main750},backgroundColor:"$$color"},v={$$color:T.main750,[`.${lf} &`]:{$$color:T.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(Dv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":f,key:`${g.symbol}${g.address}`,id:`${g.symbol}${g.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[f]),start:H.createElement(tf,null,H.createElement(Pv,{src:g.image,size:30}),t.type!=="custom-token"&&m(g,t.type)&&H.createElement(of,null,H.createElement($v,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||g.name||!g.name&&!C?H.createElement(tl,null,H.createElement(wi,{variant:"title",size:"xmedium"},g.symbol),H.createElement(tn,{direction:"horizontal",size:4}),H.createElement(ol,{css:k},H.createElement(nl,{variant:"body",size:"xsmall",css:v},g.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?Uv({address:C,token:e[f],customCssForTag:k,customCssForTagTitle:v,name:g.name,url:S.info.addressUrl.split("{wallet}").join(C)}):g.name||void 0,end:h(g)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(wi,{variant:"label",size:"large"},rl.t("Select Token")),H.createElement(tn,{size:4})),H.createElement(Rd,null,H.createElement(tn,{size:4}),l==="loading"&&H.createElement(sf,{size:Ov}),l==="success"&&(e.length?H.createElement(ki,{as:"ul"},d()):!!o&&H.createElement(_v,{title:rl.t("No results found"),description:rl.t("Try using different keywords")}))))}i(Fn,"TokenList");var jv=sl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Xv=sl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Yv=sl(Hv,{"&:hover":{"& svg":{color:"$secondary550"}}});function cf(){let[t,e]=al(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:p}=Go({}),u=Kv(),[c,m]=al(!1),[h,d]=al(),f=i(T=>{let k=T.target.value;e(k)},"handleSearch"),g=p==="dark",C=n.filter(T=>Re(T.symbol,t)||Re(T.address||"",t)||Re(T.name||"",t)),S=i(()=>{if(h){let T=a?pt(a):null,k=r?pt(r):null,v=pt(h);T===v?l({token:null}):k===v&&s({token:null}),o(h)}m(!1)},"handleDeleteCustomToken");return fe.createElement(oe,{header:{title:Ot.t("Custom Tokens")}},fe.createElement(ie,null,fe.createElement(jv,null,n.length?fe.createElement(fe.Fragment,null,fe.createElement(Tt,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ot.t("Search Token"),onChange:f}),fe.createElement(On,{size:16}),fe.createElement(Fn,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:T=>fe.createElement(Yv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),d(T)}},fe.createElement(qv,{size:12,color:"gray"}))})):fe.createElement(Xv,null,fe.createElement(Vv,{icon:g?fe.createElement(zv,{size:200}):fe.createElement(Qv,{size:200}),title:Ot.t("No custom tokens"),description:Ot.t("press the button to add your custom token")})),fe.createElement(On,{size:20}),fe.createElement(il,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u($.addCustomTokens)},Ot.t("Add Custom Token"))),fe.createElement(R,{open:c,dismissible:!0,onClose:()=>m(!1),container:W()},fe.createElement(Gv,{title:Ot.t("Delete Custom Token"),type:"error",description:Ot.t("Are you sure you want to Delete this Token?")},fe.createElement(On,{size:40}),fe.createElement(On,{size:10}),fe.createElement(il,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ot.t("Yes, Delete it")),fe.createElement(On,{size:12}),fe.createElement(il,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ot.t("No, Continue"))))))}i(cf,"CustomTokensPage");import{i18n as Qe}from"@lingui/core";import{useManager as gw}from"@rango-dev/queue-manager-react";import{Button as fl,darkTheme as hw,Divider as wo,MessageBox as yw,NotFound as Sw,styled as gl,Typography as Ei}from"@rango-dev/ui";import{TransactionStatus as Qn}from"rango-types";import ae,{useMemo as Nf,useState as Ii}from"react";import{useNavigate as Cw}from"react-router-dom";import{FilterIcon as nw,Popover as rw}from"@rango-dev/ui";import vo from"react";import{css as Zv,darkTheme as xi,IconButton as Jv,styled as Un}from"@rango-dev/ui";var ll=Un("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),uf=Un(Jv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"},[`& ${ll}::before`]:{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),mf=Un("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),df=Un("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),ff=Zv({display:"flex",justifyContent:"space-between",alignItems:"center"}),gf=Un("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as hf}from"@lingui/core";import{Button as Rv,Divider as yf,ListItemButton as ew,Radio as tw,RadioRoot as ow,Typography as Sf}from"@rango-dev/ui";import nt from"react";function Cf(t){let{filterBy:e,onClickItem:o}=t;return nt.createElement(df,null,nt.createElement("div",{className:ff()},nt.createElement(Sf,{size:"small",variant:"body"},hf.t("Status")),nt.createElement(Rv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},hf.t("Reset"))),nt.createElement(yf,{size:10}),nt.createElement(ow,{value:e},nt.createElement(gf,null,t.list.map((n,r)=>nt.createElement(ew,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:nt.createElement(nt.Fragment,null,nt.createElement(yf,{direction:"horizontal",size:4}),nt.createElement(Sf,{size:"medium",variant:"body"},n.title)),start:nt.createElement(tw,{value:n.id}),onClick:o})))))}i(Cf,"FilterSelectorContent");function pl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return vo.createElement("div",null,vo.createElement(rw,{open:a,align:"end",onOpenChange:o,container:W(),content:vo.createElement(Cf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},vo.createElement(uf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},vo.createElement(ll,{isSelect:!!n},vo.createElement(nw,{size:16,color:"black"}),!!n&&vo.createElement(mf,null)))))}i(pl,"FilterSelector");import{i18n as sw}from"@lingui/core";import{Divider as xf,GroupedVirtualizedList as lw,Skeleton as pw,SwapListItem as bf,Typography as cw}from"@rango-dev/ui";import ze,{useCallback as Ef,useEffect as uw,useRef as mw,useState as dw}from"react";function Tf(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(Tf,"calculateGroupsSoFar");import{css as iw,darkTheme as aw,styled as zn}from"@rango-dev/ui";var cl=iw(),kf=zn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),ul=zn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${cl}`]:{$$color:"$colors$neutral600",[`.${aw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ml=zn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),vf=zn("div",{gap:"$10",display:"flex",flexDirection:"column"}),wf=zn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var fw=10;function dl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=dw([]),l=mw(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=Ef(Tf,[]),h=Ef(()=>{let d=e.length-l.current;d&&(l.current+=Math.min(d,fw),s(m(u,l.current)))},[e.length]);if(uw(()=>{r||h()},[r,h]),r){let d=[1,2];return ze.createElement(ze.Fragment,null,[d,d].map((g,C)=>ze.createElement(ul,{key:C},ze.createElement(ml,null,ze.createElement(pw,{variant:"text",width:60,size:"small"}),ze.createElement(xf,{size:16})),ze.createElement(xf,{size:4}),ze.createElement(vf,null,g.map((T,k)=>ze.createElement(bf,{isLoading:!0,key:k}))))))}return ze.createElement(lw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:d=>ze.createElement(ul,null,ze.createElement(ml,null,ze.createElement(cw,{variant:"label",size:"medium",className:cl()},c[d]))),itemContent:(d,f)=>{let g=p[d];if(!g)return null;let C=g.steps[0],S=g.steps[g.steps.length-1];return ze.createElement(kf,{key:g.requestId},ze.createElement(bf,{requestId:g.requestId,creationTime:g.creationTime,status:g.status,onClick:o,tooltipContainer:W(),onlyShowTime:c[f]===sw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:L(g.inputAmount,6,6),realAmount:g.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:L(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(dl,"HistoryGroupedList");import{i18n as bi}from"@lingui/core";import If from"dayjs";var Af=i(t=>{let e=new Map([["today",{title:bi.t("Today"),swaps:[]}],["week",{title:bi.t("This week"),swaps:[]}],["month",{title:bi.t("This month"),swaps:[]}],["year",{title:bi.t("This year"),swaps:[]}]]);function o(p,u){e.has(p)||e.set(p,{title:p,swaps:[]}),e.get(p)?.swaps.push(u)}i(o,"addYearsToOutput");let n=If();t.forEach(p=>{let u=Number(p.creationTime),c=If(u);if(n.isSame(c,"day"))e.get("today")?.swaps.push(p);else if(n.isSame(c,"week"))e.get("week")?.swaps.push(p);else if(n.isSame(c,"month"))e.get("month")?.swaps.push(p);else if(n.isSame(c,"year"))e.get("year")?.swaps.push(p);else{let m=new Date(u).getFullYear().toString();o(m,p)}});let r=Array.from(e.values()).filter(p=>p.swaps.length>0),a=r.flatMap(p=>p.swaps),s=r.map(p=>p.swaps.length),l=r.map(p=>p.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Tw=gl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),kw=gl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),vw=gl("div",{"._typography":{color:"$neutral700",[`.${hw}&`]:{color:"$neutral900"}}}),ww=[{id:Qn.SUCCESS,title:Qe.t("Complete")},{id:Qn.RUNNING,title:Qe.t("Running")},{id:Qn.FAILED,title:Qe.t("Failed")}],xw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Wf(){let t=Cw(),{manager:e,state:o}=gw(),n=ut(e).map(({swap:k})=>k),[r,a]=Ii(""),[s,l]=Ii(!1),p=!o.loadedFromPersistor,[u,c]=Ii(""),[m,h]=Ii(!1),d=i(k=>{let v=k.target.value;a(v)},"handleSearch"),f=Nf(()=>!r&&!u?n:n.filter(k=>{let{inputAmount:v,status:w,steps:N,requestId:M}=k;return(!r||wt(v,r)||wt(w,r)||xw(N,r)||wt(M,r))&&(!u||u===w)}),[n,r,u]),g=!f?.length&&!p,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(k){console.log(k)}},"onClear"),T=Nf(()=>!n.some(k=>k.status===Qn.SUCCESS||k.status===Qn.FAILED),[n]);return ae.createElement(oe,{header:{title:Qe.t("History"),suffix:ae.createElement(Gt,null,ae.createElement(fl,{id:"widget-history-clear-btn",disabled:T,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(Ei,{size:"medium",variant:"label",color:"error"},Qe.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(kw,null,ae.createElement(Tt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Qe.t("Search Transaction"),autoFocus:!0,onChange:d,style:{height:36},value:r}),ae.createElement(wo,{size:10,direction:"horizontal"}),ae.createElement(pl,{filterBy:u,open:s,onOpenChange:k=>l(k),onClickItem:k=>c(k),list:ww})),ae.createElement(wo,{size:"16"}),ae.createElement(Tw,null,g&&ae.createElement(wf,null,ae.createElement(wo,{size:32}),ae.createElement(Sw,{title:r?Qe.t("No results found"):Qe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Qe.t("Try using different keywords"):Qe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!g&&ae.createElement(dl,{list:f,onSwapClick:t,groupBy:Af,isLoading:p}))),ae.createElement(R,{open:m,onClose:C,container:W()},ae.createElement(wo,{size:20}),ae.createElement(yw,{type:"warning",title:Qe.t("Clear Transaction History"),description:ae.createElement(vw,null,ae.createElement(Ei,{variant:"body",size:"medium"},Qe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(wo,{size:"24"}),ae.createElement(Ei,{variant:"body",size:"small"},Qe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(wo,{size:30}),ae.createElement(fl,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Qe.t("Yes, Clear the history")),ae.createElement(wo,{size:10}),ae.createElement(fl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(Ei,{variant:"title",size:"medium",color:"primary"},Qe.t("No, Cancel")))))}i(Wf,"HistoryPage");import{i18n as jw}from"@lingui/core";import{Button as Xw,Divider as Zf,styled as Yw,WarningIcon as Zw}from"@rango-dev/ui";import Jw from"bignumber.js";import qe,{useEffect as Jf,useState as Rf}from"react";import{useNavigate as Rw}from"react-router-dom";import{i18n as Mf}from"@lingui/core";import{Alert as Ew,Divider as hl,NoRouteIcon as Iw,Typography as Aw}from"@rango-dev/ui";import xo from"react";import{styled as bw}from"@rango-dev/ui";var Bf=bw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function yl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Mt(t,e)?xo.createElement(Bf,null,xo.createElement(hl,{size:10}),xo.createElement(Iw,{size:24,color:"gray"}),xo.createElement(hl,{size:4}),xo.createElement(Aw,{variant:"title",size:"small"},Mf.t("No Routes Found")),xo.createElement(hl,{size:4}),xo.createElement(Ew,{title:Mf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(yl,"SameTokensWarning");import{i18n as Pw}from"@lingui/core";import{Header as Dw}from"@rango-dev/ui";import Jt,{useEffect as _w,useState as $w}from"react";import{i18n as Ww}from"@lingui/core";import{Divider as Cl,FullExpandedQuote as Bw,Typography as Mw}from"@rango-dev/ui";import ye from"react";import{styled as Sl}from"@rango-dev/ui";var Lf=Sl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Pf=Sl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Df=Sl("div",{width:"146px"});import{i18n as qn}from"@lingui/core";import{Select as Nw}from"@rango-dev/ui";import _f from"react";function Ai(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:qn.t("Smart Routing")},{value:"FEE",label:qn.t("Lowest Fee")},{value:"SPEED",label:qn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:qn.t("Maximum Return")},{value:"PRICE",label:qn.t("Maximum Output")}];return _f.createElement(Df,null,_f.createElement(Nw,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ai,"SelectStrategy");var $f=3;function Hn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:h,sortStrategy:d,error:f}=O(),{slippage:g,customSlippage:C}=y(),{findToken:S}=y(),T=l||W(),k=!!u&&u.results.length,v=C??g,w=i(x=>{if(!m||!h||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...x};return zo(E,{fromToken:m,toToken:h,userSlippage:v,findToken:S})},"getQuoteWarning"),N=f?.type===0||f?.type===1,M=u?.results?Dr(d,u?.results):[];return ye.createElement(ye.Fragment,null,a&&ye.createElement(ye.Fragment,null,ye.createElement(Pf,null,ye.createElement(Mw,{size:"xmedium",variant:"title"},Ww.t("Sort by")),ye.createElement(Ai,{container:T})),ye.createElement(Cl,{size:"10"})),e&&Array.from({length:$f},(x,E)=>ye.createElement(ye.Fragment,{key:E},s?ye.createElement(Bw,{loading:!0}):ye.createElement(Pn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==$f-1&&ye.createElement(Cl,{size:16}))),!e&&ye.createElement(ye.Fragment,null,k?M.map((x,E)=>{let b=w(x),B=Hs(x.swaps),A=M.length-1===E;return ye.createElement(ye.Fragment,{key:x.requestId},ye.createElement(ko,{showModalFee:r,container:T,selected:p?.requestId===x.requestId,tagHidden:!1,quote:{...x,requestAmount:u.requestAmount,validationStatus:null},loading:e,error:B?.options||null,warning:b,fullExpandedMode:s,onClick:I=>{B||c("warning",b),c("error",B?.options||null),o(I)},type:"list-item"}),!A&&ye.createElement(Cl,{size:16}))}):N&&ye.createElement(Lf,null,ye.createElement(bn,{size:s?"large":"small",error:f,fetch:n}))))}i(Hn,"Quotes");import{darkTheme as Lw,styled as Ff}from"@rango-dev/ui";var Of=Ff("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Lw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Uf=Ff("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Fw=100;function Tl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=$w(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=ro();return _w(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Fw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Of,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${qr()}`,id:Pe.EXPANDED_BOX_ID},Jt.createElement(Dw,{title:Pw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(Ai,{container:m}),Jt.createElement(ho,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(Uf,null,Jt.createElement(Hn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:ro(),onClickOnQuote:n,fullExpandedMode:c})))}i(Tl,"ExpandedQuotes");import{i18n as Kf}from"@lingui/core";import{SwapInput as jf}from"@rango-dev/ui";import Qw from"bignumber.js";import Gn from"react";import{ReverseIcon as zw}from"@rango-dev/ui";import vl from"react";import{keyframes as Ow,styled as zf}from"@rango-dev/ui";var kl=450,Uw=Ow({"0%":{transform:"rotateX(0deg) rotateY(0deg) rotateZ(0deg)"},"33%":{transform:"rotateX(0deg) rotateZ(78deg) rotateY(66deg)"},"66%":{transform:"rotateX(0deg) rotateZ(163deg) rotateY(66deg)"},"100%":{transform:"rotateX(0deg) rotateZ(180deg) rotateY(0deg)"}}),Qf=zf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),qf=zf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${Uw} ${kl}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function wl(){let t=O.use.switchFromAndTo();return vl.createElement(Qf,null,vl.createElement(qf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},kl),t()}},vl.createElement(zw,{size:12})))}i(wl,"SwitchFromAndToButton");import{styled as Hf}from"@rango-dev/ui";var Gf=Hf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Vf=Hf("div",{position:"relative"});function xl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:h,outputUsdValue:d,selectedQuote:f}=O(),{connectedWallets:g,getBalanceFor:C}=y(),S=a?C(a):null,T=fr(S)?.amount??"0",k=S?new Qw(S.amount).shiftedBy(-S.decimals):Ce,v=!!s&&Fp(g,s.name),w=!La(f,c,m),N=!La(f,c,d),M=!m||!d||!d.gt(0)?null:ct(m.toString(),d.toString());return Gn.createElement(Gf,null,Gn.createElement(Vf,null,Gn.createElement(jf,{label:Kf.t("From"),mode:"From",onInputChange:u,balance:T,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue:w?void 0:L(m,4,4),realUsdValue:w?void 0:m?.toString(),error:w?te().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:W(),onSelectMaxBalance:()=>{let x=L(k,S?.decimals),E=S?.amount?x:"";u(E)},anyWalletConnected:g.length>0}),Gn.createElement(wl,null)),Gn.createElement(jf,{sharpBottomStyle:!r&&(!!f||e),label:Kf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:L(ct(m,d),2,2),warningLevel:Pt(M??0),price:{value:L(h,6,6),usdValue:N?void 0:L(d,4,4),realValue:h?.toString(),realUsdValue:N?void 0:d?.toString(),error:N?te().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:W()}))}i(xl,"Inputs");import{useCallback as qw,useEffect as Hw,useRef as Gw,useState as Vw}from"react";function Xf(){let{fetch:t,loading:e,cancelFetch:o}=yi({request:async(n,r)=>await bt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Xf,"useFetchAllQuotes");var Kw=600;function Ni({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Xf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:p,inputUsdValue:u,selectedQuote:c,sortStrategy:m,resetQuote:h,error:d,warning:f,setSelectedQuote:g,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:T,affiliatePercent:k,affiliateRef:v,affiliateWallets:w,fetchStatus:N}=y(),M=y().getLiquiditySources(),x=y().getDisabledLiquiditySources(),E=y().excludeLiquiditySources(),{findToken:b}=y(),[B,A]=Vw(!0),I=Gw(p),X=T??S,J=!s||!l||Mt(s,l)||!cn(p),P=i(Q=>{A(Q)},"resetState"),K=i(Q=>{let{fromToken:me,toToken:Ge,inputAmount:st,liquiditySources:de,excludeLiquiditySources:Ve,disabledLiquiditySources:V,slippage:Ke,affiliateRef:ft,affiliatePercent:_,affiliateWallets:G}=Q;if(B||P(!0),!J&&me&&Ge){h();let q=eu({fromToken:me,toToken:Ge,inputAmount:st,liquiditySources:de,excludeLiquiditySources:Ve,disabledLiquiditySources:V,wallets:a,slippage:Ke,affiliateRef:ft,affiliatePercent:_,affiliateWallets:G});Bo("experimental",r)&&(q.experimental=!0),Bo("avoidNativeFee",r)&&(q.avoidNativeFee=!0),Bo("enableCentralizedSwappers",r)&&(q.enableCentralizedSwappers=!0),r?.maxLength&&(q.maxLength=r.maxLength),e(q).then(ee=>{let ne=Dr(m,ee.results),re=fu(c,ne,ee.requestAmount);A(!1),C("quotes",ee),g(re),Si({diagnosisMessages:ee.diagnosisMessages,requestId:re?.requestId||"",swaps:re?.swaps});let $e=fo(re)||Ge?.usdPrice,or=Cn(re)||me?.usdPrice,no=re&&zo(re,{fromToken:{...me,usdPrice:or},toToken:{...Ge,usdPrice:$e},userSlippage:X,findToken:b});C("warning",no)}).catch(ee=>{let{error:ne}=Ci(ee);(ne?.type===0||ne?.type===1)&&h(),ne?.type!==2&&(C("error",ne),A(!1))})}},"fetch"),pe=qw(Ep(Q=>{K(Q)},Kw),[J]);return Hw(()=>{if(!t){A(!1);return}if(N!=="success")return;if(J){A(!1),(c||d||f)&&h();return}if(!cn(p)||u?.eq(0)){P(!1),o();return}h(),P(!0);let Q=K;return I.current&&I.current!=p&&(Q=pe),I.current=p,Q({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:X,affiliateRef:v,affiliatePercent:k,affiliateWallets:w}),o},[N,p,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,M?.length,n,x.length,X,v,k,JSON.stringify(w)]),{fetch:()=>K({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:X,affiliateRef:v,affiliatePercent:k,affiliateWallets:w}),loading:B}}i(Ni,"useSwapInput");function Yf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ge.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Yf,"emitPreventableEvent");var ex=Yw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),tx=300;function eg(){let t=Rw(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:h}=O(),[d,f]=Rf(!1),{isLargeScreen:g,isExtraLargeScreen:C}=pi(),{fetch:S,loading:T}=Ni({refetchQuote:a}),{config:k,fetchStatus:v,connectedWallets:w}=y(),{isActiveTab:N}=le(),[M,x]=Rf(!1),b=jc({fetchMetaStatus:v,fetchingQuote:T,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),B=Gp(g,C,k?.variant),A=!!n&&!!e&&!!o&&new Jw(n).gt(0)&&!pu(e,o),I=A&&v==="success"&&T,J=(!B||B&&p?.results.length)&&(l||s);Jf(()=>{c(),h("refetchQuote",!0)},[]),Jf(()=>{f(A)},[A]);let P=(r||s)&&!M?S:void 0,K=i(Q=>{B&&d?(f(!1),setTimeout(()=>{t(Q)},tx)):t(Q)},"onHandleNavigation"),pe=i(Q=>{r?.requestId!==Q.requestId&&(x(!1),u(Q))},"onClickOnQuote");return qe.createElement(ex,null,qe.createElement(oe,{height:"auto",footer:qe.createElement(Xw,{id:`widget-swap-${b.action}-btn`,type:"primary",size:"large",disabled:b.disabled||!N,prefix:b.action==="confirm-warning"&&qe.createElement(Zw,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?Yf({type:"clickConnectWallet"},()=>K($.wallets)):b.action==="confirm-warning"?x(!0):K($.confirmSwap)}},b.title),header:{onWallet:()=>{K($.wallets)},hasBackButton:!1,title:k.title||jw.t("Swap"),suffix:qe.createElement(ho,{hidden:B?["refresh"]:void 0,onClickRefresh:P,onClickHistory:()=>K($.swaps),onClickSettings:()=>{K($.settings)}})}},qe.createElement(ie,null,qe.createElement(xl,{fetchingQuote:I,fetchMetaStatus:v,isExpandable:B,onClickToken:Q=>{K(Q==="from"?$.fromSwap:$.toSwap)}}),qe.createElement(Zf,{size:"2"}),B?null:qe.createElement(ko,{quote:r,loading:I,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{h("refetchQuote",!1),K($.routes)}:void 0}),J?qe.createElement(qe.Fragment,null,qe.createElement(Zf,{size:"10"}),qe.createElement(In,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!N,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:()=>{x(!1),m(!0),K($.confirmSwap)},onChangeSettings:()=>K($.settings)})):null,qe.createElement(yl,null))),B?qe.createElement(Tl,{loading:I,onClickOnQuote:pe,fetch:S,onClickRefresh:P,isVisible:d}):null)}i(eg,"Home");import{i18n as tg}from"@lingui/core";import{Alert as ox,Divider as nx,List as rx,ListItemButton as ix,Radio as ax,RadioRoot as sx,Typography as lx}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Zp,r=o?.language||Mo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Mo),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function og(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=Ye(),r=o.map(a=>{let{local:s,label:l,SVGFlag:p}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(lx,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(ax,{value:s}),start:Wt.createElement(p,null)}});return Wt.createElement(oe,{header:{title:tg.t("Language")}},Wt.createElement(ie,null,Wt.createElement(ox,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(nx,{size:"8"}),Wt.createElement(sx,{value:t},Wt.createElement(rx,{type:Wt.createElement(ix,{title:tg.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(og,"LanguagePage");import{i18n as Ut}from"@lingui/core";import{Button as dx,Checkbox as fx,Image as gx,ListItemButton as hx,NotFound as yx,Typography as Sx}from"@rango-dev/ui";import He,{useState as Cx}from"react";import{Checkbox as ux,Skeleton as rg}from"@rango-dev/ui";import Kn from"react";import{styled as bl}from"@rango-dev/ui";var Vn=bl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),El=bl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Il=bl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as px,styled as cx}from"@rango-dev/ui";var ng=cx(px,{height:61});var mx=30;function Al(){return Kn.createElement(Vn,null,Array.from(Array(mx),(t,e)=>Kn.createElement(ng,{hasDivider:!0,key:e,start:Kn.createElement(rg,{variant:"circular",width:35,height:35}),title:Kn.createElement(rg,{variant:"text",size:"large",width:90}),end:Kn.createElement(ux,{checked:!1})})))}i(Al,"LoadingLiquiditySourceList");function Nl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=Cx(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=yr(o,n),u={Exchanges:Ut.t("Exchanges"),Bridges:Ut.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(S=>c.includes(S.type)),h=m.length===m.filter(S=>S.selected).length,d=i(()=>{m.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),f=m.map(S=>{let{selected:T,groupTitle:k,logo:v,id:w,...N}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:He.createElement(gx,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(k)},end:He.createElement(fx,{checked:T,disabled:l}),title:He.createElement(Sx,{variant:"title",size:"xmedium"},Ut.t(k)),selected:T,groupTitle:k,logo:v,...N}}),g=i(S=>{let T=S.target.value;a(T)},"handleSearch"),C=f;return r&&(C=f.filter(S=>wt(S.groupTitle,r))),He.createElement(oe,{header:{title:Ut.t(t),suffix:He.createElement(El,null,He.createElement(dx,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:d},h?Ut.t("Deselect all"):Ut.t("Select all")))}},He.createElement(ie,{view:!0},He.createElement(Tt,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search {sourceType}",{sourceType:u[t]}),onChange:g}),e==="loading"&&He.createElement(Al,null),!C.length&&r?He.createElement(Il,null,He.createElement(yx,{title:Ut.t("No results found"),description:Ut.t("Try using different keywords")})):e==="success"&&He.createElement(Vn,{disabled:l},C.map(S=>{let{groupTitle:T,...k}=S;return He.createElement(He.Fragment,{key:S.id},He.createElement(hx,{style:{height:"61px"},...k,selected:!1,hasDivider:!0}))}))))}i(Nl,"LiquiditySourcePage");import{i18n as Tx}from"@lingui/core";import Wi from"react";import{useNavigate as kx}from"react-router-dom";function ig(){let t=kx(),e=Ye(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:p}=Ni({refetchQuote:n}),u=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${$.settings}`,m=`../${$.wallets}`;return Wi.createElement(oe,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Tx.t("Routes"),suffix:Wi.createElement(ho,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Wi.createElement(ie,null,Wi.createElement(Hn,{fetch:l,loading:p,onClickOnQuote:u})))}i(ig,"RoutesPage");import{i18n as mg}from"@lingui/core";import{Divider as dg,getCategoriesCount as Bx,SelectableCategoryList as Mx}from"@rango-dev/ui";import zt,{useState as fg}from"react";import{useNavigate as Lx}from"react-router-dom";import{i18n as Wl}from"@lingui/core";import{Divider as bx,Image as Ex,ListItemButton as Ix,NotFound as Ax,Typography as ug}from"@rango-dev/ui";import rt,{useEffect as Nx,useState as Wx}from"react";var ag=i((t,e,o)=>t.filter(n=>lr(n.type,o)).filter(n=>Re(n.name,e)||Re(n.displayName,e)),"filterBlockchains");import{ImageContainer as vx,styled as sg}from"@rango-dev/ui";var lg=sg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Bi=sg(kn,{padding:0,margin:0,listStyle:"none",[`& ${vx}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as wx,Skeleton as pg}from"@rango-dev/ui";import Mi from"react";var xx=20;function cg(){return Mi.createElement(Bi,null,Array.from(Array(xx),t=>Mi.createElement(wx,{key:t,hasDivider:!0,start:Mi.createElement(pg,{variant:"circular",width:35,height:35}),title:Mi.createElement(pg,{variant:"text",size:"large",width:90})})))}i(cg,"LoadingBlockchainList");function Bl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Wx(e),{fetchStatus:p}=y();Nx(()=>{l([...ag(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?rt.createElement(Ax,{title:Wl.t("No results found"),description:Wl.t("Try using different keywords")}):rt.createElement(Bi,{as:"ul",key:`${r}-${o}`},s.map(c=>rt.createElement(Ix,{key:`${c.name}-${c.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(c),start:rt.createElement(Ex,{src:c.logo,size:30}),title:rt.createElement(ug,{variant:"title",size:"medium"},c.displayName),id:c.name}))),"renderList");return rt.createElement(rt.Fragment,null,a&&rt.createElement(rt.Fragment,null,rt.createElement(ug,{variant:"label",size:"large"},Wl.t("Select Chain")),rt.createElement(bx,{size:4})),rt.createElement(lg,null,p==="loading"&&rt.createElement(cg,null),p==="success"&&u()))}i(Bl,"BlockchainList");function Li(t){let{type:e}=t,o=Ye(),[n,r]=fg(""),[a,s]=fg("ALL"),l=O.use.setToBlockchain(),p=O.use.setFromBlockchain(),{fetchStatus:u}=y(),c=Lx(),m=y().blockchains({type:e}),h=Bx(m),d=!t.hideCategory&&h!==1;return zt.createElement(oe,{header:{title:mg.t("Select Chain")}},zt.createElement(ie,{view:!0},d&&zt.createElement(zt.Fragment,null,zt.createElement(Mx,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),zt.createElement(dg,{size:24})),zt.createElement(Tt,{value:n,autoFocus:!0,placeholder:mg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),zt.createElement(dg,{size:16}),zt.createElement(Bl,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?c(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?p(f):l(f),o())}})))}i(Li,"SelectBlockchainPage");import{i18n as Di}from"@lingui/core";import{Divider as Tg}from"@rango-dev/ui";import bo,{useState as zx}from"react";import{useNavigate as Qx}from"react-router-dom";import{i18n as Pl}from"@lingui/core";import{BlockchainsChip as Pi,Divider as Sg,Image as Cg,Skeleton as Fx,Tooltip as Ox,Typography as Dl}from"@rango-dev/ui";import Me from"react";import{useEffect as _x}from"react";var gg=["ETH","COSMOS","OSMOSIS"];function Ml(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Px),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(Dx(s)),r=n.splice(a)}return{list:n,more:r}}i(Ml,"prepare");function Px(t,e){let o=gg,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(Px,"sortByMostUsedBlockchains");function Dx(t){return i(function(o,n){let r=t.findIndex(p=>p===o.name),a=t.findIndex(p=>p===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(Dx,"generateSortByPreferredBlockchainsFor");function hg(t,e){return!!e.list.find(o=>o.name===t)}i(hg,"isInVisibleList");function Ll(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();_x(()=>{if(e?.selected){let a=Ml(t,o,e);hg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Ml(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Ll,"usePrepareBlockchainList");import{styled as $x}from"@rango-dev/ui";var yg=$x("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var Ux=12;function _l(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Ll(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=O.use.resetToBlockchain(),u=O.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,h=!m&&c;return Me.createElement(Me.Fragment,null,Me.createElement(Sg,{size:12}),Me.createElement(Dl,{variant:"label",size:"large"},Pl.t("Select Chain")),Me.createElement(Sg,{size:12}),Me.createElement(yg,null,l==="loading"&&Array.from(Array(Ux),d=>Me.createElement(Fx,{key:d,variant:"rounded",height:50})),l==="success"&&Me.createElement(Me.Fragment,null,Me.createElement(Pi,{selected:!n,onClick:()=>{o==="from"?u():p()}},Me.createElement(Dl,{variant:"body",size:"xsmall",color:"secondary500"},Pl.t("All"))),s.list.map(d=>Me.createElement(Ox,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:W()},Me.createElement(Pi,{key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},Me.createElement(Cg,{src:d.logo,size:30})))),m?Me.createElement(Pi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Me.createElement(Cg,{src:s.more[0].logo,size:30})):null,h?Me.createElement(Pi,{onClick:a,key:"more-blockchains"},Me.createElement(Dl,{variant:"body",size:"xsmall",color:"secondary500"},Pl._("More +{count}",{count:s.more.length}))):null)))}i(_l,"BlockchainsSection");function $l(t){let{type:e}=t,o=Qx(),n=Ye(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=O(),{getBalanceFor:c}=y(),[m,h]=zx(""),f=(e==="source"?r:a)?.name??"",g=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:f,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),T=i(v=>{e==="source"?s({token:v,meta:{blockchains:g,tokens:C}}):l({token:v,meta:{blockchains:g,tokens:C}})},"updateToken"),k={source:Di.t("Source"),destination:Di.t("Destination")};return bo.createElement(oe,{header:{title:Di.t("Swap {type}",{type:k[e]})}},bo.createElement(ie,null,bo.createElement(_l,{blockchains:g,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{S(v)}}),bo.createElement(Tg,{size:24}),bo.createElement(Tt,{value:m,autoFocus:!0,placeholder:Di.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),bo.createElement(Tg,{size:16}),bo.createElement(Fn,{list:C,selectedBlockchain:f,searchedFor:m,type:e,onChange:v=>{T(v);let w=g.find(N=>v.blockchain===N.name);w&&S(w),n()}})))}i($l,"SelectSwapItemsPage");import{i18n as Ul}from"@lingui/core";import{Alert as fb,Button as gb,styled as hb}from"@rango-dev/ui";import Eo from"react";import{useInRouterContext as yb,useSearchParams as Sb}from"react-router-dom";import{i18n as Eg}from"@lingui/core";import{Divider as Ig,InfoIcon as Vx,SlippageIcon as Kx,TextField as jx,Tooltip as Xx,Typography as Ag}from"@rango-dev/ui";import it from"react";import{Chip as qx,styled as jn,TextField as Hx}from"@rango-dev/ui";var kg=jn("div",{paddingTop:"$5",padding:"$10 $5"}),vg=jn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Hx}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),wg=jn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),_i=jn("div",{maxWidth:"280px",padding:"$10"}),xg=jn(qx,{width:"61px",flexShrink:0});import{i18n as Fl}from"@lingui/core";import{Typography as Gx}from"@rango-dev/ui";import Xn from"react";function bg(){return Xn.createElement(_i,null,Xn.createElement(Gx,{variant:"label",size:"medium",color:"neutral700"},Fl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Xn.createElement("br",null),Xn.createElement("br",null),Xn.createElement("b",null,Fl.t("Warning")),":\xA0",Fl.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(bg,"SlippageTooltipContent");function Ol(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return it.createElement(kg,null,it.createElement(wg,null,it.createElement(Kx,{size:16,color:"gray"}),it.createElement(Ig,{direction:"horizontal",size:4}),it.createElement(Ag,{variant:"title",size:"xmedium"},Eg.t("Slippage tolerance per swap")),it.createElement(Ig,{direction:"horizontal",size:4}),it.createElement(Xx,{container:W(),side:"top",sideOffset:4,content:it.createElement(bg,null)},it.createElement(Vx,{color:"gray"}))),it.createElement(vg,null,Jp.map((r,a)=>{let s=`slippage-${a}`;return it.createElement(xg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),it.createElement(jx,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=oc&&s<=tc?n(s):n(null)},suffix:o&&it.createElement(Ag,{variant:"body",size:"small"},"%"),placeholder:Eg.t("Custom")})))}i(Ol,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as Ng,BridgesIcon as Yx,ChevronRightIcon as $i,DarkModeIcon as Wg,Divider as Yn,ExchangeIcon as Zx,InfinityIcon as Jx,InfoIcon as Rx,LanguageIcon as eb,LightModeIcon as Bg,List as tb,ListItem as ob,ListItemButton as nb,Skeleton as rb,styled as ib,Switch as ab,Tabs as sb,TargetIcon as lb,Tooltip as pb,Typography as Je}from"@rango-dev/ui";import D from"react";import{useNavigate as cb}from"react-router-dom";var ub=ib("div",{width:"202px",height:"$40"}),mb=[{id:"light",icon:D.createElement(Bg,{color:"black",size:24}),tooltip:D.createElement(Je,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:D.createElement(Wg,{color:"black",size:24}),tooltip:D.createElement(Je,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:D.createElement(Ng,{color:"black",size:24}),tooltip:D.createElement(Je,{size:"xsmall",variant:"body"},dt.t("Auto"))}],db=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(Ng,{...e});case"dark":return D.createElement(Wg,{...e});default:return D.createElement(Bg,{...e})}},"getThemeIcon");function Mg(){let t=cb(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(P=>P.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),h=je("theme",c),d=je("liquiditySource",c),f=je("language",c),g=je("customTokens",c),C=y().infiniteApprove,S=y().toggleInfiniteApprove,T=yr(p,u),k=T.filter(P=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(P.type)),v=k.length,w=k.filter(P=>P.selected).length,N=T.filter(P=>P.type==="DEX"),M=N.length,x=N.filter(P=>P.selected).length,E=i((P,K)=>{switch(l){case"loading":return D.createElement(rb,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(Je,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return D.createElement(Je,{variant:"body",size:"medium"},`${P} / ${K}`)}},"handleSwapperEndItem"),b={id:"widget-setting-bridge-item-btn",title:D.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:D.createElement(D.Fragment,null,E(w,v),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement($i,{color:"black"})),onClick:()=>t($.bridges),start:D.createElement(Yx,{color:"gray",size:16})},B={id:"widget-setting-exchange-item-btn",title:D.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:D.createElement(D.Fragment,null,E(x,M),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement($i,{color:"black"})),start:D.createElement(Zx,{color:"gray",size:16}),onClick:()=>t($.exchanges)},A={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(Je,{variant:"body",size:"medium"},`${m.length}`),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement($i,{color:"black"})),start:D.createElement(lb,{color:"gray",size:16}),onClick:()=>t($.customTokens)},I={id:"widget-setting-language-item-btn",title:D.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Language")),start:D.createElement(eb,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(Je,{variant:"body",size:"medium"},s),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement($i,{color:"black"})),onClick:()=>t($.languages)},X={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),D.createElement(Yn,{direction:"horizontal",size:4}),D.createElement(pb,{side:"top",sideOffset:4,container:W(),content:D.createElement(_i,null,D.createElement(Je,{variant:"label",size:"medium",color:"neutral700"},D.createElement("b",null,dt.t("Warning")),":\xA0",dt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},D.createElement(Rx,{color:"gray"}))),start:D.createElement(Jx,{color:"gray",size:16}),end:D.createElement(ab,{checked:C}),onClick:S},se={id:"widget-setting-theme-item-btn",type:D.createElement(ob,null),title:D.createElement(Je,{variant:"title",size:"xmedium"},dt.t("Theme")),end:D.createElement(ub,null,D.createElement(sb,{container:W(),items:mb,value:n,onChange:P=>o(P.id),type:"primary",borderRadius:"small"})),start:db(n)},J=d?[]:[b,B];return g||J.push(A),f||J.push(I),J.push(X),!e?.singleTheme&&!h&&J.push(se),D.createElement(tb,{type:D.createElement(nb,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Mg,"SettingsLists");var Cb=hb("div",{paddingLeft:"$8"});function Lg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Sb(),r=yb(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Eo.createElement(oe,{header:{title:Ul.t("Settings")}},Eo.createElement(ie,null,o&&Eo.createElement(fb,{type:"info",variant:"alarm",title:Ul.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Eo.createElement(Cb,null,Eo.createElement(gb,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Ul.t("Reset")))}),Eo.createElement(Ol,null),Eo.createElement(Mg,null)))}i(Lg,"SettingsPage");import{i18n as aE}from"@lingui/core";import{cancelSwap as sE}from"@rango-dev/queue-manager-rango-preset";import{useManager as lE}from"@rango-dev/queue-manager-react";import{Alert as pE}from"@rango-dev/ui";import np from"react";import{useParams as cE}from"react-router-dom";import{i18n as at}from"@lingui/core";import{getCurrentNamespaceOfOrNull as zb,getCurrentStep as Qb,getRelatedWalletOrNull as qb}from"@rango-dev/queue-manager-rango-preset";import{Button as ch,CopyIcon as Hb,Divider as Gb,DoneIcon as Vb,IconButton as Kb,QuoteCost as jb,RangoExplorerIcon as Xb,StepDetails as Yb,Tooltip as uh,Typography as Io,useCopyToClipboard as Zb}from"@rango-dev/ui";import{useWallets as Jb}from"@rango-dev/wallets-react";import mh from"bignumber.js";import{PendingSwapNetworkStatus as Vi}from"rango-types";import j,{useEffect as dh,useRef as Rb,useState as fh}from"react";import{useNavigate as eE}from"react-router-dom";import{i18n as eo}from"@lingui/core";var Tb=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function Pg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?eo.t("Today"):`${Tb[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Pg,"timeSince");function Dg(t){return t.finishTime?Pg(parseInt(t.finishTime)):Pg(parseInt(t.creationTime))}i(Dg,"getSwapDate");import{PendingSwapNetworkStatus as Ui}from"rango-types";import zi from"react";import{i18n as Fi}from"@lingui/core";import{Button as _g,Divider as zl,MessageBox as kb}from"@rango-dev/ui";import to from"react";var $g=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(zl,{size:20}),to.createElement(kb,{type:"error",title:Fi.t("Cancel Swap"),description:Fi.t("Are you sure you want to cancel this swap?")}),to.createElement(zl,{size:32}),to.createElement(_g,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Fi.t("Yes, Cancel it")),to.createElement(zl,{size:12}),to.createElement(_g,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Fi.t("No, Continue"))),"CancelContent");import{i18n as Oi}from"@lingui/core";import{Button as Fg,Divider as Ql,MessageBox as vb,Typography as wb}from"@rango-dev/ui";import Qt from"react";var Og=i(({onDelete:t,onClose:e})=>Qt.createElement(Qt.Fragment,null,Qt.createElement(Ql,{size:20}),Qt.createElement(vb,{type:"error",title:Oi.t("Delete Transaction"),description:Oi.t("Are you sure you want to delete this swap?")}),Qt.createElement(Ql,{size:32}),Qt.createElement(Fg,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Oi.t("Yes, Delete it")),Qt.createElement(Ql,{size:12}),Qt.createElement(Fg,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Qt.createElement(wb,{variant:"title",size:"medium",color:"primary"},Oi.t("No, Cancel")))),"DeleteContent");import{i18n as ql}from"@lingui/core";import{PendingSwapNetworkStatus as Hl}from"rango-types";var Gl={[Hl.WaitingForNetworkChange]:{type:"loading",title:ql.t("Change Network")},[Hl.WaitingForConnectingWallet]:{type:"warning",title:ql.t("Connect Wallet")},[Hl.NetworkChanged]:{type:"success",title:ql.t("Network Changed")}};import{warn as xb}from"@rango-dev/logging-core";import{MessageBox as bb,Wallet as Eb}from"@rango-dev/ui";import{useWallets as Ib}from"@rango-dev/wallets-react";import on,{useState as Ab}from"react";import{styled as Ug}from"@rango-dev/ui";var zg=Ug("div",{display:"flex",justifyContent:"center"}),h5=Ug("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Qg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=Ab(),{getWalletInfo:u,state:c}=Ib(),m=n?.walletType,h=m?un(c(m)):null,d=m?u(m):null,f=a&&!!m&&!!h&&!!d,{list:g}=gt(),C=i(()=>{if(m){let S=g.find(T=>T.type===m);S?p(S):xb(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return on.createElement(on.Fragment,null,on.createElement(bb,{type:e,title:o,description:r}),f&&on.createElement(zg,null,on.createElement(Eb,{container:W(),title:d.name,image:d.img,type:m,state:h,link:d.installLink,disabled:s,onClick:C})),on.createElement(uo,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function Vl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===Ui.WaitingForNetworkChange||e===Ui.WaitingForConnectingWallet||e===Ui.NetworkChanged;return zi.createElement(R,{open:!!e,onClose:o,container:document.getElementById(Pe.SWAP_BOX_ID)||document.body},p&&zi.createElement(Qg,{type:Gl[e].type,title:Gl[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Ui.WaitingForNetworkChange}),e==="delete"&&zi.createElement(Og,{onClose:o,onDelete:n}),e==="cancel"&&zi.createElement($g,{onClose:o,onCancel:r}))}i(Vl,"SwapDetailsModal");import{i18n as Zn}from"@lingui/core";import{Button as Kl,Divider as Qi,MessageBox as qg,TokenAmount as Nb,Typography as jl}from"@rango-dev/ui";import _e from"react";import{useNavigate as Wb}from"react-router-dom";function Xl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:h}=t,d=Wb();return _e.createElement(R,{open:e,onClose:o,container:document.getElementById(Pe.SWAP_BOX_ID)||document.body},n==="success"?_e.createElement(qg,{type:"success",title:Zn.t("Swap Successful")},_e.createElement(Nb,{direction:"vertical",tooltipContainer:W(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),_e.createElement(Qi,{size:12}),_e.createElement(jl,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):_e.createElement(qg,{type:"error",title:Zn.t("Transaction Failed"),description:m}),_e.createElement(Qi,{size:32}),n==="success"&&_e.createElement(Kl,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{d("../../")}},_e.createElement(jl,{variant:"title",size:"medium",color:"neutral100"},Zn.t("Done"))),_e.createElement(Qi,{size:12}),h&&_e.createElement(_e.Fragment,null,_e.createElement(Kl,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},Zn.t("Diagnosis")),_e.createElement(Qi,{size:12})),_e.createElement(Kl,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},_e.createElement(jl,{variant:"title",size:"medium",color:"primary"},Zn.t("See Details"))))}i(Xl,"SwapDetailsCompleteModal");import Ub from"react";import{i18n as _b}from"@lingui/core";import{Alert as ah,IconButton as $b,LinkIcon as Fb}from"@rango-dev/ui";import oo,{Fragment as Ob}from"react";import{Alert as Mb,ChevronDownIcon as Lb,IconButton as Pb}from"@rango-dev/ui";import rn,{useState as Db}from"react";import{css as Jn,darkTheme as Hg,styled as qt,Typography as Bb}from"@rango-dev/ui";var Gg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),qi=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Hg} &`]:{color:"$secondary500"}}}}}),Vg=qt(kn,{padding:"$0 $20 $20 $20"}),R5=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Kg=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),e4=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),nn=Jn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Hg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),jg=Jn({padding:"$5 0"}),Hi=Jn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Xg=Jn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Yg=Jn({width:"100%",padding:"0 $20 $10"}),Zg=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Jg=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Gi=qt(Bb,{wordBreak:"break-word"});import{styled as Yl}from"@rango-dev/ui";var Rg=Yl("div",{display:"flex",flexDirection:"column",gap:"$10"}),eh=Yl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),th=Yl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function oh(t){let{message:e}=t,[o,n]=Db(!1);return rn.createElement(Mb,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&rn.createElement(Pb,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},rn.createElement(eh,{rotated:o},rn.createElement(Lb,{size:12,color:"gray"}))),footer:rn.createElement(th,{open:o},rn.createElement(Gi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(oh,"FailedAlert");import{i18n as nh}from"@lingui/core";import{Alert as Zl,Button as rh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Jl}from"rango-types";import Rn from"react";function ih(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Rn.createElement(Zl,{type:"warning",title:n.shortMessage,action:Rn.createElement(rh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Jl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},nh.t("Change"))}):r===Jl.WaitingForConnectingWallet?Rn.createElement(Zl,{type:"warning",title:n.shortMessage,action:Rn.createElement(rh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Jl.WaitingForConnectingWallet)}},nh.t("Connect"))}):Rn.createElement(Zl,{type:"warning",title:n.shortMessage})}i(ih,"WarningAlert");function Rl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=Sn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return oo.createElement(Rg,null,a.explorerUrl?.map((m,h,d)=>{let f=h+m.url,g=h===d.length-1,C=(g&&u||p)&&!c,S=g&&a.status==="failed";return oo.createElement(Ob,{key:f},oo.createElement(ah,{type:g&&(C&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:_b.t("View transaction"),action:m.url&&oo.createElement($b,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},oo.createElement(Fb,{size:12}))}))}),c&&oo.createElement(ah,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(ih,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(oh,{message:r}))}i(Rl,"SwapDetailsAlerts");var sh=2e3;var lh=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:lt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:L(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:lt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:L(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:an(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(p=>({from:{chain:{displayName:lt(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:lt(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:an(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:Ub.createElement(Rl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function ph(t){if(Sn(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(ph,"getStepState");function ep(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Jb(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=O.use.retry(),h=le.use.isActiveTab(),d=eE(),[f,g]=Zb(sh),C=Rb(null),[S,T]=fh(null),[k,v]=fh(null),w=i(()=>{r(),T(null)},"onCancel"),N=ve.use.getNotifications(),M=ve.use.removeNotification(),x=N(),E=Qb(e),b=E?.networkStatus;dh(()=>{x.find($e=>$e.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):k&&v(null))},[e.status,e.requestId]),dh(()=>{P?T(Vi.WaitingForNetworkChange):b===Vi.WaitingForConnectingWallet||b===Vi.NetworkChanged?T(b):T(null)},[b]);let B=au(e),A=E?zb(e,E):null,I=E?qb(e,E):null,X=Dg(e),se=su(e),J=i(re=>!!l(re)?.mobileWallet,"isMobileWallet"),P=b===Vi.WaitingForNetworkChange&&!!A&&!!I?.walletType&&(J(I.walletType)||a(I.walletType,A.network)),K=P?s.bind(null,I.walletType,[{namespace:A.namespace,network:A.network}]):void 0,pe=iu(e,E),Q=lh({swap:e,switchNetwork:K,showNetworkModal:b,setNetworkModal:T,message:pe,blockchains:p,swappers:u}),me=Q.length,[Ge,st]=[e.steps[0],e.steps[me-1]],de=st.outputAmount||st.expectedOutputAmountHumanReadable,Ve=e.steps.reduce((re,$e)=>re+parseFloat($e.feeInUsd||""),0),V=e.steps.find(re=>re.diagnosisUrl)?.diagnosisUrl,Ke=L(parseFloat(de||"0")*(st.toUsdPrice||0),4,4),ft=L(parseFloat(e.inputAmount)*(Ge.fromUsdPrice||0),4,4),_=de?new mh(de).multipliedBy(st.toUsdPrice||0).toString():"",G=new mh(e.inputAmount).multipliedBy(Ge.fromUsdPrice||0).toString(),q=ct(ft,Ke),ee=pe.detailedMessage.content||pe.shortMessage,ne=e.status==="success"?at.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(de,6,6),token:Q[me-1].to.token.displayName,conciseAddress:gr(e.wallets[Q[me-1].to.chain.displayName]?.address||""),chain:Q[me-1].to.chain.displayName}}):j.createElement(Jg,null,j.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},ee?"":at.t("Transaction was not sent."),B?`${at.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:B.outputAmount,symbol:B.symbol,blockchain:B.blockchain}})}`:""),ee&&j.createElement(Gi,{align:"center",variant:"body",size:"medium",color:"neutral700"},j.createElement("b",null,"Reason:")," ",ee));return j.createElement(oe,{header:{title:at.t("Swap Details"),onCancel:e.status==="running"?()=>T("cancel"):void 0,suffix:e.status!=="running"&&j.createElement(Gt,null,j.createElement(ch,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>T("delete")},j.createElement(Io,{size:"medium",variant:"label",color:"error"},at.t("Delete"))))},footer:se&&!k&&j.createElement(ch,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let re=Pr(e,p,c);m(re),setTimeout(()=>{d("../../")},0)}},at.t("Try again"))},j.createElement(ie,{compact:!0,view:!0},j.createElement(qi,null,j.createElement("div",{className:nn()},j.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${at.t("Request ID")}`),j.createElement("div",{className:Hi()},j.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),j.createElement(uh,{container:W(),content:f?at.t("Copied To Clipboard"):at.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},j.createElement(Kb,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:g.bind(null,o||"")},f?j.createElement(Vb,{size:16,color:"secondary"}):j.createElement(Hb,{size:16,color:"gray"}))),j.createElement(Zg,{target:"_blank",href:`${Sp}/swap/${o}`},j.createElement(uh,{container:W(),content:at.t("View on Rango Explorer"),side:"bottom"},j.createElement(Xb,{size:20}))))),j.createElement("div",{className:nn()},j.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?at.t("Finished at"):at.t("Created at")),j.createElement(Io,{variant:"label",size:"small",color:"neutral700"},X))),j.createElement("div",{className:Xg()},j.createElement(jb,{fee:L(String(Ve),2,2),time:pn(pr(e.steps)),steps:me}),j.createElement(Nn,{from:{price:{value:L(e.inputAmount,6,6),usdValue:ft,realUsdValue:G,realValue:e.inputAmount},token:{displayName:Q[0].from.token.displayName,image:Q[0].from.token.image},chain:{image:Q[0].from.chain.image,displayName:Q[0].from.chain.displayName}},to:{price:{value:L(de,6,6),usdValue:Ke,realUsdValue:_,realValue:de||""},token:{displayName:Q[me-1].to.token.displayName,image:Q[me-1].to.token.image},chain:{image:Q[me-1].to.chain.image,displayName:Q[me-1].to.chain.displayName}},percentageChange:L(q,2,2),warningLevel:Pt(q??0)})),j.createElement("div",{className:Yg()},j.createElement(Io,{variant:"title",size:"small"},at.t("Swaps steps"))),j.createElement(Gb,{size:8}),j.createElement(Vg,{ref:C},Q.map((re,$e)=>{let or=$e,no=ph(e.steps[$e]),Qh=no==="error"||no==="in-progress"||no==="warning"||no==="completed"&&$e===Q.length-1;return j.createElement(Yb,{key:or,step:re,type:"swap-progress",ref:C,state:no,hasSeparator:$e!==0,tabIndex:or,isFocused:Qh,tooltipContainer:W()})}))),j.createElement(Vl,{state:S,onClose:()=>T(null),onCancel:w,onDelete:n,message:pe.detailedMessage.content,currentStepWallet:I,walletButtonDisabled:!h}),j.createElement(Xl,{open:!!k,diagnosisUrl:V,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:L(de,6,6),usdValue:Ke,realUsdValue:_,realValue:de||"",percentageChange:L(q,2,2),token:{displayName:Q[me-1].to.token.displayName,image:Q[me-1].to.token.image},chain:{image:Q[me-1].to.chain.image},description:ne}))}i(ep,"SwapDetails");import{i18n as ji}from"@lingui/core";import{Divider as yh,NotFound as iE,Skeleton as tr,Typography as Xi}from"@rango-dev/ui";import Se from"react";import{i18n as tE}from"@lingui/core";import{Divider as oE,Skeleton as nE,Typography as rE}from"@rango-dev/ui";import Te from"react";import{css as vt,styled as tp}from"@rango-dev/ui";var gh=tp("div",{width:"100%",height:"100%",padding:"$10 $20"}),er=tp("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Ki=tp("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),mK=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),dK=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),fK=vt({paddingTop:"$15",display:"flex"}),gK=vt({padding:"$15 $0"}),hK=vt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),yK=vt({paddingBottom:"$10"}),SK=vt({display:"flex",justifyContent:"start",alignItems:"center"}),CK=vt({paddingTop:"$5",display:"flex",alignItems:"center"}),TK=vt({display:"flex",alignItems:"center"}),kK=vt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),hh=vt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function op(){return Te.createElement(gh,null,Te.createElement(Mn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(rE,{variant:"title",size:"small"},tE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(er,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:hh()},Te.createElement(oE,{direction:"horizontal",size:20}),Te.createElement(nE,{height:22,variant:"rectangular"}))),Te.createElement(Ki,null),Te.createElement(er,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Ki,null),Te.createElement(er,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Ki,null),Te.createElement(er,null,Te.createElement(Nt,{separator:!1}))))}i(op,"LoadingSwapDetails");function Sh(t){let{requestId:e,showSkeleton:o}=t;return Se.createElement(oe,{header:{title:ji.t("Swap Details"),suffix:Se.createElement(Gt,null)}},o&&Se.createElement(Gg,null,Se.createElement(qi,null,Se.createElement("div",{className:nn()},Se.createElement(Xi,{variant:"label",size:"large",color:"neutral700"},`${ji.t("Request ID")}`),Se.createElement("div",{className:Hi()},Se.createElement(Xi,{variant:"label",size:"small",color:"neutral700"},Se.createElement(tr,{width:60,height:10,variant:"rounded"})),Se.createElement(yh,{direction:"horizontal",size:4}),Se.createElement(tr,{width:16,height:16,variant:"rectangular"}),Se.createElement(yh,{direction:"horizontal",size:4}),Se.createElement(tr,{width:16,height:16,variant:"rectangular"}))),Se.createElement("div",{className:nn()},Se.createElement(Xi,{className:jg(),variant:"label",size:"large",color:"neutral700"},Se.createElement(tr,{width:60,height:10,variant:"rounded"})),Se.createElement(Xi,{variant:"label",size:"small",color:"neutral700"},Se.createElement(tr,{width:60,height:10,variant:"rounded"})))),Se.createElement(op,null)),!o&&Se.createElement(Kg,null,Se.createElement(iE,{title:ji.t("Not found"),description:ji.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(Sh,"SwapDetailsPlaceholder");function Ch(){let{manager:t,state:e}=lE(),o=!e.loadedFromPersistor,n=ut(t),{requestId:r}=cE(),a=Ye(),{fetchStatus:s}=y();if(!r)return np.createElement(pE,{containerStyles:{margin:"20px"},type:"error",title:aE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:h})=>h.requestId===r):void 0,u=i(()=>{if(p?.id){let h=t?.get(p.id);h&&sE(h)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(h){console.log(h)}},"onDelete"),m=p?.swap;return!m||l?np.createElement(Sh,{requestId:r,showSkeleton:l}):np.createElement(ep,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(Ch,"SwapDetailsPage");import{i18n as Th}from"@lingui/core";import{Divider as uE,getCategoriesCount as mE,SelectableCategoryList as dE,styled as vh,Typography as fE,Wallet as gE}from"@rango-dev/ui";import Bt,{useState as kh}from"react";var hE=vh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),yE=vh(ie,{textAlign:"center"});function wh(){let{fetchStatus:t}=y(),[e,o]=kh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=kh(),l=le.use.isActiveTab(),{list:p}=gt(),u=Up(p,n),m=mE(u)!==1,h=zp(p,e),d=i(f=>{Np(p,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:Th.t("Connect Wallets")}},Bt.createElement(yE,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(dE,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(uE,{size:24})),Bt.createElement(fE,{variant:"title",size:"xmedium",align:"center"},Th.t("Choose a wallet to connect.")),Bt.createElement(hE,null,h.map((f,g)=>{let C=`wallet-${g}-${f.type}`;return Bt.createElement(gE,{key:C,...f,container:W(),onClick:()=>d(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(uo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(wh,"WalletsPage");function xh(){return yu(),qa(),SE([{path:$.home,element:Le.createElement(eg,null)},{path:$.routes,element:Le.createElement(ig,null)},{path:$.fromSwap,children:[{index:!0,element:Le.createElement($l,{type:"source"})},{path:$.blockchains,element:Le.createElement(Li,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:Le.createElement($l,{type:"destination"})},{path:$.blockchains,element:Le.createElement(Li,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:Le.createElement(Lg,null)},{path:$.languages,element:Le.createElement(og,null)},{path:$.exchanges,element:Le.createElement(Nl,{sourceType:"Exchanges"})},{path:$.bridges,element:Le.createElement(Nl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:Le.createElement(cf,null)},{path:$.addCustomTokens,children:[{index:!0,element:Le.createElement(Ju,null)},{path:$.blockchains,element:Le.createElement(Li,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:Le.createElement(Wf,null)},{path:$.swapDetails,element:Le.createElement(Ch,null)}]},{path:$.wallets,element:Le.createElement(wh,null)},{path:$.confirmSwap,element:Le.createElement(Xd,null)}])}i(xh,"AppRoutes");import{useQueueManager as IE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as AE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as NE}from"rango-sdk";import{useContext as WE,useEffect as Bh,useState as Mh}from"react";import{globalCss as CE}from"@rango-dev/ui";var bh=i(()=>CE({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");function Eh(){let{setWatermark:t}=le();return{fetchApiConfig:i(async()=>{let o=await fetch(`${Lt("BASE_URL")}/meta/dapp/config?apiKey=${Lt("API_KEY")}`);if(!o.ok)throw new Error(`Request failed with status: ${o.status} `);let n=await o.json();t(n.config.watermark)},"fetchApiConfig")}}i(Eh,"useFetchApiConfig");import{useWallets as TE}from"@rango-dev/wallets-react";import{useEffect as kE,useRef as vE}from"react";function Ih(){let{connect:t,state:e}=TE(),o=vE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);kE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Ih,"useForceAutoConnect");import{isApprovalTX as wE,RouteEventType as Ah,StepEventType as Nh,StepExecutionEventStatus as xE,WidgetEvents as Yi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Wh}from"react";function rp(){let t=ve.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Wh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===Nh.TX_EXECUTION&&a.status===xE.TX_SENT&&!wE(s)||a.type===Nh.SUCCEEDED){let u=e.find(m=>m.chain===s?.fromBlockchain),c=s?.fromBlockchain!==s?.toBlockchain&&e.find(m=>m.chain===s?.toBlockchain);u&&o([u]),c&&o([c])}t(a,l)},"handleStepEvent");return ge.on(Yi.StepEvent,n),()=>ge.off(Yi.StepEvent,n)},[ge,e]),Wh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===Ah.FAILED||a.type===Ah.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return ge.on(Yi.RouteEvent,n),()=>ge.off(Yi.RouteEvent,n)},[ge])}i(rp,"useSubscribeToWidgetEvents");import{useManager as bE}from"@rango-dev/queue-manager-react";import{useEffect as EE}from"react";function ip(){let{isSynced:t,syncNotifications:e}=ve(),{manager:o,state:n}=bE();EE(()=>{ve.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ut(o))},[ve.persist.hasHydrated(),n.loadedFromPersistor,t])}i(ip,"useSyncNotifications");function ap(){Ih(),bh(),rp(),ip();let t=y().blockchains(),{canSwitchNetworkTo:e}=Jr(),[o,n]=Mh(""),[r,a]=Mh(),s=WE(Ir),l=t.filter(NE),{fetchApiConfig:p}=Eh();Bh(()=>()=>hu(),[]),IE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Bh(()=>(so.init(),ve.persist.hasHydrated()||ve.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===AE(o)?.[0]&&n("")}),p().catch(console.log),so.destroy),[])}i(ap,"useBootstrap");import{styled as BE}from"@rango-dev/ui";var Lh=BE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Zi(){ap();let{config:t}=y(),{activeTheme:e}=Go(t?.theme||{}),{activeLanguage:o}=Rt();return sp.createElement(ME,{language:o},sp.createElement(Lh,{id:"swap-container",className:e()},sp.createElement(xh,null)))}i(Zi,"Main");import{setSolanaSignerConfig as JE}from"@rango-dev/signer-solana";import pp,{useEffect as Oh,useMemo as RE}from"react";import{useState as LE}from"react";var PE=i(()=>{let[t,e]=LE(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=Ap(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Ph=PE;import{checkWaitingForNetworkChange as DE,makeQueueDefinition as _E}from"@rango-dev/queue-manager-rango-preset";import{Provider as $E}from"@rango-dev/queue-manager-react";import{useWallets as FE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as OE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as UE}from"rango-types";import zE,{useMemo as QE}from"react";function qE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=FE(),l=QE(()=>_E({API_KEY:t.apiKey||Lt("API_KEY"),BASE_URL:Lt("BASE_URL"),emitter:{emit:ge.emit}}),[t.apiKey]),{blockchains:p,connectedWallets:u}=y(),c=p(),m={blockchains:u.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,w)=>a(v,w.network)?await r(v,[w]):void 0,"switchNetwork"),d=i(v=>!!s(v).mobileWallet,"isMobileWallet"),f=c.filter(v=>v.enabled).reduce((v,w)=>(v[w.name]=w,v),{}),g=c.filter(UE),C=i(v=>{let{supportedChains:w}=s(v);return mr(w)},"getSupportedChainNames"),S=e(),T={meta:{blockchains:f,evmBasedChains:g,evmNetworkChainInfo:OE(g),getSupportedChainNames:C},getSigners:o,wallets:m,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:d},k=le.use.isActiveTab();return zE.createElement($E,{queuesDefs:[l],context:T,onPersistedDataLoaded:v=>{DE(v)},isPaused:!k},t.children)}i(qE,"QueueManager");var Dh=qE;import{useManager as jE}from"@rango-dev/queue-manager-react";import XE,{createContext as YE,useContext as ZE}from"react";function _h(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:h,toToken:d,requestAmount:f}=u,g={blockchains:e,tokens:o};if(c!==void 0){let C=e.find(S=>S.name===c)??null;n(C)}if(m!==void 0){let C=m?t(m)??null:null;r({meta:g,token:C})}if(h!==void 0){let C=e.find(S=>S.name===h)??null;a(C)}if(d!==void 0){let C=d?t(d)??null:null;s({meta:g,token:C})}f!==void 0&&l(f)},"updateQuoteInputs")}i(_h,"useUpdateQuoteInputs");import{cancelSwap as HE,getCurrentNamespaceOfOrNull as GE,getCurrentStep as VE,getRelatedWalletOrNull as KE}from"@rango-dev/queue-manager-rango-preset";var Ji=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return ut(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=Pr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&HE(o)}getCurrentStepInfo(e){let o=VE(e);return{step:o,wallet:o?KE(e,o):null,network:o?GE(e,o)?.network:null}}};var $h=YE(void 0);function lp(t){let{manager:e}=jE(),o=le.use.isActiveTab(),n=O.use.retry(),{findToken:r,connectedWallets:a,getBalances:s,fetchBalances:l}=y(),p=new Ji(e,{retrySwap:n,findToken:r}),{fetchingWallets:u}=y(),c=Pp(s()),m=y().blockchains(),h=y().tokens(),d=y().swappers(),f=y().fetchStatus,g=Rt().resetLanguage,C=ve().getNotifications(),S=ve().clearNotifications,T=_h(),{fromBlockchain:k,toBlockchain:v,fromToken:w,toToken:N,inputAmount:M}=O(),x={isActiveTab:o,setCurrentTabAsActive:so.forceClaim,history:p,wallets:{isLoading:u,details:a,totalBalance:c,refetch:async E=>l(E)},meta:{blockchains:m,tokens:h,swappers:d,loadingStatus:f,findToken:r},resetLanguage:g,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:v?.name??null,toToken:N?{symbol:N.symbol,blockchain:N.blockchain,address:N.address}:null,requestAmount:M},updateQuoteInputs:T}};return XE.createElement($h.Provider,{value:x},t.children)}i(lp,"WidgetInfo");function Fh(){let t=ZE($h);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Fh,"useWidget");function Ri(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Ph();return Oh(()=>{n&&r(n)},[n]),RE(()=>{Qp({API_KEY:o?.apiKey||ar,BASE_URL:o?.apiUrl||yp})},[o.apiKey,o.apiUrl]),Oh(()=>{t.config?.signers?.customSolanaRPC&&JE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),pp.createElement(Ar,{config:o,onUpdateState:e},pp.createElement(Dh,{apiKey:o.apiKey},pp.createElement(lp,null,t.children)))}i(Ri,"WidgetProvider");function Uh(t){let e=t.config?.externalWallets;return ea.createElement(Uc,null,e?ea.createElement(Zi,null):ea.createElement(Ri,{config:t.config??ra},ea.createElement(Zi,null)))}i(Uh,"Widget");function zh(){let{on:t,off:e}=ge;return{on:t,off:e}}i(zh,"useWidgetEvents");var Aj={DerivationPath:gn,Namespaces:fn,isOnDerivationPath:yn,isOnNamespace:hn};export{ej as EventSeverity,Lo as MainEvents,cj as Networks,dj as PendingSwapNetworkStatus,ha as QuoteEventTypes,tj as RouteEventType,ia as SUPPORTED_FONTS,Aj as StatefulConnect,oj as StepEventType,nj as StepExecutionBlockedEventStatus,rj as StepExecutionEventStatus,Pe as UI_ID,Sa as UiEventTypes,ya as WalletEventTypes,lj as WalletEvents,uj as WalletTypes,Uh as Widget,Lo as WidgetEvents,Ri as WidgetProvider,Ar as WidgetWallets,ts as customizedThemeTokens,aj as readAccountAddress,Ht as useStatefulConnect,gt as useWalletList,Jr as useWallets,Fh as useWidget,zh as useWidgetEvents,Hy as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map