@rango-dev/widget-embedded 0.40.2-next.4 → 0.40.2-next.6

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.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var Vh=Object.defineProperty;var i=(t,e)=>Vh(t,"name",{value:e,configurable:!0});import{EventSeverity as v3,RouteEventType as w3,StepEventType as b3,StepExecutionBlockedEventStatus as x3,StepExecutionEventStatus as E3}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as A3}from"@rango-dev/wallets-core/legacy";import{useWallets as Yr,Events as W3}from"@rango-dev/wallets-react";import{Networks as L3,WalletTypes as M3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as _3}from"rango-types";import{Divider as zS}from"@rango-dev/ui";import co,{useEffect as QS,useRef as HS,useState as Mp}from"react";import{WalletState as Kh}from"@rango-dev/ui";import{useWallets as jh}from"@rango-dev/wallets-react";import{useReducer as Xh}from"react";function ic(t){return!!t.derivationPath}i(ic,"isStateOnDerivationPathStep");function ac(t){return!!t.namespace}i(ac,"isStateOnNamespace");var ar={status:"init",namespace:null,derivationPath:null};function sc(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 ar;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ar;default:throw new Error("Action hasn't been defined.")}}i(sc,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=jh(),[n,r]=Xh(sc,ar),a=i(async(u,d,h)=>{r({type:"reset"});try{let f=d?.map(g=>({...g,network:void 0}));return await o(u,f),{status:"connected"}}catch(f){let g=f?.message?`Error: ${f.message}`:"An unknown error happened during connecting wallet.";throw new Error(g,{cause:f})}},"runConnect"),s=i(async(u,d)=>{if(u.state===Kh.DISCONNECTED){if(!!u.isHub&&u.properties?.find(k=>k.name==="detached")&&u.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(!u.needsNamespace)return await a(u.type,void 0,d);let g=u.needsNamespace.data.length>1,m=u.needsDerivationPath;if(g)return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(m){let C=u.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:C.value}}),{status:"derivation-path"}}return await a(u.type,u.needsNamespace?.data.map(C=>({namespace:C.value})),d)}return d?.disconnectIfConnected?(await p(u.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(u,d)=>{let h=u.needsNamespace?.selection==="single",f=u.needsDerivationPath,g=d[0];if(!g)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&f)return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:g}}),{status:"derivation-path"};if(!ac(n))throw new Error("Something went wrong on handling namespace. Please retry.");let m=n.namespace.targetWallet.type,C=d.map(S=>({namespace:S}));return await a(m,C)},"handleNamespace"),c=i(async u=>{if(!u)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!ic(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=n.derivationPath.providerType,f=[{namespace:n.derivationPath.namespace,derivationPath:u}];return await a(d,f)},"handleDerivationPath"),p=i(async u=>{let d=t(u);return d.connected||d.connecting?(await e(u),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:p,handleNamespace:l,handleDerivationPath:c,getState:()=>n,resetState:u=>{r(u==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Gt,"useStatefulConnect");import{WalletState as ya}from"@rango-dev/ui";import{useWallets as iS}from"@rango-dev/wallets-react";import{detectMobileScreens as aS,KEPLR_COMPATIBLE_WALLETS as sS,WalletTypes as gn}from"@rango-dev/wallets-shared";import{useCallback as lS,useEffect as cS}from"react";import eS,{createContext as tS,useContext as oS,useEffect as nS,useRef as rS}from"react";import{create as Jy}from"zustand";import{persist as Ry}from"zustand/middleware";import{allProviders as Yh}from"@rango-dev/provider-all";var Ji=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()}},Eo=new Ji;import{defineVersions as cc,pickVersion as pc,Provider as Ri}from"@rango-dev/wallets-core";function uc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=dc(a);return s instanceof Ri?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof Ri?o.push(cc().version("1.0.0",n).build()):o.push(cc().version("0.0.0",n).build())}),o}return t}i(uc,"matchAndGenerateProviders");function dc(t){try{return pc(t,"1.0.0")[1]}catch{return pc(t,"0.0.0")[1]}}i(dc,"pickProviderVersionWithFallbackToLegacy");function mc(t){return t.map(o=>dc(o)).map(o=>o instanceof Ri?o.id:o.config.type)}i(mc,"configWalletsToWalletName");function sr(t,e){return e.find(o=>o.name===t)?.displayName}i(sr,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function fc(t,e){return e.find(o=>o.name===t)?.logo}i(fc,"getBlockchainImage");function rn(t,e){return e.find(o=>o.id===t)?.title}i(rn,"getSwapperDisplayName");function an(t,e){return e.find(o=>o.name===t)??null}i(an,"findBlockchain");function ea(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(ea,"isTokenNative");function lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function Io(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Io,"isValidTokenAddress");function sn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=lt(c));let p=o.tokensMapByTokenHash.get(c);p&&(n[c]=p)})},"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(c=>{l.has(c)||a(o.tokensMapByBlockchainName[c])})}return s.forEach(l=>{let c=r[l];if(!c&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}c&&(c.isExcluded?(a(o.tokensMapByBlockchainName[l]),c.tokens.forEach(p=>{let u=lt(p);delete n[u]})):a(c.tokens))}),Object.values(n)}i(sn,"matchTokensFromConfigWithMeta");function lr(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(lr,"getSupportedBlockchainsFromConfig");function hc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(hc,"makeProvidersOptionsFromConfig");var cr={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"}},Zh={clientUrl:void 0},Jh={liquiditySources:void 0};function gc(t){let e=hc(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return Yh(o).map(a=>a())}i(gc,"generateProviders");var yc=i((t,e,o)=>{let n=gc({...cr,...t});return{config:{...cr,...t},iframe:Zh,campaignMode:Jh,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l}=o(),c=sn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),p=sn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});Eo.set("supportedSourceTokens",c),Eo.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=gc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=hc(a);return uc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Sc}from"rango-types";var Cc=[Sc.EVM,Sc.SOLANA];import{RangoClient as my}from"rango-sdk";import{UI_ID as Rh}from"@rango-dev/ui";var pr="c6381a79-2817-4602-83bf-6a641a409e32",kc="https://api.rango.exchange",Tc="https://explorer.rango.exchange",De={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Rh};import{BlockchainCategories as ay,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as sy}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as ly,getCosmosExperimentalChainInfo as cy,isEvmAddress as py,KEPLR_COMPATIBLE_WALLETS as dA,Networks as _c}from"@rango-dev/wallets-shared";import No from"bignumber.js";import{isCosmosBlockchain as uy}from"rango-types";import ey from"bignumber.js";var ce=new ey(0);import{WalletTypes as ty}from"@rango-dev/wallets-shared";var no="~",vc=[ty.LEAP];import{BlockchainCategories as oa,WalletState as iy}from"@rango-dev/ui";import{TransactionType as ur}from"rango-sdk";var wc="Roboto",ta=[{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 Ao(t){return Array.from(new Set(t))}i(Ao,"removeDuplicateFrom");function Nc(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Nc,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function Ec(t,e){return t.toLowerCase()===e.toLowerCase()}i(Ec,"exactText");function Ic(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(Ic,"startWithText");var I=i(()=>document.getElementById(De.SWAP_BOX_ID),"getContainer"),ro=i(()=>document.getElementById(De.EXPANDED_BOX_ID),"getExpanded");function Ac(t,e,o){let n=!!e&&Ec(e,t),r=!!o&&Ec(o,t);return n!==r?n?-1:1:0}i(Ac,"compareExactMatchText");function na(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(na,"compareContainsText");function ra(t,e,o){let n=!!e&&Ic(e,t),r=!!o&&Ic(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ra,"compareStartWithText");function Wc(t,e,o){if(!o)return 0;let n=Ac(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Ac(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=ra(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=na(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ra(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=na(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=ra(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=na(o,t.address,e.address);if(r!==0)return r}return 0}i(Wc,"compareWithSearchFor");var dr=i((t,e)=>{switch(e){case oa.ALL:return!0;case oa.UTXO:return t===ur.TRANSFER;case oa.OTHER:return t!==ur.TRANSFER&&t!==ur.COSMOS&&t!==ur.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Bc=i(t=>ta.find(o=>o.value===t)?.url,"getFontUrlByName");function Lc(t,e){let o=!!t.find(n=>n.state===iy.CONNECTED);return e===!1&&o}i(Lc,"isSingleWalletActive");function Mc(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(Mc,"memoizedResult");import{BigNumber as Pc}from"bignumber.js";var ln=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),B=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Pc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Pc(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 mr=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 pn(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(pn,"mapStatusToWalletState");function Dc(t,e,o,n){return o.filter(r=>!vc.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:c}=t(r);return s&&(!l||!!n&&c!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:c,needsNamespace:p,supportedChains:u,needsDerivationPath:d,properties:h,isHub:f}=e(r),g=Ao(u.map(C=>C.type)),m=pn(t(r));return{title:a,image:s,link:ly(l),state:m,type:r,showOnMobile:c,needsNamespace:p,blockchainTypes:g,needsDerivationPath:d,properties:h,isHub:f}})}i(Dc,"mapWalletTypesToWalletInfo");function un(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(un,"walletAndSupportedChainsNames");function aa(t,e,o,n,r){let a=[];function s(c,p){if(!!!a.find(d=>d.chain===c)){let d={address:p,chain:c,walletType:t};a.push(d)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:p,network:u}=sy(c),d=l.length>0,h=l.includes(u),f=u===_c.Unknown;if(d&&!h&&!f)return;let m=u===_c.Unknown&&py(p);if(f&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,p.toLowerCase())}):s(u,p)}),a}i(aa,"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:c}=r;c.forEach((p,u)=>{let d=p.from.blockchain,h=p.to.blockchain,f=a===o.swaps.length-1,g=u===c.length-1;(!f&&!g||f&&l!==d||e==="all")&&n.add(d),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function dn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(dn,"isAccountAndWalletMatched");var $c=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?ia(n.usdValue,n.decimals):ce.toFixed();return o.plus(r)},new No(ce));return dy(e.toString())},"calculateWalletUsdValue");function dy(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(dy,"numberWithThousandSeparator");var hr=i((t,e)=>{let o=cy(Object.entries(t).map(([,n])=>n).filter(uy));return o&&o[e]?.experimental},"isExperimentalChain");function ia(t,e){return new No(t).shiftedBy(-e).toFixed()}i(ia,"representAmountInNumber");function yr(t){if(!t)return null;let e=ia(t.amount,t.decimals),o=t.usdValue?ia(t.usdValue,t.decimals):null,n=B(e,8,8),r=o?B(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(yr,"formatBalance");function Fc(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new No(t.usdValue).shiftedBy(-t.decimals):ce,n=e&&e.usdValue?new No(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 No(t.amount).shiftedBy(-t.decimals):ce,n=e&&e.amount?new No(e.amount).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Fc,"compareTokenBalance");function Lt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Lt,"areTokensEqual");function Oc(t){return t.sort((e,o)=>+(o.state===bt.CONNECTED)-+(e.state===bt.CONNECTED)||+(o.state===bt.DISCONNECTED||o.state===bt.CONNECTING)-+(e.state===bt.DISCONNECTED||e.state===bt.CONNECTING))}i(Oc,"sortWalletsBasedOnConnectionState");function Sr(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(Sr,"getConciseAddress");function Uc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Uc,"getAddress");var zc=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Qc(t){return t.map(e=>e.state).join("-")}i(Qc,"hashWalletsState");function Hc(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(Hc,"filterBlockchainsByWalletTypes");function qc(t,e){return e===ay.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(dr(n,e))return!0;return!1})}i(qc,"filterWalletsByCategory");var sa={API_KEY:pr};function Mt(t){return sa[t]||""}i(Mt,"getConfig");function Gc(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),sa=e,sa}i(Gc,"initConfig");var Vc=20,Kc=25,la="theme-widget",ca=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Lt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Lt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),pa=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),jc=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Cr,xt=i(()=>Cr||(Cr=new my(Mt("API_KEY"),Mt("BASE_URL")),Cr),"httpService");function kr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Ao(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(c=>c===s.swapperGroup)),l&&s.types.map(c=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:c,selected:!e.includes(s.swapperGroup)})})}}),n}i(kr,"getUniqueSwappersGroups");function Xc(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Xc,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function Wo(t,e){return e?.[t]==="enabled"}i(Wo,"isRoutingEnabled");var Yc=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Zc=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 c=lr({config:a}),p=r;return c.length>0&&(p=p.filter(u=>c.includes(u.name))),p.filter(u=>Cc.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(c=>!(s.length>0&&!s.includes(c.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),c=e()._blockchainsMapByName;if(!o||!o.type)return l;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=Eo.get(u);d?.length||(d=sn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Eo.set(u,d)),d=Yc(d,s,a.features);let h=e().blockchains({type:o.type});return d.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!h.some(m=>m.name===g.blockchain)?!1:o.searchFor?!!(Je(g.symbol,o.searchFor)||Je(g.address||"",o.searchFor)||Je(g.name||"",o.searchFor)):!0).sort((g,m)=>{let C=e().isTokenPinned(g,o.type),S=e().isTokenPinned(m,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(g),D=o.getBalanceFor(m),w=Fc(A,D);if(w!==0)return w}let k=c.get(g.blockchain),T=c.get(m.blockchain),v=ea(g,k),b=ea(m,T);if(v!==b)return v?-1:1;if(g.isPopular!==m.isPopular)return g.isPopular?-1:1;if(o.searchFor){let A=Wc(g,m,o.searchFor);if(A)return A}return g.isSecondaryCoin!==m.isSecondaryCoin?g.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=>Lt(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(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort(Xc)},fetch:async()=>{try{let{routing:o}=e().config,n=Wo("enableCentralizedSwappers",o),r=await xt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],p=r.popularTokens,u=r.swappers.filter(f=>f.enabled),d=new Set;r.tokens.forEach(f=>{d.add(f.blockchain),c.push(f)}),r.blockchains.sort((f,g)=>f.sort-g.sort).forEach(f=>{f.enabled&&d.has(f.name)&&a.set(f.name,f)}),c.forEach(f=>{let g=lt(f);l[f.blockchain]||(l[f.blockchain]=[]),s.set(g,f),l[f.blockchain].push(g)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as fy,Catalonia as gy,Chinese as Jc,Denmark as hy,English as yy,Finland as Sy,French as Cy,German as ky,Greece as Ty,Hungary as vy,India as wy,Indonesian as by,Italian as xy,Japanese as Ey,Korea as Iy,Lithuania as Ay,Malay as Ny,Netherlands as Wy,Pakistan as By,Philippines as Ly,Poland as My,Portuguese as Py,Russian as _y,SaudiArabia as Dy,Serbia as $y,Slovakia as Fy,SouthAfrica as Oy,Spanish as Uy,Swahili as zy,Swedish as Qy,Thai as Hy,Turkish as qy,Ukrainian as Gy,Vietnamese as Vy}from"@rango-dev/ui";var Rc=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:Oy},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Dy},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:fy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:gy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Jc},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Jc},{title:"Danish",label:"Dansk",local:"da",SVGFlag:hy},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:Wy},{title:"English",label:"English",local:"en",SVGFlag:yy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:Ly},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:Sy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:Cy},{title:"German",label:"Deutsch",local:"de",SVGFlag:ky},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:Ty},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:wy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:vy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:by},{title:"Italian",label:"Italiana",local:"it",SVGFlag:xy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Ey},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:Iy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:Ay},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Ny},{title:"Polish",label:"Polski",local:"pl",SVGFlag:My},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Py},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:_y},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:$y},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Fy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:Uy},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:zy},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Qy},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:Hy},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:qy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Gy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:By},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Vy}],Bo="en";var ep=[.5,1,3],tp=1,op=5,np=100,rp=0;var ip=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:tp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let c=s===o,p=l<=9;return c&&p}))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=Ao(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),c=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...c&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Bo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||Bo}})},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=lr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import ha from"bignumber.js";import Ky from"mitt";var ye=Ky(),jy={on:ye.on,off:ye.off};import{WidgetEvents as ap}from"@rango-dev/queue-manager-rango-preset";var da=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(da||{}),ma=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ma||{}),fa=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(fa||{}),Lo=(a=>(a[a.RouteEvent=ap.RouteEvent]="RouteEvent",a[a.StepEvent=ap.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Lo||{});var sp=i(t=>(e,o,n)=>t(i((...a)=>{e(s=>({...s,lastUpdatedAt:+new Date})),e(...a)},"modifedSet"),o,n),"keepLastUpdated");import Xy from"bignumber.js";function mn(t){return`${t.blockchain}${no}${t.address}${no}${t.symbol}`}i(mn,"createAssetKey");function ga(t,e){return`${mn(e)}${no}${t}`}i(ga,"createBalanceKey");function fn(t){let[e,o,n]=t.split(no);return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(fn,"extractAssetFromBalanceKey");function lp(t,e){let o={};return t.balances?.forEach(n=>{let r=ga(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,c=l?new Xy(l??ce).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:c};o[r]=p}),o}i(lp,"createBalanceStateForNewAccount");function cp(t,e){for(let o in e){let n=fn(o),r=mn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(cp,"updateAggregatedBalanceStateForNewAccount");function pp(t,e){let o=fn(e),n=mn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(pp,"removeBalanceFromAggregatedBalance");function Yy(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(Yy,"matchWalletDetailsWithConnectedWallet");var Zy=Mc(),up=sp((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>dn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>dn(s,a))?{...a,loading:!1,error:!1,explorerUrl:Yy(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>dn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>dn(s,l)));if(a.length>0){let s=a.map(l=>{let c=!r.some(p=>p.chain===l.chain&&p.selected&&p.walletType!==l.walletType);return{address:l.address,chain:l.chain,explorerUrl:null,walletType:l.walletType,selected:c,namespace:n,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(p=>!s.some(u=>u.walletType===p.walletType&&u.chain===p.chain)),...s]}))}},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,n)=>{ye.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o,n),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(p=>p.walletType===o);e().connectedWallets.forEach(p=>{p.walletType!==o&&(r=r.filter(u=>!(u.chain===p.chain&&u.address===p.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(p=>n.chains?.includes(p.chain))),n?.namespaces&&n.namespaces.length>0&&(r=r.filter(p=>p.namespace?n.namespaces?.includes(p.namespace):!1));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(p=>{let u=fn(p);!!r.find(h=>ga(h.address,{address:u.address,blockchain:h.chain,symbol:u.symbol})===p)?s=pp(s,p):a[p]=l[p]}),t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(ye.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(l=>a.includes(l.chain)?(a=a.filter(c=>c!==l.chain),{...l,selected:!0}):l);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(c=>({address:c.address,blockchain:c.chain})),s;try{s=await xt().getWalletsDetails(a)}catch(c){throw e().setConnectedWalletHasError(o),new Error("Request for fetching balances failed.",{cause:c})}let l=s.wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let d=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));d.length>0&&e().fetchBalances(d,{retryOnFailedBalances:!1})}let p={},u=e()._aggregatedBalances;l.forEach(d=>{if(d.failed||(e().removeBalancesForWallet(r,{chains:[d.blockChain]}),!e().connectedWallets.find(f=>f.walletType===r&&f.address===d.address&&f.chain===d.blockChain)))return;let h=lp(d,e);u=cp(u,h),p={...p,...h}}),t(d=>({_balances:{...d._balances,...p},_aggregatedBalances:u})),e().setConnectedWalletRetrievedData(o,l)}else throw e().setConnectedWalletHasError(o),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 c=a[0];return n[c]}let l=n[a[0]];return a.forEach(c=>{let p=n[c],u=new ha(p.amount),d=new ha(l.amount);u.isGreaterThan(d)&&(l=p)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,p]=l.split(no);return p===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>Zy(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,l)=>{let c=r[l],p=fn(l);if(p.blockchain===n.chain){let u=e().findToken(p),d=c.amount?new ha(c.amount).shiftedBy(-c.decimals):ce;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:c.amount,decimal:c.decimals,amount:d.toString(),logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function dp(t){return Jy()(Ry((...e)=>({...up(...e),...Zc(...e),...ip(...e),...yc(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(dp,"createAppStore");var mp=tS(null);function y(){let t=oS(mp);if(nS(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function fp(t){let e=rS();return e.current||(e.current=dp(t.config)),eS.createElement(mp.Provider,{value:e.current},t.children)}i(fp,"AppStoreProvider");function ft(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=iS(),s=y().blockchains(),{handleDisconnect:l}=Gt(),c=mc(n()),p=Dc(r,a,c,e);p=aS()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Oc(p),d=i(m=>!o.find(C=>C.walletType===m&&C.chain===e),"isExperimentalChainNotAdded"),h=lS(()=>{let m=p?.filter(C=>C.state===ya.CONNECTING)||[];for(let C of m)l(C.type)},[Qc(p)]);cS(()=>()=>{h()},[]);let f=i(m=>{let C=m.find(k=>k.type===gn.DEFAULT);return!C||C.state===ya.NOT_INSTALLED?!1:m.filter(k=>k.state!=ya.NOT_INSTALLED&&![gn.DEFAULT,gn.WALLET_CONNECT_2,gn.LEDGER].includes(k.type)&&a(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((m,C,S)=>hr(S,C)&&d(m)&&!sS.includes(m)||m==gn.DEFAULT&&!f(p),"shouldExcludeWallet");return{list:u.filter(m=>!g(m.type,e??"",s)),terminateConnectingWallets:h}}i(ft,"useWalletList");import{Modal as mS}from"@rango-dev/ui";import fS from"react";import{create as dS}from"zustand";var gp="rango-widget";var hn=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(gp),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 uS=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=uS;var re=Mo(dS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,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})},setShowProfileBanner:o=>{t({showProfileBanner:o})}}))),ao=new hn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function Z(t){let{watermark:e}=re();return fS.createElement(mS,{hasWatermark:e==="FULL",...t},t.children)}i(Z,"WatermarkedModal");import{i18n as Sa}from"@lingui/core";import{Button as kS,Checkbox as TS,Divider as vS,Image as xp,ListItemButton as wS,MessageBox as bS,Radio as xS,RadioRoot as ES}from"@rango-dev/ui";import we,{useState as IS}from"react";import{css as gS,darkTheme as yp,IconButton as hS,styled as so}from"@rango-dev/ui";var Et=so(hS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${yp} &`]:{backgroundColor:"$neutral"}}}),Sp=so("div",{position:"absolute",background:"$secondary500",[`.${yp} &`]:{$$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}}),Cp=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"}}}}),kp=so("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Tp=so("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),vp=gS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Tr=so("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as yS,styled as vr}from"@rango-dev/ui";var TN=vr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Po=vr("div",{position:"relative"}),SS=yS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),_o=vr("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}),wr=vr("div",{"& img":{borderRadius:"50%"}});function wp(t,e){return t.find(o=>o.name===e)?.logo}i(wp,"getBlockchainLogo");import{styled as CS}from"@rango-dev/ui";var bp=CS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function yn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=IS([]),s=y().blockchains(),l=i(p=>{a(o?[p]:u=>u.includes(p)?u.filter(d=>d!==p):u.concat(p))},"onSelect"),c=i(p=>o?we.createElement(ES,{value:r?.[0]},p):we.createElement(we.Fragment,null,p),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(vS,{size:20}),we.createElement(bS,{type:"info",title:Sa.t("Select chain types"),description:Sa.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Po,null,we.createElement(Tr,null,we.createElement(xp,{src:n,size:45})),we.createElement(_o,null))}),we.createElement(bp,null,c(we.createElement(we.Fragment,null,e.needsNamespace?.data.map(p=>we.createElement(wS,{key:p.id,id:p.id,title:p.label,hasDivider:!0,style:{height:60},onClick:()=>l(p.value),start:we.createElement(xp,{src:wp(s,p.id),size:22}),end:o?we.createElement(xS,{value:p.value}):we.createElement(TS,{checked:r.includes(p.value)})}))))),we.createElement(kS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Sa.t("Confirm")))}i(yn,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as WS,Divider as Ap,Image as BS,MessageBox as LS,Select as MS,TextField as PS}from"@rango-dev/ui";import Oe,{useEffect as _S,useState as Np}from"react";import{namespaces as AS}from"@rango-dev/wallets-shared";var br={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ca(t){let e=t?AS[t].derivationPaths:null;return e?[...e,br]:[]}i(Ca,"getDerivationPaths");import{styled as Ep,Typography as NS}from"@rango-dev/ui";var Ip=Ep("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),ka=Ep(NS,{paddingLeft:"$10"}),Ta={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Wp="0";function Sn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Np(null),[l,c]=Np(Wp),p=a===br.id,u=Ca(o),d=i(({value:f})=>{let g=u?.find(m=>m.id===f);g&&(a===br.id&&Number.isNaN(Number(l))&&c(Wp),s(g.id))},"handleDerivationPathItemClick"),h=i(()=>{let f=u.find(g=>g.id===a);if(f)e(f.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return _S(()=>{s(Ca(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(Ap,{size:20}),Oe.createElement(LS,{type:"info",title:Do.t("Select Derivation Path"),description:Do.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Po,null,Oe.createElement(wr,null,Oe.createElement(BS,{src:n,size:45})),Oe.createElement(_o,null))}),Oe.createElement(Ip,null,Oe.createElement(ka,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),Oe.createElement(MS,{value:a||"",options:u.map(f=>({value:f.id,label:f.label})),variant:"filled",handleItemClick:d,styles:{trigger:Ta}}),Oe.createElement(Ap,{size:20}),Oe.createElement(ka,{variant:"body",size:"xsmall",color:"$neutral600"},p?Do.t("Enter Path"):Do.t("Enter Index")),Oe.createElement(PS,{type:p?"text":"number",variant:"contained",value:l,onChange:f=>c(f.target.value),style:Ta})),Oe.createElement(WS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!u||!a||!l},Do.t("Confirm")))}i(Sn,"DerivationPath");import{i18n as $o}from"@lingui/core";import{Image as DS,MessageBox as va,WalletState as $S}from"@rango-dev/ui";import{useWallets as FS}from"@rango-dev/wallets-react";import lo from"react";function wa(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=FS();return pn(a(n))===$S.CONNECTED?lo.createElement(va,{type:"success",title:$o.t("Wallet Connected"),description:$o.t("Your wallet is connected, you can use it to swap.")}):o?lo.createElement(va,{type:"error",title:$o.t("Failed to Connect"),description:o||$o.t("Your wallet is not connected. Please try again.")}):lo.createElement(va,{type:"loading",title:$o.t("Connecting to your wallet"),description:$o.t("Click connect in your wallet popup."),icon:lo.createElement(Po,null,lo.createElement(wr,null,lo.createElement(DS,{src:r,size:45})),lo.createElement(_o,null))})}i(wa,"ConnectStatus");import{i18n as ba}from"@lingui/core";import{Button as OS,Divider as Bp,MessageBox as US}from"@rango-dev/ui";import xr from"react";function xa(t){let{displayName:e,onConfirm:o}=t;return xr.createElement(US,{title:ba.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:ba.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},xr.createElement(Bp,{size:18}),xr.createElement(Bp,{size:32}),xr.createElement(OS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},ba.t("Confirm")))}i(xa,"ExperimentalChain");function Lp(t,e){return t().status==="init"&&!!e}i(Lp,"isOnStatus");function Cn(t){return t().status==="namespace"}i(Cn,"isOnNamespace");function kn(t){return t().status==="derivationPath"}i(kn,"isOnDerivationPath");var qS=3e3,GS=300;function po(t){let e=HS(),[o,n]=Mp(!1),[r,a]=Mp(),s=i(k=>{a(k.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:c,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:h}=Gt(),f=i(k=>{u(t.wallet,k).then(S).catch(s)},"handleConfirmNamespaces"),g=i(k=>{if(!k)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(k).then(S).catch(s)},"handleDerivationPathConfirm"),m=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),S=i((k,T)=>{let v=k.status==="connected",b=["disconnected","disconnected-unhandled"].includes(k.status);v?(t.onConnect?.(),T||(e.current=setTimeout(m,qS))):b&&m()},"afterConnected");return QS(()=>{if(t.wallet){C();let k=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,k||n(!0)},GS)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(b=>{["namespace","derivation-path"].includes(b.status)||(k=!0),S(b,T)}).catch(s)}},[t.wallet]),co.createElement(Z,{open:o,onClose:m,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:I()},Lp(d,t.wallet)&&co.createElement(co.Fragment,null,co.createElement(wa,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),co.createElement(zS,{direction:"vertical",size:32})),Cn(d)&&co.createElement(yn,{onConfirm:f,value:d().namespace}),kn(d)&&co.createElement(Sn,{onConfirm:g,value:d().derivationPath}))}i(po,"StatefulConnectModal");import{Provider as YS}from"@rango-dev/wallets-react";import Er,{createContext as ZS,useEffect as Fp,useMemo as JS,useRef as Op}from"react";import{useEffect as VS}from"react";function Pp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Pp,"hashProviders");function Ea(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return VS(()=>{o(),r()},[Pp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Ea,"useWalletProviders");import{legacyFormatAddressWithNetwork as KS,legacyReadAccountAddress as _p}from"@rango-dev/wallets-core/legacy";import{Events as uo}from"@rango-dev/wallets-react";import{isEvmBlockchain as jS}from"rango-sdk";function Dp(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=y(),{onConnectWalletHandler:l,onDisconnectWalletHandler:c}=t,p=s().filter(jS).map(m=>m.name),u=i((m,C)=>{let[S,,k,,T]=m,v=aa(S,k,p,C.supportedChainNames,T.isContractWallet);v.length&&e(v,T.namespace)},"onAccountsEvent"),d=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains);S&&u([m,C,S,k,T],{supportedChainNames:v})}if(C===uo.CONNECTED){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}C===uo.PROVIDER_DISCONNECTED&&(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),C===uo.NAMESPACE_DISCONNECTED&&n(m,S)},"handleUpdatesForHub"),h=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains),b=[],A=[];if(S?.forEach(w=>{let{network:x}=_p(w);p.includes(x)?b.push(w):A.push(w)}),r.filter(w=>w.walletType===m).map(w=>KS(w.address,w.chain)).length>0){if(b.length>0){let w=aa(m,b,p,v,T.isContractWallet);a(m,{chains:w.map(x=>x.chain)})}A.length>0&&a(m,{chains:A.map(w=>{let{network:x}=_p(w);return x})})}S?u([m,C,S,k,T],{supportedChainNames:v}):(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}if(C===uo.ACCOUNTS&&k.connected){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForLegacy"),f=i((m,C,S,k,T)=>{if(C===uo.NETWORK&&k.network){let v=`${m}-${k.network}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,C,S,k,T)=>{T.isHub?d(m,C,S,k,T):h(m,C,S,k,T),f(m,C,S,k,T)},"handler")}}i(Dp,"useUpdates");import{LegacyEvents as XS}from"@rango-dev/wallets-core/legacy";function $p(t,e){let[o,n,r,a,s]=e;n!==XS.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i($p,"propagateEvents");var Ir=ZS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function RS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),s=y().config,l={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:c}=Ea(s.wallets,l),p=Op(),u=Op(),{handler:d}=Dp({onConnectWalletHandler:p,onDisconnectWalletHandler:u});Fp(()=>{n().catch(console.log)},[]),Fp(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let h=re.use.isActiveTab(),f=JS(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return Er.createElement(Ir.Provider,{value:f},Er.createElement(YS,{allBlockChains:a,providers:c,onUpdateState:(g,m,C,S,k)=>{let T=[g,m,C,S,k];d(...T),t.onUpdateState&&$p(t.onUpdateState,T)},autoConnect:!!h,configs:{wallets:s.wallets}},t.children))}i(RS,"Main");function Ar(t){let{config:e,...o}=t;return Er.createElement(fp,{config:e},Er.createElement(RS,{...o,config:e}))}i(Ar,"WidgetWallets");import Zi from"react";import eC,{Fragment as tC}from"react";import{MemoryRouter as oC,useInRouterContext as nC}from"react-router";function Up({children:t}){let o=nC()?tC:oC;return eC.createElement(o,null,t)}i(Up,"AppRouter");import{I18nManager as OE}from"@rango-dev/ui";import tc from"react";import _e from"react";import{useRoutes as xE}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 Oo,useRef as $r}from"react";import Ke from"bignumber.js";import{create as aC}from"zustand";import{subscribeWithSelector as sC}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as DB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as _r}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 zp(t){switch(t.type){case 0:return t.diagnosisMessage??R().noResultError.title;case 1:return R().genericServerError;default:return""}}i(zp,"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 Ia(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(Ia,"getFeeLabel");var Aa=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Qp=100,Hp=30,qp=15,Gp=60;var Vp=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Kp=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as iC}from"@rango-dev/queue-manager-rango-preset";import vB from"bignumber.js";function Xp(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(Xp,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Br(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=iC(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=an(a?a.toBlockchain:n.fromBlockchain,e),c=an(r.toBlockchain,e),p=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:p,toBlockchain:c,toToken:u,inputAmount:d}}i(Br,"createRetryQuote");function Fo(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=Tn(o),s=ct(o);if(o&&a&&s){let p=Pt(a.toString(),s.toString());if(!!p&&eu(a,p)){let d=Mr(o?.swaps,n),h=_t(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:h}}}if(e&&nu(e,o))return{type:4,usdValueChange:B(ct(o)?.minus(ct(e)??0).toString()??"0",null,2),percentageChange:B(Pt(ct(e)??"1",ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Pr(o.swaps),c=r>op;if(ou(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:tu(o,r),minRequiredSlippage:l};return null}i(Fo,"generateQuoteWarnings");function Yp(t){return![4].includes(t.type)}i(Yp,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Na(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Zp=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"),Lr=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),c=n.requestId.toLowerCase();return l.localeCompare(c)}),"sortQuotesBy"),Jp=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"),Rp=i(t=>{let e=i((o,n)=>{let r=Aa.indexOf(o.value),a=Aa.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function eu(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Vp.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(eu,"hasHighValueLoss");function ru(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(ru,"hasLimitError");function iu(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,p=l.fromAmountMaxValue?new Ue(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?c?.gte(l.fromAmount)||p?.lte(l.fromAmount):c?.gt(l.fromAmount)||p?.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:B(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:B(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:B(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:B(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(iu,"getLimitErrorMessage");function au(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=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}:c?{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(au,"getSwapButtonState");function Wa(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ce))&&e&&e!=="0"&&n!==0)}i(Wa,"canComputePriceImpact");function Ba(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 Ue(r.amount).multipliedBy(a||0))}return o}i(Ba,"getUsdFeeOfStep");function Mr(t,e){return t.reduce((o,n)=>o.plus(Ba(n,e)),ce)}i(Mr,"getTotalFeeInUsd");function La(t){let e=ce;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(La,"getUsdFee");function su(t){return t.reduce((e,o)=>e.plus(La(o)),ce)}i(su,"getTotalFeesInUsd");function lu(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(lu,"getFeesGroup");function cu(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(cu,"checkSlippageErrors");function tu(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(tu,"checkSlippageWarnings");function Pr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Pr,"getMinRequiredSlippage");function ou(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(ou,"hasProperSlippage");function pu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:h,destination:f}=t,g=a?.reduce((S,k)=>(S[k.chain]=k.address,S),{}),m=[];return r?.forEach(S=>{m.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:d??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:m,selectedWallets:g??{},slippage:p.toString(),...f&&{destination:f},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(pu,"createQuoteRequestBody");function uu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(uu,"getWalletsForNewSwap");function Tn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(Tn,"getUsdInputFrom");function ct(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(ct,"getUsdOutputFrom");function Na(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy(Qp).toNumber()}i(Na,"getPercentageChange");function nu(t,e){let o=Tn(t),n=ct(t),r=ct(e);if(!o||!n||!r)return!1;let a=Na(n.toString(),r.toString());return Kp.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(nu,"isOutputAmountChangedExcessively");function du(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=>Xp(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=B(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=B(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=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:p,symbol:l,reason:u,currentAmount:c,blockchain:st(s.asset.blockchain,o)}})})}i(du,"generateBalanceWarnings");function vn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==_r.NetworkChanged}i(vn,"isNetworkStatusInWarningState");function mu(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),vn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case _r.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case _r.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case _r.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(mu,"getSwapMessages");function fu(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(fu,"getLastConvertedTokenInFailedSwap");function gu(t){return t.status==="failed"}i(gu,"shouldRetrySwap");function hu(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),c=s.every(d=>r.some(h=>h.chain===d)),p=l.every(d=>r.some(h=>h.chain===d)),u=o&&a?Io(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!u||!p)}i(hu,"isConfirmSwapDisabled");function yu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(yu,"isTokensIdentical");var Dr=i((t,e)=>t?.usdPrice?new Ke(e||ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Mo(aC()(sC(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=ce,a=o.inputUsdValue;return cn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=Tn(e)??ce,r=ct(e)??ce),{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:Dr(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:Dr(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:Dr(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?Dr(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})})))),Su=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ye.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&&ye.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 Cu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:c,toBlockchain:p}=O(),u=y().config,d=y().fetchStatus,h=y().blockchains(),f=y().tokens(),{findToken:g}=y(),{setAffiliateRef:m,setAffiliatePercent:C,setAffiliateWallets:S}=y(),k=u?.from?.tokens,T=u?.from?.blockchains,v=u?.to?.tokens,b=u?.to?.blockchains,A=$r(void 0),D=$r(void 0),w=$r(void 0),x=$r(void 0);Oo(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Oo(()=>{if(d==="success"){r();let E=h.find(W=>W.name===u?.from?.blockchain),N=u?.from?.token,L=N&&g(N);(E||!E&&w.current)&&n(E??null),L?a({token:L,meta:{blockchains:h,tokens:f}}):!L&&A.current&&a({token:null}),w.current=u?.from?.blockchain,A.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,d]),Oo(()=>{ca(s,k)&&a({token:null}),pa(c,T)&&n(null)},[k,T]),Oo(()=>{ca(l,v)&&a({token:null}),pa(p,b)&&o(null)},[v,b]),Oo(()=>{if(d==="success"){r();let E=h.find(W=>W.name===u?.to?.blockchain),N=u?.to?.token,L=N&&g(N);(E||!E&&x.current)&&o(E??null),L?e({token:L,meta:{blockchains:h,tokens:f}}):!L&&D.current&&e({token:null}),x.current=u?.to?.blockchain,D.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),Oo(()=>{m(u?.affiliate?.ref??null),C(u?.affiliate?.percent??null),S(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(Cu,"useSyncStoresWithConfig");import{useEffect as _a,useRef as lC}from"react";import{useInRouterContext as cC,useLocation as pC,useSearchParams as uC}from"react-router-dom";function Ma(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Ma,"convertTokenSearchParamToAsset");function Pa(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Pa,"tokenToSearchParam");function $a(){let t=pC(),[e,o]=uC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:h}=O(),f=y().fetchStatus,g=y().blockchains(),m=y().tokens(),C=cC(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=lC(),{findToken:b}=y(),A=i(()=>{let w={};for(let[X,se]of e.entries())X.startsWith("utm_")&&(w[X]=se);let x=e.get("fromAmount"),E=e.get("fromBlockchain"),N=e.get("fromToken"),L=e.get("toBlockchain"),W=e.get("toToken"),j=e.get("autoConnect"),te=e.get("clientUrl"),J=e.get("liquiditySources"),M=e.get("blockchain");return{fromAmount:x,fromBlockchain:E,fromToken:N,toBlockchain:L,toToken:W,autoConnect:j,clientUrl:te,liquiditySources:J,utmQueryParams:w,blockchain:M}},"getUrlSearchParams"),D=i(w=>{for(let x in w)w[x]||delete w[x];o(w,{replace:!0})},"updateUrlSearchParams");_a(()=>{let{autoConnect:w,clientUrl:x,utmQueryParams:E,blockchain:N}=A();C&&f==="success"&&D({fromBlockchain:n?.name,fromToken:Pa(a),toBlockchain:r?.name,toToken:Pa(s),fromAmount:l,autoConnect:w??void 0,clientUrl:x??void 0,blockchain:N??void 0,liquiditySources:T?v.current:void 0,...E})},[t.pathname,l,n,a,r,s,T]),_a(()=>{if(!C)return;let w=A();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&h(w.fromAmount),f==="success"){let x=g.find(W=>W.name===w.fromBlockchain),E=w.fromToken&&x?b(Ma(w.fromToken,x)):void 0,N=g.find(W=>W.name===w.toBlockchain),L=w.toToken&&N?b(Ma(w.toToken,N)):void 0;x&&(c(x),E&&u({token:E,meta:{blockchains:g,tokens:m}})),N&&(p(N),L&&d({token:L,meta:{blockchains:g,tokens:m}}))}},[f]),_a(()=>{let{clientUrl:w,liquiditySources:x}=A();S("clientUrl",w||void 0),k("liquiditySources",x?.split(",")??void 0)},[])}i($a,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as xk,Button as Ru,darkTheme as Ek,Divider as xn,DoneIcon as Ik,MessageBox as Ak,styled as Nk,TextField as Wk,Typography as Bk}from"@rango-dev/ui";import Se,{useEffect as Lk,useState as qr}from"react";import{useNavigate as Mk,useSearchParams as Pk}from"react-router-dom";import{ChevronRightIcon as dC,Divider as bu,Image as mC,Typography as xu}from"@rango-dev/ui";import ht from"react";import{darkTheme as ku,styled as Fa}from"@rango-dev/ui";var Tu=Fa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${ku} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${ku} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),vu=Fa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),wu=Fa("div",{display:"flex"});function Oa(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(vu,null,ht.createElement(xu,{size:"large",variant:"label"},n),ht.createElement(bu,{size:10}),ht.createElement(Tu,{onClick:s?void 0:e,disabled:s},ht.createElement(wu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(mC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(bu,{size:4,direction:"horizontal"})),ht.createElement(xu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(dC,{size:12,color:"black"})))}i(Oa,"BlockchainSelectorButton");import{i18n as za}from"@lingui/core";import{Button as fC,Divider as wn,ExternalLinkIcon as gC,Image as hC,Typography as zo}from"@rango-dev/ui";import Ne from"react";function Eu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Eu,"generateExplorerLink");import{darkTheme as Uo,styled as Iu}from"@rango-dev/ui";var Ua=Iu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Au=Iu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Uo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}}});function Qa(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=Eu(n.address,a);return Ne.createElement(Z,{open:e,dismissible:!0,onClose:o,container:I()},Ne.createElement(Au,null,Ne.createElement(hC,{src:n.image,size:45,type:"circular"}),Ne.createElement(zo,{variant:"title",size:"medium"},n.name),Ne.createElement(zo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ne.createElement(wn,{size:4}),Ne.createElement(zo,{variant:"body",size:"medium"},s?Ne.createElement(Ua,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ne.createElement(gC,{size:12,color:"gray"})):Ne.createElement(Ua,null,n.address)),Ne.createElement(wn,{size:4}),n.coinSource&&Ne.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},za.t("via")," ",Ne.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ne.createElement(wn,{size:"32"}),Ne.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},za.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ne.createElement(wn,{size:40}),Ne.createElement(wn,{size:10}),Ne.createElement(fC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},za.t("Import")))}i(Qa,"CustomTokenModal");import{useManager as Ck}from"@rango-dev/queue-manager-react";import{BottomLogo as kk,Divider as ju,Header as Tk}from"@rango-dev/ui";import Be,{useEffect as ps,useRef as Xu,useState as vk}from"react";import{useRef as yC}from"react";function Fr(){return window.self!==window.top}i(Fr,"isAppLoadedIntoIframe");function Ha(){let t=yC(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 c of l)n({type:"widget_height",data:{height:c.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ha,"useIframe");import{useNavigate as SC}from"react-router-dom";function je(){let t=SC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as Ya,darkTheme as LC,lightTheme as MC}from"@rango-dev/ui";import{useEffect as PC,useState as _C}from"react";import{theme as WC,darkColors as BC}from"@rango-dev/ui";import ja from"react";function CC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(CC,"expandShortHexColor");function kC(t){return/[0-9]+$/.test(t)}i(kC,"isOverridingColor");function TC(t,e){return t.padStart(e,"0")}i(TC,"pad");function qa(t){let e=Math.min(Math.max(Math.round(t),0),255);return TC(e.toString(16),2)}i(qa,"intToHex");function vC(t){return`#${qa(t.red)}${qa(t.green)}${qa(t.blue)}`}i(vC,"rgbToHex");function wC(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(wC,"hexToRGB");function bC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(bC,"generateShade");function xC(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(xC,"generateTint");function EC(t){return Nu(t,bC)}i(EC,"calculateShades");function IC(t){return Nu(t,xC)}i(IC,"calculateTints");function Nu(t,e){let o=wC(t),n=[];for(let r=1;r<9;r++)n.push(vC(e(o,r)));return n}i(Nu,"calculateColors");function Ga(t,e,o){let a=IC(t).reverse().concat(t),s=EC(t),l=a.concat(s),c={},p=l.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50;c[`${e}${d}`]=l[u]}return c}i(Ga,"createTintsAndShades");function Va(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)&&!kC(r)){let c=CC(a);Object.assign(n,Ga(c,r,s))}}return{...n,...e}}i(Va,"expandToGenerateThemeColors");var Wu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),AC=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"),NC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Ka=i(t=>AC(NC(5381,JSON.stringify(t))>>>0),"toHash");function Xa(t){let e=WC.colors,o={...e,...BC},n,r;if(t?.light){let s={colors:Va(e,t.light)};n={id:`${la}-light-${Ka(s)}`,tokens:s}}if(t?.dark){let s={colors:Va(o,t.dark,{reverseNeutralRange:!0})};r={id:`${la}-dark-${Ka(s)}`,tokens:s}}return{light:n,dark:r}}i(Xa,"customizedThemeTokens");function Bu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>ja.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(ja.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(ja.cloneElement(e,{key:l}))}}),o}i(Bu,"joinList");function Lu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Lu,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=wc,borderRadius:n=Vc,secondaryBorderRadius:r=Kc}=t,[a,s]=_C(Lu()?"dark":"light"),{theme:l}=y(),{dark:c,light:p}=Xa(e),u=Ya({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,MC.className],h=[u.className,LC.className];if(p){let g=Ya(p.id,p.tokens);d.push(g.className)}if(c){let g=Ya(c.id,c.tokens);h.push(g.className)}return PC(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Lu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=d.join(" "),m=h.join(" ");return l==="auto"?a==="dark"?m:g:l==="dark"?m:g},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var pt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Mu}from"@lingui/core";import{Alert as DC,Button as $C}from"@rango-dev/ui";import Pu from"react";function Za(t){return Pu.createElement(DC,{action:Pu.createElement($C,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Mu.t("Activate this tab")),type:"warning",variant:"alarm",title:Mu.t("Another tab is open and handles transactions.")})}i(Za,"ActivateTabAlert");import{i18n as Ja}from"@lingui/core";import{Button as FC,Divider as OC,MessageBox as UC}from"@rango-dev/ui";import Or from"react";function Ra(t){let{open:e,onClose:o,onConfirm:n}=t;return Or.createElement(Z,{open:e,dismissible:!0,onClose:o,container:I()},Or.createElement(UC,{title:Ja.t("Activate current tab"),type:"warning",description:Ja.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(OC,{size:20}),Or.createElement(FC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Ja.t("Confirm"))))}i(Ra,"ActivateTabModal");import{ChevronLeftIcon as zC}from"@rango-dev/ui";import _u from"react";function es(t){return _u.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},_u.createElement(zC,{color:"black",size:16}))}i(es,"BackButton");import{i18n as QC}from"@lingui/core";import{Button as HC,Typography as qC}from"@rango-dev/ui";import ts from"react";function os(t){return ts.createElement(Vt,null,ts.createElement(HC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},ts.createElement(qC,{variant:"label",size:"medium",color:"error500"},QC.t("Cancel"))))}i(os,"CancelButton");import{i18n as GC}from"@lingui/core";import{Image as VC,Tooltip as KC,WalletIcon as jC}from"@rango-dev/ui";import fo from"react";function ns(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?fo.createElement("div",{className:vp()},o.map(r=>fo.createElement(Tr,{key:r.title},fo.createElement(VC,{src:r.image,size:14})))):GC.t("Connect Wallet");return fo.createElement(KC,{container:t.container,side:"bottom",content:n},fo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&fo.createElement(Sp,null),fo.createElement(jC,{size:18,color:"black"})))}i(ns,"WalletButton");import{i18n as zr}from"@lingui/core";import{NotificationsIcon as pk,Popover as uk,SettingsIcon as dk,Tooltip as Qr,TransactionIcon as mk}from"@rango-dev/ui";import We from"react";import{Notifications as JC}from"@rango-dev/ui";import RC from"react";import{useNavigate as ek}from"react-router-dom";import{create as XC}from"zustand";import{persist as YC,subscribeWithSelector as ZC}from"zustand/middleware";var be=Mo(XC()(YC(ZC((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(c=>c.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(c=>c.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 rs(){let t=ek(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return RC.createElement(JC,{list:n,getBlockchainImage:l=>fc(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(rs,"NotificationContent");import{useManager as tk}from"@rango-dev/queue-manager-react";import{InProgressIcon as ok}from"@rango-dev/ui";import Du from"react";var nk=i(()=>{let{manager:t}=tk();return pt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Du.createElement(Tp,null,Du.createElement(ok,{color:"info",size:6})):null},"InProgressTransactionBadge"),$u=nk;import{EventSeverity as rk}from"@rango-dev/queue-manager-rango-preset";import{Typography as ik}from"@rango-dev/ui";import Fu from"react";function Ou(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===rk.WARNING);return o?Fu.createElement(Cp,{isSever:n},Fu.createElement(ik,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Ou,"NotificationsBadge");import{RefreshProgressButton as ak}from"@rango-dev/ui";import is,{useEffect as sk,useState as Uu}from"react";var lk=1e3,zu=60,ck=100;function Ur({onClick:t}){let[e,o]=Uu(0),[n,r]=Uu(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");sk(()=>{let c;return t?c=window.setInterval(()=>{o(p=>p+1),e===zu&&l()},lk):s(c),document.addEventListener("visibilitychange",()=>a(c)),()=>{document.removeEventListener("visibilitychange",()=>a(c)),c&&clearInterval(c)}},[e,t]);let s=i(c=>{c&&clearInterval(c),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return is.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},is.createElement(kp,{onTransitionEnd:()=>r(!1),isRefetched:n},is.createElement(ak,{size:22,color:t?"black":"gray",progress:e/zu*ck})))}i(Ur,"RefreshButton");function go(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 We.createElement(We.Fragment,null,!r.includes("refresh")&&We.createElement(Qr,{container:a||I(),side:"top",content:zr.t("Refresh")},We.createElement(Ur,{onClick:e})),!l&&We.createElement(uk,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:I(),content:We.createElement(rs,null)},We.createElement("div",null,We.createElement(Qr,{container:I(),side:"top",content:zr.t("Notifications")},We.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},We.createElement(pk,{size:18,color:"black"}),We.createElement(Ou,null))))),!r.includes("settings")&&We.createElement(Qr,{container:I(),side:"top",content:zr.t("Settings")},We.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},We.createElement(dk,{size:18,color:"black"}))),!r.includes("history")&&We.createElement(Qr,{container:I(),side:"top",content:zr.t("History")},We.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},We.createElement(mk,{size:18,color:"black"}),We.createElement($u,null))))}i(go,"HeaderButtons");import{i18n as as}from"@lingui/core";import{Divider as Hu,MessageBox as hk,RefreshIcon as yk}from"@rango-dev/ui";import Ho from"react";import{Button as fk,styled as gk}from"@rango-dev/ui";var Qu=gk(fk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function ss(t){let{open:e,onClose:o}=t;return Ho.createElement(Z,{open:e,dismissible:!0,onClose:o,container:I()},Ho.createElement(hk,{title:as.t("Something went wrong"),type:"error",description:as.t("Something went wrong. Please refresh the app.")},Ho.createElement(Hu,{size:30}),Ho.createElement(Qu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Ho.createElement(yk,{size:20,color:"primary"}),Ho.createElement(Hu,{size:4,direction:"horizontal"}),as.t("Refresh"))))}i(ss,"RefreshModal");function ls(t){let e=t.target;if(e){let o=e.scrollTop,n=I();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(ls,"onScrollContentAttachStatusToContainer");import{css as Sk,styled as cs}from"@rango-dev/ui";var qu="700px",Hr=Sk({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Gu=cs("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:qu},fixed:{height:qu}}}}),Vu=cs("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Ku=cs("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}=Ha(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c}=y(),[p,u]=vk(!1),{config:{features:d,theme:h}}=y(),{watermark:f}=re(),g=f==="FULL",{activeTheme:m}=Qo(h||{}),C=Ve("connectWalletButton",d),{isActiveTab:S,tabManagerInitiated:k,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:b}=re(),A=je(),{manager:D}=Ck(),x=pt(D).map(({swap:te})=>te).some(te=>te.status==="running"),E=i(()=>b(ao.forceClaim,x),"onActivateTab"),N=i(()=>{r.onWallet?.()},"onConnectWallet"),L=typeof r.hasBackButton>"u"||r.hasBackButton,W=Xu(null),j=Xu(null);return ps(()=>(Fr()&&j.current&&e(j.current),()=>{o()}),[]),ps(()=>(W.current?.addEventListener("scroll",ls),()=>{W.current?.removeEventListener("scroll",ls)}),[]),ps(()=>{u(l==="failed")},[l]),Be.createElement(Gu,{height:s,id:De.SWAP_BOX_ID,className:`${m()} ${Hr()}`,ref:j},Be.createElement(Tk,{prefix:L?Be.createElement(es,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!C&&Be.createElement(ns,{container:I(),onClick:N,isConnected:!!c?.length}),r.onCancel&&Be.createElement(os,{onClick:r.onCancel}))}),Be.createElement(Vu,{ref:W},n),Be.createElement(Ra,{open:T,onClose:()=>v(!1),onConfirm:E}),Be.createElement(Ku,null,Be.createElement("div",{className:"footer__content"},k&&!S&&Be.createElement("div",{className:"footer__alert"},Be.createElement(Za,{onActivateTab:E}),Be.createElement(ju,{size:10})),a),Be.createElement(ju,{size:12}),Be.createElement("div",{className:`footer__logo ${g?"logo__show":"logo__hidden"}`},Be.createElement(kk,null))),Be.createElement(ss,{open:p,onClose:()=>u(!1)}))}i(oe,"Layout");import{styled as wk}from"@rango-dev/ui";var Yu="$20 $20 $10 $20",bn=wk("div",{padding:Yu,overflowY:"auto",flexGrow:1});import{styled as bk}from"@rango-dev/ui";var ie=bk("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 Zu}from"react";function Ju(){let[t,e]=Zu(!1),[o,n]=Zu(void 0),{findToken:r}=y(),a=y().customTokens();function s(c,p){switch(c){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:p}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:c,tokenAddress:p})=>{e(!0);try{if(a.some(g=>g.address?.toLowerCase()===p.toLowerCase())){let g=s("duplicated");n(g);return}let d=await xt().getCustomToken({blockchain:c,address:p});if(!d||!d.token||d.error){let g=s("not-found",c);n(g);return}let h=d.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let g=s("token-exist");n(g);return}return h}catch(u){if(u?.code==="ERR_BAD_REQUEST"){let d=s("not-found",c);n(d);return}throw n(void 0),new Error(u.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Ju,"useFetchCustomToken");var _k=Nk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${Ek} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),Dk=1e3;function ed(){let t=Mk(),[e]=Pk(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=an(a,r),[l,c]=qr(""),[p,u]=qr(!1),[d,h]=qr(),{fetchCustomToken:f,loading:g,error:m}=Ju(),[C,S]=qr(""),k=!!s&&Io(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let D=await f({blockchain:a,tokenAddress:l});S(""),D&&h(D)}catch(D){D.message==="Failed to fetch"&&(S(It.t("Network Error")),u(!0))}},"getCustomToken"),b=i(()=>{m&&c(""),u(!1)},"closeErrorModal"),A=i(async()=>{C&&setTimeout(async()=>{await v()},Dk),b()},"handleErrorModalButtonClick");return Lk(()=>{m&&u(!0)},[m]),Se.createElement(oe,{header:{title:It.t("Add Custom Token")}},Se.createElement(ie,null,Se.createElement(_k,null,Se.createElement("div",null,Se.createElement(Oa,{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")}),Se.createElement(xn,{size:"24"}),Se.createElement(Bk,{size:"large",variant:"label"},It.t("Enter Address")),Se.createElement(xn,{size:10}),Se.createElement(Wk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&Se.createElement(Ik,{color:"success",size:12}),onChange:D=>c(D.target.value)}),!k&&!!l&&Se.createElement(Se.Fragment,null,Se.createElement(xn,{size:4}),Se.createElement(xk,{type:"error",variant:"alarm",title:"Invalid Address"}))),Se.createElement(Ru,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:g,size:"large",onClick:v},It.t("Import"))),Se.createElement(Z,{open:p,dismissible:!0,onClose:b,container:I()},Se.createElement(Ak,{title:m?.title||C,type:"error",description:m?.message||It.t("Failed Network, Please retry.")},Se.createElement(xn,{size:40}),Se.createElement(xn,{size:10}),Se.createElement(Ru,{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&&d&&Se.createElement(Qa,{blockchain:s,token:d,onSubmitClick:()=>{d&&(n(d),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!d})))}i(ed,"AddCustomTokenPage");import{i18n as Us}from"@lingui/core";import{useManager as Cv}from"@rango-dev/queue-manager-react";import{Alert as kv,Button as Tv,css as Qs,Divider as zs,IconButton as jm,styled as vv,Typography as wv,WalletIcon as bv}from"@rango-dev/ui";import Me,{useEffect as Si,useLayoutEffect as xv,useRef as Ev,useState as Fn}from"react";import{useNavigate as Iv}from"react-router-dom";import{i18n as ho}from"@lingui/core";import{Alert as sT,BalanceErrors as lT,Button as Ad,ChevronLeftIcon as cT,Divider as Ss,MessageBox as pT,Typography as Cs}from"@rango-dev/ui";import ee,{useCallback as uT,useEffect as Nd,useMemo as dT,useState as Ko}from"react";import{useNavigate as mT}from"react-router-dom";import{i18n as fs}from"@lingui/core";import{Alert as zk,ChevronDownIcon as Qk,CloseIcon as Hk,Divider as sd,IconButton as ld,PasteIcon as qk,Typography as Gk,WalletIcon as Vk}from"@rango-dev/ui";import Le,{useEffect as Kk,useRef as jk}from"react";import jr,{useRef as Ok}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as td,styled as Gr}from"@rango-dev/ui";var us=300,$k=td({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Fk=td({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),od=Gr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ds=Gr(Go.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Vr=Gr(Go.Content,{overflow:"hidden",variants:{open:{true:{animation:`${$k} ${us}ms ease-out`},false:{animation:`${Fk} ${us}ms ease-out`}}}}),Kr=Gr("div",{transition:`all ${us}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Xr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=Ok(null);return jr.createElement(od,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&jr.createElement(ds,{className:"collapsible_trigger",onClick:a},s),jr.createElement(Vr,{className:"collapsible_content",open:e},r),l==="bottom"&&jr.createElement(ds,{className:"collapsible_trigger",onClick:a},s))}i(Xr,"CustomCollapsible");import{darkTheme as nd,styled as ms,TextField as Uk}from"@rango-dev/ui";var rd=ms("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),id=ms(Uk,{backgroundColor:"$neutral100",padding:"$15"}),ad=ms("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${nd} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${nd} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function cd(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=sr(e.name,l),p=jk(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),f=n&&!!r&&e&&!Io(e,r),g=i(()=>{a("")},"handleClear"),m=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),p?.current?.focus()}},"handlePaste"),C=i(()=>r?Le.createElement(ld,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Le.createElement(Hk,{size:12,color:"gray"})):d?null:Le.createElement(ld,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Le.createElement(qk,{size:16})),"renderSuffix");return Kk(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Le.createElement(rd,null,Le.createElement(Xr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Le.createElement(ad,null,Le.createElement("div",{className:"button__content"},Le.createElement(Vk,{size:18,color:"info"}),Le.createElement(sd,{size:4,direction:"horizontal"}),Le.createElement(Gk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},fs.t("Send to a different address"))),Le.createElement(Kr,{orientation:n?"up":"down"},Le.createElement(Qk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Le.createElement(id,{ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:fs.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),f&&Le.createElement(Le.Fragment,null,Le.createElement(sd,{size:4}),Le.createElement(zk,{variant:"alarm",type:"error",title:fs.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(cd,"CustomDestination");import{css as Xk,darkTheme as gs,IconButton as Yk,styled as Dt}from"@rango-dev/ui";var pd=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),ud=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Zk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${gs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${gs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${gs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),dd=Dt(Zk,{alignSelf:"stretch",minHeight:"93px"}),md=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),fd=Dt(Yk,{position:"absolute",left:"$20"}),gd=Dt("div",{paddingTop:"$20"}),hd=Xk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),yd=Dt("div",{display:"flex"}),Sd=Dt("div",{overflow:"visible",width:"100%"});import{i18n as bd}from"@lingui/core";import{warn as oT}from"@rango-dev/logging-core";import{Divider as nT,SelectableWallet as rT,Typography as xd,WalletState as Ed}from"@rango-dev/ui";import Xe,{useEffect as Id,useState as In}from"react";import{Image as eT,MessageBox as tT}from"@rango-dev/ui";import En from"react";import{keyframes as Jk,styled as hs}from"@rango-dev/ui";var Cd=hs("div",{position:"relative"}),Rk=Jk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),kd=hs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Rk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Td=hs("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function vd(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Vo.t("Request Rejected"),description:Vo.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(vd,"generateMessageByStatus");function wd(t){let{status:e,displayName:o,image:n}=t,r=vd(e,o),a=e=="in-progress";return En.createElement(tT,{type:r.type,title:r.title,description:r.description,icon:a?En.createElement(Cd,null,En.createElement(Td,null,En.createElement(eT,{src:n,size:45})),En.createElement(kd,null)):void 0})}i(wd,"ExperimentalChainStatus");var iT=7,aT=3e3;function ys(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[p,u]=In(),[d,h]=In(null),[f,g]=In(!1),[m,C]=In(null),{suggestAndConnect:S}=Yr(),{handleDisconnect:k}=Gt(),{list:T}=ft({chain:e}),[v,b]=In(T),A=T.length,D=r&&A-r>0,w=i(async E=>{g(!1),C("in-progress");try{await S(E.walletType,E.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");Id(()=>{b(E=>{let N=T.findIndex(L=>o(L.type,e));return D&&N>1?[T[N]].concat(T.filter((L,W)=>W!==N)):E.map(L=>T.find(W=>W.type===L.type)??L)})},[JSON.stringify(T)]);let x=document.getElementById(De.SWAP_BOX_ID);return Id(()=>{let E=null;return(m==="completed"||m==="rejected")&&(E=setTimeout(()=>C(null),aT)),()=>{E&&clearTimeout(E)}},[m]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(E=>{let N=Uc({connectedWallets:c,walletType:E.type,chain:e}),L=N?Sr(N,iT):"",W=hr(l(),e),j=!c.find(se=>se.walletType===E.type&&se.chain===e),te=W&&j&&E.state===Ed.CONNECTED,J=te?bd.t({id:"Add {chain} chain",values:{chain:e}}):L,M=i(async()=>{let se=E.state===Ed.DISCONNECTED,z=(E.isHub||!!E.needsNamespace)&&!L;se?u(E):z?(await k(E.type),u(E)):te?(h({walletType:E.type,chain:e,address:N??""}),g(!0)):n({walletType:E.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=d?.chain?sr(d.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${E.title}_${X}`},!!d&&Xe.createElement(Z,{open:!!d&&f,container:x,onClose:()=>{h(null)}},Xe.createElement(xa,{displayName:X,onConfirm:()=>{w(d)}})),m&&Xe.createElement(Z,{open:!!m,onClose:C.bind(null,null),container:x},Xe.createElement(wd,{status:m,displayName:X,image:E.image}),Xe.createElement(nT,{direction:"vertical",size:32})),Xe.createElement(rT,{key:E.type,description:J,onClick:M,selected:o(E.type,e),disabled:!s,...E}))}),Xe.createElement(po,{wallet:p,onClose:()=>{u(void 0)},onConnect:()=>{t.onConnect&&(p?.type?t.onConnect(p.type):oT(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),D&&Xe.createElement(dd,{selected:!1,onClick:a},Xe.createElement(xd,{variant:"label",size:"medium"},bd.t("Show more wallets"),Xe.createElement(xd,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(ys,"WalletList");var fT=2;function Wd(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=mT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:h,setCustomDestination:f}=O(),{config:g,connectedWallets:m,setWalletsAsSelected:C}=y(),[S,k]=Ko(""),[T,v]=Ko([]),[b,A]=Ko(""),[D,w]=Ko(!!h),x=dT(()=>io({filter:"all",quote:c}),[c]),E=io({filter:"required",quote:c}),N=l.find(P=>P.name===c?.swaps[c?.swaps.length-1].to.blockchain),L=i(P=>E.includes(P),"isWalletRequiredFor"),W=uT(()=>m.filter(P=>P.selected&&x.includes(P.chain)),[m,x]),[j,te]=Ko(W()),[J,M]=Ko([]),X=i((P,q)=>M(V=>V.concat({blockchain:P,walletType:q})),"addNextSelectedWallets"),se=T.length>0,z=i((P,q)=>!!j.find(V=>V.walletType===P&&V.chain===q&&V.selected&&(L(q)||!L(q)&&!h)),"isSelected"),me=i((P,q,V)=>{let ge=!1;return P.map(ne=>{if(ne.chain===q){let he=ne.selected;return!ge&&V?(ge=!0,he=!0):V||(he=!1),{...ne,selected:he}}return ne})},"updateSelectableWallets"),vt=i(P=>{w(P),P?L(N?.name??"")||te(q=>me(q,N?.name||"",!1)):(f(""),te(q=>me(q,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(P=>{if(S&&k(""),z(P.walletType,P.chain))return;let V=m.find(ge=>ge.walletType===P.walletType&&ge.chain===P.chain);V&&(n(),P.chain===N?.name&&D&&!L(N.name)&&(w(!1),f(null)),te(ge=>ge.filter(ne=>ne.chain!==P.chain).concat({...V,selected:!0})))},"onChange"),le=i(()=>{let P=j.filter(q=>q.selected);C(P),p(P),d(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),A("");let P=await r?.({selectedWallets:j.filter(V=>V.selected),customDestination:h}),q=P.warnings;q?.balance?.messages&&v(q.balance.messages),P.error&&A(zp(P.error)),!P.error&&!q?.balance?.messages.length?le():v(q?.balance?.messages??[])},"onConfirmWallets");Nd(()=>{te(P=>{let q=[];return P.forEach(V=>{!m.some(ne=>ne.chain===V.chain&&ne.walletType===V.walletType&&ne.address===V.address)||q.push(V)}),q=q.concat(m.filter(V=>!!!q.find(ne=>ne.chain===V.chain)&&V.selected&&x.includes(V.chain))),q})},[m,x]),Nd(()=>{let P=[];J.length>0&&(J.forEach(q=>{let V=m.find(ge=>ge.chain===q.blockchain&&ge.walletType===q.walletType);V?Ze(V):P.push(q)}),M(P))},[m,J]);let G=document.getElementById(De.SWAP_BOX_ID);return ee.createElement(Z,{open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:G,...!S&&{styles:{container:{height:"100%"}},footer:ee.createElement(yd,null,ee.createElement(Ad,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:hu(a,D,h,c,j,N),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ee.createElement(md,null,ee.createElement(fd,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},ee.createElement(cT,{size:16})),ee.createElement(Cs,{variant:"headline",size:"small"},ho.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(pT,{title:ho.t("Insufficient account balance"),type:"error",description:ee.createElement(lT,{messages:T??[]})},ee.createElement(Ad,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},ho.t("Proceed anyway")))),S&&ee.createElement(gd,null,ee.createElement("div",{className:hd()},ee.createElement(ys,{chain:S,isSelected:z,selectWallet:Ze,onShowMore:()=>k(S),onConnect:P=>{X(S,P)}}))),!S&&ee.createElement(ee.Fragment,null,b&&ee.createElement(ee.Fragment,null,ee.createElement(sT,{variant:"alarm",type:"error",title:ho.t(b)}),ee.createElement(Ss,{size:12})),ee.createElement(Sd,null,x.map((P,q)=>{let V=l.find(Fe=>Fe.name===P),ge=`wallet-${q}`,ne=q===x.length-1,he=ne&&N&&g?.customDestination!==!1;return ee.createElement("div",{key:ge},ee.createElement(pd,null,ee.createElement(Cs,{variant:"title",size:"xmedium"},ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ee.createElement(Cs,{variant:"label",color:"$neutral700",size:"medium"},ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ee.createElement(Ss,{size:24}),ee.createElement(ud,null,ee.createElement(ys,{chain:P,isSelected:z,selectWallet:Ze,limit:fT,onShowMore:()=>k(V?.name??""),onConnect:Fe=>{X(P,Fe)}})),!ne&&ee.createElement(Ss,{size:32}),he&&ee.createElement(cd,{blockchain:N,open:D,handleOpenChange:vt}))}))))}i(Wd,"ConfirmWalletsModal");import{i18n as MT}from"@lingui/core";import{Alert as PT,Button as _T,InfoIcon as DT}from"@rango-dev/ui";import et from"react";import{Alert as yT,Button as ST,Divider as vs,NoRouteIcon as CT,RefreshIcon as kT,Typography as $d}from"@rango-dev/ui";import Re from"react";import{i18n as Bd}from"@lingui/core";var gT=24,hT=60;function Ld(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:R().genericServerError,action:{onClick:n,title:Bd.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:R().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Bd.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(Ld,"makeInfo");var ks=(o=>(o[o.small=gT]="small",o[o.large=hT]="large",o))(ks||{}),Ts=(o=>(o.small="small",o.large="medium",o))(Ts||{});import{styled as Zr}from"@rango-dev/ui";var Md=Zr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Pd=Zr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),_d=Zr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Dd=Zr("div",{padding:"$6 $0"});function An(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Ld(o,r,()=>a(s,!0),e);return Re.createElement(Md,null,Re.createElement(CT,{size:ks[n],color:"gray"}),Re.createElement(vs,{size:4}),Re.createElement($d,{variant:"title",size:Ts[n]},R().noResultError.title),n==="large"&&Re.createElement(vs,{size:4}),!!l.description&&Re.createElement(Pd,{size:n},Re.createElement($d,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(vs,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(_d,{size:n},Re.createElement(yT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(ST,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement(Dd,null,Re.createElement(kT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(An,"NoResult");import{i18n as Nn}from"@lingui/core";import{Button as vT,Divider as wT,MessageBox as bT,Typography as xT,WarningIcon as ET}from"@rango-dev/ui";import $t from"react";import{Typography as zd}from"@rango-dev/ui";import bs from"react";import{darkTheme as TT,styled as Jr}from"@rango-dev/ui";var Fd=Jr("div",{width:"100%"}),ws=Jr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Od=Jr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${TT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ud=Jr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Qd(t){let{title:e,value:o,valueColor:n}=t;return bs.createElement(Od,null,bs.createElement(zd,{size:"medium",variant:"label",className:"_title"},e),bs.createElement(zd,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Qd,"QuoteErrorsModalItem");function Hd(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:Nn.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:Nn.t("Gas cost"),value:B(r.totalFee,2,2)},{title:Nn.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:Nn.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(Z,{footer:$t.createElement(vT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(ET,null),fullWidth:!0,disabled:a,onClick:n},R().highValueLossError.confirmMessage),open:e,onClose:o,container:I()},$t.createElement(bT,{type:s,title:R().highValueLossError.impactTitle,description:R().highValueLossError.description}),$t.createElement(ws,null,$t.createElement(wT,{size:"4"}),$t.createElement(xT,{size:"small",variant:"title"},Nn.t("Details")),$t.createElement(ws,null,l.map((c,p)=>$t.createElement(Qd,{key:p,...c})))))}i(Hd,"HighValueLossWarningModal");import{i18n as Rr}from"@lingui/core";function qd(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=Rr.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=Rr.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=Rr.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=Rr.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(qd,"makeAlerts");import{i18n as jo}from"@lingui/core";import{Button as Gd,Divider as Vd,MessageBox as IT,Typography as AT}from"@rango-dev/ui";import yo from"react";import{useNavigate as NT}from"react-router-dom";function Kd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=NT(),p=e??o;return yo.createElement(Z,{anchor:"bottom",open:n,prefix:yo.createElement(Gd,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+$.settings)},yo.createElement(AT,{variant:"label",size:"medium",color:"$neutral900"},jo.t("Change settings"))),container:I(),onClose:r},yo.createElement(IT,{type:"warning",title:s.type===3?jo.t("High slippage"):jo.t("Low slippage"),description:s.type===3?jo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:p}}):jo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},yo.createElement(Vd,{size:18}),yo.createElement(Vd,{size:32}),yo.createElement(Gd,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},jo.t("Confirm anyway"))))}i(Kd,"SlippageWarningModal");import{Button as WT,MessageBox as BT,WarningIcon as LT}from"@rango-dev/ui";import ei from"react";function jd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ei.createElement(Z,{footer:ei.createElement(WT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ei.createElement(LT,null),fullWidth:!0,disabled:r,onClick:n},R().unknownPriceError.confirmMessage),open:e,onClose:o,container:I()},ei.createElement(BT,{type:"warning",title:R().unknownPriceError.impactTitle,description:R().unknownPriceError.description}))}i(jd,"UnknownPriceWarningModal");function Wn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:p,onChangeSettings:u}=t,d={confirmationDisabled:a,open:r,onClose:c,onConfirm:p},h=o?.type===0||o?.type===1,f=qd(e,o?.type===3||o?.type===4?o:null);return f&&!n&&(f.action=null),et.createElement(et.Fragment,null,h&&et.createElement(An,{error:o,fetch:s}),!!f&&et.createElement(Fd,null,et.createElement(PT,{title:f.title,type:f.alertType,variant:"alarm",...f.action==="show-info"&&{action:et.createElement(Ud,{onClick:l},et.createElement(DT,{size:12,color:"gray"}))},...f.action==="change-settings"&&{action:et.createElement(_T,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:f.alertType,onClick:u},MT.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement(Hd,{...d,warning:e}),(e.type===3||e.type===2)&&et.createElement(Kd,{...d,warning:e}),e.type===1&&et.createElement(jd,{...d,warning:e})))}i(Wn,"QuoteWarningsAndErrors");import mv from"bignumber.js";import fi from"react";import{i18n as So}from"@lingui/core";import{Alert as ev,Divider as Yo,FullExpandedQuote as tv,InfoIcon as ov,NumericTooltip as Em,QuoteTag as nv,StepDetails as rv,TokenAmount as iv,Typography as Zo}from"@rango-dev/ui";import Ms from"bignumber.js";import F,{useRef as av,useState as sv}from"react";import{styled as xs}from"@rango-dev/ui";var Es=xs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Xd=xs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Yd=xs("div",{width:"100%",display:"flex"});import*as ti from"@radix-ui/react-collapsible";import{Button as $T,css as Bn,darkTheme as xe,Image as Zd,styled as ze,Typography as FT}from"@rango-dev/ui";var OT=300,Jd=ze(ti.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"}}]}),Rd=Bn({padding:"$10 $15"}),em=ze($T,{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"}}}),tm=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"}}}}]}),om=Bn({width:"100%",padding:"$15 $15 $10 $15"}),nm=Bn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Xo=Bn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),rm=Bn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),im=ze(ti.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:{[`& ${Zd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Zd}`]:{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"}}}),am=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"}}}}),sm=ze(Vr,{width:"100%",background:"inherit"}),Is=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${OT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),a1=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),lm=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),cm=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),As=ze(FT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),pm=ze("div",{display:"flex",flexWrap:"wrap"}),Ns=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"}}}}),um=ze("div",{display:"flex"}),oi=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 zT,CloseIcon as QT,Divider as ii,IconButton as HT,NumericTooltip as qT,QuoteCost as GT,Typography as yt}from"@rango-dev/ui";import Y,{useState as gm}from"react";import{css as UT,styled as ni}from"@rango-dev/ui";var ri=ni("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ws=ni("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),dm=ni("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),mm=ni("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),fm=UT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var VT=i(t=>t.fee.isZero()?null:Y.createElement(ri,null,Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Y.createElement(yt,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function Bs(t){let[e,o]=gm(!1),[n,r]=gm(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:h=!1}=t,f=s?.swaps??[],g=h?ro():I(),m=lu(f);return Y.createElement(Y.Fragment,null,Y.createElement(GT,{onClickFee:d?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:p,timeWarning:u,time:c,steps:a,tooltipGas:d?At.t("View more info"):void 0,tooltipContainer:g}),Y.createElement(Z,{container:g,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Y.createElement(mm,{style:{textAlign:h?"left":"center"}},Y.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Y.createElement(HT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Y.createElement(QT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Y.createElement(dm,null,Y.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Y.createElement(ii,{size:10}),Object.entries(m.payable).flatMap(([C,S])=>S.map((k,T)=>{let v=`payable-fee-${T}`,b=La(k);return Y.createElement(ri,{key:v},Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Ia(C,At.t)),Y.createElement(qT,{content:k.amount,container:g},Y.createElement(yt,{variant:"label",size:"medium"},B(k.amount,2,2)," ",k.asset.symbol," ($",B(b,4,4),")")))})),Y.createElement(ri,{className:"total_payable_fee"},Y.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Y.createElement(yt,{variant:"label",size:"medium"},"$",B(l,4,4))),Y.createElement(Ws,null),Object.keys(m.nonePayable).length&&Y.createElement(Xr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Y.createElement("div",{className:fm()},Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Y.createElement(ii,{size:4,direction:"horizontal"}),Y.createElement(Kr,{orientation:n?"up":"down"},Y.createElement(zT,{size:12,color:"gray"}))),open:n},Y.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Y.createElement(ii,{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(ii,{size:10}),Object.entries(m.nonePayable).map(([C,S],k)=>{let T=su(S),v=Ia(C,At.t),b=`non-payable-fee-${k}`;return Y.createElement(VT,{key:b,fee:T,label:v})}),Y.createElement(Ws,null)))))}i(Bs,"QuoteCostDetails");import{i18n as Sm}from"@lingui/core";import{TokenAmount as Cm}from"@rango-dev/ui";import ai from"react";import{css as KT,styled as jT}from"@rango-dev/ui";var hm=jT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),ym=KT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Ln(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ai.createElement(hm,null,ai.createElement(Cm,{direction:"horizontal",label:Sm.t("Swap input"),type:"input",tooltipContainer:I(),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}}),ai.createElement("div",{className:ym()}),ai.createElement(Cm,{direction:"horizontal",tooltipContainer:I(),label:Sm.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(Ln,"QuoteSummary");import{i18n as bm}from"@lingui/core";import{ChevronDownIcon as ZT,ChevronRightIcon as JT,Divider as Ls,Image as RT,Tooltip as ui,Typography as li}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as XT,useState as Mn}from"react";var km=480,Tm=768,vm=1024,wm=1200,YT=i(()=>{let[t,e]=Mn(!1),[o,n]=Mn(!1),[r,a]=Mn(!1),[s,l]=Mn(!1),[c,p]=Mn(!1),u=i(()=>{e(window.innerWidth<=km),n(window.innerWidth>km&&window.innerWidth<=Tm),a(window.innerWidth>Tm&&window.innerWidth<=vm),l(window.innerWidth>vm&&window.innerWidth<=wm),p(window.innerWidth>wm)},"handleResize");return XT(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),si=YT;var ci=4,pi=6,Pn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||I();return U.createElement(ui,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(am,{className:n,state:a},U.createElement(RT,{src:o,size:16})))},"ImageComponent");function xm(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||I(),p=r.length,u=Zp(r),{isTablet:d,isMobile:h}=si();return U.createElement(im,{listItem:s==="list-item",ref:f=>e.current=f,selected:o,onClick:f=>{f.stopPropagation(),n(g=>!g)}},U.createElement("div",{className:Xo()},U.createElement(li,{variant:"body",size:"xsmall"},bm.t("Via:")),U.createElement(Ls,{direction:"horizontal",size:4}),r.map((f,g)=>{let m=`item-${g}`,C=U.createElement(Is,null,U.createElement(JT,{size:12,color:"black"}));return h||d?U.createElement(U.Fragment,{key:m},U.createElement(Pn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),g!==p-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:m},p<=ci||p>ci&&g<ci-1?U.createElement(U.Fragment,null,U.createElement(Pn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),g!==p-1&&U.createElement(U.Fragment,null,C)):g===ci-1&&U.createElement(ui,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=g&&U.createElement(U.Fragment,{key:T},U.createElement(Pn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==p-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Ns,{state:r.find((S,k)=>k>=g&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(li,{size:"xsmall",variant:"body"},"+",p-g))))})),U.createElement("div",{className:Xo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Xo()},U.createElement(li,{variant:"body",size:"xsmall"},bm.t("Chains:")),U.createElement(Ls,{direction:"horizontal",size:4}),u.map((f,g)=>U.createElement(U.Fragment,{key:f.displayName},u.length<=pi||u.length>pi&&g<pi-1?U.createElement(ui,{container:c,side:"bottom",content:f.displayName,sideOffset:4},U.createElement(Pn,{content:"",src:f.image,open:!1,className:g!==0?"blockchainImage":""})):g===pi-1&&U.createElement(ui,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},u.map((m,C)=>C>=g&&U.createElement(Pn,{key:m.displayName,content:"",src:m.image,open:!1,className:C>g?"blockchainImage":"",container:l})))},U.createElement(Ns,{className:"blockchainImage"},U.createElement(li,{size:"xsmall",variant:"body"},"+",u.length-g))))),U.createElement(Ls,{direction:"horizontal",size:32}))),U.createElement(Is,{orientation:a?"up":"down"},U.createElement(ZT,{size:12,color:"black"}))))}i(xm,"QuoteTrigger");function Ps(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:c=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:d=!1,container:h}=t,f=y().blockchains(),{findToken:g}=y(),m=y().swappers(),{customSlippage:C,slippage:S}=y(),k=C||S,[T,v]=sv(t.expanded),b=av(null),A=B(o.value,6,6),D=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",x=Pt(o.usdValue,n.usdValue??null),E=B(x,2,2),N=_t(x??0),L=i((le,at)=>le.map((G,P)=>{let q,V=r?.type===3&&r.swap.swapperId===G.swapperId,ge=r?.type===4&&r.recommendedSlippages?.has(P),ne=a?.type===2&&a.recommendedSlippages?.has(P),he=V||ge,Fe=ne;he?q="error":Fe&&(q="warning");let ve=he?So.t("Slippage Error"):So.t("Slippage Warning");return V&&(ve=So.t("Bridge Limit Error")),{swapper:{displayName:rn(G.swapperId,m)??"",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:P===0&&!at?B(o.value,6,6):B(G.fromAmount,6,6),usdValue:B((G.from.usdPrice??0)*parseFloat(G.fromAmount),4,4),realValue:P===0?o.value:G.fromAmount,realUsdValue:new Ms(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:B(G.toAmount,6,6),usdValue:B((G.to.usdPrice??0)*parseFloat(G.toAmount),4,4),realValue:G.toAmount,realUsdValue:new Ms(G.to.usdPrice??0).multipliedBy(G.toAmount).toString()}},state:q,alerts:he||Fe?F.createElement(Xd,{dense:d},F.createElement(ev,{variant:"alarm",type:he?"error":"warning",title:ve,footer:F.createElement(Yd,null,V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {amount} {symbol}",values:{amount:B(G.fromAmount,6,6),symbol:G?.from.symbol}}))),(ge||ne)&&!V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(P)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(P)}}})),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:ln(G.estimatedTimeInSeconds),fee:B(Ba(G,g),2,2),internalSwaps:G.internalSwaps?L(G.internalSwaps):void 0}}),"getQuoteSteps"),W=L(e?.swaps??[]),j=W.length,te=h||I(),J=Rp(t.quote.tags||[]),M=!!u,X=mr(e?.swaps),se=ln(X),z=Mr(e?.swaps??[],g),me=B(z,2,2),vt=z.gte(new Ms(Hp)),Ze=X/Gp>=qp;return d?F.createElement(tv,{selected:l,fee:me,time:se,tooltipContainer:ro(),steps:W,tags:J,quoteCost:F.createElement(Bs,{quote:e,fullExpandedMode:!0,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:j}),percentageChange:E,warningLevel:N,outputPrice:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(tm,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:om()},!c&&J.length?F.createElement(F.Fragment,null,F.createElement(um,null,J.map((le,at)=>{let G=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:G},F.createElement(nv,{label:le.label,value:le.value}),F.createElement(Yo,{size:4,direction:"horizontal"}))})),F.createElement(oi,null),!M&&F.createElement(Yo,{size:4})):null,F.createElement("div",{id:"portal-root",className:nm()},F.createElement(Bs,{quote:e,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:j}),M&&F.createElement(em,{onClick:le=>{le.stopPropagation(),u()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Zo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},So.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:rm()},F.createElement(cm,null,F.createElement(ov,{size:12,color:"gray"})),F.createElement(pm,null,F.createElement(As,{size:"small",variant:"body"},`${A} ${W[0].from.token.displayName} = `),F.createElement(Em,{content:n.value,container:te,open:n.value?void 0:!1},F.createElement(As,{size:"small",variant:"body"},"\xA0",`${D} ${W[W.length-1].to.token.displayName}`))),F.createElement(Em,{content:n.usdValue,container:te},F.createElement(Yo,{size:2,direction:"horizontal"}),F.createElement(Zo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(iv,{tooltipContainer:te,type:"output",direction:"vertical",price:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:W[j-1].to.token.displayName,image:W[j-1].to.token.image},chain:{image:W[j-1].to.chain.image},percentageChange:E,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Ln,{from:W[0].from,to:W[j-1].to,percentageChange:E,warningLevel:N}),F.createElement(Yo,{size:4}))),F.createElement(Jd,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(xm,{type:s,quoteRef:b,selected:l,setExpanded:v,container:te,expanded:T,steps:W}),F.createElement(sm,{open:T},F.createElement(lm,null),F.createElement("div",{className:Rd()},W.map((le,at)=>{let G=`item-${at}`;return F.createElement(rv,{type:"quote-details",key:G,tooltipContainer:te,step:le,hasSeparator:at!==W.length-1,state:le.state})})))))}i(Ps,"Quote");import{Divider as uv,Skeleton as dv}from"@rango-dev/ui";import Ot from"react";import{darkTheme as lv,styled as di}from"@rango-dev/ui";var Im=di("div",{$$color:"$colors$neutral100",[`.${lv} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Am=di("div",{paddingTop:"$2"}),Nm=di("div",{paddingLeft:"$8"}),Wm=di("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Um,Divider as St,Skeleton as tt}from"@rango-dev/ui";import Q from"react";import{css as cv,styled as Ft}from"@rango-dev/ui";var _s=Ft("div",{display:"flex"}),Bm=Ft("div",{padding:"$10 $0 $20"}),Lm=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Mm=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Pm=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),_m=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Dm=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),$m=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Fm=Ft("div",{padding:"$15 $0 $15 $0"}),Om=cv({display:"flex",justifyContent:"space-between",alignItems:"center"});function _n(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(Pm,null,Q.createElement(Dm,null,Q.createElement(Um,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{size:8,direction:"horizontal"}),Q.createElement($m,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(_s,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(oi,null),!r&&Q.createElement(St,{size:4})),Q.createElement("div",{className:Om()},Q.createElement(_s,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(Bm,null,Q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(Lm,null,Q.createElement(Mm,null,Q.createElement(Um,{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(Fm,null,n,Q.createElement(_m,null),n),Q.createElement(St,{size:12})))}i(_n,"QuoteSummarySkeleton");import{ChainToken as Gm,Divider as $s,NextIcon as pv,Skeleton as mi}from"@rango-dev/ui";import Ee from"react";import{styled as Dn}from"@rango-dev/ui";var zm=Dn("div",{display:"flex",alignItems:"start"}),Qm=Dn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Ds=Dn("div",{display:"flex",alignItems:"center",flexGrow:1}),Hm=Dn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),qm=Dn("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(qm,null,Ee.createElement(mi,{height:22,width:22,variant:"circular"}),Ee.createElement($s,{direction:"horizontal",size:8}),Ee.createElement(mi,{height:15,width:148,variant:"rounded"})),Ee.createElement(zm,null,Ee.createElement(Wm,{hideSeparator:!e}),Ee.createElement(Qm,{extraSpace:e},Ee.createElement(Ds,null,Ee.createElement(Gm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement($s,{direction:"horizontal",size:8}),Ee.createElement(mi,{height:12,variant:"rounded"})),Ee.createElement(Hm,null,Ee.createElement(pv,{color:"gray",size:16})),Ee.createElement(Ds,null,Ee.createElement(Gm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement($s,{direction:"horizontal",size:8}),Ee.createElement(mi,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function $n(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Im,{expanded:o,rounded:e!=="basic"},Ot.createElement(_n,{type:e,tagHidden:n}),Ot.createElement(Am,null,Ot.createElement(dv,{height:15,variant:"rounded"})),o&&Ot.createElement(Nm,null,Ot.createElement(uv,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i($n,"QuoteSkeleton");function Co(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:p,selected:u,onClickAllRoutes:d,fullExpandedMode:h=!1,container:f}=t,{inputAmount:g,inputUsdValue:m}=O(),C=e?.outputAmount?new mv(e?.outputAmount):null,S=e?ct(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?fi.createElement(Es,null,fi.createElement($n,{tagHidden:l,type:o,expanded:s})):T?fi.createElement(Es,{onClick:()=>c?.(e)},fi.createElement(Ps,{quote:e,error:r,container:f,showModalFee:p,warning:a,tagHidden:l,selected:u,type:o,expanded:s,onClickAllRoutes:d,fullExpandedMode:h,input:{value:g,usdValue:m?.toString()??""},output:{value:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(Co,"QuoteInfo");import{calculatePendingSwap as yv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Sv}from"react";import{useRef as fv,useState as gv}from"react";var hv=2e3;function gi({request:t}){let[e,o]=gv(!1),n=fv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,hv)),await s(l,!1)),"retryFetch"),s=i(async(l,c=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(l,{signal:n.current.signal});return n.current=null,p}catch(p){if(c)return await a(l);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(gi,"useFetch");function Vm(){let{fetch:t,loading:e,cancelFetch:o}=gi({request:async(n,r)=>await xt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Vm,"useFetchConfirmQuote");function hi(t){if(!t.swaps)throw new Error(R().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Fs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(hi,"throwErrorIfResponseIsNotValid");function Fs(t){if(ru(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=iu(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=cu(t);if(o){let n=Pr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Fs,"getQuoteError");function Km(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Fo({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let p=du(e,r,n.blockchains);return p.length===0||(l.balance={messages:p}),l}i(Km,"generateWarnings");function yi(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(yi,"handleQuoteErrors");function Os(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:c,customSlippage:p}=y(),u=y().getDisabledLiquiditySources(),d=y().blockchains(),h=y().tokens(),{findToken:f}=y(),g=p||c,{fetch:m,cancelFetch:C,loading:S}=Vm();return Sv(()=>C,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,b=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((w,x)=>(w[x.chain]=x.address,w),{}),D={requestId:a?.requestId||"",selectedWallets:A,destination:b||void 0};try{return await m(D,!0).then(w=>{let{result:x}=w;if(!x)throw new Error("Error fetching updated route");hi({diagnosisMessages:x.diagnosisMessages,requestId:x.requestId,swaps:x.result?.swaps});let E={outputAmount:x.result?.outputAmount,requestId:x.requestId,resultType:x.result?.resultType,swaps:x.result?.swaps||[],validationStatus:x.validationStatus,requestAmount:x.requestAmount};r(E);let N={slippage:g.toString(),disabledSwappersGroups:u},L=Km({previousQuote:a??void 0,currentQuote:E,meta:{blockchains:d},selectedWallets:v,userSlippage:g,inputUsdValue:n,findToken:f});l();let W=!!L.balance,j=yv(o.toString(),x,uu(v),N,!W,{blockchains:d,tokens:h});return{quote:E,swap:j,error:null,warnings:L}})}catch(w){return yi(w)}},"fetch"),cancelFetch:C}}i(Os,"useConfirmSwap");var Av=vv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${jm}`]:{width:"$48",height:"$48"}}),Nv=Qs({flexGrow:1,paddingRight:"$10"}),Wv=Qs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Bv=Qs({display:"flex",justifyContent:"space-between",alignItems:"center"});function Xm(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=Iv(),[l,c]=Fn(""),p=!n,[u,d]=Fn(!1),[h,f]=Fn(!1),{isActiveTab:g}=re(),m=y().getDisabledLiquiditySources(),C=Ev(m),{manager:S}=Cv(),{fetch:k,loading:T,cancelFetch:v}=Os(),[b,A]=Fn({swap:null,error:null,warnings:null}),[D,w]=Fn(!1),x=i(async({selectedWallets:M,customDestination:X})=>{let se=await k?.({selectedWallets:M,customDestination:X});return A(se),se},"onConfirmSwap"),E=i(async()=>{if(b.swap&&n)try{await S?.create("swap",{swapDetails:b.swap},{id:b.swap.requestId});let M=`../${$.swaps}/${b.swap.requestId}`;s(M,{replace:!0}),setTimeout(()=>{e("")},0)}catch(M){c("Error: "+M?.message)}},"addNewSwap"),N=i(async()=>{f(!0),await E(),f(!1)},"onConfirm"),L=i(async()=>{b.warnings?.quote&&Yp(b.warnings.quote)&&!a?w(!0):await N()},"onStartConfirmSwap"),W=i(async()=>{A({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(M=>{A(M)}).catch(M=>console.error(M))},"onRefresh");Si(()=>{!!C.current.length&&!m.length&&W(),C.current=m},[m.length]),Si(()=>{p&&v()},[p]),Si(()=>{p&&d(p)},[p]),Si(()=>{p||k({selectedWallets:o,customDestination:r}).then(M=>A(M)).catch(M=>console.error(M))},[]),xv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let j=b.warnings?.quote??null,te=b.error,J=[];if(l&&J.push(Me.createElement(kv,{type:"error",variant:"alarm",title:l})),j||te){let M=`../${$.settings}`;J.push(Me.createElement(Wn,{warning:j,error:te,couldChangeSettings:!1,refetchQuote:W,showWarningModal:D,confirmationDisabled:!g,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await E()},onChangeSettings:()=>s(M)}))}return Me.createElement(oe,{header:{title:Us.t("Confirm Swap"),onWallet:()=>{let M=`../${$.wallets}`;s(M)}},footer:Me.createElement(Av,null,Me.createElement("div",{className:Nv()},Me.createElement(Tv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!b.error||!g,onClick:L},Us.t("Start Swap"))),Me.createElement(jm,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!g,onClick:d.bind(null,!0)},Me.createElement(bv,{size:24})))},u&&Me.createElement(Wd,{open:u,onClose:()=>d(!1),onCancel:v,loading:T,onCheckBalance:x}),Me.createElement(ie,null,Me.createElement("div",{className:Bv()},Me.createElement(wv,{variant:"title",size:"small"},Us.t("You get")),Me.createElement("div",{className:Wv()},Me.createElement(Ur,{onClick:!T&&!u&&!D?W:void 0}))),Me.createElement(zs,{size:"12"}),Bu(J.map((M,X)=>({element:M,key:`alert-${X}`})),Me.createElement(zs,{size:10})),J.length>0?Me.createElement(zs,{size:10}):null,Me.createElement(Co,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:b.error,loading:T,warning:b.warnings?.quote??null})))}i(Xm,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Rs,CustomTokensZeroStateDarkIcon as Kv,CustomTokensZeroStateIcon as jv,DeleteIcon as Xv,Divider as Qn,IconButton as Yv,MessageBox as Zv,NotFound as Jv,styled as tl}from"@rango-dev/ui";import de,{useState as el}from"react";import{useNavigate as Rv}from"react-router-dom";import{CloseIcon as Mv,IconButton as Pv,SearchIcon as _v,TextField as Dv}from"@rango-dev/ui";import On from"react";import{styled as Lv}from"@rango-dev/ui";var Ym=Lv("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:c,...p}=t;return On.createElement(Dv,{prefix:On.createElement(Ym,null,On.createElement(_v,{color:"black"})),suffix:!!s.length&&On.createElement(Pv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},On.createElement(Mv,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...p})}i(Ct,"SearchInput");import{i18n as Js}from"@lingui/core";import{darkTheme as lf,Divider as Ro,ExternalLinkIcon as Ov,Image as Uv,ListItemButton as zv,NotFound as Qv,PinIcon as Hv,Skeleton as cf,Typography as Ti,VirtualizedList as qv}from"@rango-dev/ui";import H from"react";import{Divider as af,ListItem as Fv,Skeleton as Un}from"@rango-dev/ui";import kt from"react";import{css as Jo,darkTheme as Zm,ImageContainer as $v,styled as ut,Typography as Jm}from"@rango-dev/ui";var Hs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),qs=Jo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Gs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Vs=Jo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Zm} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Ks=Jo({}),js=Jo(),Rm=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Xs=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ci=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${qs}`]:{[`& .${Vs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Ks}`]:{bottom:"-15px"},[`& .${Hs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Gs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Ys=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Zs=ut(Jm,{}),ef=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${js}`]:{$$color:"$colors$neutral600",[`.${Zm} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ki=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),ez=ut("div",{display:"flex",alignItems:"center"}),tf=ut("div",{position:"relative",[`& ${$v}`]:{borderRadius:"$xm",overflow:"hidden"}}),of=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),nf=ut(Jm,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),rf=ut("a",{"& svg:hover":{color:"$colors$info"}});function sf(t){return kt.createElement(Ci,null,Array.from(Array(t.size),e=>kt.createElement(Fv,{key:e,hasDivider:!0,start:kt.createElement(Un,{variant:"circular",width:35,height:35}),end:kt.createElement(ki,null,kt.createElement(Un,{variant:"text",size:"large",width:70}),kt.createElement(af,{size:4}),kt.createElement(Un,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Un,{variant:"text",size:"large",width:90}),kt.createElement(af,{size:4}),kt.createElement(Un,{variant:"text",size:"medium",width:90}))})))}i(sf,"LoadingTokenList");var Gv=20,Vv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:qs()},o?H.createElement("div",{className:Hs()},o):H.createElement(Xs,{className:Gs()},H.createElement(Ti,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Ys,{css:a},H.createElement(Zs,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Vs()} ${!o&&Ks()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Ro,{size:4,direction:"horizontal"}),H.createElement(rf,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},H.createElement(Ov,{size:12}))))},"renderDesc");function zn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,c=y().blockchains(),{getBalanceFor:p,fetchingWallets:u}=y(),{isTokenPinned:d}=y(),h=i(g=>{let m=yr(p(g));return s?s(g):u?H.createElement(ki,null,H.createElement(cf,{variant:"text",size:"large",width:70}),H.createElement(Ro,{size:4}),H.createElement(cf,{variant:"text",size:"medium",width:50})):m&&H.createElement(ef,null,H.createElement(nf,{variant:"title",size:"small"},m.amount),H.createElement("div",null),m.usdValue&&H.createElement(Ti,{variant:"body",className:js(),size:"xsmall"},`$${m.usdValue}`))},"endRenderer"),f=i(()=>H.createElement(qv,{itemContent:g=>{let m=e[g],C=m.address||"",S=c.find(b=>b.name===m.blockchain),k=Ga(S.color,"main"),T={$$color:k.main150,[`.${lf} &`]:{$$color:k.main750},backgroundColor:"$$color"},v={$$color:k.main750,[`.${lf} &`]:{$$color:k.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(zv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":g,key:`${m.symbol}${m.address}`,id:`${m.symbol}${m.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[g]),start:H.createElement(tf,null,H.createElement(Uv,{src:m.image,size:30}),t.type!=="custom-token"&&d(m,t.type)&&H.createElement(of,null,H.createElement(Hv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||m.name||!m.name&&!C?H.createElement(Xs,null,H.createElement(Ti,{variant:"title",size:"xmedium"},m.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Ys,{css:T},H.createElement(Zs,{variant:"body",size:"xsmall",css:v},m.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?Vv({address:C,token:e[g],customCssForTag:T,customCssForTagTitle:v,name:m.name,url:S.info.addressUrl.split("{wallet}").join(C)}):m.name||void 0,end:h(m)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(Ti,{variant:"label",size:"large"},Js.t("Select Token")),H.createElement(Ro,{size:4})),H.createElement(Rm,null,H.createElement(Ro,{size:4}),l==="loading"&&H.createElement(sf,{size:Gv}),l==="success"&&(e.length?H.createElement(Ci,{as:"ul"},f()):!!o&&H.createElement(Qv,{title:Js.t("No results found"),description:Js.t("Try using different keywords")}))))}i(zn,"TokenList");var ew=tl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),tw=tl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),ow=tl(Yv,{"&:hover":{"& svg":{color:"$secondary550"}}});function pf(){let[t,e]=el(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=Qo({}),p=Rv(),[u,d]=el(!1),[h,f]=el(),g=i(k=>{let T=k.target.value;e(T)},"handleSearch"),m=c==="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)}d(!1)},"handleDeleteCustomToken");return de.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},de.createElement(ie,null,de.createElement(ew,null,n.length?de.createElement(de.Fragment,null,de.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:g}),de.createElement(Qn,{size:16}),de.createElement(zn,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>de.createElement(ow,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),f(k)}},de.createElement(Xv,{size:12,color:"gray"}))})):de.createElement(tw,null,de.createElement(Jv,{icon:m?de.createElement(Kv,{size:200}):de.createElement(jv,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),de.createElement(Qn,{size:20}),de.createElement(Rs,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},Ut.t("Add Custom Token"))),de.createElement(Z,{open:u,dismissible:!0,onClose:()=>d(!1),container:I()},de.createElement(Zv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},de.createElement(Qn,{size:40}),de.createElement(Qn,{size:10}),de.createElement(Rs,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),de.createElement(Qn,{size:12}),de.createElement(Rs,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},Ut.t("No, Continue"))))))}i(pf,"CustomTokensPage");import{i18n as He}from"@lingui/core";import{useManager as Tw}from"@rango-dev/queue-manager-react";import{Button as ll,darkTheme as vw,Divider as To,MessageBox as ww,NotFound as bw,styled as cl,Typography as bi}from"@rango-dev/ui";import{TransactionStatus as Gn}from"rango-types";import ae,{useMemo as Nf,useState as xi}from"react";import{useNavigate as xw}from"react-router-dom";import{FilterIcon as cw,Popover as pw}from"@rango-dev/ui";import ko from"react";import{css as nw,darkTheme as vi,IconButton as rw,styled as Hn}from"@rango-dev/ui";var ol=Hn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${vi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),uf=Hn(rw,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${vi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${vi} &`]:{backgroundColor:"$neutral"},[`& ${ol}::before`]:{backgroundColor:"$secondary100",[`.${vi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),df=Hn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),mf=Hn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),ff=nw({display:"flex",justifyContent:"space-between",alignItems:"center"}),gf=Hn("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 iw,Divider as yf,ListItemButton as aw,Radio as sw,RadioRoot as lw,Typography as Sf}from"@rango-dev/ui";import ot from"react";function Cf(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(mf,null,ot.createElement("div",{className:ff()},ot.createElement(Sf,{size:"small",variant:"body"},hf.t("Status")),ot.createElement(iw,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},hf.t("Reset"))),ot.createElement(yf,{size:10}),ot.createElement(lw,{value:e},ot.createElement(gf,null,t.list.map((n,r)=>ot.createElement(aw,{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(yf,{direction:"horizontal",size:4}),ot.createElement(Sf,{size:"medium",variant:"body"},n.title)),start:ot.createElement(sw,{value:n.id}),onClick:o})))))}i(Cf,"FilterSelectorContent");function nl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return ko.createElement("div",null,ko.createElement(pw,{open:a,align:"end",onOpenChange:o,container:I(),content:ko.createElement(Cf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},ko.createElement(uf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},ko.createElement(ol,{isSelect:!!n},ko.createElement(cw,{size:16,color:"black"}),!!n&&ko.createElement(df,null)))))}i(nl,"FilterSelector");import{i18n as mw}from"@lingui/core";import{Divider as bf,GroupedVirtualizedList as fw,Skeleton as gw,SwapListItem as xf,Typography as hw}from"@rango-dev/ui";import Qe,{useCallback as Ef,useEffect as yw,useRef as Sw,useState as Cw}from"react";function kf(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(kf,"calculateGroupsSoFar");import{css as uw,darkTheme as dw,styled as qn}from"@rango-dev/ui";var rl=uw(),Tf=qn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),il=qn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${rl}`]:{$$color:"$colors$neutral600",[`.${dw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),al=qn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),vf=qn("div",{gap:"$10",display:"flex",flexDirection:"column"}),wf=qn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var kw=10;function sl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Cw([]),l=Sw(0),{swaps:c,groupCounts:p,groups:u}=n(e),d=Ef(kf,[]),h=Ef(()=>{let f=e.length-l.current;f&&(l.current+=Math.min(f,kw),s(d(p,l.current)))},[e.length]);if(yw(()=>{r||h()},[r,h]),r){let f=[1,2];return Qe.createElement(Qe.Fragment,null,[f,f].map((m,C)=>Qe.createElement(il,{key:C},Qe.createElement(al,null,Qe.createElement(gw,{variant:"text",width:60,size:"small"}),Qe.createElement(bf,{size:16})),Qe.createElement(bf,{size:4}),Qe.createElement(vf,null,m.map((k,T)=>Qe.createElement(xf,{isLoading:!0,key:T}))))))}return Qe.createElement(fw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:f=>Qe.createElement(il,null,Qe.createElement(al,null,Qe.createElement(hw,{variant:"label",size:"medium",className:rl()},u[f]))),itemContent:(f,g)=>{let m=c[f];if(!m)return null;let C=m.steps[0],S=m.steps[m.steps.length-1];return Qe.createElement(Tf,{key:m.requestId},Qe.createElement(xf,{requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,tooltipContainer:I(),onlyShowTime:u[g]===mw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:B(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:B(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(sl,"HistoryGroupedList");import{i18n as wi}from"@lingui/core";import If from"dayjs";var Af=i(t=>{let e=new Map([["today",{title:wi.t("Today"),swaps:[]}],["week",{title:wi.t("This week"),swaps:[]}],["month",{title:wi.t("This month"),swaps:[]}],["year",{title:wi.t("This year"),swaps:[]}]]);function o(c,p){e.has(c)||e.set(c,{title:c,swaps:[]}),e.get(c)?.swaps.push(p)}i(o,"addYearsToOutput");let n=If();t.forEach(c=>{let p=Number(c.creationTime),u=If(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(c);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(c);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(c);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(c);else{let d=new Date(p).getFullYear().toString();o(d,c)}});let r=Array.from(e.values()).filter(c=>c.swaps.length>0),a=r.flatMap(c=>c.swaps),s=r.map(c=>c.swaps.length),l=r.map(c=>c.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Ew=cl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),Iw=cl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Aw=cl("div",{"._typography":{color:"$neutral700",[`.${vw}&`]:{color:"$neutral900"}}}),Nw=[{id:Gn.SUCCESS,title:He.t("Complete")},{id:Gn.RUNNING,title:He.t("Running")},{id:Gn.FAILED,title:He.t("Failed")}],Ww=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=xw(),{manager:e,state:o}=Tw(),n=pt(e).map(({swap:T})=>T),[r,a]=xi(""),[s,l]=xi(!1),c=!o.loadedFromPersistor,[p,u]=xi(""),[d,h]=xi(!1),f=i(T=>{let v=T.target.value;a(v)},"handleSearch"),g=Nf(()=>!r&&!p?n:n.filter(T=>{let{inputAmount:v,status:b,steps:A,requestId:D}=T;return(!r||wt(v,r)||wt(b,r)||Ww(A,r)||wt(D,r))&&(!p||p===b)}),[n,r,p]),m=!g?.length&&!c,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),k=Nf(()=>!n.some(T=>T.status===Gn.SUCCESS||T.status===Gn.FAILED),[n]);return ae.createElement(oe,{header:{title:He.t("History"),suffix:ae.createElement(Vt,null,ae.createElement(ll,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(bi,{size:"medium",variant:"label",color:"error"},He.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(Iw,null,ae.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:He.t("Search Transaction"),autoFocus:!0,onChange:f,style:{height:36},value:r}),ae.createElement(To,{size:10,direction:"horizontal"}),ae.createElement(nl,{filterBy:p,open:s,onOpenChange:T=>l(T),onClickItem:T=>u(T),list:Nw})),ae.createElement(To,{size:"16"}),ae.createElement(Ew,null,m&&ae.createElement(wf,null,ae.createElement(To,{size:32}),ae.createElement(bw,{title:r?He.t("No results found"):He.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?He.t("Try using different keywords"):He.t("Your transaction history is stored locally and will appear here after you start a swap")})),!m&&ae.createElement(sl,{list:g,onSwapClick:t,groupBy:Af,isLoading:c}))),ae.createElement(Z,{open:d,onClose:C,container:I()},ae.createElement(To,{size:20}),ae.createElement(ww,{type:"warning",title:He.t("Clear Transaction History"),description:ae.createElement(Aw,null,ae.createElement(bi,{variant:"body",size:"medium"},He.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(To,{size:"24"}),ae.createElement(bi,{variant:"body",size:"small"},He.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(To,{size:30}),ae.createElement(ll,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},He.t("Yes, Clear the history")),ae.createElement(To,{size:10}),ae.createElement(ll,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(bi,{variant:"title",size:"medium",color:"primary"},He.t("No, Cancel")))))}i(Wf,"HistoryPage");import{i18n as eb}from"@lingui/core";import{Button as tb,Divider as Zf,styled as ob,WarningIcon as nb}from"@rango-dev/ui";import rb from"bignumber.js";import qe,{useEffect as Jf,useState as Rf}from"react";import{useNavigate as ib}from"react-router-dom";import{i18n as Lf}from"@lingui/core";import{Alert as Lw,Divider as pl,NoRouteIcon as Mw,Typography as Pw}from"@rango-dev/ui";import vo from"react";import{styled as Bw}from"@rango-dev/ui";var Bf=Bw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function ul(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Lt(t,e)?vo.createElement(Bf,null,vo.createElement(pl,{size:10}),vo.createElement(Mw,{size:24,color:"gray"}),vo.createElement(pl,{size:4}),vo.createElement(Pw,{variant:"title",size:"small"},Lf.t("No Routes Found")),vo.createElement(pl,{size:4}),vo.createElement(Lw,{title:Lf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(ul,"SameTokensWarning");import{i18n as Uw}from"@lingui/core";import{Header as zw}from"@rango-dev/ui";import Jt,{useEffect as Qw,useState as Hw}from"react";import{i18n as Dw}from"@lingui/core";import{Divider as ml,FullExpandedQuote as $w,Typography as Fw}from"@rango-dev/ui";import Ce from"react";import{styled as dl}from"@rango-dev/ui";var Mf=dl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Pf=dl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),_f=dl("div",{width:"146px"});import{i18n as Vn}from"@lingui/core";import{Select as _w}from"@rango-dev/ui";import Df from"react";function Ei(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:Vn.t("Smart Routing")},{value:"FEE",label:Vn.t("Lowest Fee")},{value:"SPEED",label:Vn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Vn.t("Maximum Return")},{value:"PRICE",label:Vn.t("Maximum Output")}];return Df.createElement(_f,null,Df.createElement(_w,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ei,"SelectStrategy");var $f=3;function Kn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:c,quotes:p,updateQuotePartialState:u,fromToken:d,toToken:h,sortStrategy:f,error:g}=O(),{slippage:m,customSlippage:C}=y(),{findToken:S}=y(),k=l||I(),T=!!p&&p.results.length,v=C??m,b=i(w=>{if(!d||!h||!p)return null;let x={requestAmount:p.requestAmount,validationStatus:null,...w};return Fo({currentQuote:x,userSlippage:v,findToken:S})},"getQuoteWarning"),A=g?.type===0||g?.type===1,D=p?.results?Lr(f,p?.results):[];return Ce.createElement(Ce.Fragment,null,a&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Pf,null,Ce.createElement(Fw,{size:"xmedium",variant:"title"},Dw.t("Sort by")),Ce.createElement(Ei,{container:k})),Ce.createElement(ml,{size:"10"})),e&&Array.from({length:$f},(w,x)=>Ce.createElement(Ce.Fragment,{key:x},s?Ce.createElement($w,{loading:!0}):Ce.createElement($n,{tagHidden:!1,type:"list-item",expanded:!1}),x!==$f-1&&Ce.createElement(ml,{size:16}))),!e&&Ce.createElement(Ce.Fragment,null,T?D.map((w,x)=>{let E=b(w),N=Fs(w.swaps),L=D.length-1===x;return Ce.createElement(Ce.Fragment,{key:w.requestId},Ce.createElement(Co,{showModalFee:r,container:k,selected:c?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:N?.options||null,warning:E,fullExpandedMode:s,onClick:W=>{N||u("warning",E),u("error",N?.options||null),o(W)},type:"list-item"}),!L&&Ce.createElement(ml,{size:16}))}):A&&Ce.createElement(Mf,null,Ce.createElement(An,{size:s?"large":"small",error:g,fetch:n}))))}i(Kn,"Quotes");import{darkTheme as Ow,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",[`.${Ow} &`]:{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 qw=100;function fl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Hw(!1),c=s?"":"is-hidden",{config:p}=y(),u=p?.variant==="full-expanded",d=ro();return Qw(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},qw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Of,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${c} ${Hr()}`,id:De.EXPANDED_BOX_ID},Jt.createElement(zw,{title:Uw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(Ei,{container:d}),Jt.createElement(go,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(Uf,null,Jt.createElement(Kn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:ro(),onClickOnQuote:n,fullExpandedMode:u})))}i(fl,"ExpandedQuotes");import{i18n as Kf}from"@lingui/core";import{SwapInput as jf}from"@rango-dev/ui";import jw from"bignumber.js";import jn from"react";import{ReverseIcon as Kw}from"@rango-dev/ui";import hl from"react";import{keyframes as Gw,styled as zf}from"@rango-dev/ui";var gl=450,Vw=Gw({"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"}),Hf=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:`${Vw} ${gl}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 yl(){let t=O.use.switchFromAndTo();return hl.createElement(Qf,null,hl.createElement(Hf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},gl),t()}},hl.createElement(Kw,{size:12})))}i(yl,"SwitchFromAndToButton");import{styled as qf}from"@rango-dev/ui";var Gf=qf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Vf=qf("div",{position:"relative"});function Sl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:p,inputAmount:u,inputUsdValue:d,outputAmount:h,outputUsdValue:f,selectedQuote:g}=O(),{connectedWallets:m,getBalanceFor:C}=y(),S=a?C(a):null,k=yr(S)?.amount??"0",T=S?new jw(S.amount).shiftedBy(-S.decimals):ce,v=!!s&&zc(m,s.name),b=!Wa(g,u,d),A=!Wa(g,u,f),D=!d||!f||!f.gt(0)?null:Pt(d.toString(),f.toString());return jn.createElement(Gf,null,jn.createElement(Vf,null,jn.createElement(jf,{label:Kf.t("From"),mode:"From",onInputChange:p,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:u,usdValue:b?void 0:B(d,4,4),realUsdValue:b?void 0:d?.toString(),error:b?R().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:I(),onSelectMaxBalance:()=>{let w=B(T,S?.decimals),x=S?.amount?w.split(",").join(""):"";p(x)},anyWalletConnected:m.length>0}),jn.createElement(yl,null)),jn.createElement(jf,{sharpBottomStyle:!r&&(!!g||e),label:Kf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(Pt(d,f),2,2),warningLevel:_t(D??0),price:{value:B(h,6,6),usdValue:A?void 0:B(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:I()}))}i(Sl,"Inputs");import{useCallback as Xw,useEffect as Yw,useRef as Zw,useState as Jw}from"react";function Xf(){let{fetch:t,loading:e,cancelFetch:o}=gi({request:async(n,r)=>await xt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Xf,"useFetchAllQuotes");var Rw=600;function Ii({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Xf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:c,inputUsdValue:p,selectedQuote:u,sortStrategy:d,resetQuote:h,error:f,warning:g,setSelectedQuote:m,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:b,fetchStatus:A}=y(),D=y().getLiquiditySources(),w=y().getDisabledLiquiditySources(),x=y().excludeLiquiditySources(),{findToken:E}=y(),[N,L]=Jw(!0),W=Zw(c),j=k??S,J=!s||!l||Lt(s,l)||!cn(c),M=i(z=>{L(z)},"resetState"),X=i(z=>{let{fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:ge}=z;if(N||M(!0),!J&&me&&vt){h();let ne=pu({fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,wallets:a,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:ge});Wo("experimental",r)&&(ne.experimental=!0),Wo("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),Wo("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(he=>{let Fe=Lr(d,he.results),ve=Jp(u,Fe,he.requestAmount);L(!1),C("quotes",he),m(ve),hi({diagnosisMessages:he.diagnosisMessages,requestId:ve?.requestId||"",swaps:ve?.swaps});let mt=ve&&Fo({currentQuote:ve,userSlippage:j,findToken:E});C("warning",mt)}).catch(he=>{let{error:Fe}=yi(he);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),L(!1))})}},"fetch"),se=Xw(Nc(z=>{X(z)},Rw),[J]);return Yw(()=>{if(!t){L(!1);return}if(A!=="success")return;if(J){L(!1),(u||f||g)&&h();return}if(!cn(c)||p?.eq(0)){M(!1),o();return}h(),M(!0);let z=X;return W.current&&W.current!=c&&(z=se),W.current=c,z({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:j,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),o},[A,c,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,D?.length,n,w.length,j,v,T,JSON.stringify(b)]),{fetch:()=>X({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:j,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),loading:N}}i(Ii,"useSwapInput");function Yf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ye.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Yf,"emitPreventableEvent");var ab=ob("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),sb=300;function eg(){let t=ib(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:h}=O(),[f,g]=Rf(!1),{isLargeScreen:m,isExtraLargeScreen:C}=si(),{fetch:S,loading:k}=Ii({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:b}=y(),{isActiveTab:A}=re(),[D,w]=Rf(!1),E=au({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:b.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),N=jc(m,C,T?.variant),L=!!n&&!!e&&!!o&&new rb(n).gt(0)&&!yu(e,o),W=L&&v==="success"&&k,J=(!N||N&&c?.results.length)&&(l||s);Jf(()=>{u(),h("refetchQuote",!0)},[]),Jf(()=>{g(L)},[L]);let M=(r||s)&&!D?S:void 0,X=i(z=>{N&&f?(g(!1),setTimeout(()=>{t(z)},sb)):t(z)},"onHandleNavigation"),se=i(z=>{r?.requestId!==z.requestId&&(w(!1),p(z))},"onClickOnQuote");return qe.createElement(ab,null,qe.createElement(oe,{height:"auto",footer:qe.createElement(tb,{id:`widget-swap-${E.action}-btn`,type:"primary",size:"large",disabled:E.disabled||!A,prefix:E.action==="confirm-warning"&&qe.createElement(nb,null),fullWidth:!0,onClick:()=>{E.action==="connect-wallet"?Yf({type:"clickConnectWallet"},()=>X($.wallets)):E.action==="confirm-warning"?w(!0):X($.confirmSwap)}},E.title),header:{onWallet:()=>{X($.wallets)},hasBackButton:!1,title:T.title||eb.t("Swap"),suffix:qe.createElement(go,{hidden:N?["refresh"]:void 0,onClickRefresh:M,onClickHistory:()=>X($.swaps),onClickSettings:()=>{X($.settings)}})}},qe.createElement(ie,null,qe.createElement(Sl,{fetchingQuote:W,fetchMetaStatus:v,isExpandable:N,onClickToken:z=>{X(z==="from"?$.fromSwap:$.toSwap)}}),qe.createElement(Zf,{size:"2"}),N?null:qe.createElement(Co,{quote:r,loading:W,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),X($.routes)}:void 0}),J?qe.createElement(qe.Fragment,null,qe.createElement(Zf,{size:"10"}),qe.createElement(Wn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:D,confirmationDisabled:!A,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),d(!0),X($.confirmSwap)},onChangeSettings:()=>X($.settings)})):null,qe.createElement(ul,null))),N?qe.createElement(fl,{loading:W,onClickOnQuote:se,fetch:S,onClickRefresh:M,isVisible:f}):null)}i(eg,"Home");import{i18n as tg}from"@lingui/core";import{Alert as lb,Divider as cb,List as pb,ListItemButton as ub,Radio as db,RadioRoot as mb,Typography as fb}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Rc,r=o?.language||Bo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Bo),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function og(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(fb,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(db,{value:s}),start:Wt.createElement(c,null)}});return Wt.createElement(oe,{header:{title:tg.t("Language")}},Wt.createElement(ie,null,Wt.createElement(lb,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(cb,{size:"8"}),Wt.createElement(mb,{value:t},Wt.createElement(pb,{type:Wt.createElement(ub,{title:tg.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(og,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as Cb,Checkbox as kb,Image as Tb,ListItemButton as vb,NotFound as wb,Typography as bb}from"@rango-dev/ui";import Ge,{useState as xb}from"react";import{Checkbox as yb,Skeleton as rg}from"@rango-dev/ui";import Yn from"react";import{styled as Cl}from"@rango-dev/ui";var Xn=Cl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),kl=Cl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Tl=Cl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as gb,styled as hb}from"@rango-dev/ui";var ng=hb(gb,{height:61});var Sb=30;function vl(){return Yn.createElement(Xn,null,Array.from(Array(Sb),(t,e)=>Yn.createElement(ng,{hasDivider:!0,key:e,start:Yn.createElement(rg,{variant:"circular",width:35,height:35}),title:Yn.createElement(rg,{variant:"text",size:"large",width:90}),end:Yn.createElement(yb,{checked:!1})})))}i(vl,"LoadingLiquiditySourceList");function wl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=xb(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=kr(o,n),p={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=c.filter(S=>u.includes(S.type)),h=d.length===d.filter(S=>S.selected).length,f=i(()=>{d.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),g=d.map(S=>{let{selected:k,groupTitle:T,logo:v,id:b,...A}=S;return{id:`widget-setting-liquidity-source-${b.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(Tb,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ge.createElement(kb,{checked:k,disabled:l}),title:Ge.createElement(bb,{variant:"title",size:"xmedium"},zt.t(T)),selected:k,groupTitle:T,logo:v,...A}}),m=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=g;return r&&(C=g.filter(S=>wt(S.groupTitle,r))),Ge.createElement(oe,{header:{title:zt.t(t),suffix:Ge.createElement(kl,null,Ge.createElement(Cb,{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(ie,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ge.createElement(vl,null),!C.length&&r?Ge.createElement(Tl,null,Ge.createElement(wb,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(Xn,{disabled:l},C.map(S=>{let{groupTitle:k,...T}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(vb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(wl,"LiquiditySourcePage");import{i18n as Eb}from"@lingui/core";import Ai from"react";import{useNavigate as Ib}from"react-router-dom";function ig(){let t=Ib(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=Ii({refetchQuote:n}),p=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Ai.createElement(oe,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Eb.t("Routes"),suffix:Ai.createElement(go,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ai.createElement(ie,null,Ai.createElement(Kn,{fetch:l,loading:c,onClickOnQuote:p})))}i(ig,"RoutesPage");import{i18n as dg}from"@lingui/core";import{Divider as mg,getCategoriesCount as $b,SelectableCategoryList as Fb}from"@rango-dev/ui";import Qt,{useState as fg}from"react";import{useNavigate as Ob}from"react-router-dom";import{i18n as bl}from"@lingui/core";import{Divider as Bb,Image as Lb,ListItemButton as Mb,NotFound as Pb,Typography as ug}from"@rango-dev/ui";import nt,{useEffect as _b,useState as Db}from"react";var ag=i((t,e,o)=>t.filter(n=>dr(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as Ab,styled as sg}from"@rango-dev/ui";var lg=sg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ni=sg(bn,{padding:0,margin:0,listStyle:"none",[`& ${Ab}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Nb,Skeleton as cg}from"@rango-dev/ui";import Wi from"react";var Wb=20;function pg(){return Wi.createElement(Ni,null,Array.from(Array(Wb),t=>Wi.createElement(Nb,{key:t,hasDivider:!0,start:Wi.createElement(cg,{variant:"circular",width:35,height:35}),title:Wi.createElement(cg,{variant:"text",size:"large",width:90})})))}i(pg,"LoadingBlockchainList");function xl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Db(e),{fetchStatus:c}=y();_b(()=>{l([...ag(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?nt.createElement(Pb,{title:bl.t("No results found"),description:bl.t("Try using different keywords")}):nt.createElement(Ni,{as:"ul",key:`${r}-${o}`},s.map(u=>nt.createElement(Mb,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:nt.createElement(Lb,{src:u.logo,size:30}),title:nt.createElement(ug,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(ug,{variant:"label",size:"large"},bl.t("Select Chain")),nt.createElement(Bb,{size:4})),nt.createElement(lg,null,c==="loading"&&nt.createElement(pg,null),c==="success"&&p()))}i(xl,"BlockchainList");function Bi(t){let{type:e}=t,o=je(),[n,r]=fg(""),[a,s]=fg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:p}=y(),u=Ob(),d=y().blockchains({type:e}),h=$b(d),f=!t.hideCategory&&h!==1;return Qt.createElement(oe,{header:{title:dg.t("Select Chain")}},Qt.createElement(ie,{view:!0},f&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Fb,{setCategory:s,category:a,blockchains:d,isLoading:p==="loading"}),Qt.createElement(mg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:dg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:g=>r(g.target.value)}),Qt.createElement(mg,{size:16}),Qt.createElement(xl,{list:d,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:g=>{e==="custom-token"?u(`..?blockchain=${g.name}`,{replace:!0}):(e==="source"?c(g):l(g),o())}})))}i(Bi,"SelectBlockchainPage");import{i18n as Mi}from"@lingui/core";import{Divider as kg}from"@rango-dev/ui";import wo,{useState as Kb}from"react";import{useNavigate as jb}from"react-router-dom";import{i18n as Al}from"@lingui/core";import{BlockchainsChip as Li,Divider as Sg,Image as Cg,Skeleton as qb,Tooltip as Gb,Typography as Nl}from"@rango-dev/ui";import Pe from"react";import{useEffect as Qb}from"react";var gg=["ETH","COSMOS","OSMOSIS"];function El(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Ub),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 c=0;c<=l;c++){let p=n[c];s=s.filter(u=>p.name!==u)}}n.sort(zb(s)),r=n.splice(a)}return{list:n,more:r}}i(El,"prepare");function Ub(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(Ub,"sortByMostUsedBlockchains");function zb(t){return i(function(o,n){let r=t.findIndex(c=>c===o.name),a=t.findIndex(c=>c===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(zb,"generateSortByPreferredBlockchainsFor");function hg(t,e){return!!e.list.find(o=>o.name===t)}i(hg,"isInVisibleList");function Il(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();Qb(()=>{if(e?.selected){let a=El(t,o,e);hg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=El(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Il,"usePrepareBlockchainList");import{styled as Hb}from"@rango-dev/ui";var yg=Hb("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var Vb=12;function Wl(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Il(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),p=O.use.resetFromBlockchain(),u=s.more.length>0,d=s.more.length===1,h=!d&&u;return Pe.createElement(Pe.Fragment,null,Pe.createElement(Sg,{size:12}),Pe.createElement(Nl,{variant:"label",size:"large"},Al.t("Select Chain")),Pe.createElement(Sg,{size:12}),Pe.createElement(yg,null,l==="loading"&&Array.from(Array(Vb),f=>Pe.createElement(qb,{key:f,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Li,{selected:!n,onClick:()=>{o==="from"?p():c()}},Pe.createElement(Nl,{variant:"body",size:"xsmall",color:"secondary500"},Al.t("All"))),s.list.map(f=>Pe.createElement(Gb,{key:f.name,content:f.shortName,side:"bottom",sideOffset:2,container:I()},Pe.createElement(Li,{key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},Pe.createElement(Cg,{src:f.logo,size:30})))),d?Pe.createElement(Li,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(Cg,{src:s.more[0].logo,size:30})):null,h?Pe.createElement(Li,{onClick:a,key:"more-blockchains"},Pe.createElement(Nl,{variant:"body",size:"xsmall",color:"secondary500"},Al._("More +{count}",{count:s.more.length}))):null)))}i(Wl,"BlockchainsSection");function Bl(t){let{type:e}=t,o=jb(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:p}=O(),{getBalanceFor:u}=y(),[d,h]=Kb(""),g=(e==="source"?r:a)?.name??"",m=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:g,searchFor:d,getBalanceFor:u}),S=i(v=>{e==="source"?c(v):p(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:m,tokens:C}}):l({token:v,meta:{blockchains:m,tokens:C}})},"updateToken"),T={source:Mi.t("Source"),destination:Mi.t("Destination")};return wo.createElement(oe,{header:{title:Mi.t("Swap {type}",{type:T[e]})}},wo.createElement(ie,null,wo.createElement(Wl,{blockchains:m,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{S(v)}}),wo.createElement(kg,{size:24}),wo.createElement(Ct,{value:d,autoFocus:!0,placeholder:Mi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),wo.createElement(kg,{size:16}),wo.createElement(zn,{list:C,selectedBlockchain:g,searchedFor:d,type:e,onChange:v=>{k(v);let b=m.find(A=>v.blockchain===A.name);b&&S(b),n()}})))}i(Bl,"SelectSwapItemsPage");import{i18n as Pl}from"@lingui/core";import{Alert as kx,Button as Tx,styled as vx}from"@rango-dev/ui";import bo from"react";import{useInRouterContext as wx,useSearchParams as bx}from"react-router-dom";import{i18n as Eg}from"@lingui/core";import{Divider as Ig,InfoIcon as Jb,SlippageIcon as Rb,TextField as ex,Tooltip as tx,Typography as Ag}from"@rango-dev/ui";import rt from"react";import{Chip as Xb,styled as Zn,TextField as Yb}from"@rango-dev/ui";var Tg=Zn("div",{paddingTop:"$5",padding:"$10 $5"}),vg=Zn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Yb}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),wg=Zn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Pi=Zn("div",{maxWidth:"280px",padding:"$10"}),bg=Zn(Xb,{width:"61px",flexShrink:0});import{i18n as Ll}from"@lingui/core";import{Typography as Zb}from"@rango-dev/ui";import Jn from"react";function xg(){return Jn.createElement(Pi,null,Jn.createElement(Zb,{variant:"label",size:"medium",color:"neutral700"},Ll.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Jn.createElement("br",null),Jn.createElement("br",null),Jn.createElement("b",null,Ll.t("Warning")),":\xA0",Ll.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(xg,"SlippageTooltipContent");function Ml(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(Tg,null,rt.createElement(wg,null,rt.createElement(Rb,{size:16,color:"gray"}),rt.createElement(Ig,{direction:"horizontal",size:4}),rt.createElement(Ag,{variant:"title",size:"xmedium"},Eg.t("Slippage tolerance per swap")),rt.createElement(Ig,{direction:"horizontal",size:4}),rt.createElement(tx,{container:I(),side:"top",sideOffset:4,content:rt.createElement(xg,null)},rt.createElement(Jb,{color:"gray"}))),rt.createElement(vg,null,ep.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(bg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(ex,{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>=rp&&s<=np?n(s):n(null)},suffix:o&&rt.createElement(Ag,{variant:"body",size:"small"},"%"),placeholder:Eg.t("Custom")})))}i(Ml,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as Ng,BridgesIcon as ox,ChevronRightIcon as _i,DarkModeIcon as Wg,Divider as Rn,ExchangeIcon as nx,InfinityIcon as rx,InfoIcon as ix,LanguageIcon as ax,LightModeIcon as Bg,List as sx,ListItem as lx,ListItemButton as cx,Skeleton as px,styled as ux,Switch as dx,Tabs as mx,TargetIcon as fx,Tooltip as gx,Typography as Ye}from"@rango-dev/ui";import _ from"react";import{useNavigate as hx}from"react-router-dom";var yx=ux("div",{width:"202px",height:"$40"}),Sx=[{id:"light",icon:_.createElement(Bg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:_.createElement(Wg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:_.createElement(Ng,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Auto"))}],Cx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return _.createElement(Ng,{...e});case"dark":return _.createElement(Wg,{...e});default:return _.createElement(Bg,{...e})}},"getThemeIcon");function Lg(){let t=hx(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(M=>M.local===r)?.label,l=y().fetchStatus,c=y().swappers(),p=y().getDisabledLiquiditySources(),{config:{features:u}}=y(),d=y().customTokens(),h=Ve("theme",u),f=Ve("liquiditySource",u),g=Ve("language",u),m=Ve("customTokens",u),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=kr(c,p),T=k.filter(M=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(M.type)),v=T.length,b=T.filter(M=>M.selected).length,A=k.filter(M=>M.type==="DEX"),D=A.length,w=A.filter(M=>M.selected).length,x=i((M,X)=>{switch(l){case"loading":return _.createElement(px,{variant:"text",size:"medium",width:50});case"failed":return _.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return _.createElement(Ye,{variant:"body",size:"medium"},`${M} / ${X}`)}},"handleSwapperEndItem"),E={id:"widget-setting-bridge-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:_.createElement(_.Fragment,null,x(b,v),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(_i,{color:"black"})),onClick:()=>t($.bridges),start:_.createElement(ox,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:_.createElement(_.Fragment,null,x(w,D),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(_i,{color:"black"})),start:_.createElement(nx,{color:"gray",size:16}),onClick:()=>t($.exchanges)},L={id:"widget-setting-custom-tokens-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},`${d.length}`),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(_i,{color:"black"})),start:_.createElement(fx,{color:"gray",size:16}),onClick:()=>t($.customTokens)},W={id:"widget-setting-language-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Language")),start:_.createElement(ax,{color:"gray",size:16}),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},s),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(_i,{color:"black"})),onClick:()=>t($.languages)},j={id:"widget-setting-infinite-approval-item-btn",title:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),_.createElement(Rn,{direction:"horizontal",size:4}),_.createElement(gx,{side:"top",sideOffset:4,container:I(),content:_.createElement(Pi,null,_.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},_.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.")))},_.createElement(ix,{color:"gray"}))),start:_.createElement(rx,{color:"gray",size:16}),end:_.createElement(dx,{checked:C}),onClick:S},te={id:"widget-setting-theme-item-btn",type:_.createElement(lx,null),title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Theme")),end:_.createElement(yx,null,_.createElement(mx,{container:I(),items:Sx,value:n,onChange:M=>o(M.id),type:"primary",borderRadius:"small"})),start:Cx(n)},J=f?[]:[E,N];return m||J.push(L),g||J.push(W),J.push(j),!e?.singleTheme&&!h&&J.push(te),_.createElement(sx,{type:_.createElement(cx,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Lg,"SettingsLists");var xx=vx("div",{paddingLeft:"$8"});function Mg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=bx(),r=wx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return bo.createElement(oe,{header:{title:Pl.t("Settings")}},bo.createElement(ie,null,o&&bo.createElement(kx,{type:"info",variant:"alarm",title:Pl.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:bo.createElement(xx,null,bo.createElement(Tx,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Pl.t("Reset")))}),bo.createElement(Ml,null),bo.createElement(Lg,null)))}i(Mg,"SettingsPage");import{i18n as mE}from"@lingui/core";import{cancelSwap as fE}from"@rango-dev/queue-manager-rango-preset";import{useManager as gE}from"@rango-dev/queue-manager-react";import{Alert as hE}from"@rango-dev/ui";import Zl from"react";import{useParams as yE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as jx,getCurrentStep as Xx,getRelatedWalletOrNull as Yx}from"@rango-dev/queue-manager-rango-preset";import{Button as mh,CopyIcon as Zx,Divider as Jx,DoneIcon as Rx,IconButton as eE,QuoteCost as tE,RangoExplorerIcon as oE,StepDetails as nE,Tooltip as fh,Typography as xo,useCopyToClipboard as rE}from"@rango-dev/ui";import{useWallets as iE}from"@rango-dev/wallets-react";import gh from"bignumber.js";import{PendingSwapNetworkStatus as Hi}from"rango-types";import K,{useEffect as hh,useRef as aE,useState as yh}from"react";import{useNavigate as sE}from"react-router-dom";import{i18n as eo}from"@lingui/core";var Ex=[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"):`${Ex[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Pg,"timeSince");function _g(t){return t.finishTime?Pg(parseInt(t.finishTime)):Pg(parseInt(t.creationTime))}i(_g,"getSwapDate");import{PendingSwapNetworkStatus as Fi}from"rango-types";import Oi from"react";import{i18n as Di}from"@lingui/core";import{Button as Dg,Divider as _l,MessageBox as Ix}from"@rango-dev/ui";import to from"react";var $g=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(_l,{size:20}),to.createElement(Ix,{type:"error",title:Di.t("Cancel Swap"),description:Di.t("Are you sure you want to cancel this swap?")}),to.createElement(_l,{size:32}),to.createElement(Dg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Di.t("Yes, Cancel it")),to.createElement(_l,{size:12}),to.createElement(Dg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Di.t("No, Continue"))),"CancelContent");import{i18n as $i}from"@lingui/core";import{Button as Fg,Divider as Dl,MessageBox as Ax,Typography as Nx}from"@rango-dev/ui";import Ht from"react";var Og=i(({onDelete:t,onClose:e})=>Ht.createElement(Ht.Fragment,null,Ht.createElement(Dl,{size:20}),Ht.createElement(Ax,{type:"error",title:$i.t("Delete Transaction"),description:$i.t("Are you sure you want to delete this swap?")}),Ht.createElement(Dl,{size:32}),Ht.createElement(Fg,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},$i.t("Yes, Delete it")),Ht.createElement(Dl,{size:12}),Ht.createElement(Fg,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Ht.createElement(Nx,{variant:"title",size:"medium",color:"primary"},$i.t("No, Cancel")))),"DeleteContent");import{i18n as $l}from"@lingui/core";import{PendingSwapNetworkStatus as Fl}from"rango-types";var Ol={[Fl.WaitingForNetworkChange]:{type:"loading",title:$l.t("Change Network")},[Fl.WaitingForConnectingWallet]:{type:"warning",title:$l.t("Connect Wallet")},[Fl.NetworkChanged]:{type:"success",title:$l.t("Network Changed")}};import{warn as Wx}from"@rango-dev/logging-core";import{MessageBox as Bx,Wallet as Lx}from"@rango-dev/ui";import{useWallets as Mx}from"@rango-dev/wallets-react";import en,{useState as Px}from"react";import{styled as Ul}from"@rango-dev/ui";var Ug=Ul("div",{display:"flex",justifyContent:"center"}),P5=Ul("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}}),zg=Ul("img",{width:"100%"});var Qg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=Px(),{getWalletInfo:p,state:u}=Mx(),d=n?.walletType,h=d?pn(u(d)):null,f=d?p(d):null,g=a&&!!d&&!!h&&!!f,{list:m}=ft(),C=i(()=>{if(d){let S=m.find(k=>k.type===d);S?c(S):Wx(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return en.createElement(en.Fragment,null,en.createElement(Bx,{type:e,title:o,description:r}),g&&en.createElement(Ug,null,en.createElement(Lx,{container:I(),title:f.name,image:f.img,type:d,state:h,link:f.installLink,disabled:s,onClick:C})),en.createElement(po,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function zl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===Fi.WaitingForNetworkChange||e===Fi.WaitingForConnectingWallet||e===Fi.NetworkChanged;return Oi.createElement(Z,{open:!!e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},c&&Oi.createElement(Qg,{type:Ol[e].type,title:Ol[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Fi.WaitingForNetworkChange}),e==="delete"&&Oi.createElement(Og,{onClose:o,onDelete:n}),e==="cancel"&&Oi.createElement($g,{onClose:o,onCancel:r}))}i(zl,"SwapDetailsModal");import{i18n as er}from"@lingui/core";import{Button as Ql,Divider as tr,MessageBox as Gg,TokenAmount as _x,Typography as Vg}from"@rango-dev/ui";import fe from"react";import{Link as Dx,useNavigate as $x}from"react-router-dom";var Hg="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",qg="/profile";function Hl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:p,percentageChange:u,description:d,diagnosisUrl:h}=t,f=$x(),{showProfileBanner:g}=re();return fe.createElement(Z,{open:e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},n==="success"?fe.createElement(Gg,{type:"success",title:er.t("Swap Successful")},fe.createElement(_x,{direction:"vertical",tooltipContainer:I(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:p,percentageChange:u}),fe.createElement(tr,{size:12}),fe.createElement(Vg,{variant:"body",size:"medium",color:"neutral700",align:"center"},d)):fe.createElement(Gg,{type:"error",title:er.t("Transaction Failed"),description:d}),fe.createElement(tr,{size:30}),n==="success"&&fe.createElement(fe.Fragment,null,g&&fe.createElement(fe.Fragment,null,fe.createElement(Dx,{to:qg},fe.createElement(zg,{src:Hg,alt:"Profile Banner"})),fe.createElement(tr,{size:30})),fe.createElement(Ql,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{f("../../")}},er.t("Done"))),fe.createElement(tr,{size:12}),h&&fe.createElement(fe.Fragment,null,fe.createElement(Ql,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},er.t("Diagnosis")),fe.createElement(tr,{size:12})),fe.createElement(Ql,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},fe.createElement(Vg,{variant:"title",size:"medium",color:"primary"},er.t("See Details"))))}i(Hl,"SwapDetailsCompleteModal");import Kx from"react";import{i18n as Hx}from"@lingui/core";import{Alert as ch,IconButton as qx,LinkIcon as Gx}from"@rango-dev/ui";import oo,{Fragment as Vx}from"react";import{Alert as Ox,ChevronDownIcon as Ux,IconButton as zx}from"@rango-dev/ui";import on,{useState as Qx}from"react";import{css as or,darkTheme as Kg,styled as qt,Typography as Fx}from"@rango-dev/ui";var jg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Ui=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Kg} &`]:{color:"$secondary500"}}}}}),Xg=qt(bn,{padding:"$0 $20 $20 $20"}),TK=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Yg=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),vK=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),tn=or({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Kg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Zg=or({padding:"$5 0"}),zi=or({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Jg=or({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Rg=or({width:"100%",padding:"0 $20 $10"}),eh=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),th=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Qi=qt(Fx,{wordBreak:"break-word"});import{styled as ql}from"@rango-dev/ui";var oh=ql("div",{display:"flex",flexDirection:"column",gap:"$10"}),nh=ql("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),rh=ql("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function ih(t){let{message:e}=t,[o,n]=Qx(!1);return on.createElement(Ox,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&on.createElement(zx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},on.createElement(nh,{rotated:o},on.createElement(Ux,{size:12,color:"gray"}))),footer:on.createElement(rh,{open:o},on.createElement(Qi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(ih,"FailedAlert");import{i18n as ah}from"@lingui/core";import{Alert as Gl,Button as sh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Vl}from"rango-types";import nr from"react";function lh(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?nr.createElement(Gl,{type:"warning",title:n.shortMessage,action:nr.createElement(sh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Vl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},ah.t("Change"))}):r===Vl.WaitingForConnectingWallet?nr.createElement(Gl,{type:"warning",title:n.shortMessage,action:nr.createElement(sh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Vl.WaitingForConnectingWallet)}},ah.t("Connect"))}):nr.createElement(Gl,{type:"warning",title:n.shortMessage})}i(lh,"WarningAlert");function Kl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=vn(a),c=a.status==="waitingForApproval"&&!l,p=a.status==="running"&&!l,u=p&&!s||c&&!a.explorerUrl?.length;return oo.createElement(oh,null,a.explorerUrl?.map((d,h,f)=>{let g=h+d.url,m=h===f.length-1,C=(m&&p||c)&&!u,S=m&&a.status==="failed";return oo.createElement(Vx,{key:g},oo.createElement(ch,{type:m&&(C&&"loading"||S&&"error")||"success",title:d.description?`${d.description} Tx`:Hx.t("View transaction"),action:d.url&&oo.createElement(qx,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(d.url,"_blank")},oo.createElement(Gx,{size:12}))}))}),u&&oo.createElement(ch,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(lh,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(ih,{message:r}))}i(Kl,"SwapDetailsAlerts");var ph=2e3;var uh=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:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:rn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:st(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:st(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:rn(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:Kx.createElement(Kl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function dh(t){if(vn(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(dh,"getStepState");function jl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=iE(),c=y().blockchains(),p=y().swappers(),{findToken:u}=y(),d=O.use.retry(),h=re.use.isActiveTab(),f=sE(),[g,m]=rE(ph),C=aE(null),[S,k]=yh(null),[T,v]=yh(null),b=i(()=>{r(),k(null)},"onCancel"),A=be.use.getNotifications(),D=be.use.removeNotification(),w=A(),x=Xx(e),E=x?.networkStatus;hh(()=>{w.find(mt=>mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),D(e.requestId)):T&&v(null))},[e.status,e.requestId]),hh(()=>{M?k(Hi.WaitingForNetworkChange):E===Hi.WaitingForConnectingWallet||E===Hi.NetworkChanged?k(E):k(null)},[E]);let N=fu(e),L=x?jx(e,x):null,W=x?Yx(e,x):null,j=_g(e),te=gu(e),J=i(ve=>!!l(ve)?.mobileWallet,"isMobileWallet"),M=E===Hi.WaitingForNetworkChange&&!!L&&!!W?.walletType&&(J(W.walletType)||a(W.walletType,L.network)),X=M?s.bind(null,W.walletType,[{namespace:L.namespace,network:L.network}]):void 0,se=mu(e,x),z=uh({swap:e,switchNetwork:X,showNetworkModal:E,setNetworkModal:k,message:se,blockchains:c,swappers:p}),me=z.length,[vt,Ze]=[e.steps[0],e.steps[me-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((ve,mt)=>ve+parseFloat(mt.feeInUsd||""),0),G=e.steps.find(ve=>ve.diagnosisUrl)?.diagnosisUrl,P=B(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),q=B(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),V=le?new gh(le).multipliedBy(Ze.toUsdPrice||0).toString():"",ge=new gh(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(q,P),he=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:B(le,6,6),token:z[me-1].to.token.displayName,conciseAddress:Sr(e.wallets[z[me-1].to.chain.displayName]?.address||""),chain:z[me-1].to.chain.displayName}}):K.createElement(th,null,K.createElement(xo,{variant:"body",size:"medium",color:"neutral700",align:"center"},he?"":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}})}`:""),he&&K.createElement(Qi,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",he));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(mh,{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(mh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ve=Br(e,c,u);d(ve),setTimeout(()=>{f("../../")},0)}},it.t("Try again"))},K.createElement(ie,{compact:!0,view:!0},K.createElement(Ui,null,K.createElement("div",{className:tn()},K.createElement(xo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),K.createElement("div",{className:zi()},K.createElement(xo,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(fh,{container:I(),content:g?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:g||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(eE,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:m.bind(null,o||"")},g?K.createElement(Rx,{size:16,color:"secondary"}):K.createElement(Zx,{size:16,color:"gray"}))),K.createElement(eh,{target:"_blank",href:`${Tc}/swap/${o}`},K.createElement(fh,{container:I(),content:it.t("View on Rango Explorer"),side:"bottom"},K.createElement(oE,{size:20}))))),K.createElement("div",{className:tn()},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:Jg()},K.createElement(tE,{fee:B(String(at),2,2),time:ln(mr(e.steps)),steps:me}),K.createElement(Ln,{from:{price:{value:B(e.inputAmount,6,6),usdValue:q,realUsdValue:ge,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:B(le,6,6),usdValue:P,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:B(ne,2,2),warningLevel:_t(ne??0)})),K.createElement("div",{className:Rg()},K.createElement(xo,{variant:"title",size:"small"},it.t("Swaps steps"))),K.createElement(Jx,{size:8}),K.createElement(Xg,{ref:C},z.map((ve,mt)=>{let rc=mt,nn=dh(e.steps[mt]),Gh=nn==="error"||nn==="in-progress"||nn==="warning"||nn==="completed"&&mt===z.length-1;return K.createElement(nE,{key:rc,step:ve,type:"swap-progress",ref:C,state:nn,hasSeparator:mt!==0,tabIndex:rc,isFocused:Gh,tooltipContainer:I()})}))),K.createElement(zl,{state:S,onClose:()=>k(null),onCancel:b,onDelete:n,message:se.detailedMessage.content,currentStepWallet:W,walletButtonDisabled:!h}),K.createElement(Hl,{open:!!T,diagnosisUrl:G,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(le,6,6),usdValue:P,realUsdValue:V,realValue:le||"",percentageChange:B(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(jl,"SwapDetails");import{i18n as Gi}from"@lingui/core";import{Divider as kh,NotFound as dE,Skeleton as ir,Typography as Vi}from"@rango-dev/ui";import ke from"react";import{i18n as lE}from"@lingui/core";import{Divider as cE,Skeleton as pE,Typography as uE}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Xl}from"@rango-dev/ui";var Sh=Xl("div",{width:"100%",height:"100%",padding:"$10 $20"}),rr=Xl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),qi=Xl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),P4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),_4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),D4=Tt({paddingTop:"$15",display:"flex"}),$4=Tt({padding:"$15 $0"}),F4=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),O4=Tt({paddingBottom:"$10"}),U4=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),z4=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),Q4=Tt({display:"flex",alignItems:"center"}),H4=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),Ch=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Yl(){return Te.createElement(Sh,null,Te.createElement(_n,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(uE,{variant:"title",size:"small"},lE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(rr,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:Ch()},Te.createElement(cE,{direction:"horizontal",size:20}),Te.createElement(pE,{height:22,variant:"rectangular"}))),Te.createElement(qi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(qi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(qi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1}))))}i(Yl,"LoadingSwapDetails");function Th(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(oe,{header:{title:Gi.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(jg,null,ke.createElement(Ui,null,ke.createElement("div",{className:tn()},ke.createElement(Vi,{variant:"label",size:"large",color:"neutral700"},`${Gi.t("Request ID")}`),ke.createElement("div",{className:zi()},ke.createElement(Vi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})),ke.createElement(kh,{direction:"horizontal",size:4}),ke.createElement(ir,{width:16,height:16,variant:"rectangular"}),ke.createElement(kh,{direction:"horizontal",size:4}),ke.createElement(ir,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:tn()},ke.createElement(Vi,{className:Zg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})),ke.createElement(Vi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})))),ke.createElement(Yl,null)),!o&&ke.createElement(Yg,null,ke.createElement(dE,{title:Gi.t("Not found"),description:Gi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(Th,"SwapDetailsPlaceholder");function vh(){let{manager:t,state:e}=gE(),o=!e.loadedFromPersistor,n=pt(t),{requestId:r}=yE(),a=je(),{fetchStatus:s}=y();if(!r)return Zl.createElement(hE,{containerStyles:{margin:"20px"},type:"error",title:mE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",c=r?n.find(({swap:h})=>h.requestId===r):void 0,p=i(()=>{if(c?.id){let h=t?.get(c.id);h&&fE(h)}},"onCancel"),u=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),d=c?.swap;return!d||l?Zl.createElement(Th,{requestId:r,showSkeleton:l}):Zl.createElement(jl,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(vh,"SwapDetailsPage");import{i18n as wh}from"@lingui/core";import{Divider as SE,getCategoriesCount as CE,SelectableCategoryList as kE,styled as xh,Typography as TE,Wallet as vE}from"@rango-dev/ui";import Bt,{useState as bh}from"react";var wE=xh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),bE=xh(ie,{textAlign:"center"});function Eh(){let{fetchStatus:t}=y(),[e,o]=bh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=bh(),l=re.use.isActiveTab(),{list:c}=ft(),p=Hc(c,n),d=CE(p)!==1,h=qc(c,e),f=i(g=>{Lc(c,r.multiWallets)||s(g)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:wh.t("Connect Wallets")}},Bt.createElement(bE,null,d&&Bt.createElement(Bt.Fragment,null,Bt.createElement(kE,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Bt.createElement(SE,{size:24})),Bt.createElement(TE,{variant:"title",size:"xmedium",align:"center"},wh.t("Choose a wallet to connect.")),Bt.createElement(wE,null,h.map((g,m)=>{let C=`wallet-${m}-${g.type}`;return Bt.createElement(vE,{key:C,...g,container:I(),onClick:()=>f(g),isLoading:t==="loading",disabled:!l})}),Bt.createElement(po,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Eh,"WalletsPage");function Ih(){return Cu(),$a(),xE([{path:$.home,element:_e.createElement(eg,null)},{path:$.routes,element:_e.createElement(ig,null)},{path:$.fromSwap,children:[{index:!0,element:_e.createElement(Bl,{type:"source"})},{path:$.blockchains,element:_e.createElement(Bi,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:_e.createElement(Bl,{type:"destination"})},{path:$.blockchains,element:_e.createElement(Bi,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:_e.createElement(Mg,null)},{path:$.languages,element:_e.createElement(og,null)},{path:$.exchanges,element:_e.createElement(wl,{sourceType:"Exchanges"})},{path:$.bridges,element:_e.createElement(wl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:_e.createElement(pf,null)},{path:$.addCustomTokens,children:[{index:!0,element:_e.createElement(ed,null)},{path:$.blockchains,element:_e.createElement(Bi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:_e.createElement(Wf,null)},{path:$.swapDetails,element:_e.createElement(vh,null)}]},{path:$.wallets,element:_e.createElement(Eh,null)},{path:$.confirmSwap,element:_e.createElement(Xm,null)}])}i(Ih,"AppRoutes");import{useQueueManager as PE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as _E}from"@rango-dev/wallets-shared";import{isEvmBlockchain as DE}from"rango-sdk";import{useContext as $E,useEffect as Ph,useState as _h}from"react";import{globalCss as EE}from"@rango-dev/ui";var Ah=i(()=>EE({"@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 Nh(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Mt("BASE_URL")}/meta/dapp/config?apiKey=${Mt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(Nh,"useFetchApiConfig");import{useWallets as IE}from"@rango-dev/wallets-react";import{useEffect as AE,useRef as NE}from"react";function Wh(){let{connect:t,state:e}=IE(),o=NE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);AE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Wh,"useForceAutoConnect");import{isApprovalTX as WE,RouteEventType as Bh,StepEventType as Lh,StepExecutionEventStatus as BE,WidgetEvents as Ki}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Mh}from"react";function Jl(){let t=be.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Mh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===Lh.TX_EXECUTION&&a.status===BE.TX_SENT&&!WE(s)||a.type===Lh.SUCCEEDED){let p=l.wallets[s?.fromBlockchain],u=e.find(d=>d.address?.toLocaleLowerCase()===p.address?.toLocaleLowerCase()&&d.walletType===p.walletType&&d.chain===s?.fromBlockchain);if(u&&o([u]),s?.fromBlockchain!==s?.toBlockchain){let d=l.wallets[s?.toBlockchain],h=e.find(f=>f.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&f.walletType===d.walletType&&f.chain===s?.toBlockchain);h&&o([h])}}t(a,l)},"handleStepEvent");return ye.on(Ki.StepEvent,n),()=>ye.off(Ki.StepEvent,n)},[ye,e]),Mh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===Bh.FAILED||a.type===Bh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return ye.on(Ki.RouteEvent,n),()=>ye.off(Ki.RouteEvent,n)},[ye])}i(Jl,"useSubscribeToWidgetEvents");import{useManager as LE}from"@rango-dev/queue-manager-react";import{useEffect as ME}from"react";function Rl(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=LE();ME(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(pt(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Rl,"useSyncNotifications");function ec(){Wh(),Ah(),Jl(),Rl();let t=y().blockchains(),{canSwitchNetworkTo:e}=Yr(),[o,n]=_h(""),[r,a]=_h(),s=$E(Ir),l=t.filter(DE),{fetchApiConfig:c}=Nh();Ph(()=>()=>Su(),[]),PE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Ph(()=>(ao.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(p=>{a(p),p===_E(o)?.[0]&&n("")}),c().catch(console.log),ao.destroy),[])}i(ec,"useBootstrap");import{styled as FE}from"@rango-dev/ui";var Dh=FE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function ji(){ec();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=Rt();return tc.createElement(OE,{language:o},tc.createElement(Dh,{id:"swap-container",className:e()},tc.createElement(Ih,null)))}i(ji,"Main");import{setSolanaSignerConfig as iI}from"@rango-dev/signer-solana";import nc,{useEffect as Qh,useMemo as aI}from"react";import{useState as UE}from"react";var zE=i(()=>{let[t,e]=UE(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=Bc(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),$h=zE;import{checkWaitingForNetworkChange as QE,makeQueueDefinition as HE}from"@rango-dev/queue-manager-rango-preset";import{Provider as qE}from"@rango-dev/queue-manager-react";import{useWallets as GE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as VE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as KE}from"rango-types";import jE,{useMemo as XE}from"react";function YE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=GE(),l=XE(()=>HE({API_KEY:t.apiKey||Mt("API_KEY"),BASE_URL:Mt("BASE_URL"),emitter:{emit:ye.emit}}),[t.apiKey]),{blockchains:c,connectedWallets:p}=y(),u=c(),d={blockchains:p.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,b)=>a(v,b.network)?await r(v,[b]):void 0,"switchNetwork"),f=i(v=>!!s(v).mobileWallet,"isMobileWallet"),g=u.filter(v=>v.enabled).reduce((v,b)=>(v[b.name]=b,v),{}),m=u.filter(KE),C=i(v=>{let{supportedChains:b}=s(v);return un(b)},"getSupportedChainNames"),S=e(),k={meta:{blockchains:g,evmBasedChains:m,evmNetworkChainInfo:VE(m),getSupportedChainNames:C},getSigners:o,wallets:d,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:f},T=re.use.isActiveTab();return jE.createElement(qE,{queuesDefs:[l],context:k,onPersistedDataLoaded:v=>{QE(v)},isPaused:!T},t.children)}i(YE,"QueueManager");var Fh=YE;import{useManager as tI}from"@rango-dev/queue-manager-react";import oI,{createContext as nI,useContext as rI}from"react";function Oh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:h,toToken:f,requestAmount:g}=p,m={blockchains:e,tokens:o};if(u!==void 0){let C=e.find(S=>S.name===u)??null;n(C)}if(d!==void 0){let C=d?t(d)??null:null;r({meta:m,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:m,token:C})}g!==void 0&&l(g)},"updateQuoteInputs")}i(Oh,"useUpdateQuoteInputs");import{cancelSwap as ZE,getCurrentNamespaceOfOrNull as JE,getCurrentStep as RE,getRelatedWalletOrNull as eI}from"@rango-dev/queue-manager-rango-preset";var Xi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return pt(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=Br(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&ZE(o)}getCurrentStepInfo(e){let o=RE(e);return{step:o,wallet:o?eI(e,o):null,network:o?JE(e,o)?.network:null}}};var Uh=nI(void 0);function oc(t){let{manager:e}=tI(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new Xi(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=y(),u=$c(a()),d=y().blockchains(),h=y().tokens(),f=y().swappers(),g=y().fetchStatus,m=Rt().resetLanguage,C=be().getNotifications(),S=be().clearNotifications,k=Oh(),{fromBlockchain:T,toBlockchain:v,fromToken:b,toToken:A,inputAmount:D}=O(),w={isActiveTab:o,setCurrentTabAsActive:ao.forceClaim,history:c,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async x=>l(x)},meta:{blockchains:d,tokens:h,swappers:f,loadingStatus:g,findToken:r},resetLanguage:m,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:b?{symbol:b.symbol,blockchain:b.blockchain,address:b.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:D},updateQuoteInputs:k}};return oI.createElement(Uh.Provider,{value:w},t.children)}i(oc,"WidgetInfo");function zh(){let t=rI(Uh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(zh,"useWidget");function Yi(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=$h();return Qh(()=>{n&&r(n)},[n]),aI(()=>{Gc({API_KEY:o?.apiKey||pr,BASE_URL:o?.apiUrl||kc})},[o.apiKey,o.apiUrl]),Qh(()=>{t.config?.signers?.customSolanaRPC&&iI("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),nc.createElement(Ar,{config:o,onUpdateState:e},nc.createElement(Fh,{apiKey:o.apiKey},nc.createElement(oc,null,t.children)))}i(Yi,"WidgetProvider");function Hh(t){let e=t.config?.externalWallets;return Zi.createElement(Up,null,e?Zi.createElement(ji,null):Zi.createElement(Yi,{config:t.config??cr},Zi.createElement(ji,null)))}i(Hh,"Widget");function qh(){let{on:t,off:e}=ye;return{on:t,off:e}}i(qh,"useWidgetEvents");var Y3={DerivationPath:Sn,Namespaces:yn,isOnDerivationPath:kn,isOnNamespace:Cn};export{v3 as EventSeverity,Lo as MainEvents,L3 as Networks,_3 as PendingSwapNetworkStatus,da as QuoteEventTypes,w3 as RouteEventType,ta as SUPPORTED_FONTS,Y3 as StatefulConnect,b3 as StepEventType,x3 as StepExecutionBlockedEventStatus,E3 as StepExecutionEventStatus,De as UI_ID,fa as UiEventTypes,ma as WalletEventTypes,W3 as WalletEvents,M3 as WalletTypes,Hh as Widget,Lo as WidgetEvents,Yi as WidgetProvider,Ar as WidgetWallets,Xa as customizedThemeTokens,A3 as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,Yr as useWallets,zh as useWidget,qh as useWidgetEvents,jy as widgetEventEmitter};
1
+ var Kh=Object.defineProperty;var i=(t,e)=>Kh(t,"name",{value:e,configurable:!0});import{EventSeverity as b3,RouteEventType as x3,StepEventType as E3,StepExecutionBlockedEventStatus as I3,StepExecutionEventStatus as A3}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as W3}from"@rango-dev/wallets-core/legacy";import{useWallets as Zr,Events as L3}from"@rango-dev/wallets-react";import{Networks as P3,WalletTypes as _3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as $3}from"rango-types";import{Divider as QS}from"@rango-dev/ui";import co,{useEffect as HS,useRef as qS,useState as Mp}from"react";import{WalletState as jh}from"@rango-dev/ui";import{useWallets as Xh}from"@rango-dev/wallets-react";import{useReducer as Yh}from"react";function ic(t){return!!t.derivationPath}i(ic,"isStateOnDerivationPathStep");function ac(t){return!!t.namespace}i(ac,"isStateOnNamespace");var ar={status:"init",namespace:null,derivationPath:null};function sc(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 ar;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ar;default:throw new Error("Action hasn't been defined.")}}i(sc,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=Xh(),[n,r]=Yh(sc,ar),a=i(async(u,d,h)=>{r({type:"reset"});try{let f=d?.map(g=>({...g,network:void 0}));return await o(u,f),{status:"connected"}}catch(f){let g=f?.message?`Error: ${f.message}`:"An unknown error happened during connecting wallet.";throw new Error(g,{cause:f})}},"runConnect"),s=i(async(u,d)=>{if(u.state===jh.DISCONNECTED){if(!!u.isHub&&u.properties?.find(k=>k.name==="detached")&&u.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(!u.needsNamespace)return await a(u.type,void 0,d);let g=u.needsNamespace.data.length>1,m=u.needsDerivationPath;if(g)return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(m){let C=u.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:C.value}}),{status:"derivation-path"}}return await a(u.type,u.needsNamespace?.data.map(C=>({namespace:C.value})),d)}return d?.disconnectIfConnected?(await p(u.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(u,d)=>{let h=u.needsNamespace?.selection==="single",f=u.needsDerivationPath,g=d[0];if(!g)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&f)return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:g}}),{status:"derivation-path"};if(!ac(n))throw new Error("Something went wrong on handling namespace. Please retry.");let m=n.namespace.targetWallet.type,C=d.map(S=>({namespace:S}));return await a(m,C)},"handleNamespace"),c=i(async u=>{if(!u)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!ic(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=n.derivationPath.providerType,f=[{namespace:n.derivationPath.namespace,derivationPath:u}];return await a(d,f)},"handleDerivationPath"),p=i(async u=>{let d=t(u);return d.connected||d.connecting?(await e(u),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:p,handleNamespace:l,handleDerivationPath:c,getState:()=>n,resetState:u=>{r(u==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Gt,"useStatefulConnect");import{WalletState as Sa}from"@rango-dev/ui";import{useWallets as aS}from"@rango-dev/wallets-react";import{detectMobileScreens as sS,KEPLR_COMPATIBLE_WALLETS as lS,WalletTypes as gn}from"@rango-dev/wallets-shared";import{useCallback as cS,useEffect as pS}from"react";import tS,{createContext as oS,useContext as nS,useEffect as rS,useRef as iS}from"react";import{create as Ry}from"zustand";import{persist as eS}from"zustand/middleware";import{allProviders as Zh}from"@rango-dev/provider-all";var Ri=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()}},Eo=new Ri;import{defineVersions as cc,pickVersion as pc,Provider as ea}from"@rango-dev/wallets-core";function uc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=dc(a);return s instanceof ea?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof ea?o.push(cc().version("1.0.0",n).build()):o.push(cc().version("0.0.0",n).build())}),o}return t}i(uc,"matchAndGenerateProviders");function dc(t){try{return pc(t,"1.0.0")[1]}catch{return pc(t,"0.0.0")[1]}}i(dc,"pickProviderVersionWithFallbackToLegacy");function mc(t){return t.map(o=>dc(o)).map(o=>o instanceof ea?o.id:o.config.type)}i(mc,"configWalletsToWalletName");function sr(t,e){return e.find(o=>o.name===t)?.displayName}i(sr,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function fc(t,e){return e.find(o=>o.name===t)?.logo}i(fc,"getBlockchainImage");function rn(t,e){return e.find(o=>o.id===t)?.title}i(rn,"getSwapperDisplayName");function an(t,e){return e.find(o=>o.name===t)??null}i(an,"findBlockchain");function ta(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(ta,"isTokenNative");function lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function Io(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Io,"isValidTokenAddress");function sn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=lt(c));let p=o.tokensMapByTokenHash.get(c);p&&(n[c]=p)})},"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(c=>{l.has(c)||a(o.tokensMapByBlockchainName[c])})}return s.forEach(l=>{let c=r[l];if(!c&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}c&&(c.isExcluded?(a(o.tokensMapByBlockchainName[l]),c.tokens.forEach(p=>{let u=lt(p);delete n[u]})):a(c.tokens))}),Object.values(n)}i(sn,"matchTokensFromConfigWithMeta");function lr(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(lr,"getSupportedBlockchainsFromConfig");function hc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(hc,"makeProvidersOptionsFromConfig");var cr={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"}},Jh={clientUrl:void 0},Rh={liquiditySources:void 0};function gc(t){let e=hc(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return Zh(o).map(a=>a())}i(gc,"generateProviders");var yc=i((t,e,o)=>{let n=gc({...cr,...t});return{config:{...cr,...t},iframe:Jh,campaignMode:Rh,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l}=o(),c=sn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),p=sn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});Eo.set("supportedSourceTokens",c),Eo.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=gc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=hc(a);return uc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Sc}from"rango-types";var Cc=[Sc.EVM,Sc.SOLANA];import{RangoClient as fy}from"rango-sdk";import{UI_ID as ey}from"@rango-dev/ui";var pr="c6381a79-2817-4602-83bf-6a641a409e32",kc="https://api.rango.exchange",Tc="https://explorer.rango.exchange",De={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...ey};import{BlockchainCategories as sy,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as ly}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as cy,getCosmosExperimentalChainInfo as py,isEvmAddress as uy,KEPLR_COMPATIBLE_WALLETS as fA,Networks as _c}from"@rango-dev/wallets-shared";import No from"bignumber.js";import{isCosmosBlockchain as dy}from"rango-types";import ty from"bignumber.js";var ce=new ty(0);import{WalletTypes as oy}from"@rango-dev/wallets-shared";var no="~",vc=[oy.LEAP];import{BlockchainCategories as na,WalletState as ay}from"@rango-dev/ui";import{TransactionType as ur}from"rango-sdk";var wc="Roboto",oa=[{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 Ao(t){return Array.from(new Set(t))}i(Ao,"removeDuplicateFrom");function Nc(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Nc,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function Ec(t,e){return t.toLowerCase()===e.toLowerCase()}i(Ec,"exactText");function Ic(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(Ic,"startWithText");var I=i(()=>document.getElementById(De.SWAP_BOX_ID),"getContainer"),ro=i(()=>document.getElementById(De.EXPANDED_BOX_ID),"getExpanded");function Ac(t,e,o){let n=!!e&&Ec(e,t),r=!!o&&Ec(o,t);return n!==r?n?-1:1:0}i(Ac,"compareExactMatchText");function ra(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(ra,"compareContainsText");function ia(t,e,o){let n=!!e&&Ic(e,t),r=!!o&&Ic(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ia,"compareStartWithText");function Wc(t,e,o){if(!o)return 0;let n=Ac(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Ac(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=ia(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ra(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ia(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=ra(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=ia(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=ra(o,t.address,e.address);if(r!==0)return r}return 0}i(Wc,"compareWithSearchFor");var dr=i((t,e)=>{switch(e){case na.ALL:return!0;case na.UTXO:return t===ur.TRANSFER;case na.OTHER:return t!==ur.TRANSFER&&t!==ur.COSMOS&&t!==ur.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Bc=i(t=>oa.find(o=>o.value===t)?.url,"getFontUrlByName");function Lc(t,e){let o=!!t.find(n=>n.state===ay.CONNECTED);return e===!1&&o}i(Lc,"isSingleWalletActive");function Mc(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(Mc,"memoizedResult");import{BigNumber as Pc}from"bignumber.js";var ln=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),B=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Pc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Pc(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 mr=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 pn(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(pn,"mapStatusToWalletState");function Dc(t,e,o,n){return o.filter(r=>!vc.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:c}=t(r);return s&&(!l||!!n&&c!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:c,needsNamespace:p,supportedChains:u,needsDerivationPath:d,properties:h,isHub:f}=e(r),g=Ao(u.map(C=>C.type)),m=pn(t(r));return{title:a,image:s,link:cy(l),state:m,type:r,showOnMobile:c,needsNamespace:p,blockchainTypes:g,needsDerivationPath:d,properties:h,isHub:f}})}i(Dc,"mapWalletTypesToWalletInfo");function un(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(un,"walletAndSupportedChainsNames");function sa(t,e,o,n,r){let a=[];function s(c,p){if(!!!a.find(d=>d.chain===c)){let d={address:p,chain:c,walletType:t};a.push(d)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:p,network:u}=ly(c),d=l.length>0,h=l.includes(u),f=u===_c.Unknown;if(d&&!h&&!f)return;let m=u===_c.Unknown&&uy(p);if(f&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,p.toLowerCase())}):s(u,p)}),a}i(sa,"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:c}=r;c.forEach((p,u)=>{let d=p.from.blockchain,h=p.to.blockchain,f=a===o.swaps.length-1,g=u===c.length-1;(!f&&!g||f&&l!==d||e==="all")&&n.add(d),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function dn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(dn,"isAccountAndWalletMatched");var $c=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?aa(n.usdValue,n.decimals):ce.toFixed();return o.plus(r)},new No(ce));return my(e.toString())},"calculateWalletUsdValue");function my(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(my,"numberWithThousandSeparator");var hr=i((t,e)=>{let o=py(Object.entries(t).map(([,n])=>n).filter(dy));return o&&o[e]?.experimental},"isExperimentalChain");function aa(t,e){return new No(t).shiftedBy(-e).toFixed()}i(aa,"representAmountInNumber");function yr(t){if(!t)return null;let e=aa(t.amount,t.decimals),o=t.usdValue?aa(t.usdValue,t.decimals):null,n=B(e,8,8),r=o?B(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(yr,"formatBalance");function Fc(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new No(t.usdValue).shiftedBy(-t.decimals):ce,n=e&&e.usdValue?new No(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 No(t.amount).shiftedBy(-t.decimals):ce,n=e&&e.amount?new No(e.amount).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Fc,"compareTokenBalance");function Lt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Lt,"areTokensEqual");function Oc(t){return t.sort((e,o)=>+(o.state===bt.CONNECTED)-+(e.state===bt.CONNECTED)||+(o.state===bt.DISCONNECTED||o.state===bt.CONNECTING)-+(e.state===bt.DISCONNECTED||e.state===bt.CONNECTING))}i(Oc,"sortWalletsBasedOnConnectionState");function Sr(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(Sr,"getConciseAddress");function Uc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Uc,"getAddress");var zc=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Qc(t){return t.map(e=>e.state).join("-")}i(Qc,"hashWalletsState");function Hc(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(Hc,"filterBlockchainsByWalletTypes");function qc(t,e){return e===sy.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(dr(n,e))return!0;return!1})}i(qc,"filterWalletsByCategory");var la={API_KEY:pr};function Mt(t){return la[t]||""}i(Mt,"getConfig");function Gc(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),la=e,la}i(Gc,"initConfig");var Vc=20,Kc=25,ca="theme-widget",pa=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Lt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Lt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),ua=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),jc=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Cr,xt=i(()=>Cr||(Cr=new fy(Mt("API_KEY"),Mt("BASE_URL")),Cr),"httpService");function kr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Ao(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(c=>c===s.swapperGroup)),l&&s.types.map(c=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:c,selected:!e.includes(s.swapperGroup)})})}}),n}i(kr,"getUniqueSwappersGroups");function Xc(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Xc,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function Wo(t,e){return e?.[t]==="enabled"}i(Wo,"isRoutingEnabled");var Yc=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Zc=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 c=lr({config:a}),p=r;return c.length>0&&(p=p.filter(u=>c.includes(u.name))),p.filter(u=>Cc.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(c=>!(s.length>0&&!s.includes(c.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),c=e()._blockchainsMapByName;if(!o||!o.type)return l;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=Eo.get(u);d?.length||(d=sn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Eo.set(u,d)),d=Yc(d,s,a.features);let h=e().blockchains({type:o.type});return d.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!h.some(m=>m.name===g.blockchain)?!1:o.searchFor?!!(Je(g.symbol,o.searchFor)||Je(g.address||"",o.searchFor)||Je(g.name||"",o.searchFor)):!0).sort((g,m)=>{let C=e().isTokenPinned(g,o.type),S=e().isTokenPinned(m,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let N=o.getBalanceFor(g),D=o.getBalanceFor(m),w=Fc(N,D);if(w!==0)return w}let k=c.get(g.blockchain),T=c.get(m.blockchain),v=ta(g,k),b=ta(m,T);if(v!==b)return v?-1:1;if(g.isPopular!==m.isPopular)return g.isPopular?-1:1;if(o.searchFor){let N=Wc(g,m,o.searchFor);if(N)return N}return g.isSecondaryCoin!==m.isSecondaryCoin?g.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=>Lt(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(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort(Xc)},fetch:async()=>{try{let{routing:o}=e().config,n=Wo("enableCentralizedSwappers",o),r=await xt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],p=r.popularTokens,u=r.swappers.filter(f=>f.enabled),d=new Set;r.tokens.forEach(f=>{d.add(f.blockchain),c.push(f)}),r.blockchains.sort((f,g)=>f.sort-g.sort).forEach(f=>{f.enabled&&d.has(f.name)&&a.set(f.name,f)}),c.forEach(f=>{let g=lt(f);l[f.blockchain]||(l[f.blockchain]=[]),s.set(g,f),l[f.blockchain].push(g)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as gy,Catalonia as hy,Chinese as Jc,Denmark as yy,English as Sy,Finland as Cy,French as ky,German as Ty,Greece as vy,Hungary as wy,India as by,Indonesian as xy,Italian as Ey,Japanese as Iy,Korea as Ay,Lithuania as Ny,Malay as Wy,Netherlands as By,Pakistan as Ly,Philippines as My,Poland as Py,Portuguese as _y,Russian as Dy,SaudiArabia as $y,Serbia as Fy,Slovakia as Oy,SouthAfrica as Uy,Spanish as zy,Swahili as Qy,Swedish as Hy,Thai as qy,Turkish as Gy,Ukrainian as Vy,Vietnamese as Ky}from"@rango-dev/ui";var Rc=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:Uy},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:$y},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:gy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:hy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Jc},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Jc},{title:"Danish",label:"Dansk",local:"da",SVGFlag:yy},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:By},{title:"English",label:"English",local:"en",SVGFlag:Sy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:My},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:Cy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ky},{title:"German",label:"Deutsch",local:"de",SVGFlag:Ty},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:vy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:by},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:wy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:xy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:Ey},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Iy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:Ay},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:Ny},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Wy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Py},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:_y},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Dy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Fy},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Oy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:zy},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Qy},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Hy},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:qy},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Gy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Vy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:Ly},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Ky}],Bo="en";var ep=[.5,1,3],tp=1,op=5,np=100,rp=0;var ip=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:tp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let c=s===o,p=l<=9;return c&&p}))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=Ao(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),c=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...c&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Bo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||Bo}})},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=lr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import ya from"bignumber.js";import jy from"mitt";var ye=jy(),Xy={on:ye.on,off:ye.off};import{WidgetEvents as ap}from"@rango-dev/queue-manager-rango-preset";var ma=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ma||{}),fa=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(fa||{}),ga=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ga||{}),Lo=(a=>(a[a.RouteEvent=ap.RouteEvent]="RouteEvent",a[a.StepEvent=ap.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Lo||{});var sp=i(t=>(e,o,n)=>t(i((...a)=>{e(s=>({...s,lastUpdatedAt:+new Date})),e(...a)},"modifedSet"),o,n),"keepLastUpdated");import Yy from"bignumber.js";function mn(t){return`${t.blockchain}${no}${t.address}${no}${t.symbol}`}i(mn,"createAssetKey");function ha(t,e){return`${mn(e)}${no}${t}`}i(ha,"createBalanceKey");function fn(t){let[e,o,n]=t.split(no);return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(fn,"extractAssetFromBalanceKey");function lp(t,e){let o={};return t.balances?.forEach(n=>{let r=ha(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,c=l?new Yy(l??ce).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:c};o[r]=p}),o}i(lp,"createBalanceStateForNewAccount");function cp(t,e){for(let o in e){let n=fn(o),r=mn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(cp,"updateAggregatedBalanceStateForNewAccount");function pp(t,e){let o=fn(e),n=mn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(pp,"removeBalanceFromAggregatedBalance");function Zy(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(Zy,"matchWalletDetailsWithConnectedWallet");var Jy=Mc(),up=sp((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>dn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>dn(s,a))?{...a,loading:!1,error:!1,explorerUrl:Zy(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>dn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>dn(s,l)));if(a.length>0){let s=a.map(l=>{let c=!r.some(p=>p.chain===l.chain&&p.selected&&p.walletType!==l.walletType);return{address:l.address,chain:l.chain,explorerUrl:null,walletType:l.walletType,selected:c,namespace:n,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(p=>!s.some(u=>u.walletType===p.walletType&&u.chain===p.chain)),...s]}))}},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,n)=>{ye.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o,n),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(p=>p.walletType===o);e().connectedWallets.forEach(p=>{p.walletType!==o&&(r=r.filter(u=>!(u.chain===p.chain&&u.address===p.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(p=>n.chains?.includes(p.chain))),n?.namespaces&&n.namespaces.length>0&&(r=r.filter(p=>p.namespace?n.namespaces?.includes(p.namespace):!1));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(p=>{let u=fn(p);!!r.find(h=>ha(h.address,{address:u.address,blockchain:h.chain,symbol:u.symbol})===p)?s=pp(s,p):a[p]=l[p]}),t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(ye.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(l=>a.includes(l.chain)?(a=a.filter(c=>c!==l.chain),{...l,selected:!0}):l);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(c=>({address:c.address,blockchain:c.chain})),s;try{s=await xt().getWalletsDetails(a)}catch(c){throw e().setConnectedWalletHasError(o),new Error("Request for fetching balances failed.",{cause:c})}let l=s.wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let d=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));d.length>0&&e().fetchBalances(d,{retryOnFailedBalances:!1})}let p={},u=e()._aggregatedBalances;l.forEach(d=>{if(d.failed||(e().removeBalancesForWallet(r,{chains:[d.blockChain]}),!e().connectedWallets.find(f=>f.walletType===r&&f.address===d.address&&f.chain===d.blockChain)))return;let h=lp(d,e);u=cp(u,h),p={...p,...h}}),t(d=>({_balances:{...d._balances,...p},_aggregatedBalances:u})),e().setConnectedWalletRetrievedData(o,l)}else throw e().setConnectedWalletHasError(o),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 c=a[0];return n[c]}let l=n[a[0]];return a.forEach(c=>{let p=n[c],u=new ya(p.amount),d=new ya(l.amount);u.isGreaterThan(d)&&(l=p)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,p]=l.split(no);return p===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>Jy(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,l)=>{let c=r[l],p=fn(l);if(p.blockchain===n.chain){let u=e().findToken(p),d=c.amount?new ya(c.amount).shiftedBy(-c.decimals):ce;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:c.amount,decimal:c.decimals,amount:d.toString(),logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function dp(t){return Ry()(eS((...e)=>({...up(...e),...Zc(...e),...ip(...e),...yc(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(dp,"createAppStore");var mp=oS(null);function y(){let t=nS(mp);if(rS(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function fp(t){let e=iS();return e.current||(e.current=dp(t.config)),tS.createElement(mp.Provider,{value:e.current},t.children)}i(fp,"AppStoreProvider");function ft(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=aS(),s=y().blockchains(),{handleDisconnect:l}=Gt(),c=mc(n()),p=Dc(r,a,c,e);p=sS()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Oc(p),d=i(m=>!o.find(C=>C.walletType===m&&C.chain===e),"isExperimentalChainNotAdded"),h=cS(()=>{let m=p?.filter(C=>C.state===Sa.CONNECTING)||[];for(let C of m)l(C.type)},[Qc(p)]);pS(()=>()=>{h()},[]);let f=i(m=>{let C=m.find(k=>k.type===gn.DEFAULT);return!C||C.state===Sa.NOT_INSTALLED?!1:m.filter(k=>k.state!=Sa.NOT_INSTALLED&&![gn.DEFAULT,gn.WALLET_CONNECT_2,gn.LEDGER].includes(k.type)&&a(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((m,C,S)=>hr(S,C)&&d(m)&&!lS.includes(m)||m==gn.DEFAULT&&!f(p),"shouldExcludeWallet");return{list:u.filter(m=>!g(m.type,e??"",s)),terminateConnectingWallets:h}}i(ft,"useWalletList");import{Modal as fS}from"@rango-dev/ui";import gS from"react";import{create as mS}from"zustand";var gp="rango-widget";var hn=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(gp),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 dS=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=dS;var re=Mo(mS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,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})},setShowProfileBanner:o=>{t({showProfileBanner:o})}}))),ao=new hn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function J(t){let{watermark:e}=re();return gS.createElement(fS,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Ca}from"@lingui/core";import{Button as TS,Checkbox as vS,Divider as wS,Image as xp,ListItemButton as bS,MessageBox as xS,Radio as ES,RadioRoot as IS}from"@rango-dev/ui";import we,{useState as AS}from"react";import{css as hS,darkTheme as yp,IconButton as yS,styled as so}from"@rango-dev/ui";var Et=so(yS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${yp} &`]:{backgroundColor:"$neutral"}}}),Sp=so("div",{position:"absolute",background:"$secondary500",[`.${yp} &`]:{$$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}}),Cp=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"}}}}),kp=so("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Tp=so("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),vp=hS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Tr=so("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as SS,styled as vr}from"@rango-dev/ui";var wN=vr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Po=vr("div",{position:"relative"}),CS=SS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),_o=vr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${CS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),wr=vr("div",{"& img":{borderRadius:"50%"}});function wp(t,e){return t.find(o=>o.name===e)?.logo}i(wp,"getBlockchainLogo");import{styled as kS}from"@rango-dev/ui";var bp=kS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function yn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=AS([]),s=y().blockchains(),l=i(p=>{a(o?[p]:u=>u.includes(p)?u.filter(d=>d!==p):u.concat(p))},"onSelect"),c=i(p=>o?we.createElement(IS,{value:r?.[0]},p):we.createElement(we.Fragment,null,p),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(wS,{size:20}),we.createElement(xS,{type:"info",title:Ca.t("Select chain types"),description:Ca.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Po,null,we.createElement(Tr,null,we.createElement(xp,{src:n,size:45})),we.createElement(_o,null))}),we.createElement(bp,null,c(we.createElement(we.Fragment,null,e.needsNamespace?.data.map(p=>we.createElement(bS,{key:p.id,id:p.id,title:p.label,hasDivider:!0,style:{height:60},onClick:()=>l(p.value),start:we.createElement(xp,{src:wp(s,p.id),size:22}),end:o?we.createElement(ES,{value:p.value}):we.createElement(vS,{checked:r.includes(p.value)})}))))),we.createElement(TS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ca.t("Confirm")))}i(yn,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as BS,Divider as Ap,Image as LS,MessageBox as MS,Select as PS,TextField as _S}from"@rango-dev/ui";import Oe,{useEffect as DS,useState as Np}from"react";import{namespaces as NS}from"@rango-dev/wallets-shared";var br={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ka(t){let e=t?NS[t].derivationPaths:null;return e?[...e,br]:[]}i(ka,"getDerivationPaths");import{styled as Ep,Typography as WS}from"@rango-dev/ui";var Ip=Ep("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ta=Ep(WS,{paddingLeft:"$10"}),va={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Wp="0";function Sn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Np(null),[l,c]=Np(Wp),p=a===br.id,u=ka(o),d=i(({value:f})=>{let g=u?.find(m=>m.id===f);g&&(a===br.id&&Number.isNaN(Number(l))&&c(Wp),s(g.id))},"handleDerivationPathItemClick"),h=i(()=>{let f=u.find(g=>g.id===a);if(f)e(f.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return DS(()=>{s(ka(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(Ap,{size:20}),Oe.createElement(MS,{type:"info",title:Do.t("Select Derivation Path"),description:Do.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Po,null,Oe.createElement(wr,null,Oe.createElement(LS,{src:n,size:45})),Oe.createElement(_o,null))}),Oe.createElement(Ip,null,Oe.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),Oe.createElement(PS,{value:a||"",options:u.map(f=>({value:f.id,label:f.label})),variant:"filled",handleItemClick:d,styles:{trigger:va}}),Oe.createElement(Ap,{size:20}),Oe.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},p?Do.t("Enter Path"):Do.t("Enter Index")),Oe.createElement(_S,{type:p?"text":"number",variant:"contained",value:l,onChange:f=>c(f.target.value),style:va})),Oe.createElement(BS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!u||!a||!l},Do.t("Confirm")))}i(Sn,"DerivationPath");import{i18n as $o}from"@lingui/core";import{Image as $S,MessageBox as wa,WalletState as FS}from"@rango-dev/ui";import{useWallets as OS}from"@rango-dev/wallets-react";import lo from"react";function ba(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=OS();return pn(a(n))===FS.CONNECTED?lo.createElement(wa,{type:"success",title:$o.t("Wallet Connected"),description:$o.t("Your wallet is connected, you can use it to swap.")}):o?lo.createElement(wa,{type:"error",title:$o.t("Failed to Connect"),description:o||$o.t("Your wallet is not connected. Please try again.")}):lo.createElement(wa,{type:"loading",title:$o.t("Connecting to your wallet"),description:$o.t("Click connect in your wallet popup."),icon:lo.createElement(Po,null,lo.createElement(wr,null,lo.createElement($S,{src:r,size:45})),lo.createElement(_o,null))})}i(ba,"ConnectStatus");import{i18n as xa}from"@lingui/core";import{Button as US,Divider as Bp,MessageBox as zS}from"@rango-dev/ui";import xr from"react";function Ea(t){let{displayName:e,onConfirm:o}=t;return xr.createElement(zS,{title:xa.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:xa.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},xr.createElement(Bp,{size:18}),xr.createElement(Bp,{size:32}),xr.createElement(US,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},xa.t("Confirm")))}i(Ea,"ExperimentalChain");function Lp(t,e){return t().status==="init"&&!!e}i(Lp,"isOnStatus");function Cn(t){return t().status==="namespace"}i(Cn,"isOnNamespace");function kn(t){return t().status==="derivationPath"}i(kn,"isOnDerivationPath");var GS=3e3,VS=300;function po(t){let e=qS(),[o,n]=Mp(!1),[r,a]=Mp(),s=i(k=>{a(k.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:c,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:h}=Gt(),f=i(k=>{u(t.wallet,k).then(S).catch(s)},"handleConfirmNamespaces"),g=i(k=>{if(!k)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(k).then(S).catch(s)},"handleDerivationPathConfirm"),m=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),S=i((k,T)=>{let v=k.status==="connected",b=["disconnected","disconnected-unhandled"].includes(k.status);v?(t.onConnect?.(),T||(e.current=setTimeout(m,GS))):b&&m()},"afterConnected");return HS(()=>{if(t.wallet){C();let k=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,k||n(!0)},VS)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(b=>{["namespace","derivation-path"].includes(b.status)||(k=!0),S(b,T)}).catch(s)}},[t.wallet]),co.createElement(J,{open:o,onClose:m,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:I()},Lp(d,t.wallet)&&co.createElement(co.Fragment,null,co.createElement(ba,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),co.createElement(QS,{direction:"vertical",size:32})),Cn(d)&&co.createElement(yn,{onConfirm:f,value:d().namespace}),kn(d)&&co.createElement(Sn,{onConfirm:g,value:d().derivationPath}))}i(po,"StatefulConnectModal");import{Provider as ZS}from"@rango-dev/wallets-react";import Er,{createContext as JS,useEffect as Fp,useMemo as RS,useRef as Op}from"react";import{useEffect as KS}from"react";function Pp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Pp,"hashProviders");function Ia(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return KS(()=>{o(),r()},[Pp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Ia,"useWalletProviders");import{legacyFormatAddressWithNetwork as jS,legacyReadAccountAddress as _p}from"@rango-dev/wallets-core/legacy";import{Events as uo}from"@rango-dev/wallets-react";import{isEvmBlockchain as XS}from"rango-sdk";function Dp(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=y(),{onConnectWalletHandler:l,onDisconnectWalletHandler:c}=t,p=s().filter(XS).map(m=>m.name),u=i((m,C)=>{let[S,,k,,T]=m,v=sa(S,k,p,C.supportedChainNames,T.isContractWallet);v.length&&e(v,T.namespace)},"onAccountsEvent"),d=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains);S&&u([m,C,S,k,T],{supportedChainNames:v})}if(C===uo.CONNECTED){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}C===uo.PROVIDER_DISCONNECTED&&(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),C===uo.NAMESPACE_DISCONNECTED&&n(m,S)},"handleUpdatesForHub"),h=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains),b=[],N=[];if(S?.forEach(w=>{let{network:x}=_p(w);p.includes(x)?b.push(w):N.push(w)}),r.filter(w=>w.walletType===m).map(w=>jS(w.address,w.chain)).length>0){if(b.length>0){let w=sa(m,b,p,v,T.isContractWallet);a(m,{chains:w.map(x=>x.chain)})}N.length>0&&a(m,{chains:N.map(w=>{let{network:x}=_p(w);return x})})}S?u([m,C,S,k,T],{supportedChainNames:v}):(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}if(C===uo.ACCOUNTS&&k.connected){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForLegacy"),f=i((m,C,S,k,T)=>{if(C===uo.NETWORK&&k.network){let v=`${m}-${k.network}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,C,S,k,T)=>{T.isHub?d(m,C,S,k,T):h(m,C,S,k,T),f(m,C,S,k,T)},"handler")}}i(Dp,"useUpdates");import{LegacyEvents as YS}from"@rango-dev/wallets-core/legacy";function $p(t,e){let[o,n,r,a,s]=e;n!==YS.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i($p,"propagateEvents");var Ir=JS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function eC(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),s=y().config,l={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:c}=Ia(s.wallets,l),p=Op(),u=Op(),{handler:d}=Dp({onConnectWalletHandler:p,onDisconnectWalletHandler:u});Fp(()=>{n().catch(console.log)},[]),Fp(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let h=re.use.isActiveTab(),f=RS(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return Er.createElement(Ir.Provider,{value:f},Er.createElement(ZS,{allBlockChains:a,providers:c,onUpdateState:(g,m,C,S,k)=>{let T=[g,m,C,S,k];d(...T),t.onUpdateState&&$p(t.onUpdateState,T)},autoConnect:!!h,configs:{wallets:s.wallets}},t.children))}i(eC,"Main");function Ar(t){let{config:e,...o}=t;return Er.createElement(fp,{config:e},Er.createElement(eC,{...o,config:e}))}i(Ar,"WidgetWallets");import Ji from"react";import tC,{Fragment as oC}from"react";import{MemoryRouter as nC,useInRouterContext as rC}from"react-router";function Up({children:t}){let o=rC()?oC:nC;return tC.createElement(o,null,t)}i(Up,"AppRouter");import{I18nManager as zE}from"@rango-dev/ui";import tc from"react";import _e from"react";import{useRoutes as IE}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 Oo,useRef as $r}from"react";import Ke from"bignumber.js";import{create as sC}from"zustand";import{subscribeWithSelector as lC}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as FB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as _r}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 zp(t){switch(t.type){case 0:return t.diagnosisMessage??R().noResultError.title;case 1:return R().genericServerError;default:return""}}i(zp,"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 Aa(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(Aa,"getFeeLabel");var Na=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Qp=100,Hp=30,qp=15,Gp=60;var Vp=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Kp=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as aC}from"@rango-dev/queue-manager-rango-preset";import bB from"bignumber.js";function Xp(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(Xp,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Br(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=aC(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=an(a?a.toBlockchain:n.fromBlockchain,e),c=an(r.toBlockchain,e),p=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:p,toBlockchain:c,toToken:u,inputAmount:d}}i(Br,"createRetryQuote");function Fo(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=Tn(o),s=ct(o);if(o&&a&&s){let p=Pt(a.toString(),s.toString());if(!!p&&eu(a,p)){let d=Mr(o?.swaps,n),h=_t(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:h}}}if(e&&nu(e,o))return{type:4,usdValueChange:B(ct(o)?.minus(ct(e)??0).toString()??"0",null,2),percentageChange:B(Pt(ct(e)??"1",ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Pr(o.swaps),c=r>op;if(ou(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:tu(o,r),minRequiredSlippage:l};return null}i(Fo,"generateQuoteWarnings");function Yp(t){return![4].includes(t.type)}i(Yp,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Wa(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Zp=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"),Lr=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),c=n.requestId.toLowerCase();return l.localeCompare(c)}),"sortQuotesBy"),Jp=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"),Rp=i(t=>{let e=i((o,n)=>{let r=Na.indexOf(o.value),a=Na.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function eu(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Vp.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(eu,"hasHighValueLoss");function ru(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(ru,"hasLimitError");function iu(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,p=l.fromAmountMaxValue?new Ue(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?c?.gte(l.fromAmount)||p?.lte(l.fromAmount):c?.gt(l.fromAmount)||p?.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:B(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:B(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:B(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:B(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(iu,"getLimitErrorMessage");function au(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=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}:c?{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(au,"getSwapButtonState");function Ba(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ce))&&e&&e!=="0"&&n!==0)}i(Ba,"canComputePriceImpact");function La(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 Ue(r.amount).multipliedBy(a||0))}return o}i(La,"getUsdFeeOfStep");function Mr(t,e){return t.reduce((o,n)=>o.plus(La(n,e)),ce)}i(Mr,"getTotalFeeInUsd");function Ma(t){let e=ce;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(Ma,"getUsdFee");function su(t){return t.reduce((e,o)=>e.plus(Ma(o)),ce)}i(su,"getTotalFeesInUsd");function lu(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(lu,"getFeesGroup");function cu(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(cu,"checkSlippageErrors");function tu(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(tu,"checkSlippageWarnings");function Pr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Pr,"getMinRequiredSlippage");function ou(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(ou,"hasProperSlippage");function pu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:h,destination:f}=t,g=a?.reduce((S,k)=>(S[k.chain]=k.address,S),{}),m=[];return r?.forEach(S=>{m.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:d??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:m,selectedWallets:g??{},slippage:p.toString(),...f&&{destination:f},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(pu,"createQuoteRequestBody");function uu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(uu,"getWalletsForNewSwap");function Tn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(Tn,"getUsdInputFrom");function ct(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(ct,"getUsdOutputFrom");function Wa(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy(Qp).toNumber()}i(Wa,"getPercentageChange");function nu(t,e){let o=Tn(t),n=ct(t),r=ct(e);if(!o||!n||!r)return!1;let a=Wa(n.toString(),r.toString());return Kp.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(nu,"isOutputAmountChangedExcessively");function du(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=>Xp(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=B(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=B(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=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:p,symbol:l,reason:u,currentAmount:c,blockchain:st(s.asset.blockchain,o)}})})}i(du,"generateBalanceWarnings");function vn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==_r.NetworkChanged}i(vn,"isNetworkStatusInWarningState");function mu(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),vn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case _r.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case _r.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case _r.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(mu,"getSwapMessages");function fu(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(fu,"getLastConvertedTokenInFailedSwap");function gu(t){return t.status==="failed"}i(gu,"shouldRetrySwap");function hu(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),c=s.every(d=>r.some(h=>h.chain===d)),p=l.every(d=>r.some(h=>h.chain===d)),u=o&&a?Io(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!u||!p)}i(hu,"isConfirmSwapDisabled");function yu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(yu,"isTokensIdentical");var Dr=i((t,e)=>t?.usdPrice?new Ke(e||ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Mo(sC()(lC(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=ce,a=o.inputUsdValue;return cn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=Tn(e)??ce,r=ct(e)??ce),{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:Dr(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:Dr(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:Dr(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?Dr(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})})))),Su=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ye.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&&ye.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 Cu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:c,toBlockchain:p}=O(),u=y().config,d=y().fetchStatus,h=y().blockchains(),f=y().tokens(),{findToken:g}=y(),{setAffiliateRef:m,setAffiliatePercent:C,setAffiliateWallets:S}=y(),k=u?.from?.tokens,T=u?.from?.blockchains,v=u?.to?.tokens,b=u?.to?.blockchains,N=$r(void 0),D=$r(void 0),w=$r(void 0),x=$r(void 0);Oo(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Oo(()=>{if(d==="success"){r();let E=h.find(L=>L.name===u?.from?.blockchain),A=u?.from?.token,M=A&&g(A);(E||!E&&w.current)&&n(E??null),M?a({token:M,meta:{blockchains:h,tokens:f}}):!M&&N.current&&a({token:null}),w.current=u?.from?.blockchain,N.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,d]),Oo(()=>{pa(s,k)&&a({token:null}),ua(c,T)&&n(null)},[k,T]),Oo(()=>{pa(l,v)&&a({token:null}),ua(p,b)&&o(null)},[v,b]),Oo(()=>{if(d==="success"){r();let E=h.find(L=>L.name===u?.to?.blockchain),A=u?.to?.token,M=A&&g(A);(E||!E&&x.current)&&o(E??null),M?e({token:M,meta:{blockchains:h,tokens:f}}):!M&&D.current&&e({token:null}),x.current=u?.to?.blockchain,D.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),Oo(()=>{m(u?.affiliate?.ref??null),C(u?.affiliate?.percent??null),S(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(Cu,"useSyncStoresWithConfig");import{useEffect as Da,useRef as cC}from"react";import{useInRouterContext as pC,useLocation as uC,useSearchParams as dC}from"react-router-dom";function Pa(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Pa,"convertTokenSearchParamToAsset");function _a(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(_a,"tokenToSearchParam");function Fa(){let t=uC(),[e,o]=dC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:h}=O(),f=y().fetchStatus,g=y().blockchains(),m=y().tokens(),C=pC(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=cC(),{findToken:b}=y(),N=i(()=>{let w={};for(let[K,se]of e.entries())K.startsWith("utm_")&&(w[K]=se);let x=e.get("fromAmount"),E=e.get("fromBlockchain"),A=e.get("fromToken"),M=e.get("toBlockchain"),L=e.get("toToken"),X=e.get("autoConnect"),oe=e.get("clientUrl"),Y=e.get("liquiditySources"),W=e.get("blockchain");return{fromAmount:x,fromBlockchain:E,fromToken:A,toBlockchain:M,toToken:L,autoConnect:X,clientUrl:oe,liquiditySources:Y,utmQueryParams:w,blockchain:W}},"getUrlSearchParams"),D=i(w=>{for(let x in w)w[x]||delete w[x];o(w,{replace:!0})},"updateUrlSearchParams");Da(()=>{let{autoConnect:w,clientUrl:x,utmQueryParams:E,blockchain:A}=N();C&&f==="success"&&D({fromBlockchain:n?.name,fromToken:_a(a),toBlockchain:r?.name,toToken:_a(s),fromAmount:l,autoConnect:w??void 0,clientUrl:x??void 0,blockchain:A??void 0,liquiditySources:T?v.current:void 0,...E})},[t.pathname,l,n,a,r,s,T]),Da(()=>{if(!C)return;let w=N();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&h(w.fromAmount),f==="success"){let x=g.find(L=>L.name===w.fromBlockchain),E=w.fromToken&&x?b(Pa(w.fromToken,x)):void 0,A=g.find(L=>L.name===w.toBlockchain),M=w.toToken&&A?b(Pa(w.toToken,A)):void 0;x&&(c(x),E&&u({token:E,meta:{blockchains:g,tokens:m}})),A&&(p(A),M&&d({token:M,meta:{blockchains:g,tokens:m}}))}},[f]),Da(()=>{let{clientUrl:w,liquiditySources:x}=N();S("clientUrl",w||void 0),k("liquiditySources",x?.split(",")??void 0)},[])}i(Fa,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as Ik,Button as ed,darkTheme as Ak,Divider as xn,DoneIcon as Nk,MessageBox as Wk,styled as Bk,TextField as Lk,Typography as Mk}from"@rango-dev/ui";import Se,{useEffect as Pk,useState as Gr}from"react";import{useNavigate as _k,useSearchParams as Dk}from"react-router-dom";import{ChevronRightIcon as mC,Divider as bu,Image as fC,Typography as xu}from"@rango-dev/ui";import ht from"react";import{darkTheme as ku,styled as Oa}from"@rango-dev/ui";var Tu=Oa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${ku} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${ku} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),vu=Oa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),wu=Oa("div",{display:"flex"});function Ua(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(vu,null,ht.createElement(xu,{size:"large",variant:"label"},n),ht.createElement(bu,{size:10}),ht.createElement(Tu,{onClick:s?void 0:e,disabled:s},ht.createElement(wu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(fC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(bu,{size:4,direction:"horizontal"})),ht.createElement(xu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(mC,{size:12,color:"black"})))}i(Ua,"BlockchainSelectorButton");import{i18n as Qa}from"@lingui/core";import{Button as gC,Divider as wn,ExternalLinkIcon as hC,Image as yC,Typography as zo}from"@rango-dev/ui";import We from"react";function Eu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Eu,"generateExplorerLink");import{darkTheme as Uo,styled as Iu}from"@rango-dev/ui";var za=Iu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Au=Iu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Uo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}}});function Ha(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=Eu(n.address,a);return We.createElement(J,{open:e,dismissible:!0,onClose:o,container:I()},We.createElement(Au,null,We.createElement(yC,{src:n.image,size:45,type:"circular"}),We.createElement(zo,{variant:"title",size:"medium"},n.name),We.createElement(zo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),We.createElement(wn,{size:4}),We.createElement(zo,{variant:"body",size:"medium"},s?We.createElement(za,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,We.createElement(hC,{size:12,color:"gray"})):We.createElement(za,null,n.address)),We.createElement(wn,{size:4}),n.coinSource&&We.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},Qa.t("via")," ",We.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),We.createElement(wn,{size:"32"}),We.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},Qa.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),We.createElement(wn,{size:40}),We.createElement(wn,{size:10}),We.createElement(gC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Qa.t("Import")))}i(Ha,"CustomTokenModal");import{useManager as kk}from"@rango-dev/queue-manager-react";import{BottomLogo as Tk,Divider as Xu,Header as vk}from"@rango-dev/ui";import xe,{useEffect as ps,useMemo as wk,useRef as Yu,useState as bk}from"react";import{useRef as SC}from"react";function Fr(){return window.self!==window.top}i(Fr,"isAppLoadedIntoIframe");function qa(){let t=SC(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 c of l)n({type:"widget_height",data:{height:c.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(qa,"useIframe");import{useNavigate as CC}from"react-router-dom";function je(){let t=CC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as Za,darkTheme as MC,lightTheme as PC}from"@rango-dev/ui";import{useEffect as _C,useState as DC}from"react";import{theme as BC,darkColors as LC}from"@rango-dev/ui";import Xa from"react";function kC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(kC,"expandShortHexColor");function TC(t){return/[0-9]+$/.test(t)}i(TC,"isOverridingColor");function vC(t,e){return t.padStart(e,"0")}i(vC,"pad");function Ga(t){let e=Math.min(Math.max(Math.round(t),0),255);return vC(e.toString(16),2)}i(Ga,"intToHex");function wC(t){return`#${Ga(t.red)}${Ga(t.green)}${Ga(t.blue)}`}i(wC,"rgbToHex");function bC(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(bC,"hexToRGB");function xC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(xC,"generateShade");function EC(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(EC,"generateTint");function IC(t){return Nu(t,xC)}i(IC,"calculateShades");function AC(t){return Nu(t,EC)}i(AC,"calculateTints");function Nu(t,e){let o=bC(t),n=[];for(let r=1;r<9;r++)n.push(wC(e(o,r)));return n}i(Nu,"calculateColors");function Va(t,e,o){let a=AC(t).reverse().concat(t),s=IC(t),l=a.concat(s),c={},p=l.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50;c[`${e}${d}`]=l[u]}return c}i(Va,"createTintsAndShades");function Ka(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)&&!TC(r)){let c=kC(a);Object.assign(n,Va(c,r,s))}}return{...n,...e}}i(Ka,"expandToGenerateThemeColors");var Wu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),NC=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"),WC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),ja=i(t=>NC(WC(5381,JSON.stringify(t))>>>0),"toHash");function Ya(t){let e=BC.colors,o={...e,...LC},n,r;if(t?.light){let s={colors:Ka(e,t.light)};n={id:`${ca}-light-${ja(s)}`,tokens:s}}if(t?.dark){let s={colors:Ka(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ca}-dark-${ja(s)}`,tokens:s}}return{light:n,dark:r}}i(Ya,"customizedThemeTokens");function Bu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Xa.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Xa.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Xa.cloneElement(e,{key:l}))}}),o}i(Bu,"joinList");function Lu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Lu,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=wc,borderRadius:n=Vc,secondaryBorderRadius:r=Kc}=t,[a,s]=DC(Lu()?"dark":"light"),{theme:l}=y(),{dark:c,light:p}=Ya(e),u=Za({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,PC.className],h=[u.className,MC.className];if(p){let g=Za(p.id,p.tokens);d.push(g.className)}if(c){let g=Za(c.id,c.tokens);h.push(g.className)}return _C(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Lu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=d.join(" "),m=h.join(" ");return l==="auto"?a==="dark"?m:g:l==="dark"?m:g},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var pt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Mu}from"@lingui/core";import{Alert as $C,Button as FC}from"@rango-dev/ui";import Pu from"react";function Ja(t){return Pu.createElement($C,{action:Pu.createElement(FC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Mu.t("Activate this tab")),type:"warning",variant:"alarm",title:Mu.t("Another tab is open and handles transactions.")})}i(Ja,"ActivateTabAlert");import{i18n as Ra}from"@lingui/core";import{Button as OC,Divider as UC,MessageBox as zC}from"@rango-dev/ui";import Or from"react";function es(t){let{open:e,onClose:o,onConfirm:n}=t;return Or.createElement(J,{open:e,dismissible:!0,onClose:o,container:I()},Or.createElement(zC,{title:Ra.t("Activate current tab"),type:"warning",description:Ra.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(UC,{size:20}),Or.createElement(OC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Ra.t("Confirm"))))}i(es,"ActivateTabModal");import{ChevronLeftIcon as QC}from"@rango-dev/ui";import _u from"react";function ts(t){return _u.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},_u.createElement(QC,{color:"black",size:16}))}i(ts,"BackButton");import{i18n as HC}from"@lingui/core";import{Button as qC,Typography as GC}from"@rango-dev/ui";import os from"react";function ns(t){return os.createElement(Vt,null,os.createElement(qC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},os.createElement(GC,{variant:"label",size:"medium",color:"error500"},HC.t("Cancel"))))}i(ns,"CancelButton");import{i18n as VC}from"@lingui/core";import{Image as KC,Tooltip as jC,WalletIcon as XC}from"@rango-dev/ui";import fo from"react";function rs(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?fo.createElement("div",{className:vp()},o.map(r=>fo.createElement(Tr,{key:r.title},fo.createElement(KC,{src:r.image,size:14})))):VC.t("Connect Wallet");return fo.createElement(jC,{container:t.container,side:"bottom",content:n},fo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&fo.createElement(Sp,null),fo.createElement(XC,{size:18,color:"black"})))}i(rs,"WalletButton");import{i18n as zr}from"@lingui/core";import{NotificationsIcon as uk,Popover as dk,SettingsIcon as mk,Tooltip as Qr,TransactionIcon as fk}from"@rango-dev/ui";import Be from"react";import{Notifications as RC}from"@rango-dev/ui";import ek from"react";import{useNavigate as tk}from"react-router-dom";import{create as YC}from"zustand";import{persist as ZC,subscribeWithSelector as JC}from"zustand/middleware";var be=Mo(YC()(ZC(JC((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(c=>c.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(c=>c.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 is(){let t=tk(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return ek.createElement(RC,{list:n,getBlockchainImage:l=>fc(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(is,"NotificationContent");import{useManager as ok}from"@rango-dev/queue-manager-react";import{InProgressIcon as nk}from"@rango-dev/ui";import Du from"react";var rk=i(()=>{let{manager:t}=ok();return pt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Du.createElement(Tp,null,Du.createElement(nk,{color:"info",size:6})):null},"InProgressTransactionBadge"),$u=rk;import{EventSeverity as ik}from"@rango-dev/queue-manager-rango-preset";import{Typography as ak}from"@rango-dev/ui";import Fu from"react";function Ou(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===ik.WARNING);return o?Fu.createElement(Cp,{isSever:n},Fu.createElement(ak,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Ou,"NotificationsBadge");import{RefreshProgressButton as sk}from"@rango-dev/ui";import as,{useEffect as lk,useState as Uu}from"react";var ck=1e3,zu=60,pk=100;function Ur({onClick:t}){let[e,o]=Uu(0),[n,r]=Uu(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");lk(()=>{let c;return t?c=window.setInterval(()=>{o(p=>p+1),e===zu&&l()},ck):s(c),document.addEventListener("visibilitychange",()=>a(c)),()=>{document.removeEventListener("visibilitychange",()=>a(c)),c&&clearInterval(c)}},[e,t]);let s=i(c=>{c&&clearInterval(c),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return as.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},as.createElement(kp,{onTransitionEnd:()=>r(!1),isRefetched:n},as.createElement(sk,{size:22,color:t?"black":"gray",progress:e/zu*pk})))}i(Ur,"RefreshButton");function go(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 Be.createElement(Be.Fragment,null,!r.includes("refresh")&&Be.createElement(Qr,{container:a||I(),side:"top",content:zr.t("Refresh")},Be.createElement(Ur,{onClick:e})),!l&&Be.createElement(dk,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:I(),content:Be.createElement(is,null)},Be.createElement("div",null,Be.createElement(Qr,{container:I(),side:"top",content:zr.t("Notifications")},Be.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Be.createElement(uk,{size:18,color:"black"}),Be.createElement(Ou,null))))),!r.includes("settings")&&Be.createElement(Qr,{container:I(),side:"top",content:zr.t("Settings")},Be.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Be.createElement(mk,{size:18,color:"black"}))),!r.includes("history")&&Be.createElement(Qr,{container:I(),side:"top",content:zr.t("History")},Be.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Be.createElement(fk,{size:18,color:"black"}),Be.createElement($u,null))))}i(go,"HeaderButtons");import{i18n as ss}from"@lingui/core";import{Divider as Hu,MessageBox as yk,RefreshIcon as Sk}from"@rango-dev/ui";import Ho from"react";import{Button as gk,styled as hk}from"@rango-dev/ui";var Qu=hk(gk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function ls(t){let{open:e,onClose:o}=t;return Ho.createElement(J,{open:e,dismissible:!0,onClose:o,container:I()},Ho.createElement(yk,{title:ss.t("Something went wrong"),type:"error",description:ss.t("Something went wrong. Please refresh the app.")},Ho.createElement(Hu,{size:30}),Ho.createElement(Qu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Ho.createElement(Sk,{size:20,color:"primary"}),Ho.createElement(Hu,{size:4,direction:"horizontal"}),ss.t("Refresh"))))}i(ls,"RefreshModal");function cs(t){let e=t.target;if(e){let o=e.scrollTop,n=I();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(cs,"onScrollContentAttachStatusToContainer");import{css as Ck,styled as Hr}from"@rango-dev/ui";var qu="700px",qr=Ck({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Gu=Hr("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:qu},fixed:{height:qu}},showBanner:{true:{overflow:"visible"}}}}),Vu=Hr("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Ku=Hr("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"}}}),ju=Hr("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)"});function te(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=qa(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c,config:{__UNSTABLE_OR_INTERNAL__:p}}=y(),[u,d]=bk(!1),{config:{features:h,theme:f}}=y(),{watermark:g}=re(),m=g==="FULL",{activeTheme:C}=Qo(f||{}),S=Ve("connectWalletButton",h),{isActiveTab:k,tabManagerInitiated:T,showActivateTabModal:v,setShowActivateTabModal:b,activateCurrentTab:N}=re(),D=je(),{manager:w}=kk(),E=pt(w).map(({swap:W})=>W).some(W=>W.status==="running"),A=i(()=>N(ao.forceClaim,E),"onActivateTab"),M=i(()=>{r.onWallet?.()},"onConnectWallet"),L=typeof r.hasBackButton>"u"||r.hasBackButton,X=Yu(null),oe=Yu(null),Y=wk(()=>{let W=(p?.swapBoxBanner?.routes?.length??0)===0,K=!!p?.swapBoxBanner?.routes?.some(se=>location.pathname.endsWith(se));return p?.swapBoxBanner&&(W||K)},[p?.swapBoxBanner?.routes?.length,location.pathname]);return ps(()=>(Fr()&&oe.current&&e(oe.current),()=>{o()}),[]),ps(()=>(X.current?.addEventListener("scroll",cs),()=>{X.current?.removeEventListener("scroll",cs)}),[]),ps(()=>{d(l==="failed")},[l]),xe.createElement(Gu,{height:s,id:De.SWAP_BOX_ID,className:`${C()} ${qr()}`,ref:oe,showBanner:Y},xe.createElement(vk,{prefix:L?xe.createElement(ts,{onClick:()=>{D(),r.onBack?.()}}):null,title:r.title,suffix:xe.createElement(xe.Fragment,null,r.suffix,r.onWallet&&!S&&xe.createElement(rs,{container:I(),onClick:M,isConnected:!!c?.length}),r.onCancel&&xe.createElement(ns,{onClick:r.onCancel}))}),xe.createElement(Vu,{ref:X},n),xe.createElement(es,{open:v,onClose:()=>b(!1),onConfirm:A}),xe.createElement(Ku,null,xe.createElement("div",{className:"footer__content"},T&&!k&&xe.createElement("div",{className:"footer__alert"},xe.createElement(Ja,{onActivateTab:A}),xe.createElement(Xu,{size:10})),a),xe.createElement(Xu,{size:12}),xe.createElement("div",{className:`footer__logo ${m?"logo__show":"logo__hidden"}`},xe.createElement(Tk,null))),Y&&xe.createElement(ju,null,p?.swapBoxBanner?.element),xe.createElement(ls,{open:u,onClose:()=>d(!1)}))}i(te,"Layout");import{styled as xk}from"@rango-dev/ui";var Zu="$20 $20 $10 $20",bn=xk("div",{padding:Zu,overflowY:"auto",flexGrow:1});import{styled as Ek}from"@rango-dev/ui";var ie=Ek("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 Ju}from"react";function Ru(){let[t,e]=Ju(!1),[o,n]=Ju(void 0),{findToken:r}=y(),a=y().customTokens();function s(c,p){switch(c){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:p}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:c,tokenAddress:p})=>{e(!0);try{if(a.some(g=>g.address?.toLowerCase()===p.toLowerCase())){let g=s("duplicated");n(g);return}let d=await xt().getCustomToken({blockchain:c,address:p});if(!d||!d.token||d.error){let g=s("not-found",c);n(g);return}let h=d.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let g=s("token-exist");n(g);return}return h}catch(u){if(u?.code==="ERR_BAD_REQUEST"){let d=s("not-found",c);n(d);return}throw n(void 0),new Error(u.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Ru,"useFetchCustomToken");var $k=Bk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${Ak} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),Fk=1e3;function td(){let t=_k(),[e]=Dk(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=an(a,r),[l,c]=Gr(""),[p,u]=Gr(!1),[d,h]=Gr(),{fetchCustomToken:f,loading:g,error:m}=Ru(),[C,S]=Gr(""),k=!!s&&Io(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let D=await f({blockchain:a,tokenAddress:l});S(""),D&&h(D)}catch(D){D.message==="Failed to fetch"&&(S(It.t("Network Error")),u(!0))}},"getCustomToken"),b=i(()=>{m&&c(""),u(!1)},"closeErrorModal"),N=i(async()=>{C&&setTimeout(async()=>{await v()},Fk),b()},"handleErrorModalButtonClick");return Pk(()=>{m&&u(!0)},[m]),Se.createElement(te,{header:{title:It.t("Add Custom Token")}},Se.createElement(ie,null,Se.createElement($k,null,Se.createElement("div",null,Se.createElement(Ua,{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")}),Se.createElement(xn,{size:"24"}),Se.createElement(Mk,{size:"large",variant:"label"},It.t("Enter Address")),Se.createElement(xn,{size:10}),Se.createElement(Lk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&Se.createElement(Nk,{color:"success",size:12}),onChange:D=>c(D.target.value)}),!k&&!!l&&Se.createElement(Se.Fragment,null,Se.createElement(xn,{size:4}),Se.createElement(Ik,{type:"error",variant:"alarm",title:"Invalid Address"}))),Se.createElement(ed,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:g,size:"large",onClick:v},It.t("Import"))),Se.createElement(J,{open:p,dismissible:!0,onClose:b,container:I()},Se.createElement(Wk,{title:m?.title||C,type:"error",description:m?.message||It.t("Failed Network, Please retry.")},Se.createElement(xn,{size:40}),Se.createElement(xn,{size:10}),Se.createElement(ed,{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&&d&&Se.createElement(Ha,{blockchain:s,token:d,onSubmitClick:()=>{d&&(n(d),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!d})))}i(td,"AddCustomTokenPage");import{i18n as Us}from"@lingui/core";import{useManager as Tv}from"@rango-dev/queue-manager-react";import{Alert as vv,Button as wv,css as Qs,Divider as zs,IconButton as Xm,styled as bv,Typography as xv,WalletIcon as Ev}from"@rango-dev/ui";import Me,{useEffect as Ci,useLayoutEffect as Iv,useRef as Av,useState as Fn}from"react";import{useNavigate as Nv}from"react-router-dom";import{i18n as ho}from"@lingui/core";import{Alert as cT,BalanceErrors as pT,Button as Nd,ChevronLeftIcon as uT,Divider as Ss,MessageBox as dT,Typography as Cs}from"@rango-dev/ui";import ee,{useCallback as mT,useEffect as Wd,useMemo as fT,useState as Ko}from"react";import{useNavigate as gT}from"react-router-dom";import{i18n as fs}from"@lingui/core";import{Alert as Hk,ChevronDownIcon as qk,CloseIcon as Gk,Divider as ld,IconButton as cd,PasteIcon as Vk,Typography as Kk,WalletIcon as jk}from"@rango-dev/ui";import Le,{useEffect as Xk,useRef as Yk}from"react";import Xr,{useRef as zk}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as od,styled as Vr}from"@rango-dev/ui";var us=300,Ok=od({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Uk=od({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),nd=Vr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ds=Vr(Go.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Kr=Vr(Go.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Ok} ${us}ms ease-out`},false:{animation:`${Uk} ${us}ms ease-out`}}}}),jr=Vr("div",{transition:`all ${us}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Yr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=zk(null);return Xr.createElement(nd,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Xr.createElement(ds,{className:"collapsible_trigger",onClick:a},s),Xr.createElement(Kr,{className:"collapsible_content",open:e},r),l==="bottom"&&Xr.createElement(ds,{className:"collapsible_trigger",onClick:a},s))}i(Yr,"CustomCollapsible");import{darkTheme as rd,styled as ms,TextField as Qk}from"@rango-dev/ui";var id=ms("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),ad=ms(Qk,{backgroundColor:"$neutral100",padding:"$15"}),sd=ms("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${rd} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${rd} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function pd(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=sr(e.name,l),p=Yk(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),f=n&&!!r&&e&&!Io(e,r),g=i(()=>{a("")},"handleClear"),m=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),p?.current?.focus()}},"handlePaste"),C=i(()=>r?Le.createElement(cd,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Le.createElement(Gk,{size:12,color:"gray"})):d?null:Le.createElement(cd,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Le.createElement(Vk,{size:16})),"renderSuffix");return Xk(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Le.createElement(id,null,Le.createElement(Yr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Le.createElement(sd,null,Le.createElement("div",{className:"button__content"},Le.createElement(jk,{size:18,color:"info"}),Le.createElement(ld,{size:4,direction:"horizontal"}),Le.createElement(Kk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},fs.t("Send to a different address"))),Le.createElement(jr,{orientation:n?"up":"down"},Le.createElement(qk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Le.createElement(ad,{ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:fs.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),f&&Le.createElement(Le.Fragment,null,Le.createElement(ld,{size:4}),Le.createElement(Hk,{variant:"alarm",type:"error",title:fs.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(pd,"CustomDestination");import{css as Zk,darkTheme as gs,IconButton as Jk,styled as Dt}from"@rango-dev/ui";var ud=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),dd=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Rk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${gs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${gs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${gs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),md=Dt(Rk,{alignSelf:"stretch",minHeight:"93px"}),fd=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),gd=Dt(Jk,{position:"absolute",left:"$20"}),hd=Dt("div",{paddingTop:"$20"}),yd=Zk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Sd=Dt("div",{display:"flex"}),Cd=Dt("div",{overflow:"visible",width:"100%"});import{i18n as xd}from"@lingui/core";import{warn as rT}from"@rango-dev/logging-core";import{Divider as iT,SelectableWallet as aT,Typography as Ed,WalletState as Id}from"@rango-dev/ui";import Xe,{useEffect as Ad,useState as In}from"react";import{Image as oT,MessageBox as nT}from"@rango-dev/ui";import En from"react";import{keyframes as eT,styled as hs}from"@rango-dev/ui";var kd=hs("div",{position:"relative"}),tT=eT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Td=hs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${tT} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vd=hs("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function wd(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Vo.t("Request Rejected"),description:Vo.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(wd,"generateMessageByStatus");function bd(t){let{status:e,displayName:o,image:n}=t,r=wd(e,o),a=e=="in-progress";return En.createElement(nT,{type:r.type,title:r.title,description:r.description,icon:a?En.createElement(kd,null,En.createElement(vd,null,En.createElement(oT,{src:n,size:45})),En.createElement(Td,null)):void 0})}i(bd,"ExperimentalChainStatus");var sT=7,lT=3e3;function ys(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[p,u]=In(),[d,h]=In(null),[f,g]=In(!1),[m,C]=In(null),{suggestAndConnect:S}=Zr(),{handleDisconnect:k}=Gt(),{list:T}=ft({chain:e}),[v,b]=In(T),N=T.length,D=r&&N-r>0,w=i(async E=>{g(!1),C("in-progress");try{await S(E.walletType,E.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");Ad(()=>{b(E=>{let A=T.findIndex(M=>o(M.type,e));return D&&A>1?[T[A]].concat(T.filter((M,L)=>L!==A)):E.map(M=>T.find(L=>L.type===M.type)??M)})},[JSON.stringify(T)]);let x=document.getElementById(De.SWAP_BOX_ID);return Ad(()=>{let E=null;return(m==="completed"||m==="rejected")&&(E=setTimeout(()=>C(null),lT)),()=>{E&&clearTimeout(E)}},[m]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(E=>{let A=Uc({connectedWallets:c,walletType:E.type,chain:e}),M=A?Sr(A,sT):"",L=hr(l(),e),X=!c.find(se=>se.walletType===E.type&&se.chain===e),oe=L&&X&&E.state===Id.CONNECTED,Y=oe?xd.t({id:"Add {chain} chain",values:{chain:e}}):M,W=i(async()=>{let se=E.state===Id.DISCONNECTED,z=(E.isHub||!!E.needsNamespace)&&!M;se?u(E):z?(await k(E.type),u(E)):oe?(h({walletType:E.type,chain:e,address:A??""}),g(!0)):n({walletType:E.type,chain:e,address:A??""})},"onSelectableWalletClick"),K=d?.chain?sr(d.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${E.title}_${K}`},!!d&&Xe.createElement(J,{open:!!d&&f,container:x,onClose:()=>{h(null)}},Xe.createElement(Ea,{displayName:K,onConfirm:()=>{w(d)}})),m&&Xe.createElement(J,{open:!!m,onClose:C.bind(null,null),container:x},Xe.createElement(bd,{status:m,displayName:K,image:E.image}),Xe.createElement(iT,{direction:"vertical",size:32})),Xe.createElement(aT,{key:E.type,description:Y,onClick:W,selected:o(E.type,e),disabled:!s,...E}))}),Xe.createElement(po,{wallet:p,onClose:()=>{u(void 0)},onConnect:()=>{t.onConnect&&(p?.type?t.onConnect(p.type):rT(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),D&&Xe.createElement(md,{selected:!1,onClick:a},Xe.createElement(Ed,{variant:"label",size:"medium"},xd.t("Show more wallets"),Xe.createElement(Ed,{variant:"label",size:"medium",color:"$primary"},"\xA0+",N-(r??0)))))}i(ys,"WalletList");var hT=2;function Bd(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=gT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:h,setCustomDestination:f}=O(),{config:g,connectedWallets:m,setWalletsAsSelected:C}=y(),[S,k]=Ko(""),[T,v]=Ko([]),[b,N]=Ko(""),[D,w]=Ko(!!h),x=fT(()=>io({filter:"all",quote:c}),[c]),E=io({filter:"required",quote:c}),A=l.find(P=>P.name===c?.swaps[c?.swaps.length-1].to.blockchain),M=i(P=>E.includes(P),"isWalletRequiredFor"),L=mT(()=>m.filter(P=>P.selected&&x.includes(P.chain)),[m,x]),[X,oe]=Ko(L()),[Y,W]=Ko([]),K=i((P,q)=>W(V=>V.concat({blockchain:P,walletType:q})),"addNextSelectedWallets"),se=T.length>0,z=i((P,q)=>!!X.find(V=>V.walletType===P&&V.chain===q&&V.selected&&(M(q)||!M(q)&&!h)),"isSelected"),me=i((P,q,V)=>{let ge=!1;return P.map(ne=>{if(ne.chain===q){let he=ne.selected;return!ge&&V?(ge=!0,he=!0):V||(he=!1),{...ne,selected:he}}return ne})},"updateSelectableWallets"),vt=i(P=>{w(P),P?M(A?.name??"")||oe(q=>me(q,A?.name||"",!1)):(f(""),oe(q=>me(q,A?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(P=>{if(S&&k(""),z(P.walletType,P.chain))return;let V=m.find(ge=>ge.walletType===P.walletType&&ge.chain===P.chain);V&&(n(),P.chain===A?.name&&D&&!M(A.name)&&(w(!1),f(null)),oe(ge=>ge.filter(ne=>ne.chain!==P.chain).concat({...V,selected:!0})))},"onChange"),le=i(()=>{let P=X.filter(q=>q.selected);C(P),p(P),d(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),N("");let P=await r?.({selectedWallets:X.filter(V=>V.selected),customDestination:h}),q=P.warnings;q?.balance?.messages&&v(q.balance.messages),P.error&&N(zp(P.error)),!P.error&&!q?.balance?.messages.length?le():v(q?.balance?.messages??[])},"onConfirmWallets");Wd(()=>{oe(P=>{let q=[];return P.forEach(V=>{!m.some(ne=>ne.chain===V.chain&&ne.walletType===V.walletType&&ne.address===V.address)||q.push(V)}),q=q.concat(m.filter(V=>!!!q.find(ne=>ne.chain===V.chain)&&V.selected&&x.includes(V.chain))),q})},[m,x]),Wd(()=>{let P=[];Y.length>0&&(Y.forEach(q=>{let V=m.find(ge=>ge.chain===q.blockchain&&ge.walletType===q.walletType);V?Ze(V):P.push(q)}),W(P))},[m,Y]);let G=document.getElementById(De.SWAP_BOX_ID);return ee.createElement(J,{open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:G,...!S&&{styles:{container:{height:"100%"}},footer:ee.createElement(Sd,null,ee.createElement(Nd,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:hu(a,D,h,c,X,A),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ee.createElement(fd,null,ee.createElement(gd,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},ee.createElement(uT,{size:16})),ee.createElement(Cs,{variant:"headline",size:"small"},ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:st(S,l)}})))},anchor:"center"},ee.createElement(J,{open:se,onClose:v.bind(null,[]),container:G},ee.createElement(dT,{title:ho.t("Insufficient account balance"),type:"error",description:ee.createElement(pT,{messages:T??[]})},ee.createElement(Nd,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},ho.t("Proceed anyway")))),S&&ee.createElement(hd,null,ee.createElement("div",{className:yd()},ee.createElement(ys,{chain:S,isSelected:z,selectWallet:Ze,onShowMore:()=>k(S),onConnect:P=>{K(S,P)}}))),!S&&ee.createElement(ee.Fragment,null,b&&ee.createElement(ee.Fragment,null,ee.createElement(cT,{variant:"alarm",type:"error",title:ho.t(b)}),ee.createElement(Ss,{size:12})),ee.createElement(Cd,null,x.map((P,q)=>{let V=l.find(Fe=>Fe.name===P),ge=`wallet-${q}`,ne=q===x.length-1,he=ne&&A&&g?.customDestination!==!1;return ee.createElement("div",{key:ge},ee.createElement(ud,null,ee.createElement(Cs,{variant:"title",size:"xmedium"},ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ee.createElement(Cs,{variant:"label",color:"$neutral700",size:"medium"},ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ee.createElement(Ss,{size:24}),ee.createElement(dd,null,ee.createElement(ys,{chain:P,isSelected:z,selectWallet:Ze,limit:hT,onShowMore:()=>k(V?.name??""),onConnect:Fe=>{K(P,Fe)}})),!ne&&ee.createElement(Ss,{size:32}),he&&ee.createElement(pd,{blockchain:A,open:D,handleOpenChange:vt}))}))))}i(Bd,"ConfirmWalletsModal");import{i18n as _T}from"@lingui/core";import{Alert as DT,Button as $T,InfoIcon as FT}from"@rango-dev/ui";import et from"react";import{Alert as CT,Button as kT,Divider as vs,NoRouteIcon as TT,RefreshIcon as vT,Typography as Fd}from"@rango-dev/ui";import Re from"react";import{i18n as Ld}from"@lingui/core";var yT=24,ST=60;function Md(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:R().genericServerError,action:{onClick:n,title:Ld.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:R().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Ld.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(Md,"makeInfo");var ks=(o=>(o[o.small=yT]="small",o[o.large=ST]="large",o))(ks||{}),Ts=(o=>(o.small="small",o.large="medium",o))(Ts||{});import{styled as Jr}from"@rango-dev/ui";var Pd=Jr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),_d=Jr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Dd=Jr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),$d=Jr("div",{padding:"$6 $0"});function An(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Md(o,r,()=>a(s,!0),e);return Re.createElement(Pd,null,Re.createElement(TT,{size:ks[n],color:"gray"}),Re.createElement(vs,{size:4}),Re.createElement(Fd,{variant:"title",size:Ts[n]},R().noResultError.title),n==="large"&&Re.createElement(vs,{size:4}),!!l.description&&Re.createElement(_d,{size:n},Re.createElement(Fd,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(vs,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(Dd,{size:n},Re.createElement(CT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(kT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement($d,null,Re.createElement(vT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(An,"NoResult");import{i18n as Nn}from"@lingui/core";import{Button as bT,Divider as xT,MessageBox as ET,Typography as IT,WarningIcon as AT}from"@rango-dev/ui";import $t from"react";import{Typography as Qd}from"@rango-dev/ui";import bs from"react";import{darkTheme as wT,styled as Rr}from"@rango-dev/ui";var Od=Rr("div",{width:"100%"}),ws=Rr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Ud=Rr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${wT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),zd=Rr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Hd(t){let{title:e,value:o,valueColor:n}=t;return bs.createElement(Ud,null,bs.createElement(Qd,{size:"medium",variant:"label",className:"_title"},e),bs.createElement(Qd,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Hd,"QuoteErrorsModalItem");function qd(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:Nn.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:Nn.t("Gas cost"),value:B(r.totalFee,2,2)},{title:Nn.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:Nn.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(J,{footer:$t.createElement(bT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(AT,null),fullWidth:!0,disabled:a,onClick:n},R().highValueLossError.confirmMessage),open:e,onClose:o,container:I()},$t.createElement(ET,{type:s,title:R().highValueLossError.impactTitle,description:R().highValueLossError.description}),$t.createElement(ws,null,$t.createElement(xT,{size:"4"}),$t.createElement(IT,{size:"small",variant:"title"},Nn.t("Details")),$t.createElement(ws,null,l.map((c,p)=>$t.createElement(Hd,{key:p,...c})))))}i(qd,"HighValueLossWarningModal");import{i18n as ei}from"@lingui/core";function Gd(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=ei.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=ei.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=ei.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=ei.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Gd,"makeAlerts");import{i18n as jo}from"@lingui/core";import{Button as Vd,Divider as Kd,MessageBox as NT,Typography as WT}from"@rango-dev/ui";import yo from"react";import{useNavigate as BT}from"react-router-dom";function jd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=BT(),p=e??o;return yo.createElement(J,{anchor:"bottom",open:n,prefix:yo.createElement(Vd,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+$.settings)},yo.createElement(WT,{variant:"label",size:"medium",color:"$neutral900"},jo.t("Change settings"))),container:I(),onClose:r},yo.createElement(NT,{type:"warning",title:s.type===3?jo.t("High slippage"):jo.t("Low slippage"),description:s.type===3?jo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:p}}):jo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},yo.createElement(Kd,{size:18}),yo.createElement(Kd,{size:32}),yo.createElement(Vd,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},jo.t("Confirm anyway"))))}i(jd,"SlippageWarningModal");import{Button as LT,MessageBox as MT,WarningIcon as PT}from"@rango-dev/ui";import ti from"react";function Xd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ti.createElement(J,{footer:ti.createElement(LT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ti.createElement(PT,null),fullWidth:!0,disabled:r,onClick:n},R().unknownPriceError.confirmMessage),open:e,onClose:o,container:I()},ti.createElement(MT,{type:"warning",title:R().unknownPriceError.impactTitle,description:R().unknownPriceError.description}))}i(Xd,"UnknownPriceWarningModal");function Wn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:p,onChangeSettings:u}=t,d={confirmationDisabled:a,open:r,onClose:c,onConfirm:p},h=o?.type===0||o?.type===1,f=Gd(e,o?.type===3||o?.type===4?o:null);return f&&!n&&(f.action=null),et.createElement(et.Fragment,null,h&&et.createElement(An,{error:o,fetch:s}),!!f&&et.createElement(Od,null,et.createElement(DT,{title:f.title,type:f.alertType,variant:"alarm",...f.action==="show-info"&&{action:et.createElement(zd,{onClick:l},et.createElement(FT,{size:12,color:"gray"}))},...f.action==="change-settings"&&{action:et.createElement($T,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:f.alertType,onClick:u},_T.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement(qd,{...d,warning:e}),(e.type===3||e.type===2)&&et.createElement(jd,{...d,warning:e}),e.type===1&&et.createElement(Xd,{...d,warning:e})))}i(Wn,"QuoteWarningsAndErrors");import gv from"bignumber.js";import gi from"react";import{i18n as So}from"@lingui/core";import{Alert as ov,Divider as Yo,FullExpandedQuote as nv,InfoIcon as rv,NumericTooltip as Im,QuoteTag as iv,StepDetails as av,TokenAmount as sv,Typography as Zo}from"@rango-dev/ui";import Ms from"bignumber.js";import F,{useRef as lv,useState as cv}from"react";import{styled as xs}from"@rango-dev/ui";var Es=xs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Yd=xs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Zd=xs("div",{width:"100%",display:"flex"});import*as oi from"@radix-ui/react-collapsible";import{Button as OT,css as Bn,darkTheme as Ee,Image as Jd,styled as ze,Typography as UT}from"@rango-dev/ui";var zT=300,Rd=ze(oi.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${Ee} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),em=Bn({padding:"$10 $15"}),tm=ze(OT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${Ee} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${Ee} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${Ee} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),om=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",[`.${Ee} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${Ee} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${Ee} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${Ee} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${Ee} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${Ee} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${Ee} &`]:{backgroundColor:"$neutral400"}}}}]}),nm=Bn({width:"100%",padding:"$15 $15 $10 $15"}),rm=Bn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Xo=Bn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),im=Bn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${Ee} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),am=ze(oi.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:{[`& ${Jd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Jd}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${Ee} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),sm=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"}}}}),lm=ze(Kr,{width:"100%",background:"inherit"}),Is=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${zT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),l1=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),cm=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${Ee} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),pm=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),As=ze(UT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),um=ze("div",{display:"flex",flexWrap:"wrap"}),Ns=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"}}}}),dm=ze("div",{display:"flex"}),ni=ze("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${Ee} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as HT,CloseIcon as qT,Divider as ai,IconButton as GT,NumericTooltip as VT,QuoteCost as KT,Typography as yt}from"@rango-dev/ui";import Z,{useState as hm}from"react";import{css as QT,styled as ri}from"@rango-dev/ui";var ii=ri("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ws=ri("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),mm=ri("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),fm=ri("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),gm=QT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var jT=i(t=>t.fee.isZero()?null:Z.createElement(ii,null,Z.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(yt,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function Bs(t){let[e,o]=hm(!1),[n,r]=hm(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:h=!1}=t,f=s?.swaps??[],g=h?ro():I(),m=lu(f);return Z.createElement(Z.Fragment,null,Z.createElement(KT,{onClickFee:d?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:p,timeWarning:u,time:c,steps:a,tooltipGas:d?At.t("View more info"):void 0,tooltipContainer:g}),Z.createElement(J,{container:g,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Z.createElement(fm,{style:{textAlign:h?"left":"center"}},Z.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Z.createElement(GT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(qT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(mm,null,Z.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Z.createElement(ai,{size:10}),Object.entries(m.payable).flatMap(([C,S])=>S.map((k,T)=>{let v=`payable-fee-${T}`,b=Ma(k);return Z.createElement(ii,{key:v},Z.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Aa(C,At.t)),Z.createElement(VT,{content:k.amount,container:g},Z.createElement(yt,{variant:"label",size:"medium"},B(k.amount,2,2)," ",k.asset.symbol," ($",B(b,4,4),")")))})),Z.createElement(ii,{className:"total_payable_fee"},Z.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Z.createElement(yt,{variant:"label",size:"medium"},"$",B(l,4,4))),Z.createElement(Ws,null),Object.keys(m.nonePayable).length&&Z.createElement(Yr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Z.createElement("div",{className:gm()},Z.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Z.createElement(ai,{size:4,direction:"horizontal"}),Z.createElement(jr,{orientation:n?"up":"down"},Z.createElement(HT,{size:12,color:"gray"}))),open:n},Z.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Z.createElement(ai,{size:4}),Z.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.`)),Z.createElement(ai,{size:10}),Object.entries(m.nonePayable).map(([C,S],k)=>{let T=su(S),v=Aa(C,At.t),b=`non-payable-fee-${k}`;return Z.createElement(jT,{key:b,fee:T,label:v})}),Z.createElement(Ws,null)))))}i(Bs,"QuoteCostDetails");import{i18n as Cm}from"@lingui/core";import{TokenAmount as km}from"@rango-dev/ui";import si from"react";import{css as XT,styled as YT}from"@rango-dev/ui";var ym=YT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),Sm=XT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Ln(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return si.createElement(ym,null,si.createElement(km,{direction:"horizontal",label:Cm.t("Swap input"),type:"input",tooltipContainer:I(),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}}),si.createElement("div",{className:Sm()}),si.createElement(km,{direction:"horizontal",tooltipContainer:I(),label:Cm.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(Ln,"QuoteSummary");import{i18n as xm}from"@lingui/core";import{ChevronDownIcon as RT,ChevronRightIcon as ev,Divider as Ls,Image as tv,Tooltip as di,Typography as ci}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as ZT,useState as Mn}from"react";var Tm=480,vm=768,wm=1024,bm=1200,JT=i(()=>{let[t,e]=Mn(!1),[o,n]=Mn(!1),[r,a]=Mn(!1),[s,l]=Mn(!1),[c,p]=Mn(!1),u=i(()=>{e(window.innerWidth<=Tm),n(window.innerWidth>Tm&&window.innerWidth<=vm),a(window.innerWidth>vm&&window.innerWidth<=wm),l(window.innerWidth>wm&&window.innerWidth<=bm),p(window.innerWidth>bm)},"handleResize");return ZT(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),li=JT;var pi=4,ui=6,Pn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||I();return U.createElement(di,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(sm,{className:n,state:a},U.createElement(tv,{src:o,size:16})))},"ImageComponent");function Em(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||I(),p=r.length,u=Zp(r),{isTablet:d,isMobile:h}=li();return U.createElement(am,{listItem:s==="list-item",ref:f=>e.current=f,selected:o,onClick:f=>{f.stopPropagation(),n(g=>!g)}},U.createElement("div",{className:Xo()},U.createElement(ci,{variant:"body",size:"xsmall"},xm.t("Via:")),U.createElement(Ls,{direction:"horizontal",size:4}),r.map((f,g)=>{let m=`item-${g}`,C=U.createElement(Is,null,U.createElement(ev,{size:12,color:"black"}));return h||d?U.createElement(U.Fragment,{key:m},U.createElement(Pn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),g!==p-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:m},p<=pi||p>pi&&g<pi-1?U.createElement(U.Fragment,null,U.createElement(Pn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),g!==p-1&&U.createElement(U.Fragment,null,C)):g===pi-1&&U.createElement(di,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=g&&U.createElement(U.Fragment,{key:T},U.createElement(Pn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==p-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Ns,{state:r.find((S,k)=>k>=g&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(ci,{size:"xsmall",variant:"body"},"+",p-g))))})),U.createElement("div",{className:Xo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Xo()},U.createElement(ci,{variant:"body",size:"xsmall"},xm.t("Chains:")),U.createElement(Ls,{direction:"horizontal",size:4}),u.map((f,g)=>U.createElement(U.Fragment,{key:f.displayName},u.length<=ui||u.length>ui&&g<ui-1?U.createElement(di,{container:c,side:"bottom",content:f.displayName,sideOffset:4},U.createElement(Pn,{content:"",src:f.image,open:!1,className:g!==0?"blockchainImage":""})):g===ui-1&&U.createElement(di,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},u.map((m,C)=>C>=g&&U.createElement(Pn,{key:m.displayName,content:"",src:m.image,open:!1,className:C>g?"blockchainImage":"",container:l})))},U.createElement(Ns,{className:"blockchainImage"},U.createElement(ci,{size:"xsmall",variant:"body"},"+",u.length-g))))),U.createElement(Ls,{direction:"horizontal",size:32}))),U.createElement(Is,{orientation:a?"up":"down"},U.createElement(RT,{size:12,color:"black"}))))}i(Em,"QuoteTrigger");function Ps(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:c=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:d=!1,container:h}=t,f=y().blockchains(),{findToken:g}=y(),m=y().swappers(),{customSlippage:C,slippage:S}=y(),k=C||S,[T,v]=cv(t.expanded),b=lv(null),N=B(o.value,6,6),D=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",x=Pt(o.usdValue,n.usdValue??null),E=B(x,2,2),A=_t(x??0),M=i((le,at)=>le.map((G,P)=>{let q,V=r?.type===3&&r.swap.swapperId===G.swapperId,ge=r?.type===4&&r.recommendedSlippages?.has(P),ne=a?.type===2&&a.recommendedSlippages?.has(P),he=V||ge,Fe=ne;he?q="error":Fe&&(q="warning");let ve=he?So.t("Slippage Error"):So.t("Slippage Warning");return V&&(ve=So.t("Bridge Limit Error")),{swapper:{displayName:rn(G.swapperId,m)??"",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:P===0&&!at?B(o.value,6,6):B(G.fromAmount,6,6),usdValue:B((G.from.usdPrice??0)*parseFloat(G.fromAmount),4,4),realValue:P===0?o.value:G.fromAmount,realUsdValue:new Ms(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:B(G.toAmount,6,6),usdValue:B((G.to.usdPrice??0)*parseFloat(G.toAmount),4,4),realValue:G.toAmount,realUsdValue:new Ms(G.to.usdPrice??0).multipliedBy(G.toAmount).toString()}},state:q,alerts:he||Fe?F.createElement(Yd,{dense:d},F.createElement(ov,{variant:"alarm",type:he?"error":"warning",title:ve,footer:F.createElement(Zd,null,V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {amount} {symbol}",values:{amount:B(G.fromAmount,6,6),symbol:G?.from.symbol}}))),(ge||ne)&&!V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(P)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(P)}}})),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:ln(G.estimatedTimeInSeconds),fee:B(La(G,g),2,2),internalSwaps:G.internalSwaps?M(G.internalSwaps):void 0}}),"getQuoteSteps"),L=M(e?.swaps??[]),X=L.length,oe=h||I(),Y=Rp(t.quote.tags||[]),W=!!u,K=mr(e?.swaps),se=ln(K),z=Mr(e?.swaps??[],g),me=B(z,2,2),vt=z.gte(new Ms(Hp)),Ze=K/Gp>=qp;return d?F.createElement(nv,{selected:l,fee:me,time:se,tooltipContainer:ro(),steps:L,tags:Y,quoteCost:F.createElement(Bs,{quote:e,fullExpandedMode:!0,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:X}),percentageChange:E,warningLevel:A,outputPrice:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(om,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:nm()},!c&&Y.length?F.createElement(F.Fragment,null,F.createElement(dm,null,Y.map((le,at)=>{let G=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:G},F.createElement(iv,{label:le.label,value:le.value}),F.createElement(Yo,{size:4,direction:"horizontal"}))})),F.createElement(ni,null),!W&&F.createElement(Yo,{size:4})):null,F.createElement("div",{id:"portal-root",className:rm()},F.createElement(Bs,{quote:e,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:X}),W&&F.createElement(tm,{onClick:le=>{le.stopPropagation(),u()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Zo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},So.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:im()},F.createElement(pm,null,F.createElement(rv,{size:12,color:"gray"})),F.createElement(um,null,F.createElement(As,{size:"small",variant:"body"},`${N} ${L[0].from.token.displayName} = `),F.createElement(Im,{content:n.value,container:oe,open:n.value?void 0:!1},F.createElement(As,{size:"small",variant:"body"},"\xA0",`${D} ${L[L.length-1].to.token.displayName}`))),F.createElement(Im,{content:n.usdValue,container:oe},F.createElement(Yo,{size:2,direction:"horizontal"}),F.createElement(Zo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(sv,{tooltipContainer:oe,type:"output",direction:"vertical",price:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:L[X-1].to.token.displayName,image:L[X-1].to.token.image},chain:{image:L[X-1].to.chain.image},percentageChange:E,warningLevel:A}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Ln,{from:L[0].from,to:L[X-1].to,percentageChange:E,warningLevel:A}),F.createElement(Yo,{size:4}))),F.createElement(Rd,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(Em,{type:s,quoteRef:b,selected:l,setExpanded:v,container:oe,expanded:T,steps:L}),F.createElement(lm,{open:T},F.createElement(cm,null),F.createElement("div",{className:em()},L.map((le,at)=>{let G=`item-${at}`;return F.createElement(av,{type:"quote-details",key:G,tooltipContainer:oe,step:le,hasSeparator:at!==L.length-1,state:le.state})})))))}i(Ps,"Quote");import{Divider as mv,Skeleton as fv}from"@rango-dev/ui";import Ot from"react";import{darkTheme as pv,styled as mi}from"@rango-dev/ui";var Am=mi("div",{$$color:"$colors$neutral100",[`.${pv} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Nm=mi("div",{paddingTop:"$2"}),Wm=mi("div",{paddingLeft:"$8"}),Bm=mi("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as zm,Divider as St,Skeleton as tt}from"@rango-dev/ui";import Q from"react";import{css as uv,styled as Ft}from"@rango-dev/ui";var _s=Ft("div",{display:"flex"}),Lm=Ft("div",{padding:"$10 $0 $20"}),Mm=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Pm=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),_m=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Dm=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),$m=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Fm=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Om=Ft("div",{padding:"$15 $0 $15 $0"}),Um=uv({display:"flex",justifyContent:"space-between",alignItems:"center"});function _n(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(_m,null,Q.createElement($m,null,Q.createElement(zm,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{size:8,direction:"horizontal"}),Q.createElement(Fm,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(_s,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(ni,null),!r&&Q.createElement(St,{size:4})),Q.createElement("div",{className:Um()},Q.createElement(_s,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(Lm,null,Q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(Mm,null,Q.createElement(Pm,null,Q.createElement(zm,{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(Om,null,n,Q.createElement(Dm,null),n),Q.createElement(St,{size:12})))}i(_n,"QuoteSummarySkeleton");import{ChainToken as Vm,Divider as $s,NextIcon as dv,Skeleton as fi}from"@rango-dev/ui";import Ie from"react";import{styled as Dn}from"@rango-dev/ui";var Qm=Dn("div",{display:"flex",alignItems:"start"}),Hm=Dn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Ds=Dn("div",{display:"flex",alignItems:"center",flexGrow:1}),qm=Dn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Gm=Dn("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ie.createElement(Ie.Fragment,null,Ie.createElement(Gm,null,Ie.createElement(fi,{height:22,width:22,variant:"circular"}),Ie.createElement($s,{direction:"horizontal",size:8}),Ie.createElement(fi,{height:15,width:148,variant:"rounded"})),Ie.createElement(Qm,null,Ie.createElement(Bm,{hideSeparator:!e}),Ie.createElement(Hm,{extraSpace:e},Ie.createElement(Ds,null,Ie.createElement(Vm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ie.createElement($s,{direction:"horizontal",size:8}),Ie.createElement(fi,{height:12,variant:"rounded"})),Ie.createElement(qm,null,Ie.createElement(dv,{color:"gray",size:16})),Ie.createElement(Ds,null,Ie.createElement(Vm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ie.createElement($s,{direction:"horizontal",size:8}),Ie.createElement(fi,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function $n(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Am,{expanded:o,rounded:e!=="basic"},Ot.createElement(_n,{type:e,tagHidden:n}),Ot.createElement(Nm,null,Ot.createElement(fv,{height:15,variant:"rounded"})),o&&Ot.createElement(Wm,null,Ot.createElement(mv,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i($n,"QuoteSkeleton");function Co(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:p,selected:u,onClickAllRoutes:d,fullExpandedMode:h=!1,container:f}=t,{inputAmount:g,inputUsdValue:m}=O(),C=e?.outputAmount?new gv(e?.outputAmount):null,S=e?ct(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?gi.createElement(Es,null,gi.createElement($n,{tagHidden:l,type:o,expanded:s})):T?gi.createElement(Es,{onClick:()=>c?.(e)},gi.createElement(Ps,{quote:e,error:r,container:f,showModalFee:p,warning:a,tagHidden:l,selected:u,type:o,expanded:s,onClickAllRoutes:d,fullExpandedMode:h,input:{value:g,usdValue:m?.toString()??""},output:{value:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(Co,"QuoteInfo");import{calculatePendingSwap as Cv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as kv}from"react";import{useRef as hv,useState as yv}from"react";var Sv=2e3;function hi({request:t}){let[e,o]=yv(!1),n=hv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,Sv)),await s(l,!1)),"retryFetch"),s=i(async(l,c=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(l,{signal:n.current.signal});return n.current=null,p}catch(p){if(c)return await a(l);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(hi,"useFetch");function Km(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await xt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Km,"useFetchConfirmQuote");function yi(t){if(!t.swaps)throw new Error(R().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Fs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(yi,"throwErrorIfResponseIsNotValid");function Fs(t){if(ru(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=iu(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=cu(t);if(o){let n=Pr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Fs,"getQuoteError");function jm(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Fo({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let p=du(e,r,n.blockchains);return p.length===0||(l.balance={messages:p}),l}i(jm,"generateWarnings");function Si(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(Si,"handleQuoteErrors");function Os(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:c,customSlippage:p}=y(),u=y().getDisabledLiquiditySources(),d=y().blockchains(),h=y().tokens(),{findToken:f}=y(),g=p||c,{fetch:m,cancelFetch:C,loading:S}=Km();return kv(()=>C,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,b=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=v.reduce((w,x)=>(w[x.chain]=x.address,w),{}),D={requestId:a?.requestId||"",selectedWallets:N,destination:b||void 0};try{return await m(D,!0).then(w=>{let{result:x}=w;if(!x)throw new Error("Error fetching updated route");yi({diagnosisMessages:x.diagnosisMessages,requestId:x.requestId,swaps:x.result?.swaps});let E={outputAmount:x.result?.outputAmount,requestId:x.requestId,resultType:x.result?.resultType,swaps:x.result?.swaps||[],validationStatus:x.validationStatus,requestAmount:x.requestAmount};r(E);let A={slippage:g.toString(),disabledSwappersGroups:u},M=jm({previousQuote:a??void 0,currentQuote:E,meta:{blockchains:d},selectedWallets:v,userSlippage:g,inputUsdValue:n,findToken:f});l();let L=!!M.balance,X=Cv(o.toString(),x,uu(v),A,!L,{blockchains:d,tokens:h});return{quote:E,swap:X,error:null,warnings:M}})}catch(w){return Si(w)}},"fetch"),cancelFetch:C}}i(Os,"useConfirmSwap");var Wv=bv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Xm}`]:{width:"$48",height:"$48"}}),Bv=Qs({flexGrow:1,paddingRight:"$10"}),Lv=Qs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Mv=Qs({display:"flex",justifyContent:"space-between",alignItems:"center"});function Ym(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=Nv(),[l,c]=Fn(""),p=!n,[u,d]=Fn(!1),[h,f]=Fn(!1),{isActiveTab:g}=re(),m=y().getDisabledLiquiditySources(),C=Av(m),{manager:S}=Tv(),{fetch:k,loading:T,cancelFetch:v}=Os(),[b,N]=Fn({swap:null,error:null,warnings:null}),[D,w]=Fn(!1),x=i(async({selectedWallets:W,customDestination:K})=>{let se=await k?.({selectedWallets:W,customDestination:K});return N(se),se},"onConfirmSwap"),E=i(async()=>{if(b.swap&&n)try{await S?.create("swap",{swapDetails:b.swap},{id:b.swap.requestId});let W=`../${$.swaps}/${b.swap.requestId}`;s(W,{replace:!0}),setTimeout(()=>{e("")},0)}catch(W){c("Error: "+W?.message)}},"addNewSwap"),A=i(async()=>{f(!0),await E(),f(!1)},"onConfirm"),M=i(async()=>{b.warnings?.quote&&Yp(b.warnings.quote)&&!a?w(!0):await A()},"onStartConfirmSwap"),L=i(async()=>{N({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(W=>{N(W)}).catch(W=>console.error(W))},"onRefresh");Ci(()=>{!!C.current.length&&!m.length&&L(),C.current=m},[m.length]),Ci(()=>{p&&v()},[p]),Ci(()=>{p&&d(p)},[p]),Ci(()=>{p||k({selectedWallets:o,customDestination:r}).then(W=>N(W)).catch(W=>console.error(W))},[]),Iv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let X=b.warnings?.quote??null,oe=b.error,Y=[];if(l&&Y.push(Me.createElement(vv,{type:"error",variant:"alarm",title:l})),X||oe){let W=`../${$.settings}`;Y.push(Me.createElement(Wn,{warning:X,error:oe,couldChangeSettings:!1,refetchQuote:L,showWarningModal:D,confirmationDisabled:!g,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await E()},onChangeSettings:()=>s(W)}))}return Me.createElement(te,{header:{title:Us.t("Confirm Swap"),onWallet:()=>{let W=`../${$.wallets}`;s(W)}},footer:Me.createElement(Wv,null,Me.createElement("div",{className:Bv()},Me.createElement(wv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!b.error||!g,onClick:M},Us.t("Start Swap"))),Me.createElement(Xm,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!g,onClick:d.bind(null,!0)},Me.createElement(Ev,{size:24})))},u&&Me.createElement(Bd,{open:u,onClose:()=>d(!1),onCancel:v,loading:T,onCheckBalance:x}),Me.createElement(ie,null,Me.createElement("div",{className:Mv()},Me.createElement(xv,{variant:"title",size:"small"},Us.t("You get")),Me.createElement("div",{className:Lv()},Me.createElement(Ur,{onClick:!T&&!u&&!D?L:void 0}))),Me.createElement(zs,{size:"12"}),Bu(Y.map((W,K)=>({element:W,key:`alert-${K}`})),Me.createElement(zs,{size:10})),Y.length>0?Me.createElement(zs,{size:10}):null,Me.createElement(Co,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:b.error,loading:T,warning:b.warnings?.quote??null})))}i(Ym,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Rs,CustomTokensZeroStateDarkIcon as Xv,CustomTokensZeroStateIcon as Yv,DeleteIcon as Zv,Divider as Qn,IconButton as Jv,MessageBox as Rv,NotFound as ew,styled as tl}from"@rango-dev/ui";import de,{useState as el}from"react";import{useNavigate as tw}from"react-router-dom";import{CloseIcon as _v,IconButton as Dv,SearchIcon as $v,TextField as Fv}from"@rango-dev/ui";import On from"react";import{styled as Pv}from"@rango-dev/ui";var Zm=Pv("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:c,...p}=t;return On.createElement(Fv,{prefix:On.createElement(Zm,null,On.createElement($v,{color:"black"})),suffix:!!s.length&&On.createElement(Dv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},On.createElement(_v,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...p})}i(Ct,"SearchInput");import{i18n as Js}from"@lingui/core";import{darkTheme as cf,Divider as Ro,ExternalLinkIcon as zv,Image as Qv,ListItemButton as Hv,NotFound as qv,PinIcon as Gv,Skeleton as pf,Typography as vi,VirtualizedList as Vv}from"@rango-dev/ui";import H from"react";import{Divider as sf,ListItem as Uv,Skeleton as Un}from"@rango-dev/ui";import kt from"react";import{css as Jo,darkTheme as Jm,ImageContainer as Ov,styled as ut,Typography as Rm}from"@rango-dev/ui";var Hs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),qs=Jo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Gs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Vs=Jo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Jm} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Ks=Jo({}),js=Jo(),ef=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Xs=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),ki=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${qs}`]:{[`& .${Vs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Ks}`]:{bottom:"-15px"},[`& .${Hs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Gs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Ys=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Zs=ut(Rm,{}),tf=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${js}`]:{$$color:"$colors$neutral600",[`.${Jm} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ti=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),oz=ut("div",{display:"flex",alignItems:"center"}),of=ut("div",{position:"relative",[`& ${Ov}`]:{borderRadius:"$xm",overflow:"hidden"}}),nf=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),rf=ut(Rm,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),af=ut("a",{"& svg:hover":{color:"$colors$info"}});function lf(t){return kt.createElement(ki,null,Array.from(Array(t.size),e=>kt.createElement(Uv,{key:e,hasDivider:!0,start:kt.createElement(Un,{variant:"circular",width:35,height:35}),end:kt.createElement(Ti,null,kt.createElement(Un,{variant:"text",size:"large",width:70}),kt.createElement(sf,{size:4}),kt.createElement(Un,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Un,{variant:"text",size:"large",width:90}),kt.createElement(sf,{size:4}),kt.createElement(Un,{variant:"text",size:"medium",width:90}))})))}i(lf,"LoadingTokenList");var Kv=20,jv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:qs()},o?H.createElement("div",{className:Hs()},o):H.createElement(Xs,{className:Gs()},H.createElement(vi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Ys,{css:a},H.createElement(Zs,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Vs()} ${!o&&Ks()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Ro,{size:4,direction:"horizontal"}),H.createElement(af,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},H.createElement(zv,{size:12}))))},"renderDesc");function zn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,c=y().blockchains(),{getBalanceFor:p,fetchingWallets:u}=y(),{isTokenPinned:d}=y(),h=i(g=>{let m=yr(p(g));return s?s(g):u?H.createElement(Ti,null,H.createElement(pf,{variant:"text",size:"large",width:70}),H.createElement(Ro,{size:4}),H.createElement(pf,{variant:"text",size:"medium",width:50})):m&&H.createElement(tf,null,H.createElement(rf,{variant:"title",size:"small"},m.amount),H.createElement("div",null),m.usdValue&&H.createElement(vi,{variant:"body",className:js(),size:"xsmall"},`$${m.usdValue}`))},"endRenderer"),f=i(()=>H.createElement(Vv,{itemContent:g=>{let m=e[g],C=m.address||"",S=c.find(b=>b.name===m.blockchain),k=Va(S.color,"main"),T={$$color:k.main150,[`.${cf} &`]:{$$color:k.main750},backgroundColor:"$$color"},v={$$color:k.main750,[`.${cf} &`]:{$$color:k.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(Hv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":g,key:`${m.symbol}${m.address}`,id:`${m.symbol}${m.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[g]),start:H.createElement(of,null,H.createElement(Qv,{src:m.image,size:30}),t.type!=="custom-token"&&d(m,t.type)&&H.createElement(nf,null,H.createElement(Gv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||m.name||!m.name&&!C?H.createElement(Xs,null,H.createElement(vi,{variant:"title",size:"xmedium"},m.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Ys,{css:T},H.createElement(Zs,{variant:"body",size:"xsmall",css:v},m.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?jv({address:C,token:e[g],customCssForTag:T,customCssForTagTitle:v,name:m.name,url:S.info.addressUrl.split("{wallet}").join(C)}):m.name||void 0,end:h(m)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(vi,{variant:"label",size:"large"},Js.t("Select Token")),H.createElement(Ro,{size:4})),H.createElement(ef,null,H.createElement(Ro,{size:4}),l==="loading"&&H.createElement(lf,{size:Kv}),l==="success"&&(e.length?H.createElement(ki,{as:"ul"},f()):!!o&&H.createElement(qv,{title:Js.t("No results found"),description:Js.t("Try using different keywords")}))))}i(zn,"TokenList");var ow=tl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),nw=tl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),rw=tl(Jv,{"&:hover":{"& svg":{color:"$secondary550"}}});function uf(){let[t,e]=el(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=Qo({}),p=tw(),[u,d]=el(!1),[h,f]=el(),g=i(k=>{let T=k.target.value;e(T)},"handleSearch"),m=c==="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)}d(!1)},"handleDeleteCustomToken");return de.createElement(te,{header:{title:Ut.t("Custom Tokens")}},de.createElement(ie,null,de.createElement(ow,null,n.length?de.createElement(de.Fragment,null,de.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:g}),de.createElement(Qn,{size:16}),de.createElement(zn,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>de.createElement(rw,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),f(k)}},de.createElement(Zv,{size:12,color:"gray"}))})):de.createElement(nw,null,de.createElement(ew,{icon:m?de.createElement(Xv,{size:200}):de.createElement(Yv,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),de.createElement(Qn,{size:20}),de.createElement(Rs,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},Ut.t("Add Custom Token"))),de.createElement(J,{open:u,dismissible:!0,onClose:()=>d(!1),container:I()},de.createElement(Rv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},de.createElement(Qn,{size:40}),de.createElement(Qn,{size:10}),de.createElement(Rs,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),de.createElement(Qn,{size:12}),de.createElement(Rs,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},Ut.t("No, Continue"))))))}i(uf,"CustomTokensPage");import{i18n as He}from"@lingui/core";import{useManager as ww}from"@rango-dev/queue-manager-react";import{Button as ll,darkTheme as bw,Divider as To,MessageBox as xw,NotFound as Ew,styled as cl,Typography as xi}from"@rango-dev/ui";import{TransactionStatus as Gn}from"rango-types";import ae,{useMemo as Wf,useState as Ei}from"react";import{useNavigate as Iw}from"react-router-dom";import{FilterIcon as uw,Popover as dw}from"@rango-dev/ui";import ko from"react";import{css as iw,darkTheme as wi,IconButton as aw,styled as Hn}from"@rango-dev/ui";var ol=Hn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${wi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),df=Hn(aw,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${wi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${wi} &`]:{backgroundColor:"$neutral"},[`& ${ol}::before`]:{backgroundColor:"$secondary100",[`.${wi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),mf=Hn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),ff=Hn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),gf=iw({display:"flex",justifyContent:"space-between",alignItems:"center"}),hf=Hn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as yf}from"@lingui/core";import{Button as sw,Divider as Sf,ListItemButton as lw,Radio as cw,RadioRoot as pw,Typography as Cf}from"@rango-dev/ui";import ot from"react";function kf(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(ff,null,ot.createElement("div",{className:gf()},ot.createElement(Cf,{size:"small",variant:"body"},yf.t("Status")),ot.createElement(sw,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},yf.t("Reset"))),ot.createElement(Sf,{size:10}),ot.createElement(pw,{value:e},ot.createElement(hf,null,t.list.map((n,r)=>ot.createElement(lw,{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(Sf,{direction:"horizontal",size:4}),ot.createElement(Cf,{size:"medium",variant:"body"},n.title)),start:ot.createElement(cw,{value:n.id}),onClick:o})))))}i(kf,"FilterSelectorContent");function nl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return ko.createElement("div",null,ko.createElement(dw,{open:a,align:"end",onOpenChange:o,container:I(),content:ko.createElement(kf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},ko.createElement(df,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},ko.createElement(ol,{isSelect:!!n},ko.createElement(uw,{size:16,color:"black"}),!!n&&ko.createElement(mf,null)))))}i(nl,"FilterSelector");import{i18n as gw}from"@lingui/core";import{Divider as xf,GroupedVirtualizedList as hw,Skeleton as yw,SwapListItem as Ef,Typography as Sw}from"@rango-dev/ui";import Qe,{useCallback as If,useEffect as Cw,useRef as kw,useState as Tw}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 mw,darkTheme as fw,styled as qn}from"@rango-dev/ui";var rl=mw(),vf=qn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),il=qn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${rl}`]:{$$color:"$colors$neutral600",[`.${fw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),al=qn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),wf=qn("div",{gap:"$10",display:"flex",flexDirection:"column"}),bf=qn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var vw=10;function sl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Tw([]),l=kw(0),{swaps:c,groupCounts:p,groups:u}=n(e),d=If(Tf,[]),h=If(()=>{let f=e.length-l.current;f&&(l.current+=Math.min(f,vw),s(d(p,l.current)))},[e.length]);if(Cw(()=>{r||h()},[r,h]),r){let f=[1,2];return Qe.createElement(Qe.Fragment,null,[f,f].map((m,C)=>Qe.createElement(il,{key:C},Qe.createElement(al,null,Qe.createElement(yw,{variant:"text",width:60,size:"small"}),Qe.createElement(xf,{size:16})),Qe.createElement(xf,{size:4}),Qe.createElement(wf,null,m.map((k,T)=>Qe.createElement(Ef,{isLoading:!0,key:T}))))))}return Qe.createElement(hw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:f=>Qe.createElement(il,null,Qe.createElement(al,null,Qe.createElement(Sw,{variant:"label",size:"medium",className:rl()},u[f]))),itemContent:(f,g)=>{let m=c[f];if(!m)return null;let C=m.steps[0],S=m.steps[m.steps.length-1];return Qe.createElement(vf,{key:m.requestId},Qe.createElement(Ef,{requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,tooltipContainer:I(),onlyShowTime:u[g]===gw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:B(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:B(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(sl,"HistoryGroupedList");import{i18n as bi}from"@lingui/core";import Af from"dayjs";var Nf=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(c,p){e.has(c)||e.set(c,{title:c,swaps:[]}),e.get(c)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Af();t.forEach(c=>{let p=Number(c.creationTime),u=Af(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(c);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(c);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(c);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(c);else{let d=new Date(p).getFullYear().toString();o(d,c)}});let r=Array.from(e.values()).filter(c=>c.swaps.length>0),a=r.flatMap(c=>c.swaps),s=r.map(c=>c.swaps.length),l=r.map(c=>c.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Aw=cl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),Nw=cl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Ww=cl("div",{"._typography":{color:"$neutral700",[`.${bw}&`]:{color:"$neutral900"}}}),Bw=[{id:Gn.SUCCESS,title:He.t("Complete")},{id:Gn.RUNNING,title:He.t("Running")},{id:Gn.FAILED,title:He.t("Failed")}],Lw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Bf(){let t=Iw(),{manager:e,state:o}=ww(),n=pt(e).map(({swap:T})=>T),[r,a]=Ei(""),[s,l]=Ei(!1),c=!o.loadedFromPersistor,[p,u]=Ei(""),[d,h]=Ei(!1),f=i(T=>{let v=T.target.value;a(v)},"handleSearch"),g=Wf(()=>!r&&!p?n:n.filter(T=>{let{inputAmount:v,status:b,steps:N,requestId:D}=T;return(!r||wt(v,r)||wt(b,r)||Lw(N,r)||wt(D,r))&&(!p||p===b)}),[n,r,p]),m=!g?.length&&!c,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),k=Wf(()=>!n.some(T=>T.status===Gn.SUCCESS||T.status===Gn.FAILED),[n]);return ae.createElement(te,{header:{title:He.t("History"),suffix:ae.createElement(Vt,null,ae.createElement(ll,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(xi,{size:"medium",variant:"label",color:"error"},He.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(Nw,null,ae.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:He.t("Search Transaction"),autoFocus:!0,onChange:f,style:{height:36},value:r}),ae.createElement(To,{size:10,direction:"horizontal"}),ae.createElement(nl,{filterBy:p,open:s,onOpenChange:T=>l(T),onClickItem:T=>u(T),list:Bw})),ae.createElement(To,{size:"16"}),ae.createElement(Aw,null,m&&ae.createElement(bf,null,ae.createElement(To,{size:32}),ae.createElement(Ew,{title:r?He.t("No results found"):He.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?He.t("Try using different keywords"):He.t("Your transaction history is stored locally and will appear here after you start a swap")})),!m&&ae.createElement(sl,{list:g,onSwapClick:t,groupBy:Nf,isLoading:c}))),ae.createElement(J,{open:d,onClose:C,container:I()},ae.createElement(To,{size:20}),ae.createElement(xw,{type:"warning",title:He.t("Clear Transaction History"),description:ae.createElement(Ww,null,ae.createElement(xi,{variant:"body",size:"medium"},He.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(To,{size:"24"}),ae.createElement(xi,{variant:"body",size:"small"},He.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(To,{size:30}),ae.createElement(ll,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},He.t("Yes, Clear the history")),ae.createElement(To,{size:10}),ae.createElement(ll,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(xi,{variant:"title",size:"medium",color:"primary"},He.t("No, Cancel")))))}i(Bf,"HistoryPage");import{i18n as ob}from"@lingui/core";import{Button as nb,Divider as Jf,styled as rb,WarningIcon as ib}from"@rango-dev/ui";import ab from"bignumber.js";import qe,{useEffect as Rf,useState as eg}from"react";import{useNavigate as sb}from"react-router-dom";import{i18n as Mf}from"@lingui/core";import{Alert as Pw,Divider as pl,NoRouteIcon as _w,Typography as Dw}from"@rango-dev/ui";import vo from"react";import{styled as Mw}from"@rango-dev/ui";var Lf=Mw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function ul(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Lt(t,e)?vo.createElement(Lf,null,vo.createElement(pl,{size:10}),vo.createElement(_w,{size:24,color:"gray"}),vo.createElement(pl,{size:4}),vo.createElement(Dw,{variant:"title",size:"small"},Mf.t("No Routes Found")),vo.createElement(pl,{size:4}),vo.createElement(Pw,{title:Mf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(ul,"SameTokensWarning");import{i18n as Qw}from"@lingui/core";import{Header as Hw}from"@rango-dev/ui";import Jt,{useEffect as qw,useState as Gw}from"react";import{i18n as Fw}from"@lingui/core";import{Divider as ml,FullExpandedQuote as Ow,Typography as Uw}from"@rango-dev/ui";import Ce from"react";import{styled as dl}from"@rango-dev/ui";var Pf=dl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),_f=dl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Df=dl("div",{width:"146px"});import{i18n as Vn}from"@lingui/core";import{Select as $w}from"@rango-dev/ui";import $f from"react";function Ii(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:Vn.t("Smart Routing")},{value:"FEE",label:Vn.t("Lowest Fee")},{value:"SPEED",label:Vn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Vn.t("Maximum Return")},{value:"PRICE",label:Vn.t("Maximum Output")}];return $f.createElement(Df,null,$f.createElement($w,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ii,"SelectStrategy");var Ff=3;function Kn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:c,quotes:p,updateQuotePartialState:u,fromToken:d,toToken:h,sortStrategy:f,error:g}=O(),{slippage:m,customSlippage:C}=y(),{findToken:S}=y(),k=l||I(),T=!!p&&p.results.length,v=C??m,b=i(w=>{if(!d||!h||!p)return null;let x={requestAmount:p.requestAmount,validationStatus:null,...w};return Fo({currentQuote:x,userSlippage:v,findToken:S})},"getQuoteWarning"),N=g?.type===0||g?.type===1,D=p?.results?Lr(f,p?.results):[];return Ce.createElement(Ce.Fragment,null,a&&Ce.createElement(Ce.Fragment,null,Ce.createElement(_f,null,Ce.createElement(Uw,{size:"xmedium",variant:"title"},Fw.t("Sort by")),Ce.createElement(Ii,{container:k})),Ce.createElement(ml,{size:"10"})),e&&Array.from({length:Ff},(w,x)=>Ce.createElement(Ce.Fragment,{key:x},s?Ce.createElement(Ow,{loading:!0}):Ce.createElement($n,{tagHidden:!1,type:"list-item",expanded:!1}),x!==Ff-1&&Ce.createElement(ml,{size:16}))),!e&&Ce.createElement(Ce.Fragment,null,T?D.map((w,x)=>{let E=b(w),A=Fs(w.swaps),M=D.length-1===x;return Ce.createElement(Ce.Fragment,{key:w.requestId},Ce.createElement(Co,{showModalFee:r,container:k,selected:c?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:A?.options||null,warning:E,fullExpandedMode:s,onClick:L=>{A||u("warning",E),u("error",A?.options||null),o(L)},type:"list-item"}),!M&&Ce.createElement(ml,{size:16}))}):N&&Ce.createElement(Pf,null,Ce.createElement(An,{size:s?"large":"small",error:g,fetch:n}))))}i(Kn,"Quotes");import{darkTheme as zw,styled as Of}from"@rango-dev/ui";var Uf=Of("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${zw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),zf=Of("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Vw=100;function fl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Gw(!1),c=s?"":"is-hidden",{config:p}=y(),u=p?.variant==="full-expanded",d=ro();return qw(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Vw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Uf,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${c} ${qr()}`,id:De.EXPANDED_BOX_ID},Jt.createElement(Hw,{title:Qw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(Ii,{container:d}),Jt.createElement(go,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(zf,null,Jt.createElement(Kn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:ro(),onClickOnQuote:n,fullExpandedMode:u})))}i(fl,"ExpandedQuotes");import{i18n as jf}from"@lingui/core";import{SwapInput as Xf}from"@rango-dev/ui";import Yw from"bignumber.js";import jn from"react";import{ReverseIcon as Xw}from"@rango-dev/ui";import hl from"react";import{keyframes as Kw,styled as Qf}from"@rango-dev/ui";var gl=450,jw=Kw({"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)"}}),Hf=Qf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),qf=Qf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${jw} ${gl}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 yl(){let t=O.use.switchFromAndTo();return hl.createElement(Hf,null,hl.createElement(qf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},gl),t()}},hl.createElement(Xw,{size:12})))}i(yl,"SwitchFromAndToButton");import{styled as Gf}from"@rango-dev/ui";var Vf=Gf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Kf=Gf("div",{position:"relative"});function Sl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:p,inputAmount:u,inputUsdValue:d,outputAmount:h,outputUsdValue:f,selectedQuote:g}=O(),{connectedWallets:m,getBalanceFor:C}=y(),S=a?C(a):null,k=yr(S)?.amount??"0",T=S?new Yw(S.amount).shiftedBy(-S.decimals):ce,v=!!s&&zc(m,s.name),b=!Ba(g,u,d),N=!Ba(g,u,f),D=!d||!f||!f.gt(0)?null:Pt(d.toString(),f.toString());return jn.createElement(Vf,null,jn.createElement(Kf,null,jn.createElement(Xf,{label:jf.t("From"),mode:"From",onInputChange:p,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:u,usdValue:b?void 0:B(d,4,4),realUsdValue:b?void 0:d?.toString(),error:b?R().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:I(),onSelectMaxBalance:()=>{let w=B(T,S?.decimals),x=S?.amount?w.split(",").join(""):"";p(x)},anyWalletConnected:m.length>0}),jn.createElement(yl,null)),jn.createElement(Xf,{sharpBottomStyle:!r&&(!!g||e),label:jf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(Pt(d,f),2,2),warningLevel:_t(D??0),price:{value:B(h,6,6),usdValue:N?void 0:B(f,4,4),realValue:h?.toString(),realUsdValue:N?void 0:f?.toString(),error:N?R().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:I()}))}i(Sl,"Inputs");import{useCallback as Zw,useEffect as Jw,useRef as Rw,useState as eb}from"react";function Yf(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await xt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Yf,"useFetchAllQuotes");var tb=600;function Ai({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Yf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:c,inputUsdValue:p,selectedQuote:u,sortStrategy:d,resetQuote:h,error:f,warning:g,setSelectedQuote:m,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:b,fetchStatus:N}=y(),D=y().getLiquiditySources(),w=y().getDisabledLiquiditySources(),x=y().excludeLiquiditySources(),{findToken:E}=y(),[A,M]=eb(!0),L=Rw(c),X=k??S,Y=!s||!l||Lt(s,l)||!cn(c),W=i(z=>{M(z)},"resetState"),K=i(z=>{let{fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:ge}=z;if(A||W(!0),!Y&&me&&vt){h();let ne=pu({fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,wallets:a,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:ge});Wo("experimental",r)&&(ne.experimental=!0),Wo("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),Wo("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(he=>{let Fe=Lr(d,he.results),ve=Jp(u,Fe,he.requestAmount);M(!1),C("quotes",he),m(ve),yi({diagnosisMessages:he.diagnosisMessages,requestId:ve?.requestId||"",swaps:ve?.swaps});let mt=ve&&Fo({currentQuote:ve,userSlippage:X,findToken:E});C("warning",mt)}).catch(he=>{let{error:Fe}=Si(he);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),M(!1))})}},"fetch"),se=Zw(Nc(z=>{K(z)},tb),[Y]);return Jw(()=>{if(!t){M(!1);return}if(N!=="success")return;if(Y){M(!1),(u||f||g)&&h();return}if(!cn(c)||p?.eq(0)){W(!1),o();return}h(),W(!0);let z=K;return L.current&&L.current!=c&&(z=se),L.current=c,z({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:X,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),o},[N,c,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,Y,D?.length,n,w.length,X,v,T,JSON.stringify(b)]),{fetch:()=>K({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:X,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),loading:A}}i(Ai,"useSwapInput");function Zf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ye.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Zf,"emitPreventableEvent");var lb=rb("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),cb=300;function tg(){let t=sb(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:h}=O(),[f,g]=eg(!1),{isLargeScreen:m,isExtraLargeScreen:C}=li(),{fetch:S,loading:k}=Ai({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:b}=y(),{isActiveTab:N}=re(),[D,w]=eg(!1),E=au({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:b.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),A=jc(m,C,T?.variant),M=!!n&&!!e&&!!o&&new ab(n).gt(0)&&!yu(e,o),L=M&&v==="success"&&k,Y=(!A||A&&c?.results.length)&&(l||s);Rf(()=>{u(),h("refetchQuote",!0)},[]),Rf(()=>{g(M)},[M]);let W=(r||s)&&!D?S:void 0,K=i(z=>{A&&f?(g(!1),setTimeout(()=>{t(z)},cb)):t(z)},"onHandleNavigation"),se=i(z=>{r?.requestId!==z.requestId&&(w(!1),p(z))},"onClickOnQuote");return qe.createElement(lb,null,qe.createElement(te,{height:"auto",footer:qe.createElement(nb,{id:`widget-swap-${E.action}-btn`,type:"primary",size:"large",disabled:E.disabled||!N,prefix:E.action==="confirm-warning"&&qe.createElement(ib,null),fullWidth:!0,onClick:()=>{E.action==="connect-wallet"?Zf({type:"clickConnectWallet"},()=>K($.wallets)):E.action==="confirm-warning"?w(!0):K($.confirmSwap)}},E.title),header:{onWallet:()=>{K($.wallets)},hasBackButton:!1,title:T.title||ob.t("Swap"),suffix:qe.createElement(go,{hidden:A?["refresh"]:void 0,onClickRefresh:W,onClickHistory:()=>K($.swaps),onClickSettings:()=>{K($.settings)}})}},qe.createElement(ie,null,qe.createElement(Sl,{fetchingQuote:L,fetchMetaStatus:v,isExpandable:A,onClickToken:z=>{K(z==="from"?$.fromSwap:$.toSwap)}}),qe.createElement(Jf,{size:"2"}),A?null:qe.createElement(Co,{quote:r,loading:L,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),K($.routes)}:void 0}),Y?qe.createElement(qe.Fragment,null,qe.createElement(Jf,{size:"10"}),qe.createElement(Wn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:D,confirmationDisabled:!N,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),d(!0),K($.confirmSwap)},onChangeSettings:()=>K($.settings)})):null,qe.createElement(ul,null))),A?qe.createElement(fl,{loading:L,onClickOnQuote:se,fetch:S,onClickRefresh:W,isVisible:f}):null)}i(tg,"Home");import{i18n as og}from"@lingui/core";import{Alert as pb,Divider as ub,List as db,ListItemButton as mb,Radio as fb,RadioRoot as gb,Typography as hb}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Rc,r=o?.language||Bo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Bo),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function ng(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(hb,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(fb,{value:s}),start:Wt.createElement(c,null)}});return Wt.createElement(te,{header:{title:og.t("Language")}},Wt.createElement(ie,null,Wt.createElement(pb,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(ub,{size:"8"}),Wt.createElement(gb,{value:t},Wt.createElement(db,{type:Wt.createElement(mb,{title:og.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(ng,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as Tb,Checkbox as vb,Image as wb,ListItemButton as bb,NotFound as xb,Typography as Eb}from"@rango-dev/ui";import Ge,{useState as Ib}from"react";import{Checkbox as Cb,Skeleton as ig}from"@rango-dev/ui";import Yn from"react";import{styled as Cl}from"@rango-dev/ui";var Xn=Cl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),kl=Cl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Tl=Cl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as yb,styled as Sb}from"@rango-dev/ui";var rg=Sb(yb,{height:61});var kb=30;function vl(){return Yn.createElement(Xn,null,Array.from(Array(kb),(t,e)=>Yn.createElement(rg,{hasDivider:!0,key:e,start:Yn.createElement(ig,{variant:"circular",width:35,height:35}),title:Yn.createElement(ig,{variant:"text",size:"large",width:90}),end:Yn.createElement(Cb,{checked:!1})})))}i(vl,"LoadingLiquiditySourceList");function wl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=Ib(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=kr(o,n),p={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=c.filter(S=>u.includes(S.type)),h=d.length===d.filter(S=>S.selected).length,f=i(()=>{d.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),g=d.map(S=>{let{selected:k,groupTitle:T,logo:v,id:b,...N}=S;return{id:`widget-setting-liquidity-source-${b.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(wb,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ge.createElement(vb,{checked:k,disabled:l}),title:Ge.createElement(Eb,{variant:"title",size:"xmedium"},zt.t(T)),selected:k,groupTitle:T,logo:v,...N}}),m=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=g;return r&&(C=g.filter(S=>wt(S.groupTitle,r))),Ge.createElement(te,{header:{title:zt.t(t),suffix:Ge.createElement(kl,null,Ge.createElement(Tb,{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(ie,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ge.createElement(vl,null),!C.length&&r?Ge.createElement(Tl,null,Ge.createElement(xb,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(Xn,{disabled:l},C.map(S=>{let{groupTitle:k,...T}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(bb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(wl,"LiquiditySourcePage");import{i18n as Ab}from"@lingui/core";import Ni from"react";import{useNavigate as Nb}from"react-router-dom";function ag(){let t=Nb(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=Ai({refetchQuote:n}),p=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Ni.createElement(te,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Ab.t("Routes"),suffix:Ni.createElement(go,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ni.createElement(ie,null,Ni.createElement(Kn,{fetch:l,loading:c,onClickOnQuote:p})))}i(ag,"RoutesPage");import{i18n as mg}from"@lingui/core";import{Divider as fg,getCategoriesCount as Ob,SelectableCategoryList as Ub}from"@rango-dev/ui";import Qt,{useState as gg}from"react";import{useNavigate as zb}from"react-router-dom";import{i18n as bl}from"@lingui/core";import{Divider as Mb,Image as Pb,ListItemButton as _b,NotFound as Db,Typography as dg}from"@rango-dev/ui";import nt,{useEffect as $b,useState as Fb}from"react";var sg=i((t,e,o)=>t.filter(n=>dr(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as Wb,styled as lg}from"@rango-dev/ui";var cg=lg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Wi=lg(bn,{padding:0,margin:0,listStyle:"none",[`& ${Wb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Bb,Skeleton as pg}from"@rango-dev/ui";import Bi from"react";var Lb=20;function ug(){return Bi.createElement(Wi,null,Array.from(Array(Lb),t=>Bi.createElement(Bb,{key:t,hasDivider:!0,start:Bi.createElement(pg,{variant:"circular",width:35,height:35}),title:Bi.createElement(pg,{variant:"text",size:"large",width:90})})))}i(ug,"LoadingBlockchainList");function xl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Fb(e),{fetchStatus:c}=y();$b(()=>{l([...sg(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?nt.createElement(Db,{title:bl.t("No results found"),description:bl.t("Try using different keywords")}):nt.createElement(Wi,{as:"ul",key:`${r}-${o}`},s.map(u=>nt.createElement(_b,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:nt.createElement(Pb,{src:u.logo,size:30}),title:nt.createElement(dg,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(dg,{variant:"label",size:"large"},bl.t("Select Chain")),nt.createElement(Mb,{size:4})),nt.createElement(cg,null,c==="loading"&&nt.createElement(ug,null),c==="success"&&p()))}i(xl,"BlockchainList");function Li(t){let{type:e}=t,o=je(),[n,r]=gg(""),[a,s]=gg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:p}=y(),u=zb(),d=y().blockchains({type:e}),h=Ob(d),f=!t.hideCategory&&h!==1;return Qt.createElement(te,{header:{title:mg.t("Select Chain")}},Qt.createElement(ie,{view:!0},f&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Ub,{setCategory:s,category:a,blockchains:d,isLoading:p==="loading"}),Qt.createElement(fg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:mg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:g=>r(g.target.value)}),Qt.createElement(fg,{size:16}),Qt.createElement(xl,{list:d,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:g=>{e==="custom-token"?u(`..?blockchain=${g.name}`,{replace:!0}):(e==="source"?c(g):l(g),o())}})))}i(Li,"SelectBlockchainPage");import{i18n as Pi}from"@lingui/core";import{Divider as Tg}from"@rango-dev/ui";import wo,{useState as Xb}from"react";import{useNavigate as Yb}from"react-router-dom";import{i18n as Al}from"@lingui/core";import{BlockchainsChip as Mi,Divider as Cg,Image as kg,Skeleton as Vb,Tooltip as Kb,Typography as Nl}from"@rango-dev/ui";import Pe from"react";import{useEffect as qb}from"react";var hg=["ETH","COSMOS","OSMOSIS"];function El(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Qb),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 c=0;c<=l;c++){let p=n[c];s=s.filter(u=>p.name!==u)}}n.sort(Hb(s)),r=n.splice(a)}return{list:n,more:r}}i(El,"prepare");function Qb(t,e){let o=hg,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(Qb,"sortByMostUsedBlockchains");function Hb(t){return i(function(o,n){let r=t.findIndex(c=>c===o.name),a=t.findIndex(c=>c===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(Hb,"generateSortByPreferredBlockchainsFor");function yg(t,e){return!!e.list.find(o=>o.name===t)}i(yg,"isInVisibleList");function Il(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();qb(()=>{if(e?.selected){let a=El(t,o,e);yg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=El(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Il,"usePrepareBlockchainList");import{styled as Gb}from"@rango-dev/ui";var Sg=Gb("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var jb=12;function Wl(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Il(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),p=O.use.resetFromBlockchain(),u=s.more.length>0,d=s.more.length===1,h=!d&&u;return Pe.createElement(Pe.Fragment,null,Pe.createElement(Cg,{size:12}),Pe.createElement(Nl,{variant:"label",size:"large"},Al.t("Select Chain")),Pe.createElement(Cg,{size:12}),Pe.createElement(Sg,null,l==="loading"&&Array.from(Array(jb),f=>Pe.createElement(Vb,{key:f,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Mi,{selected:!n,onClick:()=>{o==="from"?p():c()}},Pe.createElement(Nl,{variant:"body",size:"xsmall",color:"secondary500"},Al.t("All"))),s.list.map(f=>Pe.createElement(Kb,{key:f.name,content:f.shortName,side:"bottom",sideOffset:2,container:I()},Pe.createElement(Mi,{key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},Pe.createElement(kg,{src:f.logo,size:30})))),d?Pe.createElement(Mi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(kg,{src:s.more[0].logo,size:30})):null,h?Pe.createElement(Mi,{onClick:a,key:"more-blockchains"},Pe.createElement(Nl,{variant:"body",size:"xsmall",color:"secondary500"},Al._("More +{count}",{count:s.more.length}))):null)))}i(Wl,"BlockchainsSection");function Bl(t){let{type:e}=t,o=Yb(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:p}=O(),{getBalanceFor:u}=y(),[d,h]=Xb(""),g=(e==="source"?r:a)?.name??"",m=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:g,searchFor:d,getBalanceFor:u}),S=i(v=>{e==="source"?c(v):p(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:m,tokens:C}}):l({token:v,meta:{blockchains:m,tokens:C}})},"updateToken"),T={source:Pi.t("Source"),destination:Pi.t("Destination")};return wo.createElement(te,{header:{title:Pi.t("Swap {type}",{type:T[e]})}},wo.createElement(ie,null,wo.createElement(Wl,{blockchains:m,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{S(v)}}),wo.createElement(Tg,{size:24}),wo.createElement(Ct,{value:d,autoFocus:!0,placeholder:Pi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),wo.createElement(Tg,{size:16}),wo.createElement(zn,{list:C,selectedBlockchain:g,searchedFor:d,type:e,onChange:v=>{k(v);let b=m.find(N=>v.blockchain===N.name);b&&S(b),n()}})))}i(Bl,"SelectSwapItemsPage");import{i18n as Pl}from"@lingui/core";import{Alert as vx,Button as wx,styled as bx}from"@rango-dev/ui";import bo from"react";import{useInRouterContext as xx,useSearchParams as Ex}from"react-router-dom";import{i18n as Ig}from"@lingui/core";import{Divider as Ag,InfoIcon as ex,SlippageIcon as tx,TextField as ox,Tooltip as nx,Typography as Ng}from"@rango-dev/ui";import rt from"react";import{Chip as Zb,styled as Zn,TextField as Jb}from"@rango-dev/ui";var vg=Zn("div",{paddingTop:"$5",padding:"$10 $5"}),wg=Zn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Jb}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),bg=Zn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),_i=Zn("div",{maxWidth:"280px",padding:"$10"}),xg=Zn(Zb,{width:"61px",flexShrink:0});import{i18n as Ll}from"@lingui/core";import{Typography as Rb}from"@rango-dev/ui";import Jn from"react";function Eg(){return Jn.createElement(_i,null,Jn.createElement(Rb,{variant:"label",size:"medium",color:"neutral700"},Ll.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Jn.createElement("br",null),Jn.createElement("br",null),Jn.createElement("b",null,Ll.t("Warning")),":\xA0",Ll.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(Eg,"SlippageTooltipContent");function Ml(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(vg,null,rt.createElement(bg,null,rt.createElement(tx,{size:16,color:"gray"}),rt.createElement(Ag,{direction:"horizontal",size:4}),rt.createElement(Ng,{variant:"title",size:"xmedium"},Ig.t("Slippage tolerance per swap")),rt.createElement(Ag,{direction:"horizontal",size:4}),rt.createElement(nx,{container:I(),side:"top",sideOffset:4,content:rt.createElement(Eg,null)},rt.createElement(ex,{color:"gray"}))),rt.createElement(wg,null,ep.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(xg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(ox,{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>=rp&&s<=np?n(s):n(null)},suffix:o&&rt.createElement(Ng,{variant:"body",size:"small"},"%"),placeholder:Ig.t("Custom")})))}i(Ml,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as Wg,BridgesIcon as rx,ChevronRightIcon as Di,DarkModeIcon as Bg,Divider as Rn,ExchangeIcon as ix,InfinityIcon as ax,InfoIcon as sx,LanguageIcon as lx,LightModeIcon as Lg,List as cx,ListItem as px,ListItemButton as ux,Skeleton as dx,styled as mx,Switch as fx,Tabs as gx,TargetIcon as hx,Tooltip as yx,Typography as Ye}from"@rango-dev/ui";import _ from"react";import{useNavigate as Sx}from"react-router-dom";var Cx=mx("div",{width:"202px",height:"$40"}),kx=[{id:"light",icon:_.createElement(Lg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:_.createElement(Bg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:_.createElement(Wg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Auto"))}],Tx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return _.createElement(Wg,{...e});case"dark":return _.createElement(Bg,{...e});default:return _.createElement(Lg,{...e})}},"getThemeIcon");function Mg(){let t=Sx(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(W=>W.local===r)?.label,l=y().fetchStatus,c=y().swappers(),p=y().getDisabledLiquiditySources(),{config:{features:u}}=y(),d=y().customTokens(),h=Ve("theme",u),f=Ve("liquiditySource",u),g=Ve("language",u),m=Ve("customTokens",u),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=kr(c,p),T=k.filter(W=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(W.type)),v=T.length,b=T.filter(W=>W.selected).length,N=k.filter(W=>W.type==="DEX"),D=N.length,w=N.filter(W=>W.selected).length,x=i((W,K)=>{switch(l){case"loading":return _.createElement(dx,{variant:"text",size:"medium",width:50});case"failed":return _.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return _.createElement(Ye,{variant:"body",size:"medium"},`${W} / ${K}`)}},"handleSwapperEndItem"),E={id:"widget-setting-bridge-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:_.createElement(_.Fragment,null,x(b,v),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(Di,{color:"black"})),onClick:()=>t($.bridges),start:_.createElement(rx,{color:"gray",size:16})},A={id:"widget-setting-exchange-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:_.createElement(_.Fragment,null,x(w,D),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(Di,{color:"black"})),start:_.createElement(ix,{color:"gray",size:16}),onClick:()=>t($.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},`${d.length}`),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(Di,{color:"black"})),start:_.createElement(hx,{color:"gray",size:16}),onClick:()=>t($.customTokens)},L={id:"widget-setting-language-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Language")),start:_.createElement(lx,{color:"gray",size:16}),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},s),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(Di,{color:"black"})),onClick:()=>t($.languages)},X={id:"widget-setting-infinite-approval-item-btn",title:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),_.createElement(Rn,{direction:"horizontal",size:4}),_.createElement(yx,{side:"top",sideOffset:4,container:I(),content:_.createElement(_i,null,_.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},_.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.")))},_.createElement(sx,{color:"gray"}))),start:_.createElement(ax,{color:"gray",size:16}),end:_.createElement(fx,{checked:C}),onClick:S},oe={id:"widget-setting-theme-item-btn",type:_.createElement(px,null),title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Theme")),end:_.createElement(Cx,null,_.createElement(gx,{container:I(),items:kx,value:n,onChange:W=>o(W.id),type:"primary",borderRadius:"small"})),start:Tx(n)},Y=f?[]:[E,A];return m||Y.push(M),g||Y.push(L),Y.push(X),!e?.singleTheme&&!h&&Y.push(oe),_.createElement(cx,{type:_.createElement(ux,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Y})}i(Mg,"SettingsLists");var Ix=bx("div",{paddingLeft:"$8"});function Pg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Ex(),r=xx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return bo.createElement(te,{header:{title:Pl.t("Settings")}},bo.createElement(ie,null,o&&bo.createElement(vx,{type:"info",variant:"alarm",title:Pl.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:bo.createElement(Ix,null,bo.createElement(wx,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Pl.t("Reset")))}),bo.createElement(Ml,null),bo.createElement(Mg,null)))}i(Pg,"SettingsPage");import{i18n as gE}from"@lingui/core";import{cancelSwap as hE}from"@rango-dev/queue-manager-rango-preset";import{useManager as yE}from"@rango-dev/queue-manager-react";import{Alert as SE}from"@rango-dev/ui";import Zl from"react";import{useParams as CE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as Yx,getCurrentStep as Zx,getRelatedWalletOrNull as Jx}from"@rango-dev/queue-manager-rango-preset";import{Button as fh,CopyIcon as Rx,Divider as eE,DoneIcon as tE,IconButton as oE,QuoteCost as nE,RangoExplorerIcon as rE,StepDetails as iE,Tooltip as gh,Typography as xo,useCopyToClipboard as aE}from"@rango-dev/ui";import{useWallets as sE}from"@rango-dev/wallets-react";import hh from"bignumber.js";import{PendingSwapNetworkStatus as qi}from"rango-types";import j,{useEffect as yh,useRef as lE,useState as Sh}from"react";import{useNavigate as cE}from"react-router-dom";import{i18n as eo}from"@lingui/core";var Ax=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function _g(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"):`${Ax[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(_g,"timeSince");function Dg(t){return t.finishTime?_g(parseInt(t.finishTime)):_g(parseInt(t.creationTime))}i(Dg,"getSwapDate");import{PendingSwapNetworkStatus as Oi}from"rango-types";import Ui from"react";import{i18n as $i}from"@lingui/core";import{Button as $g,Divider as _l,MessageBox as Nx}from"@rango-dev/ui";import to from"react";var Fg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(_l,{size:20}),to.createElement(Nx,{type:"error",title:$i.t("Cancel Swap"),description:$i.t("Are you sure you want to cancel this swap?")}),to.createElement(_l,{size:32}),to.createElement($g,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},$i.t("Yes, Cancel it")),to.createElement(_l,{size:12}),to.createElement($g,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},$i.t("No, Continue"))),"CancelContent");import{i18n as Fi}from"@lingui/core";import{Button as Og,Divider as Dl,MessageBox as Wx,Typography as Bx}from"@rango-dev/ui";import Ht from"react";var Ug=i(({onDelete:t,onClose:e})=>Ht.createElement(Ht.Fragment,null,Ht.createElement(Dl,{size:20}),Ht.createElement(Wx,{type:"error",title:Fi.t("Delete Transaction"),description:Fi.t("Are you sure you want to delete this swap?")}),Ht.createElement(Dl,{size:32}),Ht.createElement(Og,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Fi.t("Yes, Delete it")),Ht.createElement(Dl,{size:12}),Ht.createElement(Og,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Ht.createElement(Bx,{variant:"title",size:"medium",color:"primary"},Fi.t("No, Cancel")))),"DeleteContent");import{i18n as $l}from"@lingui/core";import{PendingSwapNetworkStatus as Fl}from"rango-types";var Ol={[Fl.WaitingForNetworkChange]:{type:"loading",title:$l.t("Change Network")},[Fl.WaitingForConnectingWallet]:{type:"warning",title:$l.t("Connect Wallet")},[Fl.NetworkChanged]:{type:"success",title:$l.t("Network Changed")}};import{warn as Lx}from"@rango-dev/logging-core";import{MessageBox as Mx,Wallet as Px}from"@rango-dev/ui";import{useWallets as _x}from"@rango-dev/wallets-react";import en,{useState as Dx}from"react";import{styled as Ul}from"@rango-dev/ui";var zg=Ul("div",{display:"flex",justifyContent:"center"}),D5=Ul("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}}),Qg=Ul("img",{width:"100%"});var Hg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=Dx(),{getWalletInfo:p,state:u}=_x(),d=n?.walletType,h=d?pn(u(d)):null,f=d?p(d):null,g=a&&!!d&&!!h&&!!f,{list:m}=ft(),C=i(()=>{if(d){let S=m.find(k=>k.type===d);S?c(S):Lx(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return en.createElement(en.Fragment,null,en.createElement(Mx,{type:e,title:o,description:r}),g&&en.createElement(zg,null,en.createElement(Px,{container:I(),title:f.name,image:f.img,type:d,state:h,link:f.installLink,disabled:s,onClick:C})),en.createElement(po,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function zl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===Oi.WaitingForNetworkChange||e===Oi.WaitingForConnectingWallet||e===Oi.NetworkChanged;return Ui.createElement(J,{open:!!e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},c&&Ui.createElement(Hg,{type:Ol[e].type,title:Ol[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Oi.WaitingForNetworkChange}),e==="delete"&&Ui.createElement(Ug,{onClose:o,onDelete:n}),e==="cancel"&&Ui.createElement(Fg,{onClose:o,onCancel:r}))}i(zl,"SwapDetailsModal");import{i18n as er}from"@lingui/core";import{Button as Ql,Divider as tr,MessageBox as Vg,TokenAmount as $x,Typography as Kg}from"@rango-dev/ui";import fe from"react";import{Link as Fx,useNavigate as Ox}from"react-router-dom";var qg="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",Gg="/profile";function Hl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:p,percentageChange:u,description:d,diagnosisUrl:h}=t,f=Ox(),{showProfileBanner:g}=re();return fe.createElement(J,{open:e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},n==="success"?fe.createElement(Vg,{type:"success",title:er.t("Swap Successful")},fe.createElement($x,{direction:"vertical",tooltipContainer:I(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:p,percentageChange:u}),fe.createElement(tr,{size:12}),fe.createElement(Kg,{variant:"body",size:"medium",color:"neutral700",align:"center"},d)):fe.createElement(Vg,{type:"error",title:er.t("Transaction Failed"),description:d}),fe.createElement(tr,{size:30}),n==="success"&&fe.createElement(fe.Fragment,null,g&&fe.createElement(fe.Fragment,null,fe.createElement(Fx,{to:Gg},fe.createElement(Qg,{src:qg,alt:"Profile Banner"})),fe.createElement(tr,{size:30})),fe.createElement(Ql,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{f("../../")}},er.t("Done"))),fe.createElement(tr,{size:12}),h&&fe.createElement(fe.Fragment,null,fe.createElement(Ql,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},er.t("Diagnosis")),fe.createElement(tr,{size:12})),fe.createElement(Ql,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},fe.createElement(Kg,{variant:"title",size:"medium",color:"primary"},er.t("See Details"))))}i(Hl,"SwapDetailsCompleteModal");import Xx from"react";import{i18n as Gx}from"@lingui/core";import{Alert as ph,IconButton as Vx,LinkIcon as Kx}from"@rango-dev/ui";import oo,{Fragment as jx}from"react";import{Alert as zx,ChevronDownIcon as Qx,IconButton as Hx}from"@rango-dev/ui";import on,{useState as qx}from"react";import{css as or,darkTheme as jg,styled as qt,Typography as Ux}from"@rango-dev/ui";var Xg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),zi=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${jg} &`]:{color:"$secondary500"}}}}}),Yg=qt(bn,{padding:"$0 $20 $20 $20"}),wK=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Zg=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),bK=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),tn=or({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${jg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Jg=or({padding:"$5 0"}),Qi=or({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Rg=or({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),eh=or({width:"100%",padding:"0 $20 $10"}),th=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),oh=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Hi=qt(Ux,{wordBreak:"break-word"});import{styled as ql}from"@rango-dev/ui";var nh=ql("div",{display:"flex",flexDirection:"column",gap:"$10"}),rh=ql("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),ih=ql("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function ah(t){let{message:e}=t,[o,n]=qx(!1);return on.createElement(zx,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&on.createElement(Hx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},on.createElement(rh,{rotated:o},on.createElement(Qx,{size:12,color:"gray"}))),footer:on.createElement(ih,{open:o},on.createElement(Hi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(ah,"FailedAlert");import{i18n as sh}from"@lingui/core";import{Alert as Gl,Button as lh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Vl}from"rango-types";import nr from"react";function ch(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?nr.createElement(Gl,{type:"warning",title:n.shortMessage,action:nr.createElement(lh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Vl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},sh.t("Change"))}):r===Vl.WaitingForConnectingWallet?nr.createElement(Gl,{type:"warning",title:n.shortMessage,action:nr.createElement(lh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Vl.WaitingForConnectingWallet)}},sh.t("Connect"))}):nr.createElement(Gl,{type:"warning",title:n.shortMessage})}i(ch,"WarningAlert");function Kl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=vn(a),c=a.status==="waitingForApproval"&&!l,p=a.status==="running"&&!l,u=p&&!s||c&&!a.explorerUrl?.length;return oo.createElement(nh,null,a.explorerUrl?.map((d,h,f)=>{let g=h+d.url,m=h===f.length-1,C=(m&&p||c)&&!u,S=m&&a.status==="failed";return oo.createElement(jx,{key:g},oo.createElement(ph,{type:m&&(C&&"loading"||S&&"error")||"success",title:d.description?`${d.description} Tx`:Gx.t("View transaction"),action:d.url&&oo.createElement(Vx,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(d.url,"_blank")},oo.createElement(Kx,{size:12}))}))}),u&&oo.createElement(ph,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(ch,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(ah,{message:r}))}i(Kl,"SwapDetailsAlerts");var uh=2e3;var dh=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:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:rn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:st(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:st(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:rn(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:Xx.createElement(Kl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function mh(t){if(vn(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(mh,"getStepState");function jl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=sE(),c=y().blockchains(),p=y().swappers(),{findToken:u}=y(),d=O.use.retry(),h=re.use.isActiveTab(),f=cE(),[g,m]=aE(uh),C=lE(null),[S,k]=Sh(null),[T,v]=Sh(null),b=i(()=>{r(),k(null)},"onCancel"),N=be.use.getNotifications(),D=be.use.removeNotification(),w=N(),x=Zx(e),E=x?.networkStatus;yh(()=>{w.find(mt=>mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),D(e.requestId)):T&&v(null))},[e.status,e.requestId]),yh(()=>{W?k(qi.WaitingForNetworkChange):E===qi.WaitingForConnectingWallet||E===qi.NetworkChanged?k(E):k(null)},[E]);let A=fu(e),M=x?Yx(e,x):null,L=x?Jx(e,x):null,X=Dg(e),oe=gu(e),Y=i(ve=>!!l(ve)?.mobileWallet,"isMobileWallet"),W=E===qi.WaitingForNetworkChange&&!!M&&!!L?.walletType&&(Y(L.walletType)||a(L.walletType,M.network)),K=W?s.bind(null,L.walletType,[{namespace:M.namespace,network:M.network}]):void 0,se=mu(e,x),z=dh({swap:e,switchNetwork:K,showNetworkModal:E,setNetworkModal:k,message:se,blockchains:c,swappers:p}),me=z.length,[vt,Ze]=[e.steps[0],e.steps[me-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((ve,mt)=>ve+parseFloat(mt.feeInUsd||""),0),G=e.steps.find(ve=>ve.diagnosisUrl)?.diagnosisUrl,P=B(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),q=B(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),V=le?new hh(le).multipliedBy(Ze.toUsdPrice||0).toString():"",ge=new hh(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(q,P),he=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:B(le,6,6),token:z[me-1].to.token.displayName,conciseAddress:Sr(e.wallets[z[me-1].to.chain.displayName]?.address||""),chain:z[me-1].to.chain.displayName}}):j.createElement(oh,null,j.createElement(xo,{variant:"body",size:"medium",color:"neutral700",align:"center"},he?"":it.t("Transaction was not sent."),A?`${it.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:A.outputAmount,symbol:A.symbol,blockchain:A.blockchain}})}`:""),he&&j.createElement(Hi,{align:"center",variant:"body",size:"medium",color:"neutral700"},j.createElement("b",null,"Reason:")," ",he));return j.createElement(te,{header:{title:it.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&j.createElement(Vt,null,j.createElement(fh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},j.createElement(xo,{size:"medium",variant:"label",color:"error"},it.t("Delete"))))},footer:oe&&!T&&j.createElement(fh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ve=Br(e,c,u);d(ve),setTimeout(()=>{f("../../")},0)}},it.t("Try again"))},j.createElement(ie,{compact:!0,view:!0},j.createElement(zi,null,j.createElement("div",{className:tn()},j.createElement(xo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),j.createElement("div",{className:Qi()},j.createElement(xo,{variant:"label",size:"small",color:"neutral700"},o),j.createElement(gh,{container:I(),content:g?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:g||void 0,side:"bottom",alignOffset:-16,align:"end"},j.createElement(oE,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:m.bind(null,o||"")},g?j.createElement(tE,{size:16,color:"secondary"}):j.createElement(Rx,{size:16,color:"gray"}))),j.createElement(th,{target:"_blank",href:`${Tc}/swap/${o}`},j.createElement(gh,{container:I(),content:it.t("View on Rango Explorer"),side:"bottom"},j.createElement(rE,{size:20}))))),j.createElement("div",{className:tn()},j.createElement(xo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?it.t("Finished at"):it.t("Created at")),j.createElement(xo,{variant:"label",size:"small",color:"neutral700"},X))),j.createElement("div",{className:Rg()},j.createElement(nE,{fee:B(String(at),2,2),time:ln(mr(e.steps)),steps:me}),j.createElement(Ln,{from:{price:{value:B(e.inputAmount,6,6),usdValue:q,realUsdValue:ge,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:B(le,6,6),usdValue:P,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:B(ne,2,2),warningLevel:_t(ne??0)})),j.createElement("div",{className:eh()},j.createElement(xo,{variant:"title",size:"small"},it.t("Swaps steps"))),j.createElement(eE,{size:8}),j.createElement(Yg,{ref:C},z.map((ve,mt)=>{let rc=mt,nn=mh(e.steps[mt]),Vh=nn==="error"||nn==="in-progress"||nn==="warning"||nn==="completed"&&mt===z.length-1;return j.createElement(iE,{key:rc,step:ve,type:"swap-progress",ref:C,state:nn,hasSeparator:mt!==0,tabIndex:rc,isFocused:Vh,tooltipContainer:I()})}))),j.createElement(zl,{state:S,onClose:()=>k(null),onCancel:b,onDelete:n,message:se.detailedMessage.content,currentStepWallet:L,walletButtonDisabled:!h}),j.createElement(Hl,{open:!!T,diagnosisUrl:G,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(le,6,6),usdValue:P,realUsdValue:V,realValue:le||"",percentageChange:B(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(jl,"SwapDetails");import{i18n as Vi}from"@lingui/core";import{Divider as Th,NotFound as fE,Skeleton as ir,Typography as Ki}from"@rango-dev/ui";import ke from"react";import{i18n as pE}from"@lingui/core";import{Divider as uE,Skeleton as dE,Typography as mE}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Xl}from"@rango-dev/ui";var Ch=Xl("div",{width:"100%",height:"100%",padding:"$10 $20"}),rr=Xl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Gi=Xl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),D4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),$4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),F4=Tt({paddingTop:"$15",display:"flex"}),O4=Tt({padding:"$15 $0"}),U4=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),z4=Tt({paddingBottom:"$10"}),Q4=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),H4=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),q4=Tt({display:"flex",alignItems:"center"}),G4=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),kh=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Yl(){return Te.createElement(Ch,null,Te.createElement(_n,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(mE,{variant:"title",size:"small"},pE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(rr,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:kh()},Te.createElement(uE,{direction:"horizontal",size:20}),Te.createElement(dE,{height:22,variant:"rectangular"}))),Te.createElement(Gi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Gi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Gi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1}))))}i(Yl,"LoadingSwapDetails");function vh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(te,{header:{title:Vi.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Xg,null,ke.createElement(zi,null,ke.createElement("div",{className:tn()},ke.createElement(Ki,{variant:"label",size:"large",color:"neutral700"},`${Vi.t("Request ID")}`),ke.createElement("div",{className:Qi()},ke.createElement(Ki,{variant:"label",size:"small",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})),ke.createElement(Th,{direction:"horizontal",size:4}),ke.createElement(ir,{width:16,height:16,variant:"rectangular"}),ke.createElement(Th,{direction:"horizontal",size:4}),ke.createElement(ir,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:tn()},ke.createElement(Ki,{className:Jg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})),ke.createElement(Ki,{variant:"label",size:"small",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})))),ke.createElement(Yl,null)),!o&&ke.createElement(Zg,null,ke.createElement(fE,{title:Vi.t("Not found"),description:Vi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(vh,"SwapDetailsPlaceholder");function wh(){let{manager:t,state:e}=yE(),o=!e.loadedFromPersistor,n=pt(t),{requestId:r}=CE(),a=je(),{fetchStatus:s}=y();if(!r)return Zl.createElement(SE,{containerStyles:{margin:"20px"},type:"error",title:gE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",c=r?n.find(({swap:h})=>h.requestId===r):void 0,p=i(()=>{if(c?.id){let h=t?.get(c.id);h&&hE(h)}},"onCancel"),u=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),d=c?.swap;return!d||l?Zl.createElement(vh,{requestId:r,showSkeleton:l}):Zl.createElement(jl,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(wh,"SwapDetailsPage");import{i18n as bh}from"@lingui/core";import{Divider as kE,getCategoriesCount as TE,SelectableCategoryList as vE,styled as Eh,Typography as wE,Wallet as bE}from"@rango-dev/ui";import Bt,{useState as xh}from"react";var xE=Eh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),EE=Eh(ie,{textAlign:"center"});function Ih(){let{fetchStatus:t}=y(),[e,o]=xh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=xh(),l=re.use.isActiveTab(),{list:c}=ft(),p=Hc(c,n),d=TE(p)!==1,h=qc(c,e),f=i(g=>{Lc(c,r.multiWallets)||s(g)},"handleWalletItemClick");return Bt.createElement(te,{header:{title:bh.t("Connect Wallets")}},Bt.createElement(EE,null,d&&Bt.createElement(Bt.Fragment,null,Bt.createElement(vE,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Bt.createElement(kE,{size:24})),Bt.createElement(wE,{variant:"title",size:"xmedium",align:"center"},bh.t("Choose a wallet to connect.")),Bt.createElement(xE,null,h.map((g,m)=>{let C=`wallet-${m}-${g.type}`;return Bt.createElement(bE,{key:C,...g,container:I(),onClick:()=>f(g),isLoading:t==="loading",disabled:!l})}),Bt.createElement(po,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Ih,"WalletsPage");function Ah(){return Cu(),Fa(),IE([{path:$.home,element:_e.createElement(tg,null)},{path:$.routes,element:_e.createElement(ag,null)},{path:$.fromSwap,children:[{index:!0,element:_e.createElement(Bl,{type:"source"})},{path:$.blockchains,element:_e.createElement(Li,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:_e.createElement(Bl,{type:"destination"})},{path:$.blockchains,element:_e.createElement(Li,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:_e.createElement(Pg,null)},{path:$.languages,element:_e.createElement(ng,null)},{path:$.exchanges,element:_e.createElement(wl,{sourceType:"Exchanges"})},{path:$.bridges,element:_e.createElement(wl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:_e.createElement(uf,null)},{path:$.addCustomTokens,children:[{index:!0,element:_e.createElement(td,null)},{path:$.blockchains,element:_e.createElement(Li,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:_e.createElement(Bf,null)},{path:$.swapDetails,element:_e.createElement(wh,null)}]},{path:$.wallets,element:_e.createElement(Ih,null)},{path:$.confirmSwap,element:_e.createElement(Ym,null)}])}i(Ah,"AppRoutes");import{useQueueManager as DE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as $E}from"@rango-dev/wallets-shared";import{isEvmBlockchain as FE}from"rango-sdk";import{useContext as OE,useEffect as _h,useState as Dh}from"react";import{globalCss as AE}from"@rango-dev/ui";var Nh=i(()=>AE({"@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 Wh(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Mt("BASE_URL")}/meta/dapp/config?apiKey=${Mt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(Wh,"useFetchApiConfig");import{useWallets as NE}from"@rango-dev/wallets-react";import{useEffect as WE,useRef as BE}from"react";function Bh(){let{connect:t,state:e}=NE(),o=BE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);WE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Bh,"useForceAutoConnect");import{isApprovalTX as LE,RouteEventType as Lh,StepEventType as Mh,StepExecutionEventStatus as ME,WidgetEvents as ji}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ph}from"react";function Jl(){let t=be.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Ph(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===Mh.TX_EXECUTION&&a.status===ME.TX_SENT&&!LE(s)||a.type===Mh.SUCCEEDED){let p=l.wallets[s?.fromBlockchain],u=e.find(d=>d.address?.toLocaleLowerCase()===p.address?.toLocaleLowerCase()&&d.walletType===p.walletType&&d.chain===s?.fromBlockchain);if(u&&o([u]),s?.fromBlockchain!==s?.toBlockchain){let d=l.wallets[s?.toBlockchain],h=e.find(f=>f.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&f.walletType===d.walletType&&f.chain===s?.toBlockchain);h&&o([h])}}t(a,l)},"handleStepEvent");return ye.on(ji.StepEvent,n),()=>ye.off(ji.StepEvent,n)},[ye,e]),Ph(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===Lh.FAILED||a.type===Lh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return ye.on(ji.RouteEvent,n),()=>ye.off(ji.RouteEvent,n)},[ye])}i(Jl,"useSubscribeToWidgetEvents");import{useManager as PE}from"@rango-dev/queue-manager-react";import{useEffect as _E}from"react";function Rl(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=PE();_E(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(pt(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Rl,"useSyncNotifications");function ec(){Bh(),Nh(),Jl(),Rl();let t=y().blockchains(),{canSwitchNetworkTo:e}=Zr(),[o,n]=Dh(""),[r,a]=Dh(),s=OE(Ir),l=t.filter(FE),{fetchApiConfig:c}=Wh();_h(()=>()=>Su(),[]),DE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),_h(()=>(ao.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(p=>{a(p),p===$E(o)?.[0]&&n("")}),c().catch(console.log),ao.destroy),[])}i(ec,"useBootstrap");import{styled as UE}from"@rango-dev/ui";var $h=UE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Xi(){ec();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=Rt();return tc.createElement(zE,{language:o},tc.createElement($h,{id:"swap-container",className:e()},tc.createElement(Ah,null)))}i(Xi,"Main");import{setSolanaSignerConfig as sI}from"@rango-dev/signer-solana";import nc,{useEffect as Hh,useMemo as lI}from"react";import{useState as QE}from"react";var HE=i(()=>{let[t,e]=QE(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=Bc(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Fh=HE;import{checkWaitingForNetworkChange as qE,makeQueueDefinition as GE}from"@rango-dev/queue-manager-rango-preset";import{Provider as VE}from"@rango-dev/queue-manager-react";import{useWallets as KE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as jE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as XE}from"rango-types";import YE,{useMemo as ZE}from"react";function JE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=KE(),l=ZE(()=>GE({API_KEY:t.apiKey||Mt("API_KEY"),BASE_URL:Mt("BASE_URL"),emitter:{emit:ye.emit}}),[t.apiKey]),{blockchains:c,connectedWallets:p}=y(),u=c(),d={blockchains:p.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,b)=>a(v,b.network)?await r(v,[b]):void 0,"switchNetwork"),f=i(v=>!!s(v).mobileWallet,"isMobileWallet"),g=u.filter(v=>v.enabled).reduce((v,b)=>(v[b.name]=b,v),{}),m=u.filter(XE),C=i(v=>{let{supportedChains:b}=s(v);return un(b)},"getSupportedChainNames"),S=e(),k={meta:{blockchains:g,evmBasedChains:m,evmNetworkChainInfo:jE(m),getSupportedChainNames:C},getSigners:o,wallets:d,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:f},T=re.use.isActiveTab();return YE.createElement(VE,{queuesDefs:[l],context:k,onPersistedDataLoaded:v=>{qE(v)},isPaused:!T},t.children)}i(JE,"QueueManager");var Oh=JE;import{useManager as nI}from"@rango-dev/queue-manager-react";import rI,{createContext as iI,useContext as aI}from"react";function Uh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:h,toToken:f,requestAmount:g}=p,m={blockchains:e,tokens:o};if(u!==void 0){let C=e.find(S=>S.name===u)??null;n(C)}if(d!==void 0){let C=d?t(d)??null:null;r({meta:m,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:m,token:C})}g!==void 0&&l(g)},"updateQuoteInputs")}i(Uh,"useUpdateQuoteInputs");import{cancelSwap as RE,getCurrentNamespaceOfOrNull as eI,getCurrentStep as tI,getRelatedWalletOrNull as oI}from"@rango-dev/queue-manager-rango-preset";var Yi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return pt(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=Br(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&RE(o)}getCurrentStepInfo(e){let o=tI(e);return{step:o,wallet:o?oI(e,o):null,network:o?eI(e,o)?.network:null}}};var zh=iI(void 0);function oc(t){let{manager:e}=nI(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new Yi(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=y(),u=$c(a()),d=y().blockchains(),h=y().tokens(),f=y().swappers(),g=y().fetchStatus,m=Rt().resetLanguage,C=be().getNotifications(),S=be().clearNotifications,k=Uh(),{fromBlockchain:T,toBlockchain:v,fromToken:b,toToken:N,inputAmount:D}=O(),w={isActiveTab:o,setCurrentTabAsActive:ao.forceClaim,history:c,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async x=>l(x)},meta:{blockchains:d,tokens:h,swappers:f,loadingStatus:g,findToken:r},resetLanguage:m,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:b?{symbol:b.symbol,blockchain:b.blockchain,address:b.address}:null,toBlockchain:v?.name??null,toToken:N?{symbol:N.symbol,blockchain:N.blockchain,address:N.address}:null,requestAmount:D},updateQuoteInputs:k}};return rI.createElement(zh.Provider,{value:w},t.children)}i(oc,"WidgetInfo");function Qh(){let t=aI(zh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Qh,"useWidget");function Zi(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Fh();return Hh(()=>{n&&r(n)},[n]),lI(()=>{Gc({API_KEY:o?.apiKey||pr,BASE_URL:o?.apiUrl||kc})},[o.apiKey,o.apiUrl]),Hh(()=>{t.config?.signers?.customSolanaRPC&&sI("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),nc.createElement(Ar,{config:o,onUpdateState:e},nc.createElement(Oh,{apiKey:o.apiKey},nc.createElement(oc,null,t.children)))}i(Zi,"WidgetProvider");function qh(t){let e=t.config?.externalWallets;return Ji.createElement(Up,null,e?Ji.createElement(Xi,null):Ji.createElement(Zi,{config:t.config??cr},Ji.createElement(Xi,null)))}i(qh,"Widget");function Gh(){let{on:t,off:e}=ye;return{on:t,off:e}}i(Gh,"useWidgetEvents");var J3={DerivationPath:Sn,Namespaces:yn,isOnDerivationPath:kn,isOnNamespace:Cn};export{b3 as EventSeverity,Lo as MainEvents,P3 as Networks,$3 as PendingSwapNetworkStatus,ma as QuoteEventTypes,x3 as RouteEventType,oa as SUPPORTED_FONTS,J3 as StatefulConnect,E3 as StepEventType,I3 as StepExecutionBlockedEventStatus,A3 as StepExecutionEventStatus,De as UI_ID,ga as UiEventTypes,fa as WalletEventTypes,L3 as WalletEvents,_3 as WalletTypes,qh as Widget,Lo as WidgetEvents,Zi as WidgetProvider,Ar as WidgetWallets,Ya as customizedThemeTokens,W3 as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,Zr as useWallets,Qh as useWidget,Gh as useWidgetEvents,Xy as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map