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

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 (38) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  2. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
  3. package/dist/components/Quotes/Quotes.d.ts.map +1 -1
  4. package/dist/constants/quote.d.ts +8 -0
  5. package/dist/constants/quote.d.ts.map +1 -1
  6. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
  7. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
  8. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +6 -4
  9. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
  10. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  11. package/dist/index.js +2 -2
  12. package/dist/index.js.map +4 -4
  13. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  14. package/dist/store/quote.d.ts.map +1 -1
  15. package/dist/types/quote.d.ts +8 -17
  16. package/dist/types/quote.d.ts.map +1 -1
  17. package/dist/utils/quote.d.ts +5 -6
  18. package/dist/utils/quote.d.ts.map +1 -1
  19. package/dist/utils/swap.d.ts +4 -4
  20. package/dist/utils/swap.d.ts.map +1 -1
  21. package/dist/widget-embedded.build.json +1 -1
  22. package/package.json +2 -2
  23. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +2 -19
  24. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +42 -22
  25. package/src/components/Quotes/Quotes.tsx +2 -3
  26. package/src/constants/quote.ts +23 -0
  27. package/src/containers/QuoteInfo/QuoteInfo.tsx +3 -9
  28. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +29 -66
  29. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +10 -15
  30. package/src/hooks/useSwapInput.ts +2 -9
  31. package/src/pages/ConfirmSwapPage.tsx +7 -15
  32. package/src/store/quote.ts +3 -13
  33. package/src/types/quote.ts +10 -24
  34. package/src/utils/quote.ts +57 -45
  35. package/src/utils/swap.ts +55 -36
  36. package/dist/constants/warnings.d.ts +0 -3
  37. package/dist/constants/warnings.d.ts.map +0 -1
  38. package/src/constants/warnings.ts +0 -26
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
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};
1
+ var $h=Object.defineProperty;var i=(t,e)=>$h(t,"name",{value:e,configurable:!0});import{EventSeverity as Hj,RouteEventType as Gj,StepEventType as Vj,StepExecutionBlockedEventStatus as Kj,StepExecutionEventStatus as jj}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Yj}from"@rango-dev/wallets-core/legacy";import{useWallets as Kr,Events as Jj}from"@rango-dev/wallets-react";import{Networks as e3,WalletTypes as t3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as n3}from"rango-types";import{Divider as WS}from"@rango-dev/ui";import po,{useEffect as BS,useRef as MS,useState as Ac}from"react";import{WalletState as Dh}from"@rango-dev/ui";import{useWallets as Fh}from"@rango-dev/wallets-react";import{useReducer as Oh}from"react";function np(t){return!!t.derivationPath}i(np,"isStateOnDerivationPathStep");function rp(t){return!!t.namespace}i(rp,"isStateOnNamespace");var er={status:"init",namespace:null,derivationPath:null};function ip(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 er;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:er;default:throw new Error("Action hasn't been defined.")}}i(ip,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=Fh(),[n,r]=Oh(ip,er),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===Dh.DISCONNECTED){if(!!c.isHub&&c.properties?.find(k=>k.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 d=c.needsNamespace.data.length>1,g=c.needsDerivationPath;if(d)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",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(!rp(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(!np(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(Gt,"useStatefulConnect");import{WalletState as ga}from"@rango-dev/ui";import{useWallets as Ky}from"@rango-dev/wallets-react";import{detectMobileScreens as jy,KEPLR_COMPATIBLE_WALLETS as Xy,WalletTypes as Bo}from"@rango-dev/wallets-shared";import{useCallback as Yy,useEffect as Zy}from"react";import zy,{createContext as Qy,useContext as qy,useEffect as Hy,useRef as Gy}from"react";import{create as Oy}from"zustand";import{persist as Uy}from"zustand/middleware";var Zi=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()}},bo=new Zi;function tr(t,e){return e.find(o=>o.name===t)?.displayName}i(tr,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function ap(t,e){return e.find(o=>o.name===t)?.logo}i(ap,"getBlockchainImage");function nn(t,e){return e.find(o=>o.id===t)?.title}i(nn,"getSwapperDisplayName");function rn(t,e){return e.find(o=>o.name===t)??null}i(rn,"findBlockchain");function Ji(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(Ji,"isTokenNative");function lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function Eo(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Eo,"isValidTokenAddress");function an(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=lt(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=lt(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(an,"matchTokensFromConfigWithMeta");function or(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(or,"getSupportedBlockchainsFromConfig");var Ri={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"}},Uh={clientUrl:void 0},zh={liquiditySources:void 0},sp=i((t,e,o)=>({config:{...Ri,...t},iframe:Uh,campaignMode:zh,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=an({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=an({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});bo.set("supportedSourceTokens",l),bo.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 lp}from"rango-types";var pp=[lp.EVM,lp.SOLANA];import{RangoClient as oy}from"rango-sdk";import{UI_ID as Qh}from"@rango-dev/ui";var nr="c6381a79-2817-4602-83bf-6a641a409e32",cp="https://api.rango.exchange",up="https://explorer.rango.exchange",_e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Qh};import{BlockchainCategories as Xh,WalletState as xt}from"@rango-dev/ui";import{legacyReadAccountAddress as Yh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as Zh,getCosmosExperimentalChainInfo as Jh,isEvmAddress as Rh,KEPLR_COMPATIBLE_WALLETS as jI,Networks as xp}from"@rango-dev/wallets-shared";import ro from"bignumber.js";import{isCosmosBlockchain as ey}from"rango-types";import qh from"bignumber.js";var ge=new qh(0);import{WalletTypes as Hh}from"@rango-dev/wallets-shared";var mp=[Hh.LEAP];import{BlockchainCategories as ta,WalletState as jh}from"@rango-dev/ui";import{TransactionType as rr}from"rango-sdk";var dp="Roboto",ea=[{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 Io(t){return Array.from(new Set(t))}i(Io,"removeDuplicateFrom");function Cp(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Cp,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function hp(t,e){return t.toLowerCase()===e.toLowerCase()}i(hp,"exactText");function yp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(yp,"startWithText");var W=i(()=>document.getElementById(_e.SWAP_BOX_ID),"getContainer"),no=i(()=>document.getElementById(_e.EXPANDED_BOX_ID),"getExpanded");function Sp(t,e,o){let n=!!e&&hp(e,t),r=!!o&&hp(o,t);return n!==r?n?-1:1:0}i(Sp,"compareExactMatchText");function oa(t,e,o){let n=!!e&&Je(e,t),r=!!o&&Je(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(oa,"compareContainsText");function na(t,e,o){let n=!!e&&yp(e,t),r=!!o&&yp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(na,"compareStartWithText");function kp(t,e,o){if(!o)return 0;let n=Sp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Sp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=na(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=oa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=na(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=oa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=na(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=oa(o,t.address,e.address);if(r!==0)return r}return 0}i(kp,"compareWithSearchFor");var ir=i((t,e)=>{switch(e){case ta.ALL:return!0;case ta.UTXO:return t===rr.TRANSFER;case ta.OTHER:return t!==rr.TRANSFER&&t!==rr.COSMOS&&t!==rr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Tp=i(t=>ea.find(o=>o.value===t)?.url,"getFontUrlByName");function vp(t,e){let o=!!t.find(n=>n.state===jh.CONNECTED);return e===!1&&o}i(vp,"isSingleWalletActive");import{BigNumber as wp}from"bignumber.js";var sn=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 ar=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"),ln=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function pn(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(pn,"mapStatusToWalletState");function bp(t,e,o,n){return o.filter(r=>!mp.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:f}=e(r),d=Io(c.map(C=>C.type)),g=pn(t(r));return{title:a,image:s,link:Zh(l),state:g,type:r,showOnMobile:p,needsNamespace:u,blockchainTypes:d,needsDerivationPath:m,properties:h,isHub:f}})}i(bp,"mapWalletTypesToWalletInfo");function pr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(pr,"walletAndSupportedChainsNames");function ra(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}=Yh(p),m=l.length>0,h=l.includes(c),f=c===xp.Unknown;if(m&&!h&&!f)return;let g=c===xp.Unknown&&Rh(u);if(f&&!g)return;o.includes(c)||g?r?s(c,u.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,u.toLowerCase())}):s(c,u)}),a}i(ra,"prepareAccountsForWalletStore");function io(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(io,"getQuoteWallets");function Ep(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Ep,"isAccountAndWalletMatched");var Ip=i(t=>{let e=Object.values(t).reduce((o,n)=>n.usdValue?o.plus(n.usdValue):o,new ro(ge));return ty(e.toString())},"calculateWalletUsdValue");function ty(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(ty,"numberWithThousandSeparator");var cr=i((t,e)=>{let o=Jh(Object.entries(t).map(([,n])=>n).filter(ey));return o&&o[e]?.experimental},"isExperimentalChain");function ur(t){if(!t)return null;let e=new ro(t.amount).shiftedBy(-t.decimals).toFixed(),o=t.usdValue?new ro(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(ur,"formatBalance");function Ap(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new ro(t.usdValue).shiftedBy(-t.decimals):ge,n=e&&e.usdValue?new ro(e.usdValue).shiftedBy(-e.decimals):ge;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new ro(t.amount).shiftedBy(-t.decimals):ge,n=e&&e.amount?new ro(e.amount).shiftedBy(-e.decimals):ge;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Ap,"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 Np(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(Np,"sortWalletsBasedOnConnectionState");function mr(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(mr,"getConciseAddress");function Wp({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Wp,"getAddress");var Bp=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Mp(t){return t.map(e=>e.state).join("-")}i(Mp,"hashWalletsState");function Lp(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(Lp,"filterBlockchainsByWalletTypes");function Pp(t,e){return e===Xh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ir(n,e))return!0;return!1})}i(Pp,"filterWalletsByCategory");var ia={API_KEY:nr};function Lt(t){return ia[t]||""}i(Lt,"getConfig");function _p(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ia=e,ia}i(_p,"initConfig");var $p=20,Dp=25,aa="theme-widget",sa=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"),la=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Fp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var dr,bt=i(()=>dr||(dr=new oy(Lt("API_KEY"),Lt("BASE_URL")),dr),"httpService");function fr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Io(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(fr,"getUniqueSwappersGroups");function Op(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Op,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function Up(t,e){return e?.[t]==="enabled"}i(Up,"isFeatureEnabled");function Ao(t,e){return e?.[t]==="enabled"}i(Ao,"isRoutingEnabled");var zp=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Qp=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=or({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>pp.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=bo.get(c);m?.length||(m=an({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),bo.set(c,m)),m=zp(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?!!(Je(d.symbol,o.searchFor)||Je(d.address||"",o.searchFor)||Je(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 A=o.getBalanceFor(d),M=o.getBalanceFor(g),x=Ap(A,M);if(x!==0)return x}let k=p.get(d.blockchain),T=p.get(g.blockchain),v=Ji(d,k),w=Ji(g,T);if(v!==w)return v?-1:1;if(d.isPopular!==g.isPopular)return d.isPopular?-1:1;if(o.searchFor){let A=kp(d,g,o.searchFor);if(A)return A}return d.isSecondaryCoin!==g.isSecondaryCoin?d.isSecondaryCoin?1:-1:k&&T?k.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=lt(o),s=n.get(a);return s||(s=r.find(l=>lt(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(Op)},fetch:async()=>{try{let{routing:o}=e().config,n=Ao("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=lt(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 ny,Catalonia as ry,Chinese as qp,Denmark as iy,English as ay,Finland as sy,French as ly,German as py,Greece as cy,Hungary as uy,India as my,Indonesian as dy,Italian as fy,Japanese as gy,Korea as hy,Lithuania as yy,Malay as Sy,Netherlands as Cy,Pakistan as ky,Philippines as Ty,Poland as vy,Portuguese as wy,Russian as xy,SaudiArabia as by,Serbia as Ey,Slovakia as Iy,SouthAfrica as Ay,Spanish as Ny,Swahili as Wy,Swedish as By,Thai as My,Turkish as Ly,Ukrainian as Py,Vietnamese as _y}from"@rango-dev/ui";var Hp=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:Ay},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:by},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:ny},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:ry},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:qp},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:qp},{title:"Danish",label:"Dansk",local:"da",SVGFlag:iy},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:Cy},{title:"English",label:"English",local:"en",SVGFlag:ay},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:Ty},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:sy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ly},{title:"German",label:"Deutsch",local:"de",SVGFlag:py},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:cy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:my},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:uy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:dy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:fy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:gy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:hy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:yy},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Sy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:vy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:wy},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:xy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Ey},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Iy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:Ny},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Wy},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:By},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:My},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Ly},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Py},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:ky},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:_y}],No="en";var Gp=[.5,1,3],Vp=1,Kp=5,jp=100,Xp=0;var Yp=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Vp,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=Io(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=Ve("theme",n),s=Ve("language",n),l=Ve("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||No},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||No}})},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=or({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import tc from"bignumber.js";import $y from"mitt";var he=$y(),Dy={on:he.on,off:he.off};import{WidgetEvents as Zp}from"@rango-dev/queue-manager-rango-preset";var ca=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ca||{}),ua=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ua||{}),ma=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ma||{}),Wo=(a=>(a[a.RouteEvent=Zp.RouteEvent]="RouteEvent",a[a.StepEvent=Zp.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Wo||{});import Fy from"bignumber.js";function cn(t){return`${t.blockchain}-${t.address}-${t.symbol}`}i(cn,"createAssetKey");function da(t,e){return`${cn(e)}-${t}`}i(da,"createBalanceKey");function gr(t){let[e,o,n]=t.split("-");return{address:o,blockchain:e,symbol:n}}i(gr,"extractAssetFromBalanceKey");function Jp(t,e){let o={};return t.balances?.forEach(n=>{let r=da(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,p=l?new Fy(l??ge).multipliedBy(a).toString():"",u={amount:a,decimals:s,usdValue:p};o[r]=u}),o}i(Jp,"createBalanceStateForNewAccount");function Rp(t,e){for(let o in e){let n=gr(o),r=cn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(Rp,"updateAggregatedBalanceStateForNewAccount");function ec(t,e){let o=gr(e),n=cn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(ec,"removeBalanceFromAggregatedBalance");var oc=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=>Ep(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=>{he.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=gr(u),m=!!r.find(h=>da(h.address,{address:c.address,blockchain:h.chain,symbol:c.symbol})===u);m||(a[u]=l[u]),m&&(s=ec(s,u))}),t({_balances:a,_aggregatedBalances:s})},disconnectWallet:o=>{if(e().connectedWallets.find(r=>r.walletType===o)){he.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=Jp(m,e);c=Rp(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=cn(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 tc(u.amount),m=new tc(l.amount);c.isGreaterThan(m)&&(l=u)}),l}}),"createWalletsSlice");function nc(t){return Oy()(Uy((...e)=>({...oc(...e),...Qp(...e),...Yp(...e),...sp(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(nc,"createAppStore");var rc=Qy(null);function y(){let t=qy(rc);if(Hy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function ic(t){let e=Gy();return e.current||(e.current=nc(t.config)),zy.createElement(rc.Provider,{value:e.current},t.children)}i(ic,"AppStoreProvider");import{allProviders as Vy}from"@rango-dev/provider-all";import{defineVersions as ac,pickVersion as sc,Provider as fa}from"@rango-dev/wallets-core";function hr(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=Vy(o);if(t){let r=[];return t.forEach(a=>{if(typeof a=="string"){let s=n.find(l=>{let p=lc(l,e);return p instanceof fa?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 fa?r.push(ac().version("1.0.0",a).build()):r.push(ac().version("0.0.0",a).build())}),r}return n}i(hr,"matchAndGenerateProviders");function lc(t,e){let{experimentalWallet:o="enabled"}=e||{},n=o=="disabled"?"0.0.0":"1.0.0";try{return sc(t,n)[1]}catch{return sc(t,"0.0.0")[1]}}i(lc,"pickProviderVersionWithFallbackToLegacy");function pc(t,e){return hr(t,e).map(r=>lc(r,e)).map(r=>r instanceof fa?r.id:r.config.type)}i(pc,"configWalletsToWalletName");var Jy=Object.values(Bo);function ft(t){let{chain:e}=t||{},{config:o,connectedWallets:n}=y(),{state:r,getWalletInfo:a}=Ky(),s=y().blockchains(),{handleDisconnect:l}=Gt(),p=pc(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,tonConnect:o.tonConnect})||Jy,u=bp(r,a,p,e);u=jy()?u.filter(g=>g.showOnMobile!==!1&&r(g.type).installed):u;let c=Np(u),m=i(g=>!n.find(C=>C.walletType===g&&C.chain===e),"isExperimentalChainNotAdded"),h=Yy(()=>{let g=u?.filter(C=>C.state===ga.CONNECTING)||[];for(let C of g)l(C.type)},[Mp(u)]);Zy(()=>()=>{h()},[]);let f=i(g=>{let C=g.find(k=>k.type===Bo.DEFAULT);return!C||C.state===ga.NOT_INSTALLED?!1:g.filter(k=>k.state!=ga.NOT_INSTALLED&&![Bo.DEFAULT,Bo.WALLET_CONNECT_2,Bo.LEDGER].includes(k.type)&&a(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),d=i((g,C,S)=>cr(S,C)&&m(g)&&!Xy.includes(g)||g==Bo.DEFAULT&&!f(u),"shouldExcludeWallet");return{list:c.filter(g=>!d(g.type,e??"",s)),terminateConnectingWallets:h}}i(ft,"useWalletList");import{Modal as oS}from"@rango-dev/ui";import nS from"react";import{create as tS}from"zustand";var cc="rango-widget";var un=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(cc),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 eS=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"),Mo=eS;var ae=Mo(tS()((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})}}))),ao=new un({onInit:()=>ae.setState({tabManagerInitiated:!0}),onClaim:()=>ae.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>ae.setState({isActiveTab:!1})});function Z(t){let{watermark:e}=ae();return nS.createElement(oS,{hasWatermark:e==="FULL",...t},t.children)}i(Z,"WatermarkedModal");import{i18n as ha}from"@lingui/core";import{Button as pS,Checkbox as cS,Divider as uS,Image as kc,ListItemButton as mS,MessageBox as dS,Radio as fS,RadioRoot as gS}from"@rango-dev/ui";import ve,{useState as hS}from"react";import{css as rS,darkTheme as mc,IconButton as iS,styled as so}from"@rango-dev/ui";var Et=so(iS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${mc} &`]:{backgroundColor:"$neutral"}}}),dc=so("div",{position:"absolute",background:"$secondary500",[`.${mc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=so("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),fc=so("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"}}}}),gc=so("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),hc=so("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),yc=rS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),yr=so("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as aS,styled as Sr}from"@rango-dev/ui";var eN=Sr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Lo=Sr("div",{position:"relative"}),sS=aS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Po=Sr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${sS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Cr=Sr("div",{"& img":{borderRadius:"50%"}});function Sc(t,e){return t.find(o=>o.name===e)?.logo}i(Sc,"getBlockchainLogo");import{styled as lS}from"@rango-dev/ui";var Cc=lS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function mn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=hS([]),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?ve.createElement(gS,{value:r?.[0]},u):ve.createElement(ve.Fragment,null,u),"wrapRadioRoot");return ve.createElement(ve.Fragment,null,ve.createElement(uS,{size:20}),ve.createElement(dS,{type:"info",title:ha.t("Select chain types"),description:ha.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:ve.createElement(Lo,null,ve.createElement(yr,null,ve.createElement(kc,{src:n,size:45})),ve.createElement(Po,null))}),ve.createElement(Cc,null,p(ve.createElement(ve.Fragment,null,e.needsNamespace?.data.map(u=>ve.createElement(mS,{key:u.id,id:u.id,title:u.label,hasDivider:!0,style:{height:60},onClick:()=>l(u.value),start:ve.createElement(kc,{src:Sc(s,u.id),size:22}),end:o?ve.createElement(fS,{value:u.value}):ve.createElement(cS,{checked:r.includes(u.value)})}))))),ve.createElement(pS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},ha.t("Confirm")))}i(mn,"Namespaces");import{i18n as _o}from"@lingui/core";import{Button as CS,Divider as wc,Image as kS,MessageBox as TS,Select as vS,TextField as wS}from"@rango-dev/ui";import Oe,{useEffect as xS,useState as xc}from"react";import{namespaces as yS}from"@rango-dev/wallets-shared";var kr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ya(t){let e=t?yS[t].derivationPaths:null;return e?[...e,kr]:[]}i(ya,"getDerivationPaths");import{styled as Tc,Typography as SS}from"@rango-dev/ui";var vc=Tc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Sa=Tc(SS,{paddingLeft:"$10"}),Ca={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var bc="0";function dn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=xc(null),[l,p]=xc(bc),u=a===kr.id,c=ya(o),m=i(({value:f})=>{let d=c?.find(g=>g.id===f);d&&(a===kr.id&&Number.isNaN(Number(l))&&p(bc),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 xS(()=>{s(ya(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(wc,{size:20}),Oe.createElement(TS,{type:"info",title:_o.t("Select Derivation Path"),description:_o.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Lo,null,Oe.createElement(Cr,null,Oe.createElement(kS,{src:n,size:45})),Oe.createElement(Po,null))}),Oe.createElement(vc,null,Oe.createElement(Sa,{variant:"body",size:"xsmall",color:"$neutral600"},_o.t("Choose Derivation Path Template")),Oe.createElement(vS,{value:a||"",options:c.map(f=>({value:f.id,label:f.label})),variant:"filled",handleItemClick:m,styles:{trigger:Ca}}),Oe.createElement(wc,{size:20}),Oe.createElement(Sa,{variant:"body",size:"xsmall",color:"$neutral600"},u?_o.t("Enter Path"):_o.t("Enter Index")),Oe.createElement(wS,{type:u?"text":"number",variant:"contained",value:l,onChange:f=>p(f.target.value),style:Ca})),Oe.createElement(CS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!c||!a||!l},_o.t("Confirm")))}i(dn,"DerivationPath");import{i18n as $o}from"@lingui/core";import{Image as bS,MessageBox as ka,WalletState as ES}from"@rango-dev/ui";import{useWallets as IS}from"@rango-dev/wallets-react";import lo from"react";function Ta(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=IS();return pn(a(n))===ES.CONNECTED?lo.createElement(ka,{type:"success",title:$o.t("Wallet Connected"),description:$o.t("Your wallet is connected, you can use it to swap.")}):o?lo.createElement(ka,{type:"error",title:$o.t("Failed to Connect"),description:o||$o.t("Your wallet is not connected. Please try again.")}):lo.createElement(ka,{type:"loading",title:$o.t("Connecting to your wallet"),description:$o.t("Click connect in your wallet popup."),icon:lo.createElement(Lo,null,lo.createElement(Cr,null,lo.createElement(bS,{src:r,size:45})),lo.createElement(Po,null))})}i(Ta,"ConnectStatus");import{i18n as va}from"@lingui/core";import{Button as AS,Divider as Ec,MessageBox as NS}from"@rango-dev/ui";import Tr from"react";function wa(t){let{displayName:e,onConfirm:o}=t;return Tr.createElement(NS,{title:va.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:va.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Tr.createElement(Ec,{size:18}),Tr.createElement(Ec,{size:32}),Tr.createElement(AS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},va.t("Confirm")))}i(wa,"ExperimentalChain");function Ic(t,e){return t().status==="init"&&!!e}i(Ic,"isOnStatus");function fn(t){return t().status==="namespace"}i(fn,"isOnNamespace");function gn(t){return t().status==="derivationPath"}i(gn,"isOnDerivationPath");var LS=3e3,PS=300;function co(t){let e=MS(),[o,n]=Ac(!1),[r,a]=Ac(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:h}=Gt(),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 BS(()=>{if(t.wallet){C();let S=!1,k=!0,T=i(()=>{setTimeout(()=>{k=!1,S||n(!0)},PS)},"beforeConnecting"),v=i(w=>{let A=w.status==="connected",M=["disconnected","disconnected-unhandled"].includes(w.status);["namespace","derivation-path"].includes(w.status)||(S=!0),A&&!k?e.current=setTimeout(g,LS):M&&g(),t.onConnect&&t.onConnect(w)},"afterConnected");T(),p(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),po.createElement(Z,{open:o,onClose:g,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:W()},Ic(m,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(Ta,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(WS,{direction:"vertical",size:32})),fn(m)&&po.createElement(mn,{onConfirm:f,value:m().namespace}),gn(m)&&po.createElement(dn,{onConfirm:d,value:m().derivationPath}))}i(co,"StatefulConnectModal");import{legacyFormatAddressWithNetwork as $S,legacyReadAccountAddress as Wc}from"@rango-dev/wallets-core/legacy";import{Events as vr,Provider as DS}from"@rango-dev/wallets-react";import{isEvmBlockchain as FS}from"rango-sdk";import wr,{createContext as OS,useEffect as Bc,useMemo as US,useRef as Mc}from"react";import{useEffect as _S}from"react";function Nc(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Nc,"hashProviders");function xa(t,e){let{clearConnectedWallet:o}=y(),n=hr(t,e);return _S(()=>{o(),n=hr(t,e)},[Nc(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(xa,"useWalletProviders");var xr=OS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function zS(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}=xa(c.wallets,m),f=Mc(),d=Mc();Bc(()=>{n().catch(console.log)},[]),Bc(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:c,dappConfig:t.config})},[t.config,r]);let g=s.filter(FS).map(T=>T.name),C=i((T,v,w,A,M)=>{if(v===vr.ACCOUNTS){let x=pr(M.supportedBlockchains),E=[],b=[];if(w?.forEach(I=>{let{network:B}=Wc(I);g.includes(B)?E.push(I):b.push(I)}),u.filter(I=>I.walletType===T).map(I=>$S(I.address,I.chain)).length>0){if(E.length>0){let I=ra(T,E,g,x,M.isContractWallet);a(T,{chains:I.map(B=>B.chain)})}b.length>0&&a(T,{chains:b.map(I=>{let{network:B}=Wc(I);return B})})}if(w){let I=ra(T,w,g,x,M.isContractWallet);I.length&&l(I)}else p(T),d.current?d.current(T):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")}if(v===vr.ACCOUNTS&&A.connected||v===vr.ACCOUNTS&&M.isHub){let x=`${T}-${A.network}-${w}`;f.current?f.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(v===vr.NETWORK&&A.network){let x=`${T}-${A.network}`;f.current?f.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(T,v,w,A,M)},"onUpdateState"),S=ae.use.isActiveTab(),k=US(()=>({onConnectWallet:T=>{f.current=T},onDisconnectWallet:T=>{d.current=T}}),[]);return wr.createElement(xr.Provider,{value:k},wr.createElement(DS,{allBlockChains:s,providers:h,onUpdateState:C,autoConnect:!!S,configs:{wallets:c.wallets,isExperimentalEnabled:Up("experimentalWallet",c.features)}},t.children))}i(zS,"Main");function br(t){let{config:e,...o}=t;return wr.createElement(ic,{config:e},wr.createElement(zS,{...o,config:e}))}i(br,"WidgetWallets");import Xi from"react";import QS,{Fragment as qS}from"react";import{MemoryRouter as HS,useInRouterContext as GS}from"react-router";function Lc({children:t}){let o=GS()?qS:HS;return QS.createElement(o,null,t)}i(Lc,"AppRouter");import{I18nManager as EE}from"@rango-dev/ui";import Rl from"react";import Pe from"react";import{useRoutes as mE}from"react-router-dom";var D={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 Fo,useRef as Pr}from"react";import Ke from"bignumber.js";import{create as jS}from"zustand";import{subscribeWithSelector as XS}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as lB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as Mr}from"rango-types";import{i18n as $e}from"@lingui/core";var R=i(()=>({genericServerError:$e.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:$e.t("Please reset your liquidity sources."),description:$e.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:$e.t("No Routes Found."),description:$e.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:$e.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:$e.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:$e.t("High Price Impact"),title:$e.t("Price impact is too high!"),description:$e.t("The price impact is significantly higher than the allowed amount."),confirmMessage:$e.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:$e.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:$e.t("USD Price Unknown"),title:$e.t("USD Price Unknown, Cannot calculate Price Impact."),description:$e.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:$e.t("Confirm USD Price Unknown")}}),"errorMessages");function Pc(t){switch(t.type){case 0:return t.diagnosisMessage??R().noResultError.title;case 1:return R().genericServerError;default:return""}}i(Pc,"getQuoteErrorMessage");import{i18n as Er}from"@lingui/core";var uo=i(()=>({connectWallet:Er.t("Connect Wallet"),swap:Er.t("Swap"),swapAnyway:Er.t("Swap anyway"),ethWarning:Er.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");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 Ea=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],_c=100,$c=30,Dc=15,Fc=60;var Oc=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Uc=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as KS}from"@rango-dev/queue-manager-rango-preset";import jW from"bignumber.js";function Qc(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(Qc,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Ar(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=KS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=rn(a?a.toBlockchain:n.fromBlockchain,e),p=rn(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(Ar,"createRetryQuote");function Do(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=hn(o),s=pt(o);if(o&&a&&s){let u=Pt(a.toString(),s.toString());if(!!u&&Kc(a,u)){let m=Wr(o?.swaps,n),h=_t(u);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:u,totalFee:m,warningLevel:h}}}if(e&&Yc(e,o))return{type:4,usdValueChange:L(pt(o)?.minus(pt(e)??0).toString()??"0",null,2),percentageChange:L(Pt(pt(e)??"1",pt(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Br(o.swaps),p=r>Kp;if(Xc(t.userSlippage.toString(),l)){if(p&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:jc(o,r),minRequiredSlippage:l};return null}i(Do,"generateQuoteWarnings");function qc(t){return![4].includes(t.type)}i(qc,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Ia(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Hc=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"),Nr=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"),Gc=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"),Vc=i(t=>{let e=i((o,n)=>{let r=Ea.indexOf(o.value),a=Ea.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Kc(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Oc.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(Kc,"hasHighValueLoss");function Zc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(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(Zc,"hasLimitError");function Jc(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Ue(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 Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=gt.t({id:"Required: >= {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=gt.t({id:"Required: > {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=gt.t({id:"Required: <= {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=gt.t({id:"Required: < {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Jc,"getLimitErrorMessage");function Rc(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:uo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:uo().swap,action:"confirm-swap",disabled:!0}:s?{title:uo().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:uo().ethWarning,action:"confirm-warning",disabled:!1}:{title:uo().swap,action:"confirm-swap",disabled:!1}:{title:uo().connectWallet,action:"connect-wallet",disabled:!1}}i(Rc,"getSwapButtonState");function Aa(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ge))&&e&&e!=="0"&&n!==0)}i(Aa,"canComputePriceImpact");function Na(t,e){let o=ge;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 Ue(r.amount).multipliedBy(a||0))}return o}i(Na,"getUsdFeeOfStep");function Wr(t,e){return t.reduce((o,n)=>o.plus(Na(n,e)),ge)}i(Wr,"getTotalFeeInUsd");function Wa(t){let e=ge;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(Wa,"getUsdFee");function eu(t){return t.reduce((e,o)=>e.plus(Wa(o)),ge)}i(eu,"getTotalFeesInUsd");function tu(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(tu,"getFeesGroup");function ou(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(ou,"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 Br(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(Br,"getMinRequiredSlippage");function Xc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Xc,"hasProperSlippage");function nu(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,k)=>(S[k.chain]=k.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(nu,"createQuoteRequestBody");function ru(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(ru,"getWalletsForNewSwap");function hn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(hn,"getUsdInputFrom");function pt(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(pt,"getUsdOutputFrom");function Ia(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy(_c).toNumber()}i(Ia,"getPercentageChange");function Yc(t,e){let o=hn(t),n=pt(t),r=pt(e);if(!o||!n||!r)return!1;let a=Ia(n.toString(),r.toString());return Uc.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(Yc,"isOutputAmountChangedExcessively");function iu(t,e,o){let n=t.validationStatus,r=io({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>Qc(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=L(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=L(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=gt.t(" for input and network fee")),gt.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:st(s.asset.blockchain,o)}})})}i(iu,"generateBalanceWarnings");function yn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Mr.NetworkChanged}i(yn,"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,"")),yn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Mr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Mr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Mr.WaitingForNetworkChange:n=n||gt.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=io({filter:"all",quote:n}),l=io({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?Eo(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");var Lr=i((t,e)=>t?.usdPrice?new Ke(e||ge).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Mo(jS()(XS(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ke(0),outputUsdValue:new Ke(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=ge,a=o.inputUsdValue;return ln(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=hn(e)??ge,r=pt(e)??ge),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ke(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ke(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ke(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:Lr(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 Ke(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 Ke(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Lr(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:Lr(n??null,s),outputUsdValue:new Ke(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?Lr(e.toToken,e.outputAmount?.toString()||""):new Ke(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ke(0),inputUsdValue:new Ke(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ke(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})})))),uu=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&he.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&&he.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 mu(){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(),k=c?.from?.tokens,T=c?.from?.blockchains,v=c?.to?.tokens,w=c?.to?.blockchains,A=Pr(void 0),M=Pr(void 0),x=Pr(void 0),E=Pr(void 0);Fo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Fo(()=>{if(m==="success"){r();let b=h.find(B=>B.name===c?.from?.blockchain),N=c?.from?.token,I=N&&d(N);(b||!b&&x.current)&&n(b??null),I?a({token:I,meta:{blockchains:h,tokens:f}}):!I&&A.current&&a({token:null}),x.current=c?.from?.blockchain,A.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Fo(()=>{sa(s,k)&&a({token:null}),la(p,T)&&n(null)},[k,T]),Fo(()=>{sa(l,v)&&a({token:null}),la(u,w)&&o(null)},[v,w]),Fo(()=>{if(m==="success"){r();let b=h.find(B=>B.name===c?.to?.blockchain),N=c?.to?.token,I=N&&d(N);(b||!b&&E.current)&&o(b??null),I?e({token:I,meta:{blockchains:h,tokens:f}}):!I&&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]),Fo(()=>{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(mu,"useSyncStoresWithConfig");import{useEffect as La,useRef as YS}from"react";import{useInRouterContext as ZS,useLocation as JS,useSearchParams as RS}from"react-router-dom";function Ba(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Ba,"convertTokenSearchParamToAsset");function Ma(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Ma,"tokenToSearchParam");function _a(){let t=JS(),[e,o]=RS(),{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=ZS(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=YS(),{findToken:w}=y(),A=i(()=>{let x={};for(let[X,se]of e.entries())X.startsWith("utm_")&&(x[X]=se);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),N=e.get("fromToken"),I=e.get("toBlockchain"),B=e.get("toToken"),j=e.get("autoConnect"),te=e.get("clientUrl"),J=e.get("liquiditySources"),P=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:N,toBlockchain:I,toToken:B,autoConnect:j,clientUrl:te,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");La(()=>{let{autoConnect:x,clientUrl:E,utmQueryParams:b,blockchain:N}=A();C&&f==="success"&&M({fromBlockchain:n?.name,fromToken:Ma(a),toBlockchain:r?.name,toToken:Ma(s),fromAmount:l,autoConnect:x??void 0,clientUrl:E??void 0,blockchain:N??void 0,liquiditySources:T?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,T]),La(()=>{if(!C)return;let x=A();if(!v.current&&x.liquiditySources&&(v.current=x.liquiditySources),x.fromAmount&&h(x.fromAmount),f==="success"){let E=d.find(B=>B.name===x.fromBlockchain),b=x.fromToken&&E?w(Ba(x.fromToken,E)):void 0,N=d.find(B=>B.name===x.toBlockchain),I=x.toToken&&N?w(Ba(x.toToken,N)):void 0;E&&(p(E),b&&c({token:b,meta:{blockchains:d,tokens:g}})),N&&(u(N),I&&m({token:I,meta:{blockchains:d,tokens:g}}))}},[f]),La(()=>{let{clientUrl:x,liquiditySources:E}=A();S("clientUrl",x||void 0),k("liquiditySources",E?.split(",")??void 0)},[])}i(_a,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as dk,Button as Vu,darkTheme as fk,Divider as kn,DoneIcon as gk,MessageBox as hk,styled as yk,TextField as Sk,Typography as Ck}from"@rango-dev/ui";import ye,{useEffect as kk,useState as zr}from"react";import{useNavigate as Tk,useSearchParams as vk}from"react-router-dom";import{ChevronRightIcon as eC,Divider as yu,Image as tC,Typography as Su}from"@rango-dev/ui";import ht from"react";import{darkTheme as du,styled as $a}from"@rango-dev/ui";var fu=$a("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${du} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${du} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),gu=$a("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),hu=$a("div",{display:"flex"});function Da(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(gu,null,ht.createElement(Su,{size:"large",variant:"label"},n),ht.createElement(yu,{size:10}),ht.createElement(fu,{onClick:s?void 0:e,disabled:s},ht.createElement(hu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(tC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(yu,{size:4,direction:"horizontal"})),ht.createElement(Su,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(eC,{size:12,color:"black"})))}i(Da,"BlockchainSelectorButton");import{i18n as Oa}from"@lingui/core";import{Button as oC,Divider as Sn,ExternalLinkIcon as nC,Image as rC,Typography as Uo}from"@rango-dev/ui";import Ae from"react";function Cu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Cu,"generateExplorerLink");import{darkTheme as Oo,styled as ku}from"@rango-dev/ui";var Fa=ku("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Oo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Oo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Oo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Oo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Tu=ku("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Oo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Oo} &`]:{color:"$colors$neutral900"}}});function Ua(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=Cu(n.address,a);return Ae.createElement(Z,{open:e,dismissible:!0,onClose:o,container:W()},Ae.createElement(Tu,null,Ae.createElement(rC,{src:n.image,size:45,type:"circular"}),Ae.createElement(Uo,{variant:"title",size:"medium"},n.name),Ae.createElement(Uo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ae.createElement(Sn,{size:4}),Ae.createElement(Uo,{variant:"body",size:"medium"},s?Ae.createElement(Fa,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ae.createElement(nC,{size:12,color:"gray"})):Ae.createElement(Fa,null,n.address)),Ae.createElement(Sn,{size:4}),n.coinSource&&Ae.createElement(Uo,{className:"_coin-source",variant:"body",size:"xsmall"},Oa.t("via")," ",Ae.createElement(Uo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ae.createElement(Sn,{size:"32"}),Ae.createElement(Uo,{size:"medium",variant:"body",className:"_custom-token-description"},Oa.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(Sn,{size:40}),Ae.createElement(Sn,{size:10}),Ae.createElement(oC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Oa.t("Import")))}i(Ua,"CustomTokenModal");import{useManager as sk}from"@rango-dev/queue-manager-react";import{BottomLogo as lk,Divider as zu,Header as pk}from"@rango-dev/ui";import We,{useEffect as ls,useRef as Qu,useState as ck}from"react";import{useRef as iC}from"react";function _r(){return window.self!==window.top}i(_r,"isAppLoadedIntoIframe");function za(){let t=iC(null),{iframe:e}=y(),o=_r()&&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(za,"useIframe");import{useNavigate as aC}from"react-router-dom";function je(){let t=aC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as ja,darkTheme as kC,lightTheme as TC}from"@rango-dev/ui";import{useEffect as vC,useState as wC}from"react";import{theme as SC,darkColors as CC}from"@rango-dev/ui";import Va from"react";function sC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(sC,"expandShortHexColor");function lC(t){return/[0-9]+$/.test(t)}i(lC,"isOverridingColor");function pC(t,e){return t.padStart(e,"0")}i(pC,"pad");function Qa(t){let e=Math.min(Math.max(Math.round(t),0),255);return pC(e.toString(16),2)}i(Qa,"intToHex");function cC(t){return`#${Qa(t.red)}${Qa(t.green)}${Qa(t.blue)}`}i(cC,"rgbToHex");function uC(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(uC,"hexToRGB");function mC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(mC,"generateShade");function dC(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(dC,"generateTint");function fC(t){return vu(t,mC)}i(fC,"calculateShades");function gC(t){return vu(t,dC)}i(gC,"calculateTints");function vu(t,e){let o=uC(t),n=[];for(let r=1;r<9;r++)n.push(cC(e(o,r)));return n}i(vu,"calculateColors");function qa(t,e,o){let a=gC(t).reverse().concat(t),s=fC(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(qa,"createTintsAndShades");function Ha(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)&&!lC(r)){let p=sC(a);Object.assign(n,qa(p,r,s))}}return{...n,...e}}i(Ha,"expandToGenerateThemeColors");var wu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),hC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=wu(o%52)+e;return wu(o%52)+e},"toAlphabeticName"),yC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Ga=i(t=>hC(yC(5381,JSON.stringify(t))>>>0),"toHash");function Ka(t){let e=SC.colors,o={...e,...CC},n,r;if(t?.light){let s={colors:Ha(e,t.light)};n={id:`${aa}-light-${Ga(s)}`,tokens:s}}if(t?.dark){let s={colors:Ha(o,t.dark,{reverseNeutralRange:!0})};r={id:`${aa}-dark-${Ga(s)}`,tokens:s}}return{light:n,dark:r}}i(Ka,"customizedThemeTokens");function xu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Va.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Va.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Va.cloneElement(e,{key:l}))}}),o}i(xu,"joinList");function bu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(bu,"doesWindowPreferDarkColorScheme");function zo(t){let{colors:e,fontFamily:o=dp,borderRadius:n=$p,secondaryBorderRadius:r=Dp}=t,[a,s]=wC(bu()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=Ka(e),c=ja({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,TC.className],h=[c.className,kC.className];if(u){let d=ja(u.id,u.tokens);m.push(d.className)}if(p){let d=ja(p.id,p.tokens);h.push(d.className)}return vC(()=>{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(zo,"useTheme");var ct=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 Eu}from"@lingui/core";import{Alert as xC,Button as bC}from"@rango-dev/ui";import Iu from"react";function Xa(t){return Iu.createElement(xC,{action:Iu.createElement(bC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Eu.t("Activate this tab")),type:"warning",variant:"alarm",title:Eu.t("Another tab is open and handles transactions.")})}i(Xa,"ActivateTabAlert");import{i18n as Ya}from"@lingui/core";import{Button as EC,Divider as IC,MessageBox as AC}from"@rango-dev/ui";import $r from"react";function Za(t){let{open:e,onClose:o,onConfirm:n}=t;return $r.createElement(Z,{open:e,dismissible:!0,onClose:o,container:W()},$r.createElement(AC,{title:Ya.t("Activate current tab"),type:"warning",description:Ya.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.")},$r.createElement(IC,{size:20}),$r.createElement(EC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Ya.t("Confirm"))))}i(Za,"ActivateTabModal");import{ChevronLeftIcon as NC}from"@rango-dev/ui";import Au from"react";function Ja(t){return Au.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Au.createElement(NC,{color:"black",size:16}))}i(Ja,"BackButton");import{i18n as WC}from"@lingui/core";import{Button as BC,Typography as MC}from"@rango-dev/ui";import Ra from"react";function es(t){return Ra.createElement(Vt,null,Ra.createElement(BC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},Ra.createElement(MC,{variant:"label",size:"medium",color:"error500"},WC.t("Cancel"))))}i(es,"CancelButton");import{i18n as LC}from"@lingui/core";import{Image as PC,Tooltip as _C,WalletIcon as $C}from"@rango-dev/ui";import mo from"react";function ts(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?mo.createElement("div",{className:yc()},o.map(r=>mo.createElement(yr,{key:r.title},mo.createElement(PC,{src:r.image,size:14})))):LC.t("Connect Wallet");return mo.createElement(_C,{container:t.container,side:"bottom",content:n},mo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&mo.createElement(dc,null),mo.createElement($C,{size:18,color:"black"})))}i(ts,"WalletButton");import{i18n as Fr}from"@lingui/core";import{NotificationsIcon as JC,Popover as RC,SettingsIcon as ek,Tooltip as Or,TransactionIcon as tk}from"@rango-dev/ui";import Ne from"react";import{Notifications as UC}from"@rango-dev/ui";import zC from"react";import{useNavigate as QC}from"react-router-dom";import{create as DC}from"zustand";import{persist as FC,subscribeWithSelector as OC}from"zustand/middleware";var we=Mo(DC()(FC(OC((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 os(){let t=QC(),{getNotifications:e,clearNotifications:o}=we(),n=e(),r=y().blockchains(),{findToken:a}=y();return zC.createElement(UC,{list:n,getBlockchainImage:l=>ap(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${D.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(os,"NotificationContent");import{useManager as qC}from"@rango-dev/queue-manager-react";import{InProgressIcon as HC}from"@rango-dev/ui";import Nu from"react";var GC=i(()=>{let{manager:t}=qC();return ct(t).map(({swap:o})=>o).find(o=>o.status==="running")?Nu.createElement(hc,null,Nu.createElement(HC,{color:"info",size:6})):null},"InProgressTransactionBadge"),Wu=GC;import{EventSeverity as VC}from"@rango-dev/queue-manager-rango-preset";import{Typography as KC}from"@rango-dev/ui";import Bu from"react";function Mu(){let{getNotifications:t}=we(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===VC.WARNING);return o?Bu.createElement(fc,{isSever:n},Bu.createElement(KC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Mu,"NotificationsBadge");import{RefreshProgressButton as jC}from"@rango-dev/ui";import ns,{useEffect as XC,useState as Lu}from"react";var YC=1e3,Pu=60,ZC=100;function Dr({onClick:t}){let[e,o]=Lu(0),[n,r]=Lu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");XC(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Pu&&l()},YC):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 ns.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},ns.createElement(gc,{onTransitionEnd:()=>r(!1),isRefetched:n},ns.createElement(jC,{size:22,color:t?"black":"gray",progress:e/Pu*ZC})))}i(Dr,"RefreshButton");function fo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ve("notification",s)||r.includes("notifications");return Ne.createElement(Ne.Fragment,null,!r.includes("refresh")&&Ne.createElement(Or,{container:a||W(),side:"top",content:Fr.t("Refresh")},Ne.createElement(Dr,{onClick:e})),!l&&Ne.createElement(RC,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:W(),content:Ne.createElement(os,null)},Ne.createElement("div",null,Ne.createElement(Or,{container:W(),side:"top",content:Fr.t("Notifications")},Ne.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Ne.createElement(JC,{size:18,color:"black"}),Ne.createElement(Mu,null))))),!r.includes("settings")&&Ne.createElement(Or,{container:W(),side:"top",content:Fr.t("Settings")},Ne.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Ne.createElement(ek,{size:18,color:"black"}))),!r.includes("history")&&Ne.createElement(Or,{container:W(),side:"top",content:Fr.t("History")},Ne.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Ne.createElement(tk,{size:18,color:"black"}),Ne.createElement(Wu,null))))}i(fo,"HeaderButtons");import{i18n as rs}from"@lingui/core";import{Divider as $u,MessageBox as rk,RefreshIcon as ik}from"@rango-dev/ui";import Qo from"react";import{Button as ok,styled as nk}from"@rango-dev/ui";var _u=nk(ok,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function is(t){let{open:e,onClose:o}=t;return Qo.createElement(Z,{open:e,dismissible:!0,onClose:o,container:W()},Qo.createElement(rk,{title:rs.t("Something went wrong"),type:"error",description:rs.t("Something went wrong. Please refresh the app.")},Qo.createElement($u,{size:30}),Qo.createElement(_u,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Qo.createElement(ik,{size:20,color:"primary"}),Qo.createElement($u,{size:4,direction:"horizontal"}),rs.t("Refresh"))))}i(is,"RefreshModal");function as(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(as,"onScrollContentAttachStatusToContainer");import{css as ak,styled as ss}from"@rango-dev/ui";var Du="700px",Ur=ak({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Fu=ss("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Du},fixed:{height:Du}}}}),Ou=ss("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Uu=ss("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}=za(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:p}=y(),[u,c]=ck(!1),{config:{features:m,theme:h}}=y(),{watermark:f}=ae(),d=f==="FULL",{activeTheme:g}=zo(h||{}),C=Ve("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:k,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:w}=ae(),A=je(),{manager:M}=sk(),E=ct(M).map(({swap:te})=>te).some(te=>te.status==="running"),b=i(()=>w(ao.forceClaim,E),"onActivateTab"),N=i(()=>{r.onWallet?.()},"onConnectWallet"),I=typeof r.hasBackButton>"u"||r.hasBackButton,B=Qu(null),j=Qu(null);return ls(()=>(_r()&&j.current&&e(j.current),()=>{o()}),[]),ls(()=>(B.current?.addEventListener("scroll",as),()=>{B.current?.removeEventListener("scroll",as)}),[]),ls(()=>{c(l==="failed")},[l]),We.createElement(Fu,{height:s,id:_e.SWAP_BOX_ID,className:`${g()} ${Ur()}`,ref:j},We.createElement(pk,{prefix:I?We.createElement(Ja,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:We.createElement(We.Fragment,null,r.suffix,r.onWallet&&!C&&We.createElement(ts,{container:W(),onClick:N,isConnected:!!p?.length}),r.onCancel&&We.createElement(es,{onClick:r.onCancel}))}),We.createElement(Ou,{ref:B},n),We.createElement(Za,{open:T,onClose:()=>v(!1),onConfirm:b}),We.createElement(Uu,null,We.createElement("div",{className:"footer__content"},k&&!S&&We.createElement("div",{className:"footer__alert"},We.createElement(Xa,{onActivateTab:b}),We.createElement(zu,{size:10})),a),We.createElement(zu,{size:12}),We.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},We.createElement(lk,null))),We.createElement(is,{open:u,onClose:()=>c(!1)}))}i(oe,"Layout");import{styled as uk}from"@rango-dev/ui";var qu="$20 $20 $10 $20",Cn=uk("div",{padding:qu,overflowY:"auto",flexGrow:1});import{styled as mk}from"@rango-dev/ui";var re=mk("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 qo}from"@lingui/core";import{useState as Hu}from"react";function Gu(){let[t,e]=Hu(!1),[o,n]=Hu(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:qo.t("Duplicate Token"),message:qo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:qo.t("Token Already Exists"),message:qo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:qo.t("Token Not Found"),message:qo.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(Gu,"useFetchCustomToken");var wk=yk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${fk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),xk=1e3;function Ku(){let t=Tk(),[e]=vk(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=rn(a,r),[l,p]=zr(""),[u,c]=zr(!1),[m,h]=zr(),{fetchCustomToken:f,loading:d,error:g}=Gu(),[C,S]=zr(""),k=!!s&&Eo(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let M=await f({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"),A=i(async()=>{C&&setTimeout(async()=>{await v()},xk),w()},"handleErrorModalButtonClick");return kk(()=>{g&&c(!0)},[g]),ye.createElement(oe,{header:{title:It.t("Add Custom Token")}},ye.createElement(re,null,ye.createElement(wk,null,ye.createElement("div",null,ye.createElement(Da,{onClick:()=>t(D.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")}),ye.createElement(kn,{size:"24"}),ye.createElement(Ck,{size:"large",variant:"label"},It.t("Enter Address")),ye.createElement(kn,{size:10}),ye.createElement(Sk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&ye.createElement(gk,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!k&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(kn,{size:4}),ye.createElement(dk,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(Vu,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:d,size:"large",onClick:v},It.t("Import"))),ye.createElement(Z,{open:u,dismissible:!0,onClose:w,container:W()},ye.createElement(hk,{title:g?.title||C,type:"error",description:g?.message||It.t("Failed Network, Please retry.")},ye.createElement(kn,{size:40}),ye.createElement(kn,{size:10}),ye.createElement(Vu,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},C?It.t("Retry"):It.t("Add another custom token")))),s&&m&&ye.createElement(Ua,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!m})))}i(Ku,"AddCustomTokenPage");import{i18n as Fs}from"@lingui/core";import{useManager as sv}from"@rango-dev/queue-manager-react";import{Alert as lv,Button as pv,css as Us,Divider as Os,IconButton as zd,styled as cv,Typography as uv,WalletIcon as mv}from"@rango-dev/ui";import Me,{useEffect as gi,useLayoutEffect as dv,useRef as fv,useState as Ln}from"react";import{useNavigate as gv}from"react-router-dom";import{i18n as go}from"@lingui/core";import{Alert as Xk,BalanceErrors as Yk,Button as Tm,ChevronLeftIcon as Zk,Divider as hs,MessageBox as Jk,Typography as ys}from"@rango-dev/ui";import ee,{useCallback as Rk,useEffect as vm,useMemo as eT,useState as Vo}from"react";import{useNavigate as tT}from"react-router-dom";import{i18n as ms}from"@lingui/core";import{Alert as Nk,ChevronDownIcon as Wk,CloseIcon as Bk,Divider as em,IconButton as tm,PasteIcon as Mk,Typography as Lk,WalletIcon as Pk}from"@rango-dev/ui";import Be,{useEffect as _k,useRef as $k}from"react";import Gr,{useRef as Ik}from"react";import*as Ho from"@radix-ui/react-collapsible";import{keyframes as ju,styled as Qr}from"@rango-dev/ui";var ps=300,bk=ju({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Ek=ju({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Xu=Qr(Ho.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),cs=Qr(Ho.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),qr=Qr(Ho.Content,{overflow:"hidden",variants:{open:{true:{animation:`${bk} ${ps}ms ease-out`},false:{animation:`${Ek} ${ps}ms ease-out`}}}}),Hr=Qr("div",{transition:`all ${ps}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Vr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=Ik(null);return Gr.createElement(Xu,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Gr.createElement(cs,{className:"collapsible_trigger",onClick:a},s),Gr.createElement(qr,{className:"collapsible_content",open:e},r),l==="bottom"&&Gr.createElement(cs,{className:"collapsible_trigger",onClick:a},s))}i(Vr,"CustomCollapsible");import{darkTheme as Yu,styled as us,TextField as Ak}from"@rango-dev/ui";var Zu=us("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Ju=us(Ak,{backgroundColor:"$neutral100",padding:"$15"}),Ru=us("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Yu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Yu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function om(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),p=tr(e.name,l),u=$k(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),f=n&&!!r&&e&&!Eo(e,r),d=i(()=>{a("")},"handleClear"),g=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),u?.current?.focus()}},"handlePaste"),C=i(()=>r?Be.createElement(tm,{id:"widget-custom-destination-close-icon-btn",onClick:d,variant:"ghost"},Be.createElement(Bk,{size:12,color:"gray"})):m?null:Be.createElement(tm,{id:"widget-custom-destination-paste-icon-btn",onClick:g,variant:"ghost"},Be.createElement(Mk,{size:16})),"renderSuffix");return _k(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Be.createElement(Zu,null,Be.createElement(Vr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Be.createElement(Ru,null,Be.createElement("div",{className:"button__content"},Be.createElement(Pk,{size:18,color:"info"}),Be.createElement(em,{size:4,direction:"horizontal"}),Be.createElement(Lk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},ms.t("Send to a different address"))),Be.createElement(Hr,{orientation:n?"up":"down"},Be.createElement(Wk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Be.createElement(Ju,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:ms.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),f&&Be.createElement(Be.Fragment,null,Be.createElement(em,{size:4}),Be.createElement(Nk,{variant:"alarm",type:"error",title:ms.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(om,"CustomDestination");import{css as Dk,darkTheme as ds,IconButton as Fk,styled as $t}from"@rango-dev/ui";var nm=$t("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),rm=$t("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Ok=$t("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${ds} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${ds} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${ds} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),im=$t(Ok,{alignSelf:"stretch",minHeight:"93px"}),am=$t("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),sm=$t(Fk,{position:"absolute",left:"$20"}),lm=$t("div",{paddingTop:"$20"}),pm=Dk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),cm=$t("div",{display:"flex"}),um=$t("div",{overflow:"visible",width:"100%"});import{i18n as ym}from"@lingui/core";import{warn as Hk}from"@rango-dev/logging-core";import{Divider as Gk,SelectableWallet as Vk,Typography as Sm,WalletState as Cm}from"@rango-dev/ui";import Xe,{useEffect as km,useState as vn}from"react";import{Image as Qk,MessageBox as qk}from"@rango-dev/ui";import Tn from"react";import{keyframes as Uk,styled as fs}from"@rango-dev/ui";var mm=fs("div",{position:"relative"}),zk=Uk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),dm=fs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${zk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),fm=fs("div",{"& img":{borderRadius:"50%"}});import{i18n as Go}from"@lingui/core";function gm(t,e){switch(t){case"in-progress":return{type:"loading",title:Go.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Go.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Go.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Go.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Go.t("Request Rejected"),description:Go.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(gm,"generateMessageByStatus");function hm(t){let{status:e,displayName:o,image:n}=t,r=gm(e,o),a=e=="in-progress";return Tn.createElement(qk,{type:r.type,title:r.title,description:r.description,icon:a?Tn.createElement(mm,null,Tn.createElement(fm,null,Tn.createElement(Qk,{src:n,size:45})),Tn.createElement(dm,null)):void 0})}i(hm,"ExperimentalChainStatus");var Kk=7,jk=3e3;function gs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=ae.use.isActiveTab(),{blockchains:l,connectedWallets:p}=y(),[u,c]=vn(),[m,h]=vn(null),[f,d]=vn(!1),[g,C]=vn(null),{suggestAndConnect:S}=Kr(),{handleDisconnect:k}=Gt(),{list:T}=ft({chain:e}),[v,w]=vn(T),A=T.length,M=r&&A-r>0,x=i(async b=>{d(!1),C("in-progress");try{await S(b.walletType,b.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");km(()=>{w(b=>{let N=T.findIndex(I=>o(I.type,e));return M&&N>1?[T[N]].concat(T.filter((I,B)=>B!==N)):b.map(I=>T.find(B=>B.type===I.type)??I)})},[JSON.stringify(T)]);let E=document.getElementById(_e.SWAP_BOX_ID);return km(()=>{let b=null;return(g==="completed"||g==="rejected")&&(b=setTimeout(()=>C(null),jk)),()=>{b&&clearTimeout(b)}},[g]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(b=>{let N=Wp({connectedWallets:p,walletType:b.type,chain:e}),I=N?mr(N,Kk):"",B=cr(l(),e),j=!p.find(se=>se.walletType===b.type&&se.chain===e),te=B&&j&&b.state===Cm.CONNECTED,J=te?ym.t({id:"Add {chain} chain",values:{chain:e}}):I,P=i(async()=>{let se=b.state===Cm.DISCONNECTED,z=(b.isHub||!!b.needsNamespace)&&!I;se?c(b):z?(await k(b.type),c(b)):te?(h({walletType:b.type,chain:e,address:N??""}),d(!0)):n({walletType:b.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=m?.chain?tr(m.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${b.title}_${X}`},!!m&&Xe.createElement(Z,{open:!!m&&f,container:E,onClose:()=>{h(null)}},Xe.createElement(wa,{displayName:X,onConfirm:()=>{x(m)}})),g&&Xe.createElement(Z,{open:!!g,onClose:C.bind(null,null),container:E},Xe.createElement(hm,{status:g,displayName:X,image:b.image}),Xe.createElement(Gk,{direction:"vertical",size:32})),Xe.createElement(Vk,{key:b.type,description:J,onClick:P,selected:o(b.type,e),disabled:!s,...b}))}),Xe.createElement(co,{wallet:u,onClose:()=>{c(void 0)},onConnect:b=>{t.onConnect&&b.status==="connected"&&(u?.type?t.onConnect(u.type):Hk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Xe.createElement(im,{selected:!1,onClick:a},Xe.createElement(Sm,{variant:"label",size:"medium"},ym.t("Show more wallets"),Xe.createElement(Sm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(gs,"WalletList");var oT=2;function wm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=tT(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:h,setCustomDestination:f}=O(),{config:d,connectedWallets:g,setWalletsAsSelected:C}=y(),[S,k]=Vo(""),[T,v]=Vo([]),[w,A]=Vo(""),[M,x]=Vo(!!h),E=eT(()=>io({filter:"all",quote:p}),[p]),b=io({filter:"required",quote:p}),N=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),I=i(_=>b.includes(_),"isWalletRequiredFor"),B=Rk(()=>g.filter(_=>_.selected&&E.includes(_.chain)),[g,E]),[j,te]=Vo(B()),[J,P]=Vo([]),X=i((_,H)=>P(V=>V.concat({blockchain:_,walletType:H})),"addNextSelectedWallets"),se=T.length>0,z=i((_,H)=>!!j.find(V=>V.walletType===_&&V.chain===H&&V.selected&&(I(H)||!I(H)&&!h)),"isSelected"),me=i((_,H,V)=>{let de=!1;return _.map(ne=>{if(ne.chain===H){let fe=ne.selected;return!de&&V?(de=!0,fe=!0):V||(fe=!1),{...ne,selected:fe}}return ne})},"updateSelectableWallets"),vt=i(_=>{x(_),_?I(N?.name??"")||te(H=>me(H,N?.name||"",!1)):(f(""),te(H=>me(H,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(_=>{if(S&&k(""),z(_.walletType,_.chain))return;let V=g.find(de=>de.walletType===_.walletType&&de.chain===_.chain);V&&(n(),_.chain===N?.name&&M&&!I(N.name)&&(x(!1),f(null)),te(de=>de.filter(ne=>ne.chain!==_.chain).concat({...V,selected:!0})))},"onChange"),le=i(()=>{let _=j.filter(H=>H.selected);C(_),u(_),m(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),A("");let _=await r?.({selectedWallets:j.filter(V=>V.selected),customDestination:h}),H=_.warnings;H?.balance?.messages&&v(H.balance.messages),_.error&&A(Pc(_.error)),!_.error&&!H?.balance?.messages.length?le():v(H?.balance?.messages??[])},"onConfirmWallets");vm(()=>{te(_=>{let H=[];return _.forEach(V=>{!g.some(ne=>ne.chain===V.chain&&ne.walletType===V.walletType&&ne.address===V.address)||H.push(V)}),H=H.concat(g.filter(V=>!!!H.find(ne=>ne.chain===V.chain)&&V.selected&&E.includes(V.chain))),H})},[g,E]),vm(()=>{let _=[];J.length>0&&(J.forEach(H=>{let V=g.find(de=>de.chain===H.blockchain&&de.walletType===H.walletType);V?Ze(V):_.push(H)}),P(_))},[g,J]);let G=document.getElementById(_e.SWAP_BOX_ID);return ee.createElement(Z,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:G,...!S&&{styles:{container:{height:"100%"}},footer:ee.createElement(cm,null,ee.createElement(Tm,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:pu(a,M,h,p,j,N),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},go.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ee.createElement(am,null,ee.createElement(sm,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},ee.createElement(Zk,{size:16})),ee.createElement(ys,{variant:"headline",size:"small"},go.t({id:"Your {blockchainName} wallets",values:{blockchainName:st(S,l)}})))},anchor:"center"},ee.createElement(Z,{open:se,onClose:v.bind(null,[]),container:G},ee.createElement(Jk,{title:go.t("Insufficient account balance"),type:"error",description:ee.createElement(Yk,{messages:T??[]})},ee.createElement(Tm,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},go.t("Proceed anyway")))),S&&ee.createElement(lm,null,ee.createElement("div",{className:pm()},ee.createElement(gs,{chain:S,isSelected:z,selectWallet:Ze,onShowMore:()=>k(S),onConnect:_=>{X(S,_)}}))),!S&&ee.createElement(ee.Fragment,null,w&&ee.createElement(ee.Fragment,null,ee.createElement(Xk,{variant:"alarm",type:"error",title:go.t(w)}),ee.createElement(hs,{size:12})),ee.createElement(um,null,E.map((_,H)=>{let V=l.find(Fe=>Fe.name===_),de=`wallet-${H}`,ne=H===E.length-1,fe=ne&&N&&d?.customDestination!==!1;return ee.createElement("div",{key:de},ee.createElement(nm,null,ee.createElement(ys,{variant:"title",size:"xmedium"},go.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ee.createElement(ys,{variant:"label",color:"$neutral700",size:"medium"},go.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ee.createElement(hs,{size:24}),ee.createElement(rm,null,ee.createElement(gs,{chain:_,isSelected:z,selectWallet:Ze,limit:oT,onShowMore:()=>k(V?.name??""),onConnect:Fe=>{X(_,Fe)}})),!ne&&ee.createElement(hs,{size:32}),fe&&ee.createElement(om,{blockchain:N,open:M,handleOpenChange:vt}))}))))}i(wm,"ConfirmWalletsModal");import{i18n as TT}from"@lingui/core";import{Alert as vT,Button as wT,InfoIcon as xT}from"@rango-dev/ui";import et from"react";import{Alert as iT,Button as aT,Divider as ks,NoRouteIcon as sT,RefreshIcon as lT,Typography as Wm}from"@rango-dev/ui";import Re from"react";import{i18n as xm}from"@lingui/core";var nT=24,rT=60;function bm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:R().genericServerError,action:{onClick:n,title:xm.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:R().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:xm.t("Reset")}},description:R().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:R().noResultError.description}}i(bm,"makeInfo");var Ss=(o=>(o[o.small=nT]="small",o[o.large=rT]="large",o))(Ss||{}),Cs=(o=>(o.small="small",o.large="medium",o))(Cs||{});import{styled as jr}from"@rango-dev/ui";var Em=jr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Im=jr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Am=jr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Nm=jr("div",{padding:"$6 $0"});function wn(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 Re.createElement(Em,null,Re.createElement(sT,{size:Ss[n],color:"gray"}),Re.createElement(ks,{size:4}),Re.createElement(Wm,{variant:"title",size:Cs[n]},R().noResultError.title),n==="large"&&Re.createElement(ks,{size:4}),!!l.description&&Re.createElement(Im,{size:n},Re.createElement(Wm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(ks,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(Am,{size:n},Re.createElement(iT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(aT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement(Nm,null,Re.createElement(lT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(wn,"NoResult");import{i18n as xn}from"@lingui/core";import{Button as cT,Divider as uT,MessageBox as mT,Typography as dT,WarningIcon as fT}from"@rango-dev/ui";import Dt from"react";import{Typography as Pm}from"@rango-dev/ui";import vs from"react";import{darkTheme as pT,styled as Xr}from"@rango-dev/ui";var Bm=Xr("div",{width:"100%"}),Ts=Xr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Mm=Xr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${pT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Lm=Xr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function _m(t){let{title:e,value:o,valueColor:n}=t;return vs.createElement(Mm,null,vs.createElement(Pm,{size:"medium",variant:"label",className:"_title"},e),vs.createElement(Pm,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(_m,"QuoteErrorsModalItem");function $m(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:xn.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:xn.t("Gas cost"),value:L(r.totalFee,2,2)},{title:xn.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:xn.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return Dt.createElement(Z,{footer:Dt.createElement(cT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Dt.createElement(fT,null),fullWidth:!0,disabled:a,onClick:n},R().highValueLossError.confirmMessage),open:e,onClose:o,container:W()},Dt.createElement(mT,{type:s,title:R().highValueLossError.impactTitle,description:R().highValueLossError.description}),Dt.createElement(Ts,null,Dt.createElement(uT,{size:"4"}),Dt.createElement(dT,{size:"small",variant:"title"},xn.t("Details")),Dt.createElement(Ts,null,l.map((p,u)=>Dt.createElement(_m,{key:u,...p})))))}i($m,"HighValueLossWarningModal");import{i18n as Yr}from"@lingui/core";function Dm(t,e){let o={alertType:"warning",title:"",action:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Yr.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o;if(t){switch(t.type){case 0:{_t(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=R().highValueLossError.title;break}case 4:{o.title=Yr.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=R().unknownPriceError.title;break}case 2:{o.title=Yr.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings";break}case 3:{o.title=Yr.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Dm,"makeAlerts");import{i18n as Ko}from"@lingui/core";import{Button as Fm,Divider as Om,MessageBox as gT,Typography as hT}from"@rango-dev/ui";import ho from"react";import{useNavigate as yT}from"react-router-dom";function Um(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=yT(),u=e??o;return ho.createElement(Z,{anchor:"bottom",open:n,prefix:ho.createElement(Fm,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>p("../"+D.settings)},ho.createElement(hT,{variant:"label",size:"medium",color:"$neutral900"},Ko.t("Change settings"))),container:W(),onClose:r},ho.createElement(gT,{type:"warning",title:s.type===3?Ko.t("High slippage"):Ko.t("Low slippage"),description:s.type===3?Ko.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Ko.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},ho.createElement(Om,{size:18}),ho.createElement(Om,{size:32}),ho.createElement(Fm,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Ko.t("Confirm anyway"))))}i(Um,"SlippageWarningModal");import{Button as ST,MessageBox as CT,WarningIcon as kT}from"@rango-dev/ui";import Zr from"react";function zm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Zr.createElement(Z,{footer:Zr.createElement(ST,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Zr.createElement(kT,null),fullWidth:!0,disabled:r,onClick:n},R().unknownPriceError.confirmMessage),open:e,onClose:o,container:W()},Zr.createElement(CT,{type:"warning",title:R().unknownPriceError.impactTitle,description:R().unknownPriceError.description}))}i(zm,"UnknownPriceWarningModal");function bn(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=Dm(e,o?.type===3||o?.type===4?o:null);return f&&!n&&(f.action=null),et.createElement(et.Fragment,null,h&&et.createElement(wn,{error:o,fetch:s}),!!f&&et.createElement(Bm,null,et.createElement(vT,{title:f.title,type:f.alertType,variant:"alarm",...f.action==="show-info"&&{action:et.createElement(Lm,{onClick:l},et.createElement(xT,{size:12,color:"gray"}))},...f.action==="change-settings"&&{action:et.createElement(wT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:f.alertType,onClick:c},TT.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement($m,{...m,warning:e}),(e.type===3||e.type===2)&&et.createElement(Um,{...m,warning:e}),e.type===1&&et.createElement(zm,{...m,warning:e})))}i(bn,"QuoteWarningsAndErrors");import tv from"bignumber.js";import ui from"react";import{i18n as yo}from"@lingui/core";import{Alert as QT,Divider as Xo,FullExpandedQuote as qT,InfoIcon as HT,NumericTooltip as Cd,QuoteTag as GT,StepDetails as VT,TokenAmount as KT,Typography as Yo}from"@rango-dev/ui";import Bs from"bignumber.js";import F,{useRef as jT,useState as XT}from"react";import{styled as ws}from"@rango-dev/ui";var xs=ws("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Qm=ws("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),qm=ws("div",{width:"100%",display:"flex"});import*as Jr from"@radix-ui/react-collapsible";import{Button as bT,css as En,darkTheme as xe,Image as Hm,styled as ze,Typography as ET}from"@rango-dev/ui";var IT=300,Gm=ze(Jr.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Vm=En({padding:"$10 $15"}),Km=ze(bT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${xe} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${xe} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${xe} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),jm=ze("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",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${xe} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}}}}]}),Xm=En({width:"100%",padding:"$15 $15 $10 $15"}),Ym=En({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),jo=En({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Zm=En({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Jm=ze(Jr.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:{[`& ${Hm}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Hm}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),Rm=ze("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"}}}}),ed=ze(qr,{width:"100%",background:"inherit"}),bs=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${IT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),MF=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),td=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),od=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Es=ze(ET,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),nd=ze("div",{display:"flex",flexWrap:"wrap"}),Is=ze("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"}}}}),rd=ze("div",{display:"flex"}),Rr=ze("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as NT,CloseIcon as WT,Divider as oi,IconButton as BT,NumericTooltip as MT,QuoteCost as LT,Typography as yt}from"@rango-dev/ui";import Y,{useState as ld}from"react";import{css as AT,styled as ei}from"@rango-dev/ui";var ti=ei("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),As=ei("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),id=ei("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),ad=ei("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),sd=AT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var PT=i(t=>t.fee.isZero()?null:Y.createElement(ti,null,Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Y.createElement(yt,{variant:"label",size:"medium"},"$",L(t.fee,4,4))),"NonPayableFee");function Ns(t){let[e,o]=ld(!1),[n,r]=ld(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,timeWarning:c,showModalFee:m,fullExpandedMode:h=!1}=t,f=s?.swaps??[],d=h?no():W(),g=tu(f);return Y.createElement(Y.Fragment,null,Y.createElement(LT,{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}),Y.createElement(Z,{container:d,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Y.createElement(ad,{style:{textAlign:h?"left":"center"}},Y.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Y.createElement(BT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Y.createElement(WT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Y.createElement(id,null,Y.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Y.createElement(oi,{size:10}),Object.entries(g.payable).flatMap(([C,S])=>S.map((k,T)=>{let v=`payable-fee-${T}`,w=Wa(k);return Y.createElement(ti,{key:v},Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},ba(C,At.t)),Y.createElement(MT,{content:k.amount,container:d},Y.createElement(yt,{variant:"label",size:"medium"},L(k.amount,2,2)," ",k.asset.symbol," ($",L(w,4,4),")")))})),Y.createElement(ti,{className:"total_payable_fee"},Y.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Y.createElement(yt,{variant:"label",size:"medium"},"$",L(l,4,4))),Y.createElement(As,null),Object.keys(g.nonePayable).length&&Y.createElement(Vr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Y.createElement("div",{className:sd()},Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Y.createElement(oi,{size:4,direction:"horizontal"}),Y.createElement(Hr,{orientation:n?"up":"down"},Y.createElement(NT,{size:12,color:"gray"}))),open:n},Y.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Y.createElement(oi,{size:4}),Y.createElement(yt,{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.`)),Y.createElement(oi,{size:10}),Object.entries(g.nonePayable).map(([C,S],k)=>{let T=eu(S),v=ba(C,At.t),w=`non-payable-fee-${k}`;return Y.createElement(PT,{key:w,fee:T,label:v})}),Y.createElement(As,null)))))}i(Ns,"QuoteCostDetails");import{i18n as ud}from"@lingui/core";import{TokenAmount as md}from"@rango-dev/ui";import ni from"react";import{css as _T,styled as $T}from"@rango-dev/ui";var pd=$T("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),cd=_T({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function In(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ni.createElement(pd,null,ni.createElement(md,{direction:"horizontal",label:ud.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}}),ni.createElement("div",{className:cd()}),ni.createElement(md,{direction:"horizontal",tooltipContainer:W(),label:ud.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(In,"QuoteSummary");import{i18n as yd}from"@lingui/core";import{ChevronDownIcon as OT,ChevronRightIcon as UT,Divider as Ws,Image as zT,Tooltip as li,Typography as ii}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as DT,useState as An}from"react";var dd=480,fd=768,gd=1024,hd=1200,FT=i(()=>{let[t,e]=An(!1),[o,n]=An(!1),[r,a]=An(!1),[s,l]=An(!1),[p,u]=An(!1),c=i(()=>{e(window.innerWidth<=dd),n(window.innerWidth>dd&&window.innerWidth<=fd),a(window.innerWidth>fd&&window.innerWidth<=gd),l(window.innerWidth>gd&&window.innerWidth<=hd),u(window.innerWidth>hd)},"handleResize");return DT(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),ri=FT;var ai=4,si=6,Nn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||W();return U.createElement(li,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(Rm,{className:n,state:a},U.createElement(zT,{src:o,size:16})))},"ImageComponent");function Sd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||W(),u=r.length,c=Hc(r),{isTablet:m,isMobile:h}=ri();return U.createElement(Jm,{listItem:s==="list-item",ref:f=>e.current=f,selected:o,onClick:f=>{f.stopPropagation(),n(d=>!d)}},U.createElement("div",{className:jo()},U.createElement(ii,{variant:"body",size:"xsmall"},yd.t("Via:")),U.createElement(Ws,{direction:"horizontal",size:4}),r.map((f,d)=>{let g=`item-${d}`,C=U.createElement(bs,null,U.createElement(UT,{size:12,color:"black"}));return h||m?U.createElement(U.Fragment,{key:g},U.createElement(Nn,{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<=ai||u>ai&&d<ai-1?U.createElement(U.Fragment,null,U.createElement(Nn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),d!==u-1&&U.createElement(U.Fragment,null,C)):d===ai-1&&U.createElement(li,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:jo()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=d&&U.createElement(U.Fragment,{key:T},U.createElement(Nn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==u-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Is,{state:r.find((S,k)=>k>=d&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(ii,{size:"xsmall",variant:"body"},"+",u-d))))})),U.createElement("div",{className:jo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:jo()},U.createElement(ii,{variant:"body",size:"xsmall"},yd.t("Chains:")),U.createElement(Ws,{direction:"horizontal",size:4}),c.map((f,d)=>U.createElement(U.Fragment,{key:f.displayName},c.length<=si||c.length>si&&d<si-1?U.createElement(li,{container:p,side:"bottom",content:f.displayName,sideOffset:4},U.createElement(Nn,{content:"",src:f.image,open:!1,className:d!==0?"blockchainImage":""})):d===si-1&&U.createElement(li,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:jo()},c.map((g,C)=>C>=d&&U.createElement(Nn,{key:g.displayName,content:"",src:g.image,open:!1,className:C>d?"blockchainImage":"",container:l})))},U.createElement(Is,{className:"blockchainImage"},U.createElement(ii,{size:"xsmall",variant:"body"},"+",c.length-d))))),U.createElement(Ws,{direction:"horizontal",size:32}))),U.createElement(bs,{orientation:a?"up":"down"},U.createElement(OT,{size:12,color:"black"}))))}i(Sd,"QuoteTrigger");function Ms(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(),k=C||S,[T,v]=XT(t.expanded),w=jT(null),A=L(o.value,6,6),M=L(n.value,6,6),x=n.usdValue?L(n.usdValue,4,4):"",E=Pt(o.usdValue,n.usdValue??null),b=L(E,2,2),N=_t(E??0),I=i((le,at)=>le.map((G,_)=>{let H,V=r?.type===3&&r.swap.swapperId===G.swapperId,de=r?.type===4&&r.recommendedSlippages?.has(_),ne=a?.type===2&&a.recommendedSlippages?.has(_),fe=V||de,Fe=ne;fe?H="error":Fe&&(H="warning");let Te=fe?yo.t("Slippage Error"):yo.t("Slippage Warning");return V&&(Te=yo.t("Bridge Limit Error")),{swapper:{displayName:nn(G.swapperId,g)??"",image:G.swapperLogo},from:{token:{displayName:G.from.symbol,image:G.from.logo},chain:{displayName:st(G.from.blockchain,f)??"",image:G.from.blockchainLogo},price:{value:_===0&&!at?L(o.value,6,6):L(G.fromAmount,6,6),usdValue:L((G.from.usdPrice??0)*parseFloat(G.fromAmount),4,4),realValue:_===0?o.value:G.fromAmount,realUsdValue:new Bs(G.from.usdPrice??0).multipliedBy(G.fromAmount).toString()}},to:{token:{displayName:G.to.symbol,image:G.to.logo},chain:{displayName:st(G.to.blockchain,f)||"",image:G.to.blockchainLogo},price:{value:L(G.toAmount,6,6),usdValue:L((G.to.usdPrice??0)*parseFloat(G.toAmount),4,4),realValue:G.toAmount,realUsdValue:new Bs(G.to.usdPrice??0).multipliedBy(G.toAmount).toString()}},state:H,alerts:fe||Fe?F.createElement(Qm,{dense:m},F.createElement(QT,{variant:"alarm",type:fe?"error":"warning",title:Te,footer:F.createElement(qm,null,V&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Yours: {amount} {symbol}",values:{amount:L(G.fromAmount,6,6),symbol:G?.from.symbol}}))),(de||ne)&&!V&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(_)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(_)}}})),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:sn(G.estimatedTimeInSeconds),fee:L(Na(G,d),2,2),internalSwaps:G.internalSwaps?I(G.internalSwaps):void 0}}),"getQuoteSteps"),B=I(e?.swaps??[]),j=B.length,te=h||W(),J=Vc(t.quote.tags||[]),P=!!c,X=ar(e?.swaps),se=sn(X),z=Wr(e?.swaps??[],d),me=L(z,2,2),vt=z.gte(new Bs($c)),Ze=X/Fc>=Dc;return m?F.createElement(qT,{selected:l,fee:me,time:se,tooltipContainer:no(),steps:B,tags:J,quoteCost:F.createElement(Ns,{quote:e,fullExpandedMode:!0,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:j}),percentageChange:b,warningLevel:N,outputPrice:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(jm,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:Xm()},!p&&J.length?F.createElement(F.Fragment,null,F.createElement(rd,null,J.map((le,at)=>{let G=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:G},F.createElement(GT,{label:le.label,value:le.value}),F.createElement(Xo,{size:4,direction:"horizontal"}))})),F.createElement(Rr,null),!P&&F.createElement(Xo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Ym()},F.createElement(Ns,{quote:e,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:j}),P&&F.createElement(Km,{onClick:le=>{le.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Yo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},yo.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Zm()},F.createElement(od,null,F.createElement(HT,{size:12,color:"gray"})),F.createElement(nd,null,F.createElement(Es,{size:"small",variant:"body"},`${A} ${B[0].from.token.displayName} = `),F.createElement(Cd,{content:n.value,container:te,open:n.value?void 0:!1},F.createElement(Es,{size:"small",variant:"body"},"\xA0",`${M} ${B[B.length-1].to.token.displayName}`))),F.createElement(Cd,{content:n.usdValue,container:te},F.createElement(Xo,{size:2,direction:"horizontal"}),F.createElement(Yo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${x})`))),s==="list-item"&&F.createElement(KT,{tooltipContainer:te,type:"output",direction:"vertical",price:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:B[j-1].to.token.displayName,image:B[j-1].to.token.image},chain:{image:B[j-1].to.chain.image},percentageChange:b,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(In,{from:B[0].from,to:B[j-1].to,percentageChange:b,warningLevel:N}),F.createElement(Xo,{size:4}))),F.createElement(Gm,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(Sd,{type:s,quoteRef:w,selected:l,setExpanded:v,container:te,expanded:T,steps:B}),F.createElement(ed,{open:T},F.createElement(td,null),F.createElement("div",{className:Vm()},B.map((le,at)=>{let G=`item-${at}`;return F.createElement(VT,{type:"quote-details",key:G,tooltipContainer:te,step:le,hasSeparator:at!==B.length-1,state:le.state})})))))}i(Ms,"Quote");import{Divider as RT,Skeleton as ev}from"@rango-dev/ui";import Ot from"react";import{darkTheme as YT,styled as pi}from"@rango-dev/ui";var kd=pi("div",{$$color:"$colors$neutral100",[`.${YT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Td=pi("div",{paddingTop:"$2"}),vd=pi("div",{paddingLeft:"$8"}),wd=pi("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Ld,Divider as St,Skeleton as tt}from"@rango-dev/ui";import Q from"react";import{css as ZT,styled as Ft}from"@rango-dev/ui";var Ls=Ft("div",{display:"flex"}),xd=Ft("div",{padding:"$10 $0 $20"}),bd=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Ed=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Id=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Ad=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Nd=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Wd=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Bd=Ft("div",{padding:"$15 $0 $15 $0"}),Md=ZT({display:"flex",justifyContent:"space-between",alignItems:"center"});function Wn(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(Id,null,Q.createElement(Nd,null,Q.createElement(Ld,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{size:8,direction:"horizontal"}),Q.createElement(Wd,null,Q.createElement(tt,{height:10,width:60,variant:"rounded"}),Q.createElement(St,{size:4}),Q.createElement(tt,{height:15,variant:"rounded"}))),Q.createElement(tt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return Q.createElement("div",null,!o&&Q.createElement(Q.Fragment,null,Q.createElement(Ls,null,Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"})),Q.createElement(Rr,null),!r&&Q.createElement(St,{size:4})),Q.createElement("div",{className:Md()},Q.createElement(Ls,null,Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"})),r&&Q.createElement(tt,{width:85,height:24,variant:"rounded"})),e==="basic"&&Q.createElement(xd,null,Q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(bd,null,Q.createElement(Ed,null,Q.createElement(Ld,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{direction:"horizontal",size:4}),Q.createElement(tt,{height:15,width:150,variant:"rounded"})),Q.createElement(St,{size:10}),Q.createElement(tt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&Q.createElement(Q.Fragment,null,Q.createElement(St,{size:4}),Q.createElement(Bd,null,n,Q.createElement(Ad,null),n),Q.createElement(St,{size:12})))}i(Wn,"QuoteSummarySkeleton");import{ChainToken as Fd,Divider as _s,NextIcon as JT,Skeleton as ci}from"@rango-dev/ui";import be from"react";import{styled as Bn}from"@rango-dev/ui";var Pd=Bn("div",{display:"flex",alignItems:"start"}),_d=Bn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Ps=Bn("div",{display:"flex",alignItems:"center",flexGrow:1}),$d=Bn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Dd=Bn("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return be.createElement(be.Fragment,null,be.createElement(Dd,null,be.createElement(ci,{height:22,width:22,variant:"circular"}),be.createElement(_s,{direction:"horizontal",size:8}),be.createElement(ci,{height:15,width:148,variant:"rounded"})),be.createElement(Pd,null,be.createElement(wd,{hideSeparator:!e}),be.createElement(_d,{extraSpace:e},be.createElement(Ps,null,be.createElement(Fd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),be.createElement(_s,{direction:"horizontal",size:8}),be.createElement(ci,{height:12,variant:"rounded"})),be.createElement($d,null,be.createElement(JT,{color:"gray",size:16})),be.createElement(Ps,null,be.createElement(Fd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),be.createElement(_s,{direction:"horizontal",size:8}),be.createElement(ci,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function Mn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(kd,{expanded:o,rounded:e!=="basic"},Ot.createElement(Wn,{type:e,tagHidden:n}),Ot.createElement(Td,null,Ot.createElement(ev,{height:15,variant:"rounded"})),o&&Ot.createElement(vd,null,Ot.createElement(RT,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i(Mn,"QuoteSkeleton");function So(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}=O(),C=e?.outputAmount?new tv(e?.outputAmount):null,S=e?pt(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?ui.createElement(xs,null,ui.createElement(Mn,{tagHidden:l,type:o,expanded:s})):T?ui.createElement(xs,{onClick:()=>p?.(e)},ui.createElement(Ms,{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:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(So,"QuoteInfo");import{calculatePendingSwap as iv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as av}from"react";import{useRef as ov,useState as nv}from"react";var rv=2e3;function mi({request:t}){let[e,o]=nv(!1),n=ov(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,rv)),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(mi,"useFetch");function Od(){let{fetch:t,loading:e,cancelFetch:o}=mi({request:async(n,r)=>await bt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Od,"useFetchConfirmQuote");function di(t){if(!t.swaps)throw new Error(R().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=$s(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(di,"throwErrorIfResponseIsNotValid");function $s(t){if(Zc(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=ou(t);if(o){let n=Br(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i($s,"getQuoteError");function Ud(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},p=Do({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});p&&(l.quote=p);let u=iu(e,r,n.blockchains);return u.length===0||(l.balance={messages:u}),l}i(Ud,"generateWarnings");function fi(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(fi,"handleQuoteErrors");function Ds(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination: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}=Od();return av(()=>C,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,w=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((x,E)=>(x[E.chain]=E.address,x),{}),M={requestId:a?.requestId||"",selectedWallets:A,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");di({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};r(b);let N={slippage:d.toString(),disabledSwappersGroups:c},I=Ud({previousQuote:a??void 0,currentQuote:b,meta:{blockchains:m},selectedWallets:v,userSlippage:d,inputUsdValue:n,findToken:f});l();let B=!!I.balance,j=iv(o.toString(),E,ru(v),N,!B,{blockchains:m,tokens:h});return{quote:b,swap:j,error:null,warnings:I}})}catch(x){return fi(x)}},"fetch"),cancelFetch:C}}i(Ds,"useConfirmSwap");var hv=cv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${zd}`]:{width:"$48",height:"$48"}}),yv=Us({flexGrow:1,paddingRight:"$10"}),Sv=Us({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Cv=Us({display:"flex",justifyContent:"space-between",alignItems:"center"});function Qd(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=gv(),[l,p]=Ln(""),u=!n,[c,m]=Ln(!1),[h,f]=Ln(!1),{isActiveTab:d}=ae(),g=y().getDisabledLiquiditySources(),C=fv(g),{manager:S}=sv(),{fetch:k,loading:T,cancelFetch:v}=Ds(),[w,A]=Ln({swap:null,error:null,warnings:null}),[M,x]=Ln(!1),E=i(async({selectedWallets:P,customDestination:X})=>{let se=await k?.({selectedWallets:P,customDestination:X});return A(se),se},"onConfirmSwap"),b=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let P=`../${D.swaps}/${w.swap.requestId}`;s(P,{replace:!0}),setTimeout(()=>{e("")},0)}catch(P){p("Error: "+P?.message)}},"addNewSwap"),N=i(async()=>{f(!0),await b(),f(!1)},"onConfirm"),I=i(async()=>{w.warnings?.quote&&qc(w.warnings.quote)&&!a?x(!0):await N()},"onStartConfirmSwap"),B=i(async()=>{A({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(P=>{A(P)}).catch(P=>console.error(P))},"onRefresh");gi(()=>{!!C.current.length&&!g.length&&B(),C.current=g},[g.length]),gi(()=>{u&&v()},[u]),gi(()=>{u&&m(u)},[u]),gi(()=>{u||k({selectedWallets:o,customDestination:r}).then(P=>A(P)).catch(P=>console.error(P))},[]),dv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let j=w.warnings?.quote??null,te=w.error,J=[];if(l&&J.push(Me.createElement(lv,{type:"error",variant:"alarm",title:l})),j||te){let P=`../${D.settings}`;J.push(Me.createElement(bn,{warning:j,error:te,couldChangeSettings:!1,refetchQuote:B,showWarningModal:M,confirmationDisabled:!d,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await b()},onChangeSettings:()=>s(P)}))}return Me.createElement(oe,{header:{title:Fs.t("Confirm Swap"),onWallet:()=>{let P=`../${D.wallets}`;s(P)}},footer:Me.createElement(hv,null,Me.createElement("div",{className:yv()},Me.createElement(pv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!w.error||!d,onClick:I},Fs.t("Start Swap"))),Me.createElement(zd,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!d,onClick:m.bind(null,!0)},Me.createElement(mv,{size:24})))},c&&Me.createElement(wm,{open:c,onClose:()=>m(!1),onCancel:v,loading:T,onCheckBalance:E}),Me.createElement(re,null,Me.createElement("div",{className:Cv()},Me.createElement(uv,{variant:"title",size:"small"},Fs.t("You get")),Me.createElement("div",{className:Sv()},Me.createElement(Dr,{onClick:!T&&!c&&!M?B:void 0}))),Me.createElement(Os,{size:"12"}),xu(J.map((P,X)=>({element:P,key:`alert-${X}`})),Me.createElement(Os,{size:10})),J.length>0?Me.createElement(Os,{size:10}):null,Me.createElement(So,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:T,warning:w.warnings?.quote??null})))}i(Qd,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Zs,CustomTokensZeroStateDarkIcon as _v,CustomTokensZeroStateIcon as $v,DeleteIcon as Dv,Divider as Dn,IconButton as Fv,MessageBox as Ov,NotFound as Uv,styled as Rs}from"@rango-dev/ui";import ue,{useState as Js}from"react";import{useNavigate as zv}from"react-router-dom";import{CloseIcon as Tv,IconButton as vv,SearchIcon as wv,TextField as xv}from"@rango-dev/ui";import Pn from"react";import{styled as kv}from"@rango-dev/ui";var qd=kv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return Pn.createElement(xv,{prefix:Pn.createElement(qd,null,Pn.createElement(wv,{color:"black"})),suffix:!!s.length&&Pn.createElement(vv,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Pn.createElement(Tv,{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(Ct,"SearchInput");import{i18n as Ys}from"@lingui/core";import{darkTheme as ef,Divider as Jo,ExternalLinkIcon as Iv,Image as Av,ListItemButton as Nv,NotFound as Wv,PinIcon as Bv,Skeleton as tf,Typography as Si,VirtualizedList as Mv}from"@rango-dev/ui";import q from"react";import{Divider as Jd,ListItem as Ev,Skeleton as _n}from"@rango-dev/ui";import kt from"react";import{css as Zo,darkTheme as Hd,ImageContainer as bv,styled as ut,Typography as Gd}from"@rango-dev/ui";var zs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),Qs=Zo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),qs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Hs=Zo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Hd} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Gs=Zo({}),Vs=Zo(),Vd=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Ks=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),hi=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${Qs}`]:{[`& .${Hs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Gs}`]:{bottom:"-15px"},[`& .${zs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${qs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),js=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Xs=ut(Gd,{}),Kd=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Vs}`]:{$$color:"$colors$neutral600",[`.${Hd} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),yi=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),EU=ut("div",{display:"flex",alignItems:"center"}),jd=ut("div",{position:"relative",[`& ${bv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Xd=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Yd=ut(Gd,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Zd=ut("a",{"& svg:hover":{color:"$colors$info"}});function Rd(t){return kt.createElement(hi,null,Array.from(Array(t.size),e=>kt.createElement(Ev,{key:e,hasDivider:!0,start:kt.createElement(_n,{variant:"circular",width:35,height:35}),end:kt.createElement(yi,null,kt.createElement(_n,{variant:"text",size:"large",width:70}),kt.createElement(Jd,{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(Jd,{size:4}),kt.createElement(_n,{variant:"text",size:"medium",width:90}))})))}i(Rd,"LoadingTokenList");var Lv=20,Pv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return q.createElement("div",{className:Qs()},o?q.createElement("div",{className:zs()},o):q.createElement(Ks,{className:qs()},q.createElement(Si,{variant:"title",size:"xmedium"},r.symbol),q.createElement(Jo,{direction:"horizontal",size:4}),q.createElement(js,{css:a},q.createElement(Xs,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&q.createElement("div",{className:`${Hs()} ${!o&&Gs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",q.createElement(Jo,{size:4,direction:"horizontal"}),q.createElement(Zd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},q.createElement(Iv,{size:12}))))},"renderDesc");function $n(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=ur(u(d));return s?s(d):c?q.createElement(yi,null,q.createElement(tf,{variant:"text",size:"large",width:70}),q.createElement(Jo,{size:4}),q.createElement(tf,{variant:"text",size:"medium",width:50})):g&&q.createElement(Kd,null,q.createElement(Yd,{variant:"title",size:"small"},g.amount),q.createElement("div",null),g.usdValue&&q.createElement(Si,{variant:"body",className:Vs(),size:"xsmall"},`$${g.usdValue}`))},"endRenderer"),f=i(()=>q.createElement(Mv,{itemContent:d=>{let g=e[d],C=g.address||"",S=p.find(w=>w.name===g.blockchain),k=qa(S.color,"main"),T={$$color:k.main150,[`.${ef} &`]:{$$color:k.main750},backgroundColor:"$$color"},v={$$color:k.main750,[`.${ef} &`]:{$$color:k.main150},color:"$$color"};return q.createElement("div",{style:{paddingRight:5}},q.createElement(Nv,{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:q.createElement(jd,null,q.createElement(Av,{src:g.image,size:30}),t.type!=="custom-token"&&m(g,t.type)&&q.createElement(Xd,null,q.createElement(Bv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||g.name||!g.name&&!C?q.createElement(Ks,null,q.createElement(Si,{variant:"title",size:"xmedium"},g.symbol),q.createElement(Jo,{direction:"horizontal",size:4}),q.createElement(js,{css:T},q.createElement(Xs,{variant:"body",size:"xsmall",css:v},g.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?Pv({address:C,token:e[d],customCssForTag:T,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 q.createElement(q.Fragment,null,a&&q.createElement(q.Fragment,null,q.createElement(Si,{variant:"label",size:"large"},Ys.t("Select Token")),q.createElement(Jo,{size:4})),q.createElement(Vd,null,q.createElement(Jo,{size:4}),l==="loading"&&q.createElement(Rd,{size:Lv}),l==="success"&&(e.length?q.createElement(hi,{as:"ul"},f()):!!o&&q.createElement(Wv,{title:Ys.t("No results found"),description:Ys.t("Try using different keywords")}))))}i($n,"TokenList");var Qv=Rs("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),qv=Rs("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Hv=Rs(Fv,{"&:hover":{"& svg":{color:"$secondary550"}}});function of(){let[t,e]=Js(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:p}=zo({}),u=zv(),[c,m]=Js(!1),[h,f]=Js(),d=i(k=>{let T=k.target.value;e(T)},"handleSearch"),g=p==="dark",C=n.filter(k=>Je(k.symbol,t)||Je(k.address||"",t)||Je(k.name||"",t)),S=i(()=>{if(h){let k=a?lt(a):null,T=r?lt(r):null,v=lt(h);k===v?l({token:null}):T===v&&s({token:null}),o(h)}m(!1)},"handleDeleteCustomToken");return ue.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},ue.createElement(re,null,ue.createElement(Qv,null,n.length?ue.createElement(ue.Fragment,null,ue.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:d}),ue.createElement(Dn,{size:16}),ue.createElement($n,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>ue.createElement(Hv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),f(k)}},ue.createElement(Dv,{size:12,color:"gray"}))})):ue.createElement(qv,null,ue.createElement(Uv,{icon:g?ue.createElement(_v,{size:200}):ue.createElement($v,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),ue.createElement(Dn,{size:20}),ue.createElement(Zs,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u(D.addCustomTokens)},Ut.t("Add Custom Token"))),ue.createElement(Z,{open:c,dismissible:!0,onClose:()=>m(!1),container:W()},ue.createElement(Ov,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},ue.createElement(Dn,{size:40}),ue.createElement(Dn,{size:10}),ue.createElement(Zs,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),ue.createElement(Dn,{size:12}),ue.createElement(Zs,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ut.t("No, Continue"))))))}i(of,"CustomTokensPage");import{i18n as qe}from"@lingui/core";import{useManager as pw}from"@rango-dev/queue-manager-react";import{Button as al,darkTheme as cw,Divider as ko,MessageBox as uw,NotFound as mw,styled as sl,Typography as Ti}from"@rango-dev/ui";import{TransactionStatus as Un}from"rango-types";import ie,{useMemo as vf,useState as vi}from"react";import{useNavigate as dw}from"react-router-dom";import{FilterIcon as Zv,Popover as Jv}from"@rango-dev/ui";import Co from"react";import{css as Gv,darkTheme as Ci,IconButton as Vv,styled as Fn}from"@rango-dev/ui";var el=Fn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ci} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),nf=Fn(Vv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ci} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ci} &`]:{backgroundColor:"$neutral"},[`& ${el}::before`]:{backgroundColor:"$secondary100",[`.${Ci} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),rf=Fn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),af=Fn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),sf=Gv({display:"flex",justifyContent:"space-between",alignItems:"center"}),lf=Fn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as pf}from"@lingui/core";import{Button as Kv,Divider as cf,ListItemButton as jv,Radio as Xv,RadioRoot as Yv,Typography as uf}from"@rango-dev/ui";import ot from"react";function mf(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(af,null,ot.createElement("div",{className:sf()},ot.createElement(uf,{size:"small",variant:"body"},pf.t("Status")),ot.createElement(Kv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},pf.t("Reset"))),ot.createElement(cf,{size:10}),ot.createElement(Yv,{value:e},ot.createElement(lf,null,t.list.map((n,r)=>ot.createElement(jv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:ot.createElement(ot.Fragment,null,ot.createElement(cf,{direction:"horizontal",size:4}),ot.createElement(uf,{size:"medium",variant:"body"},n.title)),start:ot.createElement(Xv,{value:n.id}),onClick:o})))))}i(mf,"FilterSelectorContent");function tl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Co.createElement("div",null,Co.createElement(Jv,{open:a,align:"end",onOpenChange:o,container:W(),content:Co.createElement(mf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Co.createElement(nf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Co.createElement(el,{isSelect:!!n},Co.createElement(Zv,{size:16,color:"black"}),!!n&&Co.createElement(rf,null)))))}i(tl,"FilterSelector");import{i18n as tw}from"@lingui/core";import{Divider as yf,GroupedVirtualizedList as ow,Skeleton as nw,SwapListItem as Sf,Typography as rw}from"@rango-dev/ui";import Qe,{useCallback as Cf,useEffect as iw,useRef as aw,useState as sw}from"react";function df(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(df,"calculateGroupsSoFar");import{css as Rv,darkTheme as ew,styled as On}from"@rango-dev/ui";var ol=Rv(),ff=On("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),nl=On("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${ol}`]:{$$color:"$colors$neutral600",[`.${ew} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),rl=On("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),gf=On("div",{gap:"$10",display:"flex",flexDirection:"column"}),hf=On("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var lw=10;function il(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=sw([]),l=aw(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=Cf(df,[]),h=Cf(()=>{let f=e.length-l.current;f&&(l.current+=Math.min(f,lw),s(m(u,l.current)))},[e.length]);if(iw(()=>{r||h()},[r,h]),r){let f=[1,2];return Qe.createElement(Qe.Fragment,null,[f,f].map((g,C)=>Qe.createElement(nl,{key:C},Qe.createElement(rl,null,Qe.createElement(nw,{variant:"text",width:60,size:"small"}),Qe.createElement(yf,{size:16})),Qe.createElement(yf,{size:4}),Qe.createElement(gf,null,g.map((k,T)=>Qe.createElement(Sf,{isLoading:!0,key:T}))))))}return Qe.createElement(ow,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:f=>Qe.createElement(nl,null,Qe.createElement(rl,null,Qe.createElement(rw,{variant:"label",size:"medium",className:ol()},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 Qe.createElement(ff,{key:g.requestId},Qe.createElement(Sf,{requestId:g.requestId,creationTime:g.creationTime,status:g.status,onClick:o,tooltipContainer:W(),onlyShowTime:c[d]===tw.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(il,"HistoryGroupedList");import{i18n as ki}from"@lingui/core";import kf from"dayjs";var Tf=i(t=>{let e=new Map([["today",{title:ki.t("Today"),swaps:[]}],["week",{title:ki.t("This week"),swaps:[]}],["month",{title:ki.t("This month"),swaps:[]}],["year",{title:ki.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=kf();t.forEach(p=>{let u=Number(p.creationTime),c=kf(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 fw=sl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),gw=sl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),hw=sl("div",{"._typography":{color:"$neutral700",[`.${cw}&`]:{color:"$neutral900"}}}),yw=[{id:Un.SUCCESS,title:qe.t("Complete")},{id:Un.RUNNING,title:qe.t("Running")},{id:Un.FAILED,title:qe.t("Failed")}],Sw=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=dw(),{manager:e,state:o}=pw(),n=ct(e).map(({swap:T})=>T),[r,a]=vi(""),[s,l]=vi(!1),p=!o.loadedFromPersistor,[u,c]=vi(""),[m,h]=vi(!1),f=i(T=>{let v=T.target.value;a(v)},"handleSearch"),d=vf(()=>!r&&!u?n:n.filter(T=>{let{inputAmount:v,status:w,steps:A,requestId:M}=T;return(!r||wt(v,r)||wt(w,r)||Sw(A,r)||wt(M,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(T){console.log(T)}},"onClear"),k=vf(()=>!n.some(T=>T.status===Un.SUCCESS||T.status===Un.FAILED),[n]);return ie.createElement(oe,{header:{title:qe.t("History"),suffix:ie.createElement(Vt,null,ie.createElement(al,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ie.createElement(Ti,{size:"medium",variant:"label",color:"error"},qe.t("Clear"))))}},ie.createElement(re,null,ie.createElement(gw,null,ie.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:qe.t("Search Transaction"),autoFocus:!0,onChange:f,style:{height:36},value:r}),ie.createElement(ko,{size:10,direction:"horizontal"}),ie.createElement(tl,{filterBy:u,open:s,onOpenChange:T=>l(T),onClickItem:T=>c(T),list:yw})),ie.createElement(ko,{size:"16"}),ie.createElement(fw,null,g&&ie.createElement(hf,null,ie.createElement(ko,{size:32}),ie.createElement(mw,{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&&ie.createElement(il,{list:d,onSwapClick:t,groupBy:Tf,isLoading:p}))),ie.createElement(Z,{open:m,onClose:C,container:W()},ie.createElement(ko,{size:20}),ie.createElement(uw,{type:"warning",title:qe.t("Clear Transaction History"),description:ie.createElement(hw,null,ie.createElement(Ti,{variant:"body",size:"medium"},qe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ie.createElement(ko,{size:"24"}),ie.createElement(Ti,{variant:"body",size:"small"},qe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ie.createElement(ko,{size:30}),ie.createElement(al,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},qe.t("Yes, Clear the history")),ie.createElement(ko,{size:10}),ie.createElement(al,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ie.createElement(Ti,{variant:"title",size:"medium",color:"primary"},qe.t("No, Cancel")))))}i(wf,"HistoryPage");import{i18n as Qw}from"@lingui/core";import{Button as qw,Divider as Hf,styled as Hw,WarningIcon as Gw}from"@rango-dev/ui";import Vw from"bignumber.js";import He,{useEffect as Gf,useState as Vf}from"react";import{useNavigate as Kw}from"react-router-dom";import{i18n as bf}from"@lingui/core";import{Alert as kw,Divider as ll,NoRouteIcon as Tw,Typography as vw}from"@rango-dev/ui";import To from"react";import{styled as Cw}from"@rango-dev/ui";var xf=Cw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function pl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Mt(t,e)?To.createElement(xf,null,To.createElement(ll,{size:10}),To.createElement(Tw,{size:24,color:"gray"}),To.createElement(ll,{size:4}),To.createElement(vw,{variant:"title",size:"small"},bf.t("No Routes Found")),To.createElement(ll,{size:4}),To.createElement(kw,{title:bf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(pl,"SameTokensWarning");import{i18n as Aw}from"@lingui/core";import{Header as Nw}from"@rango-dev/ui";import Jt,{useEffect as Ww,useState as Bw}from"react";import{i18n as xw}from"@lingui/core";import{Divider as ul,FullExpandedQuote as bw,Typography as Ew}from"@rango-dev/ui";import Se from"react";import{styled as cl}from"@rango-dev/ui";var Ef=cl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),If=cl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Af=cl("div",{width:"146px"});import{i18n as zn}from"@lingui/core";import{Select as ww}from"@rango-dev/ui";import Nf from"react";function wi(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:zn.t("Smart Routing")},{value:"FEE",label:zn.t("Lowest Fee")},{value:"SPEED",label:zn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:zn.t("Maximum Return")},{value:"PRICE",label:zn.t("Maximum Output")}];return Nf.createElement(Af,null,Nf.createElement(ww,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(wi,"SelectStrategy");var Wf=3;function Qn(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(),k=l||W(),T=!!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 Do({currentQuote:E,userSlippage:v,findToken:S})},"getQuoteWarning"),A=d?.type===0||d?.type===1,M=u?.results?Nr(f,u?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(If,null,Se.createElement(Ew,{size:"xmedium",variant:"title"},xw.t("Sort by")),Se.createElement(wi,{container:k})),Se.createElement(ul,{size:"10"})),e&&Array.from({length:Wf},(x,E)=>Se.createElement(Se.Fragment,{key:E},s?Se.createElement(bw,{loading:!0}):Se.createElement(Mn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Wf-1&&Se.createElement(ul,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?M.map((x,E)=>{let b=w(x),N=$s(x.swaps),I=M.length-1===E;return Se.createElement(Se.Fragment,{key:x.requestId},Se.createElement(So,{showModalFee:r,container:k,selected:p?.requestId===x.requestId,tagHidden:!1,quote:{...x,requestAmount:u.requestAmount,validationStatus:null},loading:e,error:N?.options||null,warning:b,fullExpandedMode:s,onClick:B=>{N||c("warning",b),c("error",N?.options||null),o(B)},type:"list-item"}),!I&&Se.createElement(ul,{size:16}))}):A&&Se.createElement(Ef,null,Se.createElement(wn,{size:s?"large":"small",error:d,fetch:n}))))}i(Qn,"Quotes");import{darkTheme as Iw,styled as Bf}from"@rango-dev/ui";var Mf=Bf("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Iw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Lf=Bf("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Mw=100;function ml(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Bw(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=no();return Ww(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Mw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Mf,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${Ur()}`,id:_e.EXPANDED_BOX_ID},Jt.createElement(Nw,{title:Aw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(wi,{container:m}),Jt.createElement(fo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(Lf,null,Jt.createElement(Qn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:no(),onClickOnQuote:n,fullExpandedMode:c})))}i(ml,"ExpandedQuotes");import{i18n as Uf}from"@lingui/core";import{SwapInput as zf}from"@rango-dev/ui";import $w from"bignumber.js";import qn from"react";import{ReverseIcon as _w}from"@rango-dev/ui";import fl from"react";import{keyframes as Lw,styled as Pf}from"@rango-dev/ui";var dl=450,Pw=Lw({"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)"}}),_f=Pf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),$f=Pf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${Pw} ${dl}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 gl(){let t=O.use.switchFromAndTo();return fl.createElement(_f,null,fl.createElement($f,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},dl),t()}},fl.createElement(_w,{size:12})))}i(gl,"SwitchFromAndToButton");import{styled as Df}from"@rango-dev/ui";var Ff=Df("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Of=Df("div",{position:"relative"});function hl(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,k=ur(S)?.amount??"0",T=S?new $w(S.amount).shiftedBy(-S.decimals):ge,v=!!s&&Bp(g,s.name),w=!Aa(d,c,m),A=!Aa(d,c,f),M=!m||!f||!f.gt(0)?null:Pt(m.toString(),f.toString());return qn.createElement(Ff,null,qn.createElement(Of,null,qn.createElement(zf,{label:Uf.t("From"),mode:"From",onInputChange:u,balance:k,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?R().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:W(),onSelectMaxBalance:()=>{let x=L(T,S?.decimals),E=S?.amount?x:"";u(E)},anyWalletConnected:g.length>0}),qn.createElement(gl,null)),qn.createElement(zf,{sharpBottomStyle:!r&&(!!d||e),label:Uf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:L(Pt(m,f),2,2),warningLevel:_t(M??0),price:{value:L(h,6,6),usdValue:A?void 0:L(f,4,4),realValue:h?.toString(),realUsdValue:A?void 0:f?.toString(),error:A?R().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:W()}))}i(hl,"Inputs");import{useCallback as Dw,useEffect as Fw,useRef as Ow,useState as Uw}from"react";function Qf(){let{fetch:t,loading:e,cancelFetch:o}=mi({request:async(n,r)=>await bt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Qf,"useFetchAllQuotes");var zw=600;function xi({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Qf(),{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:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:w,fetchStatus:A}=y(),M=y().getLiquiditySources(),x=y().getDisabledLiquiditySources(),E=y().excludeLiquiditySources(),{findToken:b}=y(),[N,I]=Uw(!0),B=Ow(p),j=k??S,J=!s||!l||Mt(s,l)||!ln(p),P=i(z=>{I(z)},"resetState"),X=i(z=>{let{fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,slippage:_,affiliateRef:H,affiliatePercent:V,affiliateWallets:de}=z;if(N||P(!0),!J&&me&&vt){h();let ne=nu({fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,wallets:a,slippage:_,affiliateRef:H,affiliatePercent:V,affiliateWallets:de});Ao("experimental",r)&&(ne.experimental=!0),Ao("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),Ao("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(fe=>{let Fe=Nr(m,fe.results),Te=Gc(c,Fe,fe.requestAmount);I(!1),C("quotes",fe),g(Te),di({diagnosisMessages:fe.diagnosisMessages,requestId:Te?.requestId||"",swaps:Te?.swaps});let dt=Te&&Do({currentQuote:Te,userSlippage:j,findToken:b});C("warning",dt)}).catch(fe=>{let{error:Fe}=fi(fe);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),I(!1))})}},"fetch"),se=Dw(Cp(z=>{X(z)},zw),[J]);return Fw(()=>{if(!t){I(!1);return}if(A!=="success")return;if(J){I(!1),(c||f||d)&&h();return}if(!ln(p)||u?.eq(0)){P(!1),o();return}h(),P(!0);let z=X;return B.current&&B.current!=p&&(z=se),B.current=p,z({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:j,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),o},[A,p,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,M?.length,n,x.length,j,v,T,JSON.stringify(w)]),{fetch:()=>X({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:j,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),loading:N}}i(xi,"useSwapInput");function qf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};he.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(qf,"emitPreventableEvent");var jw=Hw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Xw=300;function Kf(){let t=Kw(),{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]=Vf(!1),{isLargeScreen:g,isExtraLargeScreen:C}=ri(),{fetch:S,loading:k}=xi({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:w}=y(),{isActiveTab:A}=ae(),[M,x]=Vf(!1),b=Rc({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),N=Fp(g,C,T?.variant),I=!!n&&!!e&&!!o&&new Vw(n).gt(0)&&!cu(e,o),B=I&&v==="success"&&k,J=(!N||N&&p?.results.length)&&(l||s);Gf(()=>{c(),h("refetchQuote",!0)},[]),Gf(()=>{d(I)},[I]);let P=(r||s)&&!M?S:void 0,X=i(z=>{N&&f?(d(!1),setTimeout(()=>{t(z)},Xw)):t(z)},"onHandleNavigation"),se=i(z=>{r?.requestId!==z.requestId&&(x(!1),u(z))},"onClickOnQuote");return He.createElement(jw,null,He.createElement(oe,{height:"auto",footer:He.createElement(qw,{id:`widget-swap-${b.action}-btn`,type:"primary",size:"large",disabled:b.disabled||!A,prefix:b.action==="confirm-warning"&&He.createElement(Gw,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?qf({type:"clickConnectWallet"},()=>X(D.wallets)):b.action==="confirm-warning"?x(!0):X(D.confirmSwap)}},b.title),header:{onWallet:()=>{X(D.wallets)},hasBackButton:!1,title:T.title||Qw.t("Swap"),suffix:He.createElement(fo,{hidden:N?["refresh"]:void 0,onClickRefresh:P,onClickHistory:()=>X(D.swaps),onClickSettings:()=>{X(D.settings)}})}},He.createElement(re,null,He.createElement(hl,{fetchingQuote:B,fetchMetaStatus:v,isExpandable:N,onClickToken:z=>{X(z==="from"?D.fromSwap:D.toSwap)}}),He.createElement(Hf,{size:"2"}),N?null:He.createElement(So,{quote:r,loading:B,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{h("refetchQuote",!1),X(D.routes)}:void 0}),J?He.createElement(He.Fragment,null,He.createElement(Hf,{size:"10"}),He.createElement(bn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!A,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:()=>{x(!1),m(!0),X(D.confirmSwap)},onChangeSettings:()=>X(D.settings)})):null,He.createElement(pl,null))),N?He.createElement(ml,{loading:B,onClickOnQuote:se,fetch:S,onClickRefresh:P,isVisible:f}):null)}i(Kf,"Home");import{i18n as jf}from"@lingui/core";import{Alert as Yw,Divider as Zw,List as Jw,ListItemButton as Rw,Radio as ex,RadioRoot as tx,Typography as ox}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Hp,r=o?.language||No;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||No),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function Xf(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),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(ox,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(ex,{value:s}),start:Wt.createElement(p,null)}});return Wt.createElement(oe,{header:{title:jf.t("Language")}},Wt.createElement(re,null,Wt.createElement(Yw,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(Zw,{size:"8"}),Wt.createElement(tx,{value:t},Wt.createElement(Jw,{type:Wt.createElement(Rw,{title:jf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Xf,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as sx,Checkbox as lx,Image as px,ListItemButton as cx,NotFound as ux,Typography as mx}from"@rango-dev/ui";import Ge,{useState as dx}from"react";import{Checkbox as ix,Skeleton as Zf}from"@rango-dev/ui";import Gn from"react";import{styled as yl}from"@rango-dev/ui";var Hn=yl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Sl=yl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Cl=yl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as nx,styled as rx}from"@rango-dev/ui";var Yf=rx(nx,{height:61});var ax=30;function kl(){return Gn.createElement(Hn,null,Array.from(Array(ax),(t,e)=>Gn.createElement(Yf,{hasDivider:!0,key:e,start:Gn.createElement(Zf,{variant:"circular",width:35,height:35}),title:Gn.createElement(Zf,{variant:"text",size:"large",width:90}),end:Gn.createElement(ix,{checked:!1})})))}i(kl,"LoadingLiquiditySourceList");function Tl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=dx(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=fr(o,n),u={Exchanges:zt.t("Exchanges"),Bridges:zt.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:k,groupTitle:T,logo:v,id:w,...A}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(px,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ge.createElement(lx,{checked:k,disabled:l}),title:Ge.createElement(mx,{variant:"title",size:"xmedium"},zt.t(T)),selected:k,groupTitle:T,logo:v,...A}}),g=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=d;return r&&(C=d.filter(S=>wt(S.groupTitle,r))),Ge.createElement(oe,{header:{title:zt.t(t),suffix:Ge.createElement(Sl,null,Ge.createElement(sx,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:f},h?zt.t("Deselect all"):zt.t("Select all")))}},Ge.createElement(re,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:u[t]}),onChange:g}),e==="loading"&&Ge.createElement(kl,null),!C.length&&r?Ge.createElement(Cl,null,Ge.createElement(ux,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(Hn,{disabled:l},C.map(S=>{let{groupTitle:k,...T}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(cx,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(Tl,"LiquiditySourcePage");import{i18n as fx}from"@lingui/core";import bi from"react";import{useNavigate as gx}from"react-router-dom";function Jf(){let t=gx(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:p}=xi({refetchQuote:n}),u=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${D.settings}`,m=`../${D.wallets}`;return bi.createElement(oe,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:fx.t("Routes"),suffix:bi.createElement(fo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},bi.createElement(re,null,bi.createElement(Qn,{fetch:l,loading:p,onClickOnQuote:u})))}i(Jf,"RoutesPage");import{i18n as ig}from"@lingui/core";import{Divider as ag,getCategoriesCount as bx,SelectableCategoryList as Ex}from"@rango-dev/ui";import Qt,{useState as sg}from"react";import{useNavigate as Ix}from"react-router-dom";import{i18n as vl}from"@lingui/core";import{Divider as Cx,Image as kx,ListItemButton as Tx,NotFound as vx,Typography as rg}from"@rango-dev/ui";import nt,{useEffect as wx,useState as xx}from"react";var Rf=i((t,e,o)=>t.filter(n=>ir(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as hx,styled as eg}from"@rango-dev/ui";var tg=eg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ei=eg(Cn,{padding:0,margin:0,listStyle:"none",[`& ${hx}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as yx,Skeleton as og}from"@rango-dev/ui";import Ii from"react";var Sx=20;function ng(){return Ii.createElement(Ei,null,Array.from(Array(Sx),t=>Ii.createElement(yx,{key:t,hasDivider:!0,start:Ii.createElement(og,{variant:"circular",width:35,height:35}),title:Ii.createElement(og,{variant:"text",size:"large",width:90})})))}i(ng,"LoadingBlockchainList");function wl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=xx(e),{fetchStatus:p}=y();wx(()=>{l([...Rf(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?nt.createElement(vx,{title:vl.t("No results found"),description:vl.t("Try using different keywords")}):nt.createElement(Ei,{as:"ul",key:`${r}-${o}`},s.map(c=>nt.createElement(Tx,{key:`${c.name}-${c.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(c),start:nt.createElement(kx,{src:c.logo,size:30}),title:nt.createElement(rg,{variant:"title",size:"medium"},c.displayName),id:c.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(rg,{variant:"label",size:"large"},vl.t("Select Chain")),nt.createElement(Cx,{size:4})),nt.createElement(tg,null,p==="loading"&&nt.createElement(ng,null),p==="success"&&u()))}i(wl,"BlockchainList");function Ai(t){let{type:e}=t,o=je(),[n,r]=sg(""),[a,s]=sg("ALL"),l=O.use.setToBlockchain(),p=O.use.setFromBlockchain(),{fetchStatus:u}=y(),c=Ix(),m=y().blockchains({type:e}),h=bx(m),f=!t.hideCategory&&h!==1;return Qt.createElement(oe,{header:{title:ig.t("Select Chain")}},Qt.createElement(re,{view:!0},f&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Ex,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),Qt.createElement(ag,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:ig.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:d=>r(d.target.value)}),Qt.createElement(ag,{size:16}),Qt.createElement(wl,{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(Ai,"SelectBlockchainPage");import{i18n as Wi}from"@lingui/core";import{Divider as dg}from"@rango-dev/ui";import vo,{useState as _x}from"react";import{useNavigate as $x}from"react-router-dom";import{i18n as El}from"@lingui/core";import{BlockchainsChip as Ni,Divider as ug,Image as mg,Skeleton as Mx,Tooltip as Lx,Typography as Il}from"@rango-dev/ui";import Le from"react";import{useEffect as Wx}from"react";var lg=["ETH","COSMOS","OSMOSIS"];function xl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Ax),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(Nx(s)),r=n.splice(a)}return{list:n,more:r}}i(xl,"prepare");function Ax(t,e){let o=lg,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(Ax,"sortByMostUsedBlockchains");function Nx(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(Nx,"generateSortByPreferredBlockchainsFor");function pg(t,e){return!!e.list.find(o=>o.name===t)}i(pg,"isInVisibleList");function bl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();Wx(()=>{if(e?.selected){let a=xl(t,o,e);pg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=xl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(bl,"usePrepareBlockchainList");import{styled as Bx}from"@rango-dev/ui";var cg=Bx("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var Px=12;function Al(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=bl(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 Le.createElement(Le.Fragment,null,Le.createElement(ug,{size:12}),Le.createElement(Il,{variant:"label",size:"large"},El.t("Select Chain")),Le.createElement(ug,{size:12}),Le.createElement(cg,null,l==="loading"&&Array.from(Array(Px),f=>Le.createElement(Mx,{key:f,variant:"rounded",height:50})),l==="success"&&Le.createElement(Le.Fragment,null,Le.createElement(Ni,{selected:!n,onClick:()=>{o==="from"?u():p()}},Le.createElement(Il,{variant:"body",size:"xsmall",color:"secondary500"},El.t("All"))),s.list.map(f=>Le.createElement(Lx,{key:f.name,content:f.shortName,side:"bottom",sideOffset:2,container:W()},Le.createElement(Ni,{key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},Le.createElement(mg,{src:f.logo,size:30})))),m?Le.createElement(Ni,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Le.createElement(mg,{src:s.more[0].logo,size:30})):null,h?Le.createElement(Ni,{onClick:a,key:"more-blockchains"},Le.createElement(Il,{variant:"body",size:"xsmall",color:"secondary500"},El._("More +{count}",{count:s.more.length}))):null)))}i(Al,"BlockchainsSection");function Nl(t){let{type:e}=t,o=$x(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=O(),{getBalanceFor:c}=y(),[m,h]=_x(""),d=(e==="source"?r:a)?.name??"",g=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:d,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:g,tokens:C}}):l({token:v,meta:{blockchains:g,tokens:C}})},"updateToken"),T={source:Wi.t("Source"),destination:Wi.t("Destination")};return vo.createElement(oe,{header:{title:Wi.t("Swap {type}",{type:T[e]})}},vo.createElement(re,null,vo.createElement(Al,{blockchains:g,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(D.blockchains),onChange:v=>{S(v)}}),vo.createElement(dg,{size:24}),vo.createElement(Ct,{value:m,autoFocus:!0,placeholder:Wi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),vo.createElement(dg,{size:16}),vo.createElement($n,{list:C,selectedBlockchain:d,searchedFor:m,type:e,onChange:v=>{k(v);let w=g.find(A=>v.blockchain===A.name);w&&S(w),n()}})))}i(Nl,"SelectSwapItemsPage");import{i18n as Ml}from"@lingui/core";import{Alert as lb,Button as pb,styled as cb}from"@rango-dev/ui";import wo from"react";import{useInRouterContext as ub,useSearchParams as mb}from"react-router-dom";import{i18n as Cg}from"@lingui/core";import{Divider as kg,InfoIcon as Ux,SlippageIcon as zx,TextField as Qx,Tooltip as qx,Typography as Tg}from"@rango-dev/ui";import rt from"react";import{Chip as Dx,styled as Vn,TextField as Fx}from"@rango-dev/ui";var fg=Vn("div",{paddingTop:"$5",padding:"$10 $5"}),gg=Vn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Fx}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),hg=Vn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Bi=Vn("div",{maxWidth:"280px",padding:"$10"}),yg=Vn(Dx,{width:"61px",flexShrink:0});import{i18n as Wl}from"@lingui/core";import{Typography as Ox}from"@rango-dev/ui";import Kn from"react";function Sg(){return Kn.createElement(Bi,null,Kn.createElement(Ox,{variant:"label",size:"medium",color:"neutral700"},Wl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Kn.createElement("br",null),Kn.createElement("br",null),Kn.createElement("b",null,Wl.t("Warning")),":\xA0",Wl.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(Sg,"SlippageTooltipContent");function Bl(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(fg,null,rt.createElement(hg,null,rt.createElement(zx,{size:16,color:"gray"}),rt.createElement(kg,{direction:"horizontal",size:4}),rt.createElement(Tg,{variant:"title",size:"xmedium"},Cg.t("Slippage tolerance per swap")),rt.createElement(kg,{direction:"horizontal",size:4}),rt.createElement(qx,{container:W(),side:"top",sideOffset:4,content:rt.createElement(Sg,null)},rt.createElement(Ux,{color:"gray"}))),rt.createElement(gg,null,Gp.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(yg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(Qx,{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>=Xp&&s<=jp?n(s):n(null)},suffix:o&&rt.createElement(Tg,{variant:"body",size:"small"},"%"),placeholder:Cg.t("Custom")})))}i(Bl,"Slippage");import{i18n as mt}from"@lingui/core";import{AutoThemeIcon as vg,BridgesIcon as Hx,ChevronRightIcon as Mi,DarkModeIcon as wg,Divider as jn,ExchangeIcon as Gx,InfinityIcon as Vx,InfoIcon as Kx,LanguageIcon as jx,LightModeIcon as xg,List as Xx,ListItem as Yx,ListItemButton as Zx,Skeleton as Jx,styled as Rx,Switch as eb,Tabs as tb,TargetIcon as ob,Tooltip as nb,Typography as Ye}from"@rango-dev/ui";import $ from"react";import{useNavigate as rb}from"react-router-dom";var ib=Rx("div",{width:"202px",height:"$40"}),ab=[{id:"light",icon:$.createElement(xg,{color:"black",size:24}),tooltip:$.createElement(Ye,{size:"xsmall",variant:"body"},mt.t("Light"))},{id:"dark",icon:$.createElement(wg,{color:"black",size:24}),tooltip:$.createElement(Ye,{size:"xsmall",variant:"body"},mt.t("Dark"))},{id:"auto",icon:$.createElement(vg,{color:"black",size:24}),tooltip:$.createElement(Ye,{size:"xsmall",variant:"body"},mt.t("Auto"))}],sb=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return $.createElement(vg,{...e});case"dark":return $.createElement(wg,{...e});default:return $.createElement(xg,{...e})}},"getThemeIcon");function bg(){let t=rb(),{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=Ve("theme",c),f=Ve("liquiditySource",c),d=Ve("language",c),g=Ve("customTokens",c),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=fr(p,u),T=k.filter(P=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(P.type)),v=T.length,w=T.filter(P=>P.selected).length,A=k.filter(P=>P.type==="DEX"),M=A.length,x=A.filter(P=>P.selected).length,E=i((P,X)=>{switch(l){case"loading":return $.createElement(Jx,{variant:"text",size:"medium",width:50});case"failed":return $.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},mt.t("Loading failed"));default:return $.createElement(Ye,{variant:"body",size:"medium"},`${P} / ${X}`)}},"handleSwapperEndItem"),b={id:"widget-setting-bridge-item-btn",title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Bridges")),end:$.createElement($.Fragment,null,E(w,v),$.createElement(jn,{direction:"horizontal",size:8}),$.createElement(Mi,{color:"black"})),onClick:()=>t(D.bridges),start:$.createElement(Hx,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Exchanges")),end:$.createElement($.Fragment,null,E(x,M),$.createElement(jn,{direction:"horizontal",size:8}),$.createElement(Mi,{color:"black"})),start:$.createElement(Gx,{color:"gray",size:16}),onClick:()=>t(D.exchanges)},I={id:"widget-setting-custom-tokens-item-btn",title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Custom Tokens")),end:$.createElement($.Fragment,null,$.createElement(Ye,{variant:"body",size:"medium"},`${m.length}`),$.createElement(jn,{direction:"horizontal",size:8}),$.createElement(Mi,{color:"black"})),start:$.createElement(ob,{color:"gray",size:16}),onClick:()=>t(D.customTokens)},B={id:"widget-setting-language-item-btn",title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Language")),start:$.createElement(jx,{color:"gray",size:16}),end:$.createElement($.Fragment,null,$.createElement(Ye,{variant:"body",size:"medium"},s),$.createElement(jn,{direction:"horizontal",size:8}),$.createElement(Mi,{color:"black"})),onClick:()=>t(D.languages)},j={id:"widget-setting-infinite-approval-item-btn",title:$.createElement($.Fragment,null,$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Infinite approval")),$.createElement(jn,{direction:"horizontal",size:4}),$.createElement(nb,{side:"top",sideOffset:4,container:W(),content:$.createElement(Bi,null,$.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},$.createElement("b",null,mt.t("Warning")),":\xA0",mt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},$.createElement(Kx,{color:"gray"}))),start:$.createElement(Vx,{color:"gray",size:16}),end:$.createElement(eb,{checked:C}),onClick:S},te={id:"widget-setting-theme-item-btn",type:$.createElement(Yx,null),title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Theme")),end:$.createElement(ib,null,$.createElement(tb,{container:W(),items:ab,value:n,onChange:P=>o(P.id),type:"primary",borderRadius:"small"})),start:sb(n)},J=f?[]:[b,N];return g||J.push(I),d||J.push(B),J.push(j),!e?.singleTheme&&!h&&J.push(te),$.createElement(Xx,{type:$.createElement(Zx,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(bg,"SettingsLists");var db=cb("div",{paddingLeft:"$8"});function Eg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=mb(),r=ub(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return wo.createElement(oe,{header:{title:Ml.t("Settings")}},wo.createElement(re,null,o&&wo.createElement(lb,{type:"info",variant:"alarm",title:Ml.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:wo.createElement(db,null,wo.createElement(pb,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Ml.t("Reset")))}),wo.createElement(Bl,null),wo.createElement(bg,null)))}i(Eg,"SettingsPage");import{i18n as eE}from"@lingui/core";import{cancelSwap as tE}from"@rango-dev/queue-manager-rango-preset";import{useManager as oE}from"@rango-dev/queue-manager-react";import{Alert as nE}from"@rango-dev/ui";import Xl from"react";import{useParams as rE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as _b,getCurrentStep as $b,getRelatedWalletOrNull as Db}from"@rango-dev/queue-manager-rango-preset";import{Button as nh,CopyIcon as Fb,Divider as Ob,DoneIcon as Ub,IconButton as zb,QuoteCost as Qb,RangoExplorerIcon as qb,StepDetails as Hb,Tooltip as rh,Typography as xo,useCopyToClipboard as Gb}from"@rango-dev/ui";import{useWallets as Vb}from"@rango-dev/wallets-react";import ih from"bignumber.js";import{PendingSwapNetworkStatus as zi}from"rango-types";import K,{useEffect as ah,useRef as Kb,useState as sh}from"react";import{useNavigate as jb}from"react-router-dom";import{i18n as eo}from"@lingui/core";var fb=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function Ig(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"):`${fb[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Ig,"timeSince");function Ag(t){return t.finishTime?Ig(parseInt(t.finishTime)):Ig(parseInt(t.creationTime))}i(Ag,"getSwapDate");import{PendingSwapNetworkStatus as _i}from"rango-types";import $i from"react";import{i18n as Li}from"@lingui/core";import{Button as Ng,Divider as Ll,MessageBox as gb}from"@rango-dev/ui";import to from"react";var Wg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(Ll,{size:20}),to.createElement(gb,{type:"error",title:Li.t("Cancel Swap"),description:Li.t("Are you sure you want to cancel this swap?")}),to.createElement(Ll,{size:32}),to.createElement(Ng,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Li.t("Yes, Cancel it")),to.createElement(Ll,{size:12}),to.createElement(Ng,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Li.t("No, Continue"))),"CancelContent");import{i18n as Pi}from"@lingui/core";import{Button as Bg,Divider as Pl,MessageBox as hb,Typography as yb}from"@rango-dev/ui";import qt from"react";var Mg=i(({onDelete:t,onClose:e})=>qt.createElement(qt.Fragment,null,qt.createElement(Pl,{size:20}),qt.createElement(hb,{type:"error",title:Pi.t("Delete Transaction"),description:Pi.t("Are you sure you want to delete this swap?")}),qt.createElement(Pl,{size:32}),qt.createElement(Bg,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Pi.t("Yes, Delete it")),qt.createElement(Pl,{size:12}),qt.createElement(Bg,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},qt.createElement(yb,{variant:"title",size:"medium",color:"primary"},Pi.t("No, Cancel")))),"DeleteContent");import{i18n as _l}from"@lingui/core";import{PendingSwapNetworkStatus as $l}from"rango-types";var Dl={[$l.WaitingForNetworkChange]:{type:"loading",title:_l.t("Change Network")},[$l.WaitingForConnectingWallet]:{type:"warning",title:_l.t("Connect Wallet")},[$l.NetworkChanged]:{type:"success",title:_l.t("Network Changed")}};import{warn as Sb}from"@rango-dev/logging-core";import{MessageBox as Cb,Wallet as kb}from"@rango-dev/ui";import{useWallets as Tb}from"@rango-dev/wallets-react";import Ro,{useState as vb}from"react";import{styled as Lg}from"@rango-dev/ui";var Pg=Lg("div",{display:"flex",justifyContent:"center"}),a5=Lg("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var _g=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=vb(),{getWalletInfo:u,state:c}=Tb(),m=n?.walletType,h=m?pn(c(m)):null,f=m?u(m):null,d=a&&!!m&&!!h&&!!f,{list:g}=ft(),C=i(()=>{if(m){let S=g.find(k=>k.type===m);S?p(S):Sb(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return Ro.createElement(Ro.Fragment,null,Ro.createElement(Cb,{type:e,title:o,description:r}),d&&Ro.createElement(Pg,null,Ro.createElement(kb,{container:W(),title:f.name,image:f.img,type:m,state:h,link:f.installLink,disabled:s,onClick:C})),Ro.createElement(co,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function Fl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===_i.WaitingForNetworkChange||e===_i.WaitingForConnectingWallet||e===_i.NetworkChanged;return $i.createElement(Z,{open:!!e,onClose:o,container:document.getElementById(_e.SWAP_BOX_ID)||document.body},p&&$i.createElement(_g,{type:Dl[e].type,title:Dl[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==_i.WaitingForNetworkChange}),e==="delete"&&$i.createElement(Mg,{onClose:o,onDelete:n}),e==="cancel"&&$i.createElement(Wg,{onClose:o,onCancel:r}))}i(Fl,"SwapDetailsModal");import{i18n as Xn}from"@lingui/core";import{Button as Ol,Divider as Di,MessageBox as $g,TokenAmount as wb,Typography as Ul}from"@rango-dev/ui";import De from"react";import{useNavigate as xb}from"react-router-dom";function zl(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=xb();return De.createElement(Z,{open:e,onClose:o,container:document.getElementById(_e.SWAP_BOX_ID)||document.body},n==="success"?De.createElement($g,{type:"success",title:Xn.t("Swap Successful")},De.createElement(wb,{direction:"vertical",tooltipContainer:W(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),De.createElement(Di,{size:12}),De.createElement(Ul,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):De.createElement($g,{type:"error",title:Xn.t("Transaction Failed"),description:m}),De.createElement(Di,{size:32}),n==="success"&&De.createElement(Ol,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{f("../../")}},De.createElement(Ul,{variant:"title",size:"medium",color:"neutral100"},Xn.t("Done"))),De.createElement(Di,{size:12}),h&&De.createElement(De.Fragment,null,De.createElement(Ol,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},Xn.t("Diagnosis")),De.createElement(Di,{size:12})),De.createElement(Ol,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},De.createElement(Ul,{variant:"title",size:"medium",color:"primary"},Xn.t("See Details"))))}i(zl,"SwapDetailsCompleteModal");import Pb from"react";import{i18n as Wb}from"@lingui/core";import{Alert as Rg,IconButton as Bb,LinkIcon as Mb}from"@rango-dev/ui";import oo,{Fragment as Lb}from"react";import{Alert as Eb,ChevronDownIcon as Ib,IconButton as Ab}from"@rango-dev/ui";import tn,{useState as Nb}from"react";import{css as Yn,darkTheme as Dg,styled as Ht,Typography as bb}from"@rango-dev/ui";var Fg=Ht("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Fi=Ht("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Dg} &`]:{color:"$secondary500"}}}}}),Og=Ht(Cn,{padding:"$0 $20 $20 $20"}),q5=Ht("div",{display:"flex",flexDirection:"column",gap:"$10"}),Ug=Ht("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),H5=Ht("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),en=Yn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Dg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),zg=Yn({padding:"$5 0"}),Oi=Yn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Qg=Yn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),qg=Yn({width:"100%",padding:"0 $20 $10"}),Hg=Ht("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Gg=Ht("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ui=Ht(bb,{wordBreak:"break-word"});import{styled as Ql}from"@rango-dev/ui";var Vg=Ql("div",{display:"flex",flexDirection:"column",gap:"$10"}),Kg=Ql("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),jg=Ql("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Xg(t){let{message:e}=t,[o,n]=Nb(!1);return tn.createElement(Eb,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&tn.createElement(Ab,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},tn.createElement(Kg,{rotated:o},tn.createElement(Ib,{size:12,color:"gray"}))),footer:tn.createElement(jg,{open:o},tn.createElement(Ui,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Xg,"FailedAlert");import{i18n as Yg}from"@lingui/core";import{Alert as ql,Button as Zg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Hl}from"rango-types";import Zn from"react";function Jg(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Zn.createElement(ql,{type:"warning",title:n.shortMessage,action:Zn.createElement(Zg,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Hl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Yg.t("Change"))}):r===Hl.WaitingForConnectingWallet?Zn.createElement(ql,{type:"warning",title:n.shortMessage,action:Zn.createElement(Zg,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Hl.WaitingForConnectingWallet)}},Yg.t("Connect"))}):Zn.createElement(ql,{type:"warning",title:n.shortMessage})}i(Jg,"WarningAlert");function Gl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=yn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return oo.createElement(Vg,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(Lb,{key:d},oo.createElement(Rg,{type:g&&(C&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:Wb.t("View transaction"),action:m.url&&oo.createElement(Bb,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},oo.createElement(Mb,{size:12}))}))}),c&&oo.createElement(Rg,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(Jg,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(Xg,{message:r}))}i(Gl,"SwapDetailsAlerts");var eh=2e3;var th=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:st(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:L(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:L(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:nn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(p=>({from:{chain:{displayName:st(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:st(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:nn(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:Pb.createElement(Gl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function oh(t){if(yn(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(oh,"getStepState");function Vl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Vb(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=O.use.retry(),h=ae.use.isActiveTab(),f=jb(),[d,g]=Gb(eh),C=Kb(null),[S,k]=sh(null),[T,v]=sh(null),w=i(()=>{r(),k(null)},"onCancel"),A=we.use.getNotifications(),M=we.use.removeNotification(),x=A(),E=$b(e),b=E?.networkStatus;ah(()=>{x.find(dt=>dt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):T&&v(null))},[e.status,e.requestId]),ah(()=>{P?k(zi.WaitingForNetworkChange):b===zi.WaitingForConnectingWallet||b===zi.NetworkChanged?k(b):k(null)},[b]);let N=su(e),I=E?_b(e,E):null,B=E?Db(e,E):null,j=Ag(e),te=lu(e),J=i(Te=>!!l(Te)?.mobileWallet,"isMobileWallet"),P=b===zi.WaitingForNetworkChange&&!!I&&!!B?.walletType&&(J(B.walletType)||a(B.walletType,I.network)),X=P?s.bind(null,B.walletType,[{namespace:I.namespace,network:I.network}]):void 0,se=au(e,E),z=th({swap:e,switchNetwork:X,showNetworkModal:b,setNetworkModal:k,message:se,blockchains:p,swappers:u}),me=z.length,[vt,Ze]=[e.steps[0],e.steps[me-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((Te,dt)=>Te+parseFloat(dt.feeInUsd||""),0),G=e.steps.find(Te=>Te.diagnosisUrl)?.diagnosisUrl,_=L(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),H=L(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),V=le?new ih(le).multipliedBy(Ze.toUsdPrice||0).toString():"",de=new ih(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(H,_),fe=se.detailedMessage.content||se.shortMessage,Fe=e.status==="success"?it.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(le,6,6),token:z[me-1].to.token.displayName,conciseAddress:mr(e.wallets[z[me-1].to.chain.displayName]?.address||""),chain:z[me-1].to.chain.displayName}}):K.createElement(Gg,null,K.createElement(xo,{variant:"body",size:"medium",color:"neutral700",align:"center"},fe?"":it.t("Transaction was not sent."),N?`${it.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:N.outputAmount,symbol:N.symbol,blockchain:N.blockchain}})}`:""),fe&&K.createElement(Ui,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",fe));return K.createElement(oe,{header:{title:it.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(nh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},K.createElement(xo,{size:"medium",variant:"label",color:"error"},it.t("Delete"))))},footer:te&&!T&&K.createElement(nh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let Te=Ar(e,p,c);m(Te),setTimeout(()=>{f("../../")},0)}},it.t("Try again"))},K.createElement(re,{compact:!0,view:!0},K.createElement(Fi,null,K.createElement("div",{className:en()},K.createElement(xo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),K.createElement("div",{className:Oi()},K.createElement(xo,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(rh,{container:W(),content:d?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:d||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(zb,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:g.bind(null,o||"")},d?K.createElement(Ub,{size:16,color:"secondary"}):K.createElement(Fb,{size:16,color:"gray"}))),K.createElement(Hg,{target:"_blank",href:`${up}/swap/${o}`},K.createElement(rh,{container:W(),content:it.t("View on Rango Explorer"),side:"bottom"},K.createElement(qb,{size:20}))))),K.createElement("div",{className:en()},K.createElement(xo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?it.t("Finished at"):it.t("Created at")),K.createElement(xo,{variant:"label",size:"small",color:"neutral700"},j))),K.createElement("div",{className:Qg()},K.createElement(Qb,{fee:L(String(at),2,2),time:sn(ar(e.steps)),steps:me}),K.createElement(In,{from:{price:{value:L(e.inputAmount,6,6),usdValue:H,realUsdValue:de,realValue:e.inputAmount},token:{displayName:z[0].from.token.displayName,image:z[0].from.token.image},chain:{image:z[0].from.chain.image,displayName:z[0].from.chain.displayName}},to:{price:{value:L(le,6,6),usdValue:_,realUsdValue:V,realValue:le||""},token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image,displayName:z[me-1].to.chain.displayName}},percentageChange:L(ne,2,2),warningLevel:_t(ne??0)})),K.createElement("div",{className:qg()},K.createElement(xo,{variant:"title",size:"small"},it.t("Swaps steps"))),K.createElement(Ob,{size:8}),K.createElement(Og,{ref:C},z.map((Te,dt)=>{let op=dt,on=oh(e.steps[dt]),_h=on==="error"||on==="in-progress"||on==="warning"||on==="completed"&&dt===z.length-1;return K.createElement(Hb,{key:op,step:Te,type:"swap-progress",ref:C,state:on,hasSeparator:dt!==0,tabIndex:op,isFocused:_h,tooltipContainer:W()})}))),K.createElement(Fl,{state:S,onClose:()=>k(null),onCancel:w,onDelete:n,message:se.detailedMessage.content,currentStepWallet:B,walletButtonDisabled:!h}),K.createElement(zl,{open:!!T,diagnosisUrl:G,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:L(le,6,6),usdValue:_,realUsdValue:V,realValue:le||"",percentageChange:L(ne,2,2),token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image},description:Fe}))}i(Vl,"SwapDetails");import{i18n as qi}from"@lingui/core";import{Divider as ch,NotFound as Rb,Skeleton as Rn,Typography as Hi}from"@rango-dev/ui";import Ce from"react";import{i18n as Xb}from"@lingui/core";import{Divider as Yb,Skeleton as Zb,Typography as Jb}from"@rango-dev/ui";import ke from"react";import{css as Tt,styled as Kl}from"@rango-dev/ui";var lh=Kl("div",{width:"100%",height:"100%",padding:"$10 $20"}),Jn=Kl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Qi=Kl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),oK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),nK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),rK=Tt({paddingTop:"$15",display:"flex"}),iK=Tt({padding:"$15 $0"}),aK=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),sK=Tt({paddingBottom:"$10"}),lK=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),pK=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),cK=Tt({display:"flex",alignItems:"center"}),uK=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),ph=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function jl(){return ke.createElement(lh,null,ke.createElement(Wn,{type:"swap-preview"}),ke.createElement("div",{className:"swaps-steps"},ke.createElement(Jb,{variant:"title",size:"small"},Xb.t("Swaps steps"))),ke.createElement(ke.Fragment,null,ke.createElement(Jn,null,ke.createElement(Nt,{separator:!1}),ke.createElement("div",{className:ph()},ke.createElement(Yb,{direction:"horizontal",size:20}),ke.createElement(Zb,{height:22,variant:"rectangular"}))),ke.createElement(Qi,null),ke.createElement(Jn,null,ke.createElement(Nt,{separator:!1})),ke.createElement(Qi,null),ke.createElement(Jn,null,ke.createElement(Nt,{separator:!1})),ke.createElement(Qi,null),ke.createElement(Jn,null,ke.createElement(Nt,{separator:!1}))))}i(jl,"LoadingSwapDetails");function uh(t){let{requestId:e,showSkeleton:o}=t;return Ce.createElement(oe,{header:{title:qi.t("Swap Details"),suffix:Ce.createElement(Vt,null)}},o&&Ce.createElement(Fg,null,Ce.createElement(Fi,null,Ce.createElement("div",{className:en()},Ce.createElement(Hi,{variant:"label",size:"large",color:"neutral700"},`${qi.t("Request ID")}`),Ce.createElement("div",{className:Oi()},Ce.createElement(Hi,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(Rn,{width:60,height:10,variant:"rounded"})),Ce.createElement(ch,{direction:"horizontal",size:4}),Ce.createElement(Rn,{width:16,height:16,variant:"rectangular"}),Ce.createElement(ch,{direction:"horizontal",size:4}),Ce.createElement(Rn,{width:16,height:16,variant:"rectangular"}))),Ce.createElement("div",{className:en()},Ce.createElement(Hi,{className:zg(),variant:"label",size:"large",color:"neutral700"},Ce.createElement(Rn,{width:60,height:10,variant:"rounded"})),Ce.createElement(Hi,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(Rn,{width:60,height:10,variant:"rounded"})))),Ce.createElement(jl,null)),!o&&Ce.createElement(Ug,null,Ce.createElement(Rb,{title:qi.t("Not found"),description:qi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(uh,"SwapDetailsPlaceholder");function mh(){let{manager:t,state:e}=oE(),o=!e.loadedFromPersistor,n=ct(t),{requestId:r}=rE(),a=je(),{fetchStatus:s}=y();if(!r)return Xl.createElement(nE,{containerStyles:{margin:"20px"},type:"error",title:eE.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&&tE(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?Xl.createElement(uh,{requestId:r,showSkeleton:l}):Xl.createElement(Vl,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(mh,"SwapDetailsPage");import{i18n as dh}from"@lingui/core";import{Divider as iE,getCategoriesCount as aE,SelectableCategoryList as sE,styled as gh,Typography as lE,Wallet as pE}from"@rango-dev/ui";import Bt,{useState as fh}from"react";var cE=gh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),uE=gh(re,{textAlign:"center"});function hh(){let{fetchStatus:t}=y(),[e,o]=fh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=fh(),l=ae.use.isActiveTab(),{list:p}=ft(),u=Lp(p,n),m=aE(u)!==1,h=Pp(p,e),f=i(d=>{vp(p,r.multiWallets)||s(d)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:dh.t("Connect Wallets")}},Bt.createElement(uE,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(sE,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(iE,{size:24})),Bt.createElement(lE,{variant:"title",size:"xmedium",align:"center"},dh.t("Choose a wallet to connect.")),Bt.createElement(cE,null,h.map((d,g)=>{let C=`wallet-${g}-${d.type}`;return Bt.createElement(pE,{key:C,...d,container:W(),onClick:()=>f(d),isLoading:t==="loading",disabled:!l})}),Bt.createElement(co,{wallet:a,onClose:()=>{s(void 0)}}))))}i(hh,"WalletsPage");function yh(){return mu(),_a(),mE([{path:D.home,element:Pe.createElement(Kf,null)},{path:D.routes,element:Pe.createElement(Jf,null)},{path:D.fromSwap,children:[{index:!0,element:Pe.createElement(Nl,{type:"source"})},{path:D.blockchains,element:Pe.createElement(Ai,{type:"source"})}]},{path:D.toSwap,children:[{index:!0,element:Pe.createElement(Nl,{type:"destination"})},{path:D.blockchains,element:Pe.createElement(Ai,{type:"destination"})}]},{path:D.settings,children:[{index:!0,element:Pe.createElement(Eg,null)},{path:D.languages,element:Pe.createElement(Xf,null)},{path:D.exchanges,element:Pe.createElement(Tl,{sourceType:"Exchanges"})},{path:D.bridges,element:Pe.createElement(Tl,{sourceType:"Bridges"})},{path:D.customTokens,children:[{index:!0,element:Pe.createElement(of,null)},{path:D.addCustomTokens,children:[{index:!0,element:Pe.createElement(Ku,null)},{path:D.blockchains,element:Pe.createElement(Ai,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:D.swaps,children:[{index:!0,element:Pe.createElement(wf,null)},{path:D.swapDetails,element:Pe.createElement(mh,null)}]},{path:D.wallets,element:Pe.createElement(hh,null)},{path:D.confirmSwap,element:Pe.createElement(Qd,null)}])}i(yh,"AppRoutes");import{useQueueManager as TE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as vE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as wE}from"rango-sdk";import{useContext as xE,useEffect as xh,useState as bh}from"react";import{globalCss as dE}from"@rango-dev/ui";var Sh=i(()=>dE({"@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 Ch(){let{setWatermark:t}=ae();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(Ch,"useFetchApiConfig");import{useWallets as fE}from"@rango-dev/wallets-react";import{useEffect as gE,useRef as hE}from"react";function kh(){let{connect:t,state:e}=fE(),o=hE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);gE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(kh,"useForceAutoConnect");import{isApprovalTX as yE,RouteEventType as Th,StepEventType as vh,StepExecutionEventStatus as SE,WidgetEvents as Gi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as wh}from"react";function Yl(){let t=we.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();wh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===vh.TX_EXECUTION&&a.status===SE.TX_SENT&&!yE(s)||a.type===vh.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 he.on(Gi.StepEvent,n),()=>he.off(Gi.StepEvent,n)},[he,e]),wh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===Th.FAILED||a.type===Th.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return he.on(Gi.RouteEvent,n),()=>he.off(Gi.RouteEvent,n)},[he])}i(Yl,"useSubscribeToWidgetEvents");import{useManager as CE}from"@rango-dev/queue-manager-react";import{useEffect as kE}from"react";function Zl(){let{isSynced:t,syncNotifications:e}=we(),{manager:o,state:n}=CE();kE(()=>{we.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ct(o))},[we.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Zl,"useSyncNotifications");function Jl(){kh(),Sh(),Yl(),Zl();let t=y().blockchains(),{canSwitchNetworkTo:e}=Kr(),[o,n]=bh(""),[r,a]=bh(),s=xE(xr),l=t.filter(wE),{fetchApiConfig:p}=Ch();xh(()=>()=>uu(),[]),TE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),xh(()=>(ao.init(),we.persist.hasHydrated()||we.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===vE(o)?.[0]&&n("")}),p().catch(console.log),ao.destroy),[])}i(Jl,"useBootstrap");import{styled as bE}from"@rango-dev/ui";var Eh=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 Vi(){Jl();let{config:t}=y(),{activeTheme:e}=zo(t?.theme||{}),{activeLanguage:o}=Rt();return Rl.createElement(EE,{language:o},Rl.createElement(Eh,{id:"swap-container",className:e()},Rl.createElement(yh,null)))}i(Vi,"Main");import{setSolanaSignerConfig as VE}from"@rango-dev/signer-solana";import tp,{useEffect as Mh,useMemo as KE}from"react";import{useState as IE}from"react";var AE=i(()=>{let[t,e]=IE(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=Tp(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Ih=AE;import{checkWaitingForNetworkChange as NE,makeQueueDefinition as WE}from"@rango-dev/queue-manager-rango-preset";import{Provider as BE}from"@rango-dev/queue-manager-react";import{useWallets as ME}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as LE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as PE}from"rango-types";import _E,{useMemo as $E}from"react";function DE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=ME(),l=$E(()=>WE({API_KEY:t.apiKey||Lt("API_KEY"),BASE_URL:Lt("BASE_URL"),emitter:{emit:he.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"),f=i(v=>!!s(v).mobileWallet,"isMobileWallet"),d=c.filter(v=>v.enabled).reduce((v,w)=>(v[w.name]=w,v),{}),g=c.filter(PE),C=i(v=>{let{supportedChains:w}=s(v);return pr(w)},"getSupportedChainNames"),S=e(),k={meta:{blockchains:d,evmBasedChains:g,evmNetworkChainInfo:LE(g),getSupportedChainNames:C},getSigners:o,wallets:m,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:f},T=ae.use.isActiveTab();return _E.createElement(BE,{queuesDefs:[l],context:k,onPersistedDataLoaded:v=>{NE(v)},isPaused:!T},t.children)}i(DE,"QueueManager");var Ah=DE;import{useManager as QE}from"@rango-dev/queue-manager-react";import qE,{createContext as HE,useContext as GE}from"react";function Nh(){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(Nh,"useUpdateQuoteInputs");import{cancelSwap as FE,getCurrentNamespaceOfOrNull as OE,getCurrentStep as UE,getRelatedWalletOrNull as zE}from"@rango-dev/queue-manager-rango-preset";var Ki=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return ct(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=Ar(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&FE(o)}getCurrentStepInfo(e){let o=UE(e);return{step:o,wallet:o?zE(e,o):null,network:o?OE(e,o)?.network:null}}};var Wh=HE(void 0);function ep(t){let{manager:e}=QE(),o=ae.use.isActiveTab(),n=O.use.retry(),{findToken:r,connectedWallets:a,getBalances:s,fetchBalances:l}=y(),p=new Ki(e,{retrySwap:n,findToken:r}),{fetchingWallets:u}=y(),c=Ip(s()),m=y().blockchains(),h=y().tokens(),f=y().swappers(),d=y().fetchStatus,g=Rt().resetLanguage,C=we().getNotifications(),S=we().clearNotifications,k=Nh(),{fromBlockchain:T,toBlockchain:v,fromToken:w,toToken:A,inputAmount:M}=O(),x={isActiveTab:o,setCurrentTabAsActive:ao.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:T?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:M},updateQuoteInputs:k}};return qE.createElement(Wh.Provider,{value:x},t.children)}i(ep,"WidgetInfo");function Bh(){let t=GE(Wh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Bh,"useWidget");function ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Ih();return Mh(()=>{n&&r(n)},[n]),KE(()=>{_p({API_KEY:o?.apiKey||nr,BASE_URL:o?.apiUrl||cp})},[o.apiKey,o.apiUrl]),Mh(()=>{t.config?.signers?.customSolanaRPC&&VE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),tp.createElement(br,{config:o,onUpdateState:e},tp.createElement(Ah,{apiKey:o.apiKey},tp.createElement(ep,null,t.children)))}i(ji,"WidgetProvider");function Lh(t){let e=t.config?.externalWallets;return Xi.createElement(Lc,null,e?Xi.createElement(Vi,null):Xi.createElement(ji,{config:t.config??Ri},Xi.createElement(Vi,null)))}i(Lh,"Widget");function Ph(){let{on:t,off:e}=he;return{on:t,off:e}}i(Ph,"useWidgetEvents");var S3={DerivationPath:dn,Namespaces:mn,isOnDerivationPath:gn,isOnNamespace:fn};export{Hj as EventSeverity,Wo as MainEvents,e3 as Networks,n3 as PendingSwapNetworkStatus,ca as QuoteEventTypes,Gj as RouteEventType,ea as SUPPORTED_FONTS,S3 as StatefulConnect,Vj as StepEventType,Kj as StepExecutionBlockedEventStatus,jj as StepExecutionEventStatus,_e as UI_ID,ma as UiEventTypes,ua as WalletEventTypes,Jj as WalletEvents,t3 as WalletTypes,Lh as Widget,Wo as WidgetEvents,ji as WidgetProvider,br as WidgetWallets,Ka as customizedThemeTokens,Yj as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,Kr as useWallets,Bh as useWidget,Ph as useWidgetEvents,Dy as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map