@rango-dev/widget-embedded 0.33.3 → 0.33.4-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var Wh=Object.defineProperty;var i=(t,e)=>Wh(t,"name",{value:e,configurable:!0});import{EventSeverity as bj,RouteEventType as Ej,StepEventType as Ij,StepExecutionBlockedEventStatus as Aj,StepExecutionEventStatus as Nj}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Mj}from"@rango-dev/wallets-core/legacy";import{useWallets as Zr,Events as Lj}from"@rango-dev/wallets-react";import{Networks as Dj,WalletTypes as _j}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Fj}from"rango-types";import{Divider as sS}from"@rango-dev/ui";import mo,{useEffect as lS,useRef as pS,useState as Ec}from"react";import{WalletState as Mh}from"@rango-dev/ui";import{useWallets as Bh}from"@rango-dev/wallets-react";import{useReducer as Lh}from"react";function sp(t){return!!t.derivationPath}i(sp,"isStateOnDerivationPathStep");function lp(t){return!!t.namespace}i(lp,"isStateOnNamespace");var er={status:"init",namespace:null,derivationPath:null};function pp(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return er;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:er;default:throw new Error("Action hasn't been defined.")}}i(pp,"reducer");function qt(){let{state:t,disconnect:e,connect:o}=Bh(),[n,r]=Lh(pp,er),a=i(async(c,m,g)=>{r({type:"reset"});try{return await o(c,void 0,m),{status:"connected"}}catch(d){let f=d?.message?`Error: ${d.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:d})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Mh.DISCONNECTED){if(!c.namespaces)return await a(c.type,void 0,m);let d=c.namespaces.length>1,f=c.needsDerivationPath;return d?(r({type:"needsNamespace",payload:{providerType:c.type,providerImage:c.image,availableNamespaces:c.namespaces,singleNamespace:c.singleNamespace}}),{status:"namespace"}):f?(r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:c.namespaces[0]}}),{status:"derivation-path"}):await a(c.type,c.namespaces.map(h=>({namespace:h})),m)}return m?.disconnectIfConnected?(await u(c.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(c,m)=>{let g=c.singleNamespace,d=c.needsDerivationPath,f=m[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(g&&d)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:f}}),{status:"derivation-path"};if(!lp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let h=n.namespace.providerType,k=m.map(S=>({namespace:S}));return await a(h,k)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!sp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,d)},"handleDerivationPath"),u=i(async c=>{let m=t(c);return m.connected||m.connecting?(await e(c),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:p,getState:()=>n,resetState:c=>{r(c==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(qt,"useStatefulConnect");import{WalletState as Sa}from"@rango-dev/ui";import{useWallets as wy}from"@rango-dev/wallets-react";import{detectMobileScreens as by,KEPLR_COMPATIBLE_WALLETS as Ey,WalletTypes as Bo}from"@rango-dev/wallets-shared";import{useCallback as Iy,useEffect as Ay}from"react";import fy,{createContext as gy,useContext as hy,useEffect as yy,useRef as Sy}from"react";import{create as my}from"zustand";import{persist as dy}from"zustand/middleware";var oa=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},Ao=new oa;function tr(t,e){return e.find(o=>o.name===t)?.displayName}i(tr,"getBlockchainDisplayNameFor");function pt(t,e){return e.find(o=>o.name===t)?.shortName}i(pt,"getBlockchainShortNameFor");function cp(t,e){return e.find(o=>o.name===t)?.logo}i(cp,"getBlockchainImage");function on(t,e){return e.find(o=>o.id===t)?.title}i(on,"getSwapperDisplayName");function nn(t,e){return e.find(o=>o.name===t)??null}i(nn,"findBlockchain");function na(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(na,"isTokenNative");function _e(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(_e,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");function rn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=_e(p));let u=o.tokensMapByTokenHash.get(p);u&&(n[p]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(p=>{l.has(p)||a(o.tokensMapByBlockchainName[p])})}return s.forEach(l=>{let p=r[l];if(!p&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}p&&(p.isExcluded?(a(o.tokensMapByBlockchainName[l]),p.tokens.forEach(u=>{let c=_e(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(rn,"matchTokensFromConfigWithMeta");function or(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(or,"getSupportedBlockchainsFromConfig");var ra={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"}},Ph={clientUrl:void 0},Dh={liquiditySources:void 0},up=i((t,e,o)=>({config:{...ra,...t},iframe:Ph,campaignMode:Dh,getLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?r.liquiditySources:n.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:n,campaignMode:r}=o();return r.liquiditySources?.length?[]:n},excludeLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?!1:!!n.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:n}=o();return!!n.liquiditySources?.length},updateConfig:n=>{let r=o().config,{_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s}=o(),l=rn({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=rn({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});Ao.set("supportedSourceTokens",l),Ao.set("supportedDestinationTokens",p),e({config:{...r,...n}})},updateCampaignMode:(n,r)=>{let a=o().campaignMode;e({campaignMode:{...a,[n]:r}})},updateIframe:(n,r)=>{let a=o().iframe;e({iframe:{...a,[n]:r}})}}),"createConfigSlice");import{TransactionType as mp}from"rango-types";var dp=[mp.EVM,mp.SOLANA];import{RangoClient as Yh}from"rango-sdk";import{UI_ID as _h}from"@rango-dev/ui";var nr="c6381a79-2817-4602-83bf-6a641a409e32",fp="https://api.rango.exchange",gp="https://explorer.rango.exchange",$e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",..._h};import{BlockchainCategories as qh,WalletState as Et}from"@rango-dev/ui";import{legacyReadAccountAddress as Hh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as Gh,getCosmosExperimentalChainInfo as Vh,isEvmAddress as Kh,KEPLR_COMPATIBLE_WALLETS as vI,Networks as Ap}from"@rango-dev/wallets-shared";import ca from"bignumber.js";import{isCosmosBlockchain as jh}from"rango-types";import $h from"bignumber.js";var Ue=new $h(0);import{WalletTypes as Fh}from"@rango-dev/wallets-shared";var hp=[Fh.LEAP];import{BlockchainCategories as aa,WalletState as Qh}from"@rango-dev/ui";import{TransactionType as rr}from"rango-sdk";var yp="Roboto",ia=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function Wo(t){return Array.from(new Set(t))}i(Wo,"removeDuplicateFrom");function pa(t,e){return t.length===e.length&&t.every((o,n)=>o===e[n])}i(pa,"areEqual");function xp(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(xp,"debounce");function et(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(et,"containsText");function kp(t,e){return t.toLowerCase()===e.toLowerCase()}i(kp,"exactText");function Tp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(Tp,"startWithText");var A=i(()=>document.getElementById($e.SWAP_BOX_ID),"getContainer"),an=i(()=>document.getElementById($e.EXPANDED_BOX_ID),"getExpanded");function vp(t,e,o){let n=!!e&&kp(e,t),r=!!o&&kp(o,t);return n!==r?n?-1:1:0}i(vp,"compareExactMatchText");function sa(t,e,o){let n=!!e&&et(e,t),r=!!o&&et(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(sa,"compareContainsText");function la(t,e,o){let n=!!e&&Tp(e,t),r=!!o&&Tp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(la,"compareStartWithText");function wp(t,e,o){if(!o)return 0;let n=vp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=vp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=la(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=sa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=la(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=sa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=la(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=sa(o,t.address,e.address);if(r!==0)return r}return 0}i(wp,"compareWithSearchFor");var ir=i((t,e)=>{switch(e){case aa.ALL:return!0;case aa.UTXO:return t===rr.TRANSFER;case aa.OTHER:return t!==rr.TRANSFER&&t!==rr.COSMOS&&t!==rr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),bp=i(t=>ia.find(o=>o.value===t)?.url,"getFontUrlByName");function Ep(t,e){let o=!!t.find(n=>n.state===Qh.CONNECTED);return e===!1&&o}i(Ep,"isSingleWalletActive");import{BigNumber as Ip}from"bignumber.js";var sn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),B=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Ip(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Ip(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var ar=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var bt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),ln=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function pn(t){switch(!0){case t.connected:return Et.CONNECTED;case t.connecting:return Et.CONNECTING;case!t.installed:return Et.NOT_INSTALLED;default:return Et.DISCONNECTED}}i(pn,"mapStatusToWalletState");function Np(t,e,o,n){return o.filter(r=>!hp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,namespaces:u,singleNamespace:c,supportedChains:m,needsDerivationPath:g}=e(r),d=Wo(m.map(h=>h.type)),f=pn(t(r));return{title:a,image:s,link:Gh(l),state:f,type:r,showOnMobile:p,namespaces:u,singleNamespace:c,blockchainTypes:d,needsDerivationPath:g}})}i(Np,"mapWalletTypesToWalletInfo");function pr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(pr,"walletAndSupportedChainsNames");function Wp(t,e,o,n,r){let a=[];function s(p,u){if(!!!a.find(m=>m.chain===p)){let m={address:u,chain:p,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(p=>{let{address:u,network:c}=Hh(p),m=l.length>0,g=l.includes(c),d=c===Ap.Unknown;if(m&&!g&&!d)return;let h=c===Ap.Unknown&&Kh(u);if(d&&!h)return;o.includes(c)||h?r?s(c,u.toLowerCase()):l.filter(C=>o.includes(C)).forEach(C=>{s(C,u.toLowerCase())}):s(c,u)}),a}i(Wp,"prepareAccountsForWalletStore");function ao(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,g=u.to.blockchain,d=a===o.swaps.length-1,f=c===p.length-1;(!d&&!f||d&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(g)})}e==="all"&&n.add(l)}),Array.from(n)}i(ao,"getQuoteWallets");function cr(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(cr,"isAccountAndWalletMatched");function Mp(t,e){let{blockChain:o,balances:n=[]}=t;return n?.map(r=>({chain:o,symbol:r.asset.symbol,ticker:r.asset.symbol,address:r.asset.address||null,rawAmount:r.amount.amount,decimal:r.amount.decimals,amount:new ca(r.amount.amount).shiftedBy(-r.amount.decimals).toFixed(),logo:"",usdPrice:e(r.asset)?.usdPrice||null}))||[]}i(Mp,"makeBalanceFor");function Bp(t){return{...t,loading:!1,error:!0}}i(Bp,"resetConnectedWalletState");var Lp=i(t=>{let e=new Set,n=t?.reduce((a,s)=>a.findIndex(l=>l.address===s.address&&l.chain===s.chain)===-1?[...a,s]:a,[])?.map(a=>{let s={name:a.chain,accounts:[]};return e.has(a.address)||e.add(a.address),e.forEach(l=>{a.address===l&&s.accounts.push(a)}),s}),r=B(n?.flatMap(a=>a.accounts)?.flatMap(a=>a?.balances)?.map(a=>new ca(a?.amount||Ue).multipliedBy(a?.usdPrice||0))?.reduce((a,s)=>a.plus(s),Ue)||Ue).toString();return Xh(r)},"calculateWalletUsdValue");function Xh(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(Xh,"numberWithThousandSeparator");var ur=i((t,e)=>{let o=Vh(Object.entries(t).map(([,n])=>n).filter(jh));return o&&o[e]?.experimental},"isExperimentalChain");function mr(t){return t?{...t,amount:B(t.amount,8,8),usdValue:B(t.usdValue,4,4)}:null}i(mr,"formatBalance");function Pp(t,e){return t?.usdValue||e?.usdValue?parseFloat(e?.usdValue||"0")-parseFloat(t?.usdValue||"0"):t?.amount||e?.amount?parseFloat(e?.amount||"0")-parseFloat(t?.amount||"0"):0}i(Pp,"compareTokenBalance");function so(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(so,"areTokensEqual");function Dp(t){return t.sort((e,o)=>+(o.state===Et.CONNECTED)-+(e.state===Et.CONNECTED)||+(o.state===Et.DISCONNECTED||o.state===Et.CONNECTING)-+(e.state===Et.DISCONNECTED||e.state===Et.CONNECTING))}i(Dp,"sortWalletsBasedOnConnectionState");function dr(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(dr,"getConciseAddress");function _p({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(_p,"getAddress");function fr(t){return t.flatMap(e=>e.balances).reduce((e,o)=>{let n={amount:o?.amount??"",decimals:o?.decimal??0,usdValue:o?.usdPrice?new ca(o?.usdPrice??Ue).multipliedBy(o?.amount).toString():""},r=o?_e({symbol:o.symbol,blockchain:o.chain,address:o.address}):null,a=r?e[r]:null;return r&&(!a||a&&a.amount<n.amount)&&(e[r]=n),e},{})}i(fr,"makeTokensBalance");var $p=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Fp(t){return t.map(e=>e.state).join("-")}i(Fp,"hashWalletsState");function Op(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(Op,"filterBlockchainsByWalletTypes");function Up(t,e){return e===qh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ir(n,e))return!0;return!1})}i(Up,"filterWalletsByCategory");var ua={API_KEY:nr};function ct(t){return ua[t]||""}i(ct,"getConfig");function zp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ua=e,ua}i(zp,"initConfig");var Qp=20,qp=25,ma="theme-widget",da=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>so(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>so(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),fa=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Hp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var gr,Ht=i(()=>gr||(gr=new Yh(ct("API_KEY"),ct("BASE_URL")),gr),"httpService");function hr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Wo(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(p=>p===s.swapperGroup)),l&&s.types.map(p=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:p,selected:!e.includes(s.swapperGroup)})})}}),n}i(hr,"getUniqueSwappersGroups");function Gp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Gp,"sortLiquiditySourcesByGroupTitle");function je(t,e){return e?.[t]==="hidden"}i(je,"isFeatureHidden");function Vp(t,e){return e?.[t]==="enabled"}i(Vp,"isFeatureEnabled");var Kp=i((t,e,o)=>je("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var jp=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let p=or({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>dp.includes(c.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(p=>!(s.length>0&&!s.includes(p.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),p=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",c=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=Ao.get(c);m?.length||(m=rn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Ao.set(c,m)),m=Kp(m,s,a.features);let g=e().blockchains({type:o.type});return m.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!g.some(h=>h.name===f.blockchain)?!1:o.searchFor?!!(et(f.symbol,o.searchFor)||et(f.address||"",o.searchFor)||et(f.name||"",o.searchFor)):!0).sort((f,h)=>{let k=e().isTokenPinned(f,o.type),S=e().isTokenPinned(h,o.type);if(k!==S)return k?-1:1;if(o.getBalanceFor){let N=o.getBalanceFor(f),M=o.getBalanceFor(h),w=Pp(N,M);if(w!==0)return w}let C=p.get(f.blockchain),T=p.get(h.blockchain),v=na(f,C),x=na(h,T);if(v!==x)return v?-1:1;if(f.isPopular!==h.isPopular)return f.isPopular?-1:1;if(o.searchFor){let N=wp(f,h,o.searchFor);if(N)return N}return f.isSecondaryCoin!==h.isSecondaryCoin?f.isSecondaryCoin?1:-1:C&&T?C.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=_e(o),s=n.get(a);return s||(s=r.find(l=>_e(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>so(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let c=a?.includes(u.swapperGroup);return s||!a||a.length===0?!c:c}).sort(Gp)},fetch:async()=>{try{let{enableCentralizedSwappers:o}=e().config,n=await Ht().getAllMetadata({enableCentralizedSwappers:o});t({fetchStatus:"success"});let r=new Map,a=new Map,s={},l=[],p=n.popularTokens,u=n.swappers,c=new Set;n.tokens.forEach(g=>{c.add(g.blockchain),l.push(g)}),n.blockchains.sort((g,d)=>g.sort-d.sort).forEach(g=>{g.enabled&&c.has(g.name)&&r.set(g.name,g)}),l.forEach(g=>{let d=_e(g);s[g.blockchain]||(s[g.blockchain]=[]),a.set(d,g),s[g.blockchain].push(d)}),t({_blockchainsMapByName:r,_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Chinese as Zh,English as Jh,Finland as Rh,French as ey,German as ty,Greece as oy,Italian as ny,Japanese as ry,Netherlands as iy,Poland as ay,Portuguese as sy,Russian as ly,Spanish as py,Swedish as cy,Ukrainian as uy}from"@rango-dev/ui";var Xp=[{title:"English",label:"English",local:"en",SVGFlag:Jh},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:py},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ey},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:ry},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:sy},{title:"Chinese",label:"\u4E2D\u56FD\u4EBA",local:"zh",SVGFlag:Zh},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:ly},{title:"German",label:"Deutsch",local:"de",SVGFlag:ty},{title:"Ukrainian",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:uy},{title:"Swedish",label:"svenska",local:"sv",SVGFlag:cy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:Rh},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:iy},{title:"Greek",label:"Grieks",local:"el",SVGFlag:oy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:ny},{title:"Polish",label:"Polski",local:"pl",SVGFlag:ay}],Mo="en";var Yp=[.5,1,3],Zp=1,Jp=5,Rp=100,ec=0;var tc=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Zp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let p=s===o,u=l<=9;return p&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Wo(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=je("theme",n),s=je("language",n),l=je("liquiditySource",n),p=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...p&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Mo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Mo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=or({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");function oc(t){return my()(dy((...e)=>({...jp(...e),...tc(...e),...up(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(oc,"createAppStore");var nc=gy(null);function y(){let t=hy(nc);if(yy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function rc(t){let e=Sy();return e.current||(e.current=oc(t.config)),fy.createElement(nc.Provider,{value:e.current},t.children)}i(rc,"AppStoreProvider");import{create as Ty}from"zustand";import{subscribeWithSelector as vy}from"zustand/middleware";import Cy from"mitt";var ye=Cy(),yr={on:ye.on,off:ye.off};import{WidgetEvents as ic}from"@rango-dev/queue-manager-rango-preset";var ha=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ha||{}),Sr=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Sr||{}),ya=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ya||{}),lo=(a=>(a[a.RouteEvent=ic.RouteEvent]="RouteEvent",a[a.StepEvent=ic.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(lo||{});var ky=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"),Gt=ky;var Z=Gt(Ty()(vy((t,e)=>({connectedWallets:[],balances:{},loading:!1,connectWallet:(o,n)=>{ye.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}});let r=e().getWalletsDetails;t(a=>({loading:!0,connectedWallets:a.connectedWallets.filter(s=>s.walletType!==o[0].walletType).concat(o.map(s=>{let l=!a.connectedWallets.some(p=>p.chain===s.chain&&p.selected&&p.walletType!==s.walletType);return{balances:[],address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!0,error:!1}}))})),r(o,n)},disconnectWallet:o=>{t(n=>{n.connectedWallets.find(l=>l.walletType===o)&&ye.emit("walletEvent",{type:"disconnect",payload:{walletType:o}});let r=n.connectedWallets.filter(l=>l.selected&&l.walletType!==o).map(l=>l.chain),a=n.connectedWallets.filter(l=>l.walletType!==o).map(l=>r.includes(l.chain)?l:(r.push(l.chain),{...l,selected:!0}));return{balances:fr(a),connectedWallets:a}})},selectWallets:o=>t(n=>({connectedWallets:n.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})})),clearConnectedWallet:()=>t(()=>({connectedWallets:[],selectedWallets:[]})),getWalletsDetails:async(o,n,r=!0)=>{let a=e().getWalletsDetails;t(s=>({loading:!0,connectedWallets:s.connectedWallets.map(l=>o.find(p=>cr(p,l))?{...l,loading:!0}:l)}));try{let s=o.map(({address:u,chain:c})=>({address:u,blockchain:c})),p=(await Ht().getWalletsDetails(s)).wallets;if(p)t(u=>{let c=u.connectedWallets.map(g=>{let d=o.find(h=>cr(h,g)),f=p.find(h=>h.address===g.address&&h.blockChain===g.chain);return f?.failed&&d&&r&&a([d],n,!1),d&&f?{...g,explorerUrl:f.explorerUrl,balances:Mp(f,n),loading:!1,error:!1}:g});return{loading:!1,balances:fr(c),connectedWallets:c}});else throw new Error("Wallet not found")}catch{t(l=>{let p=l.connectedWallets.map(c=>o.find(m=>cr(m,c))?Bp(c):c);return{loading:!1,balances:fr(p),connectedWallets:p}})}},getBalanceFor:o=>{let{balances:n}=e(),r=_e(o);return n[r]??null}}))));import{allProviders as xy}from"@rango-dev/provider-all";function Cr(t,e){let o=xy({walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0});if(t){let n=[];return t.forEach(r=>{if(typeof r=="string"){let a=o.find(s=>s.config.type===r);a?n.push(a):console.warn(`Couldn't find ${r} provider. Please make sure you are passing the correct name.`)}else n.push(r)}),n}return o}i(Cr,"matchAndGenerateProviders");function ac(t,e){return Cr(t,e).map(r=>r.config.type)}i(ac,"configWalletsToWalletName");var Ny=Object.values(Bo);function ft(t){let{chain:e}=t||{},{config:o}=y(),{state:n,getWalletInfo:r}=wy(),{connectedWallets:a}=Z(),s=y().blockchains(),{handleDisconnect:l}=qt(),p=ac(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink})||Ny,u=Np(n,r,p,e);u=by()?u.filter(h=>h.showOnMobile!==!1&&n(h.type).installed):u;let c=Dp(u),m=i(h=>!a.find(k=>k.walletType===h&&k.chain===e),"isExperimentalChainNotAdded"),g=Iy(()=>{let h=u?.filter(k=>k.state===Sa.CONNECTING)||[];for(let k of h)l(k.type)},[Fp(u)]);Ay(()=>()=>{g()},[]);let d=i(h=>{let k=h.find(C=>C.type===Bo.DEFAULT);return!k||k.state===Sa.NOT_INSTALLED?!1:h.filter(C=>C.state!=Sa.NOT_INSTALLED&&![Bo.DEFAULT,Bo.WALLET_CONNECT_2,Bo.LEDGER].includes(C.type)&&r(C.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((h,k,S)=>ur(S,k)&&m(h)&&!Ey.includes(h)||h==Bo.DEFAULT&&!d(u),"shouldExcludeWallet");return{list:c.filter(h=>!f(h.type,e??"",s)),terminateConnectingWallets:g}}i(ft,"useWalletList");import{Modal as By}from"@rango-dev/ui";import Ly from"react";import{create as My}from"zustand";var sc="rango-widget";var cn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(sc),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var se=Gt(My()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})}}))),po=new cn({onInit:()=>se.setState({tabManagerInitiated:!0}),onClaim:()=>se.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>se.setState({isActiveTab:!1})});function J(t){let{watermark:e}=se();return Ly.createElement(By,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Ca}from"@lingui/core";import{Button as Oy,Checkbox as Uy,Divider as zy,Image as yc,ListItemButton as Qy,MessageBox as qy,Radio as Hy,RadioRoot as Gy}from"@rango-dev/ui";import{namespaces as Sc}from"@rango-dev/wallets-shared";import xe,{useMemo as Vy,useState as Ky}from"react";import{css as Py,darkTheme as pc,IconButton as Dy,styled as co}from"@rango-dev/ui";var It=co(Dy,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${pc} &`]:{backgroundColor:"$neutral"}}}),cc=co("div",{position:"absolute",background:"$secondary500",[`.${pc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=co("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),uc=co("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"}}}}),mc=co("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),dc=co("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),fc=Py({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),kr=co("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as _y,styled as Tr}from"@rango-dev/ui";var bA=Tr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Lo=Tr("div",{position:"relative"}),$y=_y({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Po=Tr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${$y} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vr=Tr("div",{"& img":{borderRadius:"50%"}});function gc(t,e){return t.find(o=>o.name===e)?.logo}i(gc,"getBlockchainLogo");import{styled as Fy}from"@rango-dev/ui";var hc=Fy("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function un(t){let{singleNamespace:e,availableNamespaces:o,providerImage:n}=t.value,[r,a]=Ky([]),s=y().blockchains(),l=Vy(()=>o?.map(c=>({name:c,logo:gc(s,Sc[c].mainBlockchain),title:Sc[c].title})),[o]),p=i(c=>{a(e?[c]:m=>m.includes(c)?m.filter(g=>g!==c):m.concat(c))},"onSelect"),u=i(c=>e?xe.createElement(Gy,{value:r?.[0]},c):xe.createElement(xe.Fragment,null,c),"wrapRadioRoot");return xe.createElement(xe.Fragment,null,xe.createElement(zy,{size:20}),xe.createElement(qy,{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:xe.createElement(Lo,null,xe.createElement(kr,null,xe.createElement(yc,{src:n,size:45})),xe.createElement(Po,null))}),xe.createElement(hc,null,u(xe.createElement(xe.Fragment,null,l?.map(c=>xe.createElement(Qy,{key:c.name,id:c.name,title:c.title,hasDivider:!0,style:{height:60},onClick:()=>p(c.name),start:xe.createElement(yc,{src:c.logo,size:22}),end:e?xe.createElement(Hy,{value:c.name}):xe.createElement(Uy,{checked:r.includes(c.name)})}))))),xe.createElement(Oy,{type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ca.t("Confirm")))}i(un,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as Yy,Divider as Tc,Image as Zy,MessageBox as Jy,Select as Ry,TextField as eS}from"@rango-dev/ui";import ze,{useEffect as tS,useState as vc}from"react";import{namespaces as jy}from"@rango-dev/wallets-shared";var xr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ka(t){let e=t?jy[t].derivationPaths:null;return e?[...e,xr]:[]}i(ka,"getDerivationPaths");import{styled as Cc,Typography as Xy}from"@rango-dev/ui";var kc=Cc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ta=Cc(Xy,{paddingLeft:"$10"}),va={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var xc="0";function mn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=vc(null),[l,p]=vc(xc),u=a===xr.id,c=ka(o),m=i(({value:d})=>{let f=c?.find(h=>h.id===d);f&&(a===xr.id&&Number.isNaN(Number(l))&&p(xc),s(f.id))},"handleDerivationPathItemClick"),g=i(()=>{let d=c.find(f=>f.id===a);if(d)e(d.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return tS(()=>{s(ka(o)[0]?.id||null)},[o]),ze.createElement(ze.Fragment,null,ze.createElement(Tc,{size:20}),ze.createElement(Jy,{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:ze.createElement(Lo,null,ze.createElement(vr,null,ze.createElement(Zy,{src:n,size:45})),ze.createElement(Po,null))}),ze.createElement(kc,null,ze.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),ze.createElement(Ry,{value:a||"",options:c.map(d=>({value:d.id,label:d.label})),variant:"filled",handleItemClick:m,styles:{trigger:va}}),ze.createElement(Tc,{size:20}),ze.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},u?Do.t("Enter Path"):Do.t("Enter Index")),ze.createElement(eS,{type:u?"text":"number",variant:"contained",value:l,onChange:d=>p(d.target.value),style:va})),ze.createElement(Yy,{type:"primary",onClick:g,disabled:!c||!a||!l},Do.t("Confirm")))}i(mn,"DerivationPath");import{i18n as _o}from"@lingui/core";import{Image as oS,MessageBox as xa,WalletState as nS}from"@rango-dev/ui";import{useWallets as rS}from"@rango-dev/wallets-react";import uo from"react";function wa(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=rS();return pn(a(n))===nS.CONNECTED?uo.createElement(xa,{type:"success",title:_o.t("Wallet Connected"),description:_o.t("Your wallet is connected, you can use it to swap.")}):o?uo.createElement(xa,{type:"error",title:_o.t("Failed to Connect"),description:o||_o.t("Your wallet is not connected. Please try again.")}):uo.createElement(xa,{type:"loading",title:_o.t("Connecting to your wallet"),description:_o.t("Click connect in your wallet popup."),icon:uo.createElement(Lo,null,uo.createElement(vr,null,uo.createElement(oS,{src:r,size:45})),uo.createElement(Po,null))})}i(wa,"ConnectStatus");import{i18n as ba}from"@lingui/core";import{Button as iS,Divider as wc,MessageBox as aS}from"@rango-dev/ui";import wr from"react";function Ea(t){let{displayName:e,onConfirm:o}=t;return wr.createElement(aS,{title:ba.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:ba.t({id:"You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address",values:{blockchainDisplayName:e}})},wr.createElement(wc,{size:18}),wr.createElement(wc,{size:32}),wr.createElement(iS,{onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},ba.t("Confirm")))}i(Ea,"ExperimentalChain");function bc(t,e){return t().status==="init"&&!!e}i(bc,"isOnStatus");function dn(t){return t().status==="namespace"}i(dn,"isOnNamespace");function fn(t){return t().status==="derivationPath"}i(fn,"isOnDerivationPath");var cS=3e3,uS=300;function fo(t){let e=pS(),[o,n]=Ec(!1),[r,a]=Ec(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:g}=qt(),d=i(S=>{c(t.wallet,S).catch(s)},"handleConfirmNamespaces"),f=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(S).catch(s)},"handleDerivationPathConfirm"),h=i(()=>{n(!1)},"handleClosingModal"),k=i(()=>{a(void 0),g(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return lS(()=>{if(t.wallet){k();let S=!1,C=!0,T=i(()=>{setTimeout(()=>{C=!1,S||n(!0)},uS)},"beforeConnecting"),v=i(x=>{let N=x.status==="connected",M=["disconnected","disconnected-unhandled"].includes(x.status);["namespace","derivation-path"].includes(x.status)||(S=!0),N&&!C?e.current=setTimeout(h,cS):M&&h(),t.onConnect&&t.onConnect(x)},"afterConnected");T(),p(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),mo.createElement(J,{open:o,onClose:h,onExit:()=>{k(),l(),t.onClose&&t.onClose()},container:A()},bc(m,t.wallet)&&mo.createElement(mo.Fragment,null,mo.createElement(wa,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),mo.createElement(sS,{direction:"vertical",size:32})),dn(m)&&mo.createElement(un,{onConfirm:d,value:m().namespace}),fn(m)&&mo.createElement(mn,{onConfirm:f,value:m().derivationPath}))}i(fo,"StatefulConnectModal");import{Events as Aa,Provider as dS}from"@rango-dev/wallets-react";import{isEvmBlockchain as fS}from"rango-sdk";import br,{createContext as gS,useEffect as Ac,useMemo as hS,useRef as Nc}from"react";import{useEffect as mS}from"react";function Ic(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Ic,"hashProviders");function Ia(t,e){let o=Z.use.clearConnectedWallet(),n=Cr(t,e);return mS(()=>{o(),n=Cr(t,e)},[Ic(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(Ia,"useWalletProviders");var Er=gS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function yS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),{findToken:s}=y(),l=y().config,p={walletConnectProjectId:l?.walletConnectProjectId,trezorManifest:l?.trezorManifest,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:u}=Ia(l.wallets,p),{connectWallet:c,disconnectWallet:m}=Z(),g=Nc(),d=Nc();Ac(()=>{n().catch(console.log)},[]),Ac(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:l,dappConfig:t.config})},[t.config,r]);let f=a.filter(fS).map(C=>C.name),h=i((C,T,v,x,N)=>{if(T===Aa.ACCOUNTS)if(v){let M=pr(N.supportedBlockchains),w=Wp(C,v,f,M,N.isContractWallet);w.length&&c(w,s)}else m(C),d.current?d.current(C):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?");if(T===Aa.ACCOUNTS&&x.connected){let M=`${C}-${x.network}-${v}`;x.connected&&(g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?"))}if(T===Aa.NETWORK&&x.network){let M=`${C}-${x.network}`;g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(C,T,v,x,N)},"onUpdateState"),k=se.use.isActiveTab(),S=hS(()=>({onConnectWallet:C=>{g.current=C},onDisconnectWallet:C=>{d.current=C}}),[]);return br.createElement(Er.Provider,{value:S},br.createElement(dS,{allBlockChains:a,providers:u,onUpdateState:h,autoConnect:!!k},t.children))}i(yS,"Main");function Ir(t){let{config:e,...o}=t;return br.createElement(rc,{config:e},br.createElement(yS,{...o,config:e}))}i(Ir,"WidgetWallets");import Ri from"react";import SS,{Fragment as CS}from"react";import{MemoryRouter as kS,useInRouterContext as TS}from"react-router";function Wc({children:t}){let o=TS()?CS:kS;return SS.createElement(o,null,t)}i(Wc,"AppRouter");import{I18nManager as eE}from"@rango-dev/ui";import rp from"react";import De from"react";import{useRoutes as Ub}from"react-router-dom";var D={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Oo,useRef as _r}from"react";import Xe from"bignumber.js";import{create as wS}from"zustand";import{subscribeWithSelector as bS}from"zustand/middleware";import{getLastSuccessfulStep as xS}from"@rango-dev/queue-manager-rango-preset";import LW from"bignumber.js";function Na(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(Na,"getFeeLabel");var Wa=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Mc=30;import{i18n as gt}from"@lingui/core";import{RouteEventType as SW}from"@rango-dev/queue-manager-rango-preset";import Qe from"bignumber.js";import{PendingSwapNetworkStatus as Nr}from"rango-types";import{i18n as Fe}from"@lingui/core";var te=i(()=>({genericServerError:Fe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Fe.t("Please reset your liquidity sources."),description:Fe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Fe.t("No Routes Found."),description:Fe.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:Fe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Fe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Fe.t("High Price Impact"),title:Fe.t("Price impact is too high!"),description:Fe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Fe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Fe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Fe.t("USD Price Unknown"),title:Fe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Fe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Fe.t("Confirm USD Price Unknown")}}),"errorMessages");function Bc(t){switch(t.type){case 0:return t.diagnosisMessage??te().noResultError.title;case 1:return te().genericServerError;default:return""}}i(Bc,"getQuoteErrorMessage");import{i18n as Ar}from"@lingui/core";var go=i(()=>({connectWallet:Ar.t("Connect Wallet"),swap:Ar.t("Swap"),swapAnyway:Ar.t("Swap anyway"),ethWarning:Ar.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Lc(t,e){return(parseInt(e.toFixed(2)||"0")<=-10&&t?.gte(new Qe(400))||parseInt(e.toFixed(2)||"0")<=-5&&t?.gte(new Qe(1e3)))??!1}i(Lc,"hasHighValueLoss");function Pc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(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(Pc,"hasLimitError");function Dc(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new Qe(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Qe(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?p?.gte(l.fromAmount)||u?.lte(l.fromAmount):p?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(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=te().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=te().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=te().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=te().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Dc,"getLimitErrorMessage");function _c(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:go().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:go().swap,action:"confirm-swap",disabled:!0}:s?{title:go().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:go().ethWarning,action:"confirm-warning",disabled:!1}:{title:go().swap,action:"confirm-swap",disabled:!1}:{title:go().connectWallet,action:"connect-wallet",disabled:!1}}i(_c,"getSwapButtonState");function Ma(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(Ue))&&e&&e!=="0"&&n!==0)}i(Ma,"canComputePriceImpact");function Ba(t,e){let o=Ue;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 Qe(r.amount).multipliedBy(a||0))}return o}i(Ba,"getUsdFeeOfStep");function Wr(t,e){return t.reduce((o,n)=>o.plus(Ba(n,e)),Ue)}i(Wr,"getTotalFeeInUsd");function La(t){let e=Ue;return e=e.plus(new Qe(t.amount).multipliedBy(t.price||0)),e}i(La,"getUsdFee");function $c(t){return t.reduce((e,o)=>e.plus(La(o)),Ue)}i($c,"getTotalFeesInUsd");function Fc(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(Fc,"getFeesGroup");function Oc(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(Oc,"checkSlippageErrors");function Uc(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(Uc,"checkSlippageWarnings");function Mr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Mr,"getMinRequiredSlippage");function zc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(zc,"hasProperSlippage");function Qc(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:g,destination:d,enableCentralizedSwappers:f}=t,h=a?.reduce((C,T)=>(C[T.chain]=T.address,C),{}),k=[];return r?.forEach(C=>{k.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:g??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:k,selectedWallets:h??{},slippage:u.toString(),...d&&{destination:d},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1},enableCentralizedSwappers:f}}i(Qc,"createQuoteRequestBody");function qc(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(qc,"getWalletsForNewSwap");function $o(t){return t?.outputAmount||null}i($o,"getQuoteOutputAmount");function Hc(t,e){return new Qe(e).div(new Qe(t)).minus(1).multipliedBy(100).toNumber()}i(Hc,"getPercentageChange");function Gc(t,e){let o=$o(t),n=$o(e);if(!o||!n)return!1;let r=ut(o,n);return r?r<=-1:!0}i(Gc,"isOutputAmountChangedALot");function Vc(t,e,o){let n=t.validationStatus,r=ao({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>Jc(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=B(new Qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=B(new Qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=gt.t(" for input and network fee")),gt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:c,currentAmount:p,blockchain:pt(s.asset.blockchain,o)}})})}i(Vc,"generateBalanceWarnings");function jt(t,e){return(t?new Qe(t):Ue).multipliedBy(e||0)}i(jt,"calcOutputUsdValue");function gn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Nr.NetworkChanged}i(gn,"isNetworkStatusInWarningState");function Kc(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),gn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Nr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Nr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Nr.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(Kc,"getSwapMessages");function jc(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(jc,"getLastConvertedTokenInFailedSwap");function Xc(t){return t.status==="failed"}i(Xc,"shouldRetrySwap");function Yc(t,e,o,n,r,a){if(!n||t)return!0;let s=ao({filter:"all",quote:n}),l=ao({filter:"required",quote:n}),p=s.every(m=>r.some(g=>g.chain===m)),u=l.every(m=>r.some(g=>g.chain===m)),c=o&&a?No(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(Yc,"isConfirmSwapDisabled");function Zc(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Zc,"isTokensIdentical");function ho(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(ho,"getQuoteToTokenUsdPrice");function hn(t){return(t?.swaps||[])[0].from.usdPrice}i(hn,"getQuoteFromTokenUsdPrice");function Pa(t,e){let o=t?.swaps||[],n=e?.swaps||[];return o.length!==n.length}i(Pa,"isNumberOfSwapsChanged");function Da(t,e){let o=t?.swaps.map(r=>r.swapperId)||[],n=e?.swaps.map(r=>r.swapperId)||[];return!pa(o,n)}i(Da,"isQuoteSwappersUpdated");function _a(t,e){let o=t?.swaps.map(r=>r.to.symbol)||[],n=e?.swaps.map(r=>r.to.symbol)||[];return!pa(o,n)}i(_a,"isQuoteInternalCoinsUpdated");function eu(t,e){return Pa(t,e)||Da(t,e)||_a(t,e)}i(eu,"isQuoteChanged");function Jc(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(Jc,"getRequiredBalanceOfWallet");function Lt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Lt,"getPriceImpactLevel");function Lr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=xS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=nn(a?a.toBlockchain:n.fromBlockchain,e),p=nn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(Lr,"createRetryQuote");function Fo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=jt(t.requestAmount,hn(t)||o?.usdPrice),l=jt(t.outputAmount,ho(t)||n?.usdPrice);if(t&&s&&l){let c=ut(s.toString(),l.toString());if(!!c&&Lc(s,c)){let g=Wr(t?.swaps,r),d=Lt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:g,warningLevel:d}}}else if(t&&(!s||!l))return{type:1};let p=Mr(t.swaps),u=a>Jp;if(zc(e.userSlippage.toString(),p)){if(u&&parseFloat(p??"0")<a)return{type:3,slippage:a.toString()}}else return{type:2,recommendedSlippages:Uc(t,a),minRequiredSlippage:p};return null}i(Fo,"generateQuoteWarnings");function ut(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Hc(t.toString(),e.toString());return n&&n<0?n:null}i(ut,"getPriceImpact");var tu=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"),Pr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(c=>c.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),p=n.requestId.toLowerCase();return l.localeCompare(p)}),"sortQuotesBy"),ou=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,...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,...r||e[0]}},"getDefaultQuote"),nu=i(t=>{let e=i((o,n)=>{let r=Wa.indexOf(o.value),a=Wa.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");var Dr=i((t,e)=>t?.usdPrice?new Xe(e||Ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),z=Gt(wS()(bS(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Xe(0),outputUsdValue:new Xe(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=Ue,a=o.inputUsdValue;return ln(o.inputAmount)?(e&&(n=e?.outputAmount?new Xe(e?.outputAmount):null,a=jt(o.inputAmount,hn(e)||o.fromToken?.usdPrice),r=jt(e.outputAmount,ho(e)||o.toToken?.usdPrice)),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Xe(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Xe(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue: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 Xe(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue: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 Xe(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Dr(e.toToken,e.outputAmount?.toString()||""):new Xe(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Xe(0),inputUsdValue:new Xe(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),ru=z.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 iu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=z(),c=y().config,m=y().fetchStatus,g=y().blockchains(),d=y().tokens(),{findToken:f}=y(),{setAffiliateRef:h,setAffiliatePercent:k,setAffiliateWallets:S}=y(),C=c?.from?.tokens,T=c?.from?.blockchains,v=c?.to?.tokens,x=c?.to?.blockchains,N=_r(void 0),M=_r(void 0),w=_r(void 0),E=_r(void 0);Oo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Oo(()=>{if(m==="success"){r();let b=g.find(I=>I.name===c?.from?.blockchain),W=c?.from?.token,$=W&&f(W);(b||!b&&w.current)&&n(b??null),$?a({token:$,meta:{blockchains:g,tokens:d}}):!$&&N.current&&a({token:null}),w.current=c?.from?.blockchain,N.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Oo(()=>{da(s,C)&&a({token:null}),fa(p,T)&&n(null)},[C,T]),Oo(()=>{da(l,v)&&a({token:null}),fa(u,x)&&o(null)},[v,x]),Oo(()=>{if(m==="success"){r();let b=g.find(I=>I.name===c?.to?.blockchain),W=c?.to?.token,$=W&&f(W);(b||!b&&E.current)&&o(b??null),$?e({token:$,meta:{blockchains:g,tokens:d}}):!$&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Oo(()=>{h(c?.affiliate?.ref??null),k(c?.affiliate?.percent??null),S(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(iu,"useSyncStoresWithConfig");import{useEffect as Oa,useRef as ES}from"react";import{useInRouterContext as IS,useLocation as AS,useSearchParams as NS}from"react-router-dom";function $a(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i($a,"convertTokenSearchParamToAsset");function Fa(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Fa,"tokenToSearchParam");function za(){let t=AS(),[e,o]=NS(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:g}=z(),d=y().fetchStatus,f=y().blockchains(),h=y().tokens(),k=IS(),{updateIframe:S,updateCampaignMode:C}=y(),T=y().isInCampaignMode(),v=ES(),{findToken:x}=y(),N=i(()=>{let w={};for(let[V,le]of e.entries())V.startsWith("utm_")&&(w[V]=le);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),W=e.get("fromToken"),$=e.get("toBlockchain"),I=e.get("toToken"),R=e.get("autoConnect"),ee=e.get("clientUrl"),oe=e.get("liquiditySources"),L=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:W,toBlockchain:$,toToken:I,autoConnect:R,clientUrl:ee,liquiditySources:oe,utmQueryParams:w,blockchain:L}},"getUrlSearchParams"),M=i(w=>{for(let E in w)w[E]||delete w[E];o(w,{replace:!0})},"updateUrlSearchParams");Oa(()=>{let{autoConnect:w,clientUrl:E,utmQueryParams:b,blockchain:W}=N();k&&d==="success"&&M({fromBlockchain:n?.name,fromToken:Fa(a),toBlockchain:r?.name,toToken:Fa(s),fromAmount:l,autoConnect:w??void 0,clientUrl:E??void 0,blockchain:W??void 0,liquiditySources:T?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,T]),Oa(()=>{if(!k)return;let w=N();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&g(w.fromAmount),d==="success"){let E=f.find(I=>I.name===w.fromBlockchain),b=w.fromToken&&E?x($a(w.fromToken,E)):void 0,W=f.find(I=>I.name===w.toBlockchain),$=w.toToken&&W?x($a(w.toToken,W)):void 0;E&&(p(E),b&&c({token:b,meta:{blockchains:f,tokens:h}})),W&&(u(W),$&&m({token:$,meta:{blockchains:f,tokens:h}}))}},[d]),Oa(()=>{let{clientUrl:w,liquiditySources:E}=N();S("clientUrl",w||void 0),C("liquiditySources",E?.split(",")??void 0)},[])}i(za,"useSyncUrlAndStore");import{i18n as At}from"@lingui/core";import{Alert as qC,Button as Ou,darkTheme as HC,Divider as Cn,DoneIcon as GC,MessageBox as VC,styled as KC,TextField as jC,Typography as XC}from"@rango-dev/ui";import Se,{useEffect as YC,useState as qr}from"react";import{useNavigate as ZC,useSearchParams as JC}from"react-router-dom";import{ChevronRightIcon as WS,Divider as cu,Image as MS,Typography as uu}from"@rango-dev/ui";import ht from"react";import{darkTheme as au,styled as Qa}from"@rango-dev/ui";var su=Qa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${au} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${au} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),lu=Qa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),pu=Qa("div",{display:"flex"});function qa(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(lu,null,ht.createElement(uu,{size:"large",variant:"label"},n),ht.createElement(cu,{size:10}),ht.createElement(su,{onClick:s?void 0:e,disabled:s},ht.createElement(pu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(MS,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(cu,{size:4,direction:"horizontal"})),ht.createElement(uu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(WS,{size:12,color:"black"})))}i(qa,"BlockchainSelectorButton");import{i18n as Ga}from"@lingui/core";import{Button as BS,Divider as yn,ExternalLinkIcon as LS,Image as PS,Typography as zo}from"@rango-dev/ui";import We from"react";function mu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(mu,"generateExplorerLink");import{darkTheme as Uo,styled as du}from"@rango-dev/ui";var Ha=du("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:{}}}}),fu=du("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 Va(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=mu(n.address,a);return We.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},We.createElement(fu,null,We.createElement(PS,{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(yn,{size:4}),We.createElement(zo,{variant:"body",size:"medium"},s?We.createElement(Ha,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,We.createElement(LS,{size:12,color:"gray"})):We.createElement(Ha,null,n.address)),We.createElement(yn,{size:4}),n.coinSource&&We.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},Ga.t("via")," ",We.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),We.createElement(yn,{size:"32"}),We.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},Ga.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(yn,{size:40}),We.createElement(yn,{size:10}),We.createElement(BS,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ga.t("Import")))}i(Va,"CustomTokenModal");import{useManager as $C}from"@rango-dev/queue-manager-react";import{BottomLogo as FC,Divider as Pu,Header as OC}from"@rango-dev/ui";import Be,{useEffect as fs,useRef as Du,useState as UC}from"react";import{useRef as DS}from"react";function $r(){return window.self!==window.top}i($r,"isAppLoadedIntoIframe");function Ka(){let t=DS(null),{iframe:e}=y(),o=$r()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let p of l)n({type:"widget_height",data:{height:p.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ka,"useIframe");import{useNavigate as _S}from"react-router-dom";function Ye(){let t=_S();return()=>t(-1)}i(Ye,"useNavigateBack");import{createTheme as es,darkTheme as YS,lightTheme as ZS}from"@rango-dev/ui";import{useEffect as JS,useState as RS}from"react";import{theme as jS,darkColors as XS}from"@rango-dev/ui";import Ja from"react";function $S(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i($S,"expandShortHexColor");function FS(t){return/[0-9]+$/.test(t)}i(FS,"isOverridingColor");function OS(t,e){return t.padStart(e,"0")}i(OS,"pad");function ja(t){let e=Math.min(Math.max(Math.round(t),0),255);return OS(e.toString(16),2)}i(ja,"intToHex");function US(t){return`#${ja(t.red)}${ja(t.green)}${ja(t.blue)}`}i(US,"rgbToHex");function zS(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(zS,"hexToRGB");function QS(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(QS,"generateShade");function qS(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(qS,"generateTint");function HS(t){return gu(t,QS)}i(HS,"calculateShades");function GS(t){return gu(t,qS)}i(GS,"calculateTints");function gu(t,e){let o=zS(t),n=[];for(let r=1;r<9;r++)n.push(US(e(o,r)));return n}i(gu,"calculateColors");function Xa(t,e,o){let a=GS(t).reverse().concat(t),s=HS(t),l=a.concat(s),p={},u=l.length;for(let c=0;c<u;c++){let m=100+(o?u-1-c:c)*50;p[`${e}${m}`]=l[c]}return p}i(Xa,"createTintsAndShades");function Ya(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)&&!FS(r)){let p=$S(a);Object.assign(n,Xa(p,r,s))}}return{...n,...e}}i(Ya,"expandToGenerateThemeColors");var hu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),VS=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=hu(o%52)+e;return hu(o%52)+e},"toAlphabeticName"),KS=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Za=i(t=>VS(KS(5381,JSON.stringify(t))>>>0),"toHash");function Ra(t){let e=jS.colors,o={...e,...XS},n,r;if(t?.light){let s={colors:Ya(e,t.light)};n={id:`${ma}-light-${Za(s)}`,tokens:s}}if(t?.dark){let s={colors:Ya(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ma}-dark-${Za(s)}`,tokens:s}}return{light:n,dark:r}}i(Ra,"customizedThemeTokens");function yu(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(yu,"joinList");function Su(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Su,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=yp,borderRadius:n=Qp,secondaryBorderRadius:r=qp}=t,[a,s]=RS(Su()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=Ra(e),c=es({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,ZS.className],g=[c.className,YS.className];if(u){let f=es(u.id,u.tokens);m.push(f.className)}if(p){let f=es(p.id,p.tokens);g.push(f.className)}return JS(()=>{let f=i(h=>{h.matches?s("dark"):s("light")},"switchThemeListener");return Su()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=m.join(" "),h=g.join(" ");return l==="auto"?a==="dark"?h:f:l==="dark"?h:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var mt=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 Cu}from"@lingui/core";import{Alert as eC,Button as tC}from"@rango-dev/ui";import ku from"react";function ts(t){return ku.createElement(eC,{action:ku.createElement(tC,{onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Cu.t("Activate this tab")),type:"warning",variant:"alarm",title:Cu.t("Another tab is open and handles transactions.")})}i(ts,"ActivateTabAlert");import{i18n as os}from"@lingui/core";import{Button as oC,Divider as nC,MessageBox as rC}from"@rango-dev/ui";import Fr from"react";function ns(t){let{open:e,onClose:o,onConfirm:n}=t;return Fr.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},Fr.createElement(rC,{title:os.t("Activate current tab"),type:"warning",description:os.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.")},Fr.createElement(nC,{size:20}),Fr.createElement(oC,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},os.t("Confirm"))))}i(ns,"ActivateTabModal");import{ChevronLeftIcon as iC}from"@rango-dev/ui";import Tu from"react";function rs(t){return Tu.createElement(It,{variant:"ghost",size:"small",onClick:t.onClick},Tu.createElement(iC,{color:"black",size:16}))}i(rs,"BackButton");import{i18n as aC}from"@lingui/core";import{Button as sC,Typography as lC}from"@rango-dev/ui";import is from"react";function as(t){return is.createElement(Vt,null,is.createElement(sC,{variant:"ghost",onClick:t.onClick,size:"xsmall"},is.createElement(lC,{variant:"label",size:"medium",color:"error500"},aC.t("Cancel"))))}i(as,"CancelButton");import{i18n as pC}from"@lingui/core";import{Image as cC,Tooltip as uC,WalletIcon as mC}from"@rango-dev/ui";import yo from"react";function ss(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?yo.createElement("div",{className:fc()},o.map(r=>yo.createElement(kr,{key:r.title},yo.createElement(cC,{src:r.image,size:14})))):pC.t("Connect Wallet");return yo.createElement(uC,{container:t.container,side:"bottom",content:n},yo.createElement(It,{variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&yo.createElement(cc,null),yo.createElement(mC,{size:18,color:"black"})))}i(ss,"WalletButton");import{i18n as Ur}from"@lingui/core";import{NotificationsIcon as AC,Popover as NC,SettingsIcon as WC,Tooltip as zr,TransactionIcon as MC}from"@rango-dev/ui";import Me from"react";import{Notifications as hC}from"@rango-dev/ui";import yC from"react";import{useNavigate as SC}from"react-router-dom";import{create as dC}from"zustand";import{persist as fC,subscribeWithSelector as gC}from"zustand/middleware";var we=Gt(dC()(fC(gC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(p=>p.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(p=>p.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function ls(){let t=SC(),{getNotifications:e,clearNotifications:o}=we(),n=e(),r=y().blockchains(),{findToken:a}=y();return yC.createElement(hC,{list:n,getBlockchainImage:l=>cp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${D.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ls,"NotificationContent");import{useManager as CC}from"@rango-dev/queue-manager-react";import{InProgressIcon as kC}from"@rango-dev/ui";import vu from"react";var TC=i(()=>{let{manager:t}=CC();return mt(t).map(({swap:o})=>o).find(o=>o.status==="running")?vu.createElement(dc,null,vu.createElement(kC,{color:"info",size:6})):null},"InProgressTransactionBadge"),xu=TC;import{EventSeverity as vC}from"@rango-dev/queue-manager-rango-preset";import{Typography as xC}from"@rango-dev/ui";import wu from"react";function bu(){let{getNotifications:t}=we(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===vC.WARNING);return o?wu.createElement(uc,{isSever:n},wu.createElement(xC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(bu,"NotificationsBadge");import{RefreshProgressButton as wC}from"@rango-dev/ui";import ps,{useEffect as bC,useState as Eu}from"react";var EC=1e3,Iu=60,IC=100;function Or({onClick:t}){let[e,o]=Eu(0),[n,r]=Eu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");bC(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Iu&&l()},EC):s(p),document.addEventListener("visibilitychange",()=>a(p)),()=>{document.removeEventListener("visibilitychange",()=>a(p)),p&&clearInterval(p)}},[e,t]);let s=i(p=>{p&&clearInterval(p),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return ps.createElement(It,{variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},ps.createElement(mc,{onTransitionEnd:()=>r(!1),isRefetched:n},ps.createElement(wC,{size:22,color:t?"black":"gray",progress:e/Iu*IC})))}i(Or,"RefreshButton");function So(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=je("notification",s)||r.includes("notifications");return Me.createElement(Me.Fragment,null,!r.includes("refresh")&&Me.createElement(zr,{container:a||A(),side:"top",content:Ur.t("Refresh")},Me.createElement(Or,{onClick:e})),!l&&Me.createElement(NC,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:A(),content:Me.createElement(ls,null)},Me.createElement("div",null,Me.createElement(zr,{container:A(),side:"top",content:Ur.t("Notifications")},Me.createElement(It,{size:"small",variant:"ghost"},Me.createElement(AC,{size:18,color:"black"}),Me.createElement(bu,null))))),!r.includes("settings")&&Me.createElement(zr,{container:A(),side:"top",content:Ur.t("Settings")},Me.createElement(It,{size:"small",variant:"ghost",onClick:n},Me.createElement(WC,{size:18,color:"black"}))),!r.includes("history")&&Me.createElement(zr,{container:A(),side:"top",content:Ur.t("Transactions History")},Me.createElement(It,{size:"small",variant:"ghost",onClick:o},Me.createElement(MC,{size:18,color:"black"}),Me.createElement(xu,null))))}i(So,"HeaderButtons");import{i18n as cs}from"@lingui/core";import{Divider as Nu,MessageBox as PC,RefreshIcon as DC}from"@rango-dev/ui";import qo from"react";import{Button as BC,styled as LC}from"@rango-dev/ui";var Au=LC(BC,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function us(t){let{open:e,onClose:o}=t;return qo.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},qo.createElement(PC,{title:cs.t("Something went wrong"),type:"error",description:cs.t("Something went wrong. Please refresh the app.")},qo.createElement(Nu,{size:30}),qo.createElement(Au,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},qo.createElement(DC,{size:20,color:"primary"}),qo.createElement(Nu,{size:4,direction:"horizontal"}),cs.t("Refresh"))))}i(us,"RefreshModal");function ms(t){let e=t.target;if(e){let o=e.scrollTop,n=A();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(ms,"onScrollContentAttachStatusToContainer");import{css as _C,styled as ds}from"@rango-dev/ui";var Wu="700px",Qr=_C({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Mu=ds("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Wu},fixed:{height:Wu}}}}),Bu=ds("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Lu=ds("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 ne(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Ka(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l}=y(),[p,u]=UC(!1),c=Z.use.connectedWallets(),{config:{features:m,theme:g}}=y(),{watermark:d}=se(),f=d==="FULL",{activeTheme:h}=Qo(g||{}),k=je("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:C,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:x}=se(),N=Ye(),{manager:M}=$C(),E=mt(M).map(({swap:ee})=>ee).some(ee=>ee.status==="running"),b=i(()=>x(po.forceClaim,E),"onActivateTab"),W=i(()=>{r.onWallet?.()},"onConnectWallet"),$=typeof r.hasBackButton>"u"||r.hasBackButton,I=Du(null),R=Du(null);return fs(()=>($r()&&R.current&&e(R.current),()=>{o()}),[]),fs(()=>(I.current?.addEventListener("scroll",ms),()=>{I.current?.removeEventListener("scroll",ms)}),[]),fs(()=>{u(l==="failed")},[l]),Be.createElement(Mu,{height:s,id:$e.SWAP_BOX_ID,className:`${h()} ${Qr()}`,ref:R},Be.createElement(OC,{prefix:$?Be.createElement(rs,{onClick:()=>{N(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!k&&Be.createElement(ss,{container:A(),onClick:W,isConnected:!!c?.length}),r.onCancel&&Be.createElement(as,{onClick:r.onCancel}))}),Be.createElement(Bu,{ref:I},n),Be.createElement(ns,{open:T,onClose:()=>v(!1),onConfirm:b}),Be.createElement(Lu,null,Be.createElement("div",{className:"footer__content"},C&&!S&&Be.createElement("div",{className:"footer__alert"},Be.createElement(ts,{onActivateTab:b}),Be.createElement(Pu,{size:10})),a),Be.createElement(Pu,{size:12}),Be.createElement("div",{className:`footer__logo ${f?"logo__show":"logo__hidden"}`},Be.createElement(FC,null))),Be.createElement(us,{open:p,onClose:()=>u(!1)}))}i(ne,"Layout");import{styled as zC}from"@rango-dev/ui";var _u="$20 $20 $10 $20",Sn=zC("div",{padding:_u,overflowY:"auto",flexGrow:1});import{styled as QC}from"@rango-dev/ui";var ie=QC("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 Ho}from"@lingui/core";import{useState as $u}from"react";function Fu(){let[t,e]=$u(!1),[o,n]=$u(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Ho.t("Duplicate Token"),message:Ho.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Ho.t("Token Already Exists"),message:Ho.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Ho.t("Token Not Found"),message:Ho.t({id:"Sorry, no token was found on {blockchain} blockchain with the provided address. please make sure you have entered the right token address.",values:{blockchain:u}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:p,tokenAddress:u})=>{e(!0);try{if(a.some(h=>h.address?.toLowerCase()===u.toLowerCase())){let h=s("duplicated");n(h);return}let m=await fetch(`${ct("BASE_URL")}/meta/token?apiKey=${ct("API_KEY")}&blockchain=${p}&address=${u}`),g=m.headers.get("content-type"),d=g&&g.includes("application/json")&&await m.json();if(!d||d.error){let h=s("not-found",p);n(h);return}if(r({blockchain:d.blockchain,address:d.address,symbol:d.symbol})){let h=s("token-exist");n(h);return}return d}catch(c){throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Fu,"useFetchCustomToken");var RC=KC("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${HC} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),ek=1e3;function Uu(){let t=ZC(),[e]=JC(),o=Ye(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=nn(a,r),[l,p]=qr(""),[u,c]=qr(!1),[m,g]=qr(),{fetchCustomToken:d,loading:f,error:h}=Fu(),[k,S]=qr(""),C=!!s&&No(s,l),T=!s||!l||!C,v=i(async()=>{if(s)try{let M=await d({blockchain:a,tokenAddress:l});S(""),M&&g(M)}catch(M){M.message==="Failed to fetch"&&(S(At.t("Network Error")),c(!0))}},"getCustomToken"),x=i(()=>{h&&p(""),c(!1)},"closeErrorModal"),N=i(async()=>{k&&setTimeout(async()=>{await v()},ek),x()},"handleErrorModalButtonClick");return YC(()=>{h&&c(!0)},[h]),Se.createElement(ne,{header:{title:At.t("Add Custom Token")}},Se.createElement(ie,null,Se.createElement(RC,null,Se.createElement("div",null,Se.createElement(qa,{onClick:()=>t(D.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:At.t("Select chain"),placeholder:At.t("Select chain")}),Se.createElement(Cn,{size:"24"}),Se.createElement(XC,{size:"large",variant:"label"},At.t("Enter Address")),Se.createElement(Cn,{size:10}),Se.createElement(jC,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:At.t("Enter token address"),size:"large",value:l,suffix:!!l&&C&&Se.createElement(GC,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!C&&!!l&&Se.createElement(Se.Fragment,null,Se.createElement(Cn,{size:4}),Se.createElement(qC,{type:"error",variant:"alarm",title:"Invalid Address"}))),Se.createElement(Ou,{disabled:T,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},At.t("Import"))),Se.createElement(J,{open:u,dismissible:!0,onClose:x,container:A()},Se.createElement(VC,{title:h?.title||k,type:"error",description:h?.message||At.t("Failed Network, Please retry.")},Se.createElement(Cn,{size:40}),Se.createElement(Cn,{size:10}),Se.createElement(Ou,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:N},k?At.t("Retry"):At.t("Add another custom token")))),s&&m&&Se.createElement(Va,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),g(void 0),o())},onClose:()=>g(void 0),open:!!s&&!!m})))}i(Uu,"AddCustomTokenPage");import{i18n as qs}from"@lingui/core";import{useManager as FT}from"@rango-dev/queue-manager-react";import{Alert as Dd,Button as OT,css as Gs,Divider as Hs,IconButton as _d,styled as UT,Typography as zT,WalletIcon as QT}from"@rango-dev/ui";import Ie,{useEffect as Ci,useLayoutEffect as qT,useRef as HT,useState as Bn}from"react";import{useNavigate as GT}from"react-router-dom";import{i18n as Co}from"@lingui/core";import{Alert as dm,BalanceErrors as Ik,Button as fm,ChevronLeftIcon as Ak,Divider as Jr,MessageBox as Nk,Typography as vs}from"@rango-dev/ui";import j,{useCallback as Wk,useEffect as gm,useMemo as Mk,useState as ko}from"react";import{useNavigate as Bk}from"react-router-dom";import{i18n as Hr}from"@lingui/core";function Gr(t){switch(t.type){case 0:return Hr.t("Route has been updated.");case 3:return Hr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Hr.t("Route swappers has been updated.");case 2:return Hr.t("Route internal coins has been updated.");default:return""}}i(Gr,"getQuoteUpdateWarningMessage");import{i18n as Ss}from"@lingui/core";import{Alert as ak,ChevronDownIcon as sk,CloseIcon as lk,Divider as Ku,IconButton as ju,PasteIcon as pk,Typography as ck,WalletIcon as uk}from"@rango-dev/ui";import Le,{useEffect as mk,useRef as dk}from"react";import Xr,{useRef as rk}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as zu,styled as Vr}from"@rango-dev/ui";var gs=300,ok=zu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),nk=zu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Qu=Vr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),hs=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} ${gs}ms ease-out`},false:{animation:`${nk} ${gs}ms ease-out`}}}}),jr=Vr("div",{transition:`all ${gs}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,p=rk(null);return Xr.createElement(Qu,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s),Xr.createElement(Kr,{className:"collapsible_content",open:e},r),l==="bottom"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s))}i(Yr,"CustomCollapsible");import{darkTheme as qu,styled as ys,TextField as ik}from"@rango-dev/ui";var Hu=ys("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Gu=ys(ik,{backgroundColor:"$neutral100",padding:"$15"}),Vu=ys("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${qu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${qu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Xu(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=z(),{config:s}=y(),l=y().blockchains(),p=tr(e.name,l),u=dk(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),d=n&&!!r&&e&&!No(e,r),f=i(()=>{a("")},"handleClear"),h=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),u?.current?.focus()}},"handlePaste"),k=i(()=>r?Le.createElement(ju,{onClick:f,variant:"ghost"},Le.createElement(lk,{size:12,color:"gray"})):m?null:Le.createElement(ju,{onClick:h,variant:"ghost"},Le.createElement(pk,{size:16})),"renderSuffix");return mk(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Le.createElement(Hu,null,Le.createElement(Yr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Le.createElement(Vu,null,Le.createElement("div",{className:"button__content"},Le.createElement(uk,{size:18,color:"info"}),Le.createElement(Ku,{size:4,direction:"horizontal"}),Le.createElement(ck,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ss.t("Send to a different address"))),Le.createElement(jr,{orientation:n?"up":"down"},Le.createElement(sk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Le.createElement(Gu,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ss.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:k(),onChange:S=>{let C=S.target.value;a(C)}})),d&&Le.createElement(Le.Fragment,null,Le.createElement(Ku,{size:4}),Le.createElement(ak,{variant:"alarm",type:"error",title:Ss.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Xu,"CustomDestination");import{css as fk,darkTheme as Cs,IconButton as gk,styled as Pt}from"@rango-dev/ui";var Yu=Pt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Zu=Pt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),hk=Pt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${Cs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),Ju=Pt(hk,{alignSelf:"stretch",minHeight:"93px"}),Ru=Pt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),em=Pt(gk,{position:"absolute",left:"$20"}),tm=Pt("div",{paddingTop:"$20"}),om=fk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),nm=Pt("div",{display:"flex"}),rm=Pt("div",{overflow:"visible",width:"100%"});import{i18n as pm}from"@lingui/core";import{warn as vk}from"@rango-dev/logging-core";import{Divider as xk,SelectableWallet as wk,Typography as cm,WalletState as um}from"@rango-dev/ui";import Ze,{useEffect as mm,useState as Tn}from"react";import{Image as Ck,MessageBox as kk,Spinner as Tk}from"@rango-dev/ui";import kn from"react";import{keyframes as yk,styled as ks}from"@rango-dev/ui";var im=ks("div",{position:"relative"}),Sk=yk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),qD=ks("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Sk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),am=ks("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function sm(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address",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(sm,"generateMessageByStatus");function lm(t){let{status:e,displayName:o,image:n}=t,r=sm(e,o),a=e=="in-progress";return kn.createElement(kk,{type:r.type,title:r.title,description:r.description,icon:a?kn.createElement(im,null,kn.createElement(am,null,kn.createElement(Ck,{src:n,size:45})),kn.createElement(Tk,null)):void 0})}i(lm,"ExperimentalChainStatus");var bk=7,Ek=3e3;function Ts(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=se.use.isActiveTab(),l=Z.use.connectedWallets(),{blockchains:p}=y(),[u,c]=Tn(),[m,g]=Tn(null),[d,f]=Tn(!1),[h,k]=Tn(null),{suggestAndConnect:S}=Zr(),{handleDisconnect:C}=qt(),{list:T}=ft({chain:e}),[v,x]=Tn(T),N=T.length,M=r&&N-r>0,w=i(async b=>{f(!1),k("in-progress");try{await S(b.walletType,b.chain),k("completed")}catch{k("rejected")}},"addExperimentalChain");mm(()=>{x(b=>{let W=T.findIndex($=>o($.type,e));return M&&W>1?[T[W]].concat(T.filter(($,I)=>I!==W)):b.map($=>T.find(I=>I.type===$.type)??$)})},[JSON.stringify(T)]);let E=document.getElementById($e.SWAP_BOX_ID);return mm(()=>{let b=null;return(h==="completed"||h==="rejected")&&(b=setTimeout(()=>k(null),Ek)),()=>{b&&clearTimeout(b)}},[h]),Ze.createElement(Ze.Fragment,null,v.slice(0,r).map(b=>{let W=_p({connectedWallets:l,walletType:b.type,chain:e}),$=W?dr(W,bk):"",I=ur(p(),e),R=!l.find(le=>le.walletType===b.type&&le.chain===e),ee=I&&R&&b.state===um.CONNECTED,oe=ee?pm.t({id:"Add {chain} chain",values:{chain:e}}):$,L=i(async()=>{b.state===um.DISCONNECTED?c(b):b.namespaces&&!$?(await C(b.type),c(b)):ee?(g({walletType:b.type,chain:e,address:W??""}),f(!0)):n({walletType:b.type,chain:e,address:W??""})},"onSelectableWalletClick"),V=m?.chain?tr(m.chain,p()):void 0;return Ze.createElement(Ze.Fragment,{key:`${b.title}_${V}`},!!m&&Ze.createElement(J,{open:!!m&&d,container:E,onClose:()=>{g(null)}},Ze.createElement(Ea,{displayName:V,onConfirm:()=>{w(m)}})),h&&Ze.createElement(J,{open:!!h,onClose:k.bind(null,null),container:E},Ze.createElement(lm,{status:h,displayName:V,image:b.image}),Ze.createElement(xk,{direction:"vertical",size:32})),Ze.createElement(wk,{key:b.type,description:oe,onClick:L,selected:o(b.type,e),disabled:!s,...b}))}),Ze.createElement(fo,{wallet:u,onClose:()=>{c(void 0)},onConnect:b=>{t.onConnect&&b.status==="connected"&&(u?.type?t.onConnect(u.type):vk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Ze.createElement(Ju,{selected:!1,onClick:a},Ze.createElement(cm,{variant:"label",size:"medium"},pm.t("Show more wallets"),Ze.createElement(cm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",N-(r??0)))))}i(Ts,"WalletList");var Lk=2;function hm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Bk(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:g,setCustomDestination:d}=z(),{connectedWallets:f,selectWallets:h}=Z(),{config:k}=y(),[S,C]=ko(""),[T,v]=ko([]),[x,N]=ko(""),[M,w]=ko(null),[E,b]=ko(!!g),W=Mk(()=>ao({filter:"all",quote:p}),[p]),$=ao({filter:"required",quote:p}),I=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),R=i(_=>$.includes(_),"isWalletRequiredFor"),ee=Wk(()=>f.filter(_=>_.selected&&W.includes(_.chain)),[f,W]),[oe,L]=ko(ee()),[V,le]=ko([]),Y=i((_,Q)=>le(G=>G.concat({blockchain:_,walletType:Q})),"addNextSelectedWallets"),ae=T.length>0,ge=i((_,Q)=>!!oe.find(G=>G.walletType===_&&G.chain===Q&&G.selected&&(R(Q)||!R(Q)&&!g)),"isSelected"),ve=i((_,Q,G)=>{let pe=!1;return _.map(ce=>{if(ce.chain===Q){let de=ce.selected;return!pe&&G?(pe=!0,de=!0):G||(de=!1),{...ce,selected:de}}return ce})},"updateSelectableWallets"),U=i(_=>{b(_),_?R(I?.name??"")||L(Q=>ve(Q,I?.name||"",!1)):(d(""),L(Q=>ve(Q,I?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ke=i(_=>{if(S&&C(""),ge(_.walletType,_.chain))return;let G=f.find(pe=>pe.walletType===_.walletType&&pe.chain===_.chain);G&&(n(),_.chain===I?.name&&E&&!R(I.name)&&(b(!1),d(null)),L(pe=>pe.filter(ce=>ce.chain!==_.chain).concat({...G,selected:!0})))},"onChange"),xt=i(()=>{let _=oe.filter(Q=>Q.selected);h(_),u(_),m(!0),o()},"onConfirmBalance"),lt=i(async()=>{v([]),N(""),w(null);let _=await r?.({selectedWallets:oe.filter(G=>G.selected),customDestination:g}),Q=_.warnings;Q?.balance?.messages&&v(Q.balance.messages),Q?.quoteUpdate&&w(Q.quoteUpdate),_.error&&N(Bc(_.error)),!_.error&&!Q?.balance?.messages.length?xt():v(Q?.balance?.messages??[])},"onConfirmWallets");gm(()=>{L(_=>{let Q=[];return _.forEach(G=>{!f.some(ce=>ce.chain===G.chain&&ce.walletType===G.walletType&&ce.address===G.address)||Q.push(G)}),Q=Q.concat(f.filter(G=>!!!Q.find(ce=>ce.chain===G.chain)&&G.selected&&W.includes(G.chain))),Q})},[f,W]),gm(()=>{let _=[];V.length>0&&(V.forEach(Q=>{let G=f.find(pe=>pe.chain===Q.blockchain&&pe.walletType===Q.walletType);G?Ke(G):_.push(Q)}),le(_))},[f,V]);let wt=document.getElementById($e.SWAP_BOX_ID);return j.createElement(J,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:wt,...!S&&{styles:{container:{height:"100%"}},footer:j.createElement(nm,null,j.createElement(fm,{loading:a,disabled:Yc(a,E,g,p,oe,I),onClick:lt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Co.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:j.createElement(Ru,null,j.createElement(em,{variant:"ghost",onClick:C.bind(null,"")},j.createElement(Ak,{size:16})),j.createElement(vs,{variant:"headline",size:"small"},Co.t({id:"Your {blockchainName} wallets",values:{blockchainName:pt(S,l)}})))},anchor:"center"},j.createElement(J,{open:ae,onClose:v.bind(null,[]),container:wt},j.createElement(Nk,{title:Co.t("Insufficient account balance"),type:"error",description:j.createElement(Ik,{messages:T??[]})},j.createElement(fm,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:xt},Co.t("Proceed anyway")))),S&&j.createElement(tm,null,j.createElement("div",{className:om()},j.createElement(Ts,{chain:S,isSelected:ge,selectWallet:Ke,onShowMore:()=>C(S),onConnect:_=>{Y(S,_)}}))),!S&&j.createElement(j.Fragment,null,x&&j.createElement(j.Fragment,null,j.createElement(dm,{variant:"alarm",type:"error",title:Co.t(x)}),j.createElement(Jr,{size:12})),M&&j.createElement(j.Fragment,null,j.createElement(dm,{variant:"alarm",type:"warning",title:Gr(M)}),j.createElement(Jr,{size:12})),j.createElement(rm,null,W.map((_,Q)=>{let G=l.find(he=>he.name===_),pe=`wallet-${Q}`,ce=Q===W.length-1,de=ce&&I&&k?.customDestination!==!1;return j.createElement("div",{key:pe},j.createElement(Yu,null,j.createElement(vs,{variant:"title",size:"xmedium"},Co.t({id:"Your {blockchainName} wallets",values:{blockchainName:G?.shortName}})),j.createElement(vs,{variant:"label",color:"$neutral700",size:"medium"},Co.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:G?.shortName}}))),j.createElement(Jr,{size:24}),j.createElement(Zu,null,j.createElement(Ts,{chain:_,isSelected:ge,selectWallet:Ke,limit:Lk,onShowMore:()=>C(G?.name??""),onConnect:he=>{Y(_,he)}})),!ce&&j.createElement(Jr,{size:32}),de&&j.createElement(Xu,{blockchain:I,open:E,handleOpenChange:U}))}))))}i(hm,"ConfirmWalletsModal");import{i18n as Jk}from"@lingui/core";import{Alert as Rk,Button as eT,InfoIcon as tT}from"@rango-dev/ui";import ot from"react";import{Alert as _k,Button as $k,Divider as bs,NoRouteIcon as Fk,RefreshIcon as Ok,Typography as xm}from"@rango-dev/ui";import tt from"react";import{i18n as ym}from"@lingui/core";var Pk=24,Dk=60;function Sm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:te().genericServerError,action:{onClick:n,title:ym.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:te().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:ym.t("Reset")}},description:te().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:te().noResultError.description}}i(Sm,"makeInfo");var xs=(o=>(o[o.small=Pk]="small",o[o.large=Dk]="large",o))(xs||{}),ws=(o=>(o.small="small",o.large="medium",o))(ws||{});import{styled as Rr}from"@rango-dev/ui";var Cm=Rr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),km=Rr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Tm=Rr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),vm=Rr("div",{padding:"$6 $0"});function vn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Sm(o,r,()=>a(s,!0),e);return tt.createElement(Cm,null,tt.createElement(Fk,{size:xs[n],color:"gray"}),tt.createElement(bs,{size:4}),tt.createElement(xm,{variant:"title",size:ws[n]},te().noResultError.title),n==="large"&&tt.createElement(bs,{size:4}),!!l.description&&tt.createElement(km,{size:n},tt.createElement(xm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),tt.createElement(bs,{size:n==="large"?"24":"4"}),!!l.alert&&tt.createElement(Tm,{size:n},tt.createElement(_k,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&tt.createElement($k,{size:"xsmall",type:l.alert.type,prefix:tt.createElement(vm,null,tt.createElement(Ok,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(vn,"NoResult");import{i18n as xn}from"@lingui/core";import{Button as zk,Divider as Qk,MessageBox as qk,Typography as Hk,WarningIcon as Gk}from"@rango-dev/ui";import Dt from"react";import{Typography as Im}from"@rango-dev/ui";import Is from"react";import{darkTheme as Uk,styled as ei}from"@rango-dev/ui";var wm=ei("div",{width:"100%"}),Es=ei("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),bm=ei("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Uk} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Em=ei("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Am(t){let{title:e,value:o,valueColor:n}=t;return Is.createElement(bm,null,Is.createElement(Im,{size:"medium",variant:"label",className:"_title"},e),Is.createElement(Im,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Am,"QuoteErrorsModalItem");function Nm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:xn.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:xn.t("Gas cost"),value:B(r.totalFee,2,2)},{title:xn.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:xn.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return Dt.createElement(J,{footer:Dt.createElement(zk,{type:"primary",size:"large",prefix:Dt.createElement(Gk,null),fullWidth:!0,disabled:a,onClick:n},te().highValueLossError.confirmMessage),open:e,onClose:o,container:A()},Dt.createElement(qk,{type:s,title:te().highValueLossError.impactTitle,description:te().highValueLossError.description}),Dt.createElement(Es,null,Dt.createElement(Qk,{size:"4"}),Dt.createElement(Hk,{size:"small",variant:"title"},xn.t("Details")),Dt.createElement(Es,null,l.map((p,u)=>Dt.createElement(Am,{key:u,...p})))))}i(Nm,"HighValueLossWarningModal");import{i18n as As}from"@lingui/core";function Wm(t,e){let o={alertType:"warning",title:"",action:null};return e?(o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=As.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o):t?(t.type===0&&(Lt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=te().highValueLossError.title),t.type===1&&(o.title=te().unknownPriceError.title),t.type===2&&(o.title=As.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings"),t.type===3&&(o.title=As.t("Caution, your slippage is high."),o.action="change-settings"),o):null}i(Wm,"makeAlerts");import{i18n as Ko}from"@lingui/core";import{Button as Mm,Divider as Bm,MessageBox as Vk,Typography as Kk}from"@rango-dev/ui";import To from"react";import{useNavigate as jk}from"react-router-dom";function Lm(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=jk(),u=e??o;return To.createElement(J,{anchor:"bottom",open:n,prefix:To.createElement(Mm,{size:"small",variant:"ghost",onClick:()=>p("../"+D.settings)},To.createElement(Kk,{variant:"label",size:"medium",color:"$neutral900"},Ko.t("Change settings"))),container:A(),onClose:r},To.createElement(Vk,{type:"warning",title:s.type===3?Ko.t("High slippage"):Ko.t("Low slippage"),description:s.type===3?Ko.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Ko.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},To.createElement(Bm,{size:18}),To.createElement(Bm,{size:32}),To.createElement(Mm,{size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Ko.t("Confirm anyway"))))}i(Lm,"SlippageWarningModal");import{Button as Xk,MessageBox as Yk,WarningIcon as Zk}from"@rango-dev/ui";import ti from"react";function Pm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ti.createElement(J,{footer:ti.createElement(Xk,{type:"primary",size:"large",prefix:ti.createElement(Zk,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:A()},ti.createElement(Yk,{type:"warning",title:te().unknownPriceError.impactTitle,description:te().unknownPriceError.description}))}i(Pm,"UnknownPriceWarningModal");function wn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,d=Wm(e,o?.type===3||o?.type===4?o:null);return d&&!n&&(d.action=null),ot.createElement(ot.Fragment,null,g&&ot.createElement(vn,{error:o,fetch:s}),!!d&&ot.createElement(wm,null,ot.createElement(Rk,{title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:ot.createElement(Em,{onClick:l},ot.createElement(tT,{size:12,color:"gray"}))},...d.action==="change-settings"&&{action:ot.createElement(eT,{size:"xxsmall",type:d.alertType,onClick:c},Jk.t("Change"))}})),e&&ot.createElement(ot.Fragment,null,e.type===0&&ot.createElement(Nm,{...m,warning:e}),(e.type===3||e.type===2)&&ot.createElement(Lm,{...m,warning:e}),e.type===1&&ot.createElement(Pm,{...m,warning:e})))}i(wn,"QuoteWarningsAndErrors");import BT from"bignumber.js";import gi from"react";import{i18n as vo}from"@lingui/core";import{Alert as CT,Divider as Xo,FullExpandedQuote as kT,InfoIcon as TT,NumericTooltip as dd,QuoteTag as vT,StepDetails as xT,TokenAmount as wT,Typography as Yo}from"@rango-dev/ui";import _s from"bignumber.js";import F,{useRef as bT,useState as ET}from"react";import{styled as Ns}from"@rango-dev/ui";var Ws=Ns("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Dm=Ns("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),_m=Ns("div",{width:"100%",display:"flex"});import*as oi from"@radix-ui/react-collapsible";import{Button as oT,css as bn,darkTheme as be,Image as $m,styled as qe,Typography as nT}from"@rango-dev/ui";var rT=300,Fm=qe(oi.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${be} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Om=bn({padding:"$10 $15"}),Um=qe(oT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${be} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${be} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${be} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),zm=qe("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",[`.${be} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${be} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${be} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${be} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${be} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${be} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${be} &`]:{backgroundColor:"$neutral400"}}}}]}),Qm=bn({width:"100%",padding:"$15 $15 $10 $15"}),qm=bn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),jo=bn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Hm=bn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${be} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Gm=qe(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:{[`& ${$m}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${$m}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${be} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),Vm=qe("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"}}}}),Km=qe(Kr,{width:"100%",background:"inherit"}),Ms=qe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${rT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),p1=qe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),jm=qe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${be} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Xm=qe("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Bs=qe(nT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),Ym=qe("div",{display:"flex",flexWrap:"wrap"}),Ls=qe("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"}}}}),Zm=qe("div",{display:"flex"}),ni=qe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${be} &`]:{borderTopColor:"$neutral800"}});import{i18n as Nt}from"@lingui/core";import{ChevronDownIcon as aT,CloseIcon as sT,Divider as ai,IconButton as lT,NumericTooltip as pT,QuoteCost as cT,Typography as yt}from"@rango-dev/ui";import X,{useState as td}from"react";import{css as iT,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"}}),Ps=ri("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Jm=ri("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Rm=ri("div",{padding:"$20 $20 $10",textAlign:"center",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),ed=iT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var uT=i(t=>t.fee.isZero()?null:X.createElement(ii,null,X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),X.createElement(yt,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function od(t){let[e,o]=td(!1),[n,r]=td(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,showModalFee:c}=t,m=s?.swaps??[],g=A(),d=Fc(m);return X.createElement(X.Fragment,null,X.createElement(cT,{onClickFee:c?f=>{f.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,time:p,steps:a,tooltipGas:c?Nt.t("View more info"):void 0,tooltipContainer:g}),X.createElement(J,{container:g,open:e,header:X.createElement(Rm,null,X.createElement(yt,{variant:"title",size:"medium"},Nt.t("Gas & Fee Explanation")),X.createElement(lT,{onClick:()=>o(!1),variant:"ghost"},X.createElement(sT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},X.createElement(Jm,null,X.createElement(yt,{variant:"title",size:"small"},Nt.t("Details")),X.createElement(ai,{size:10}),Object.entries(d.payable).flatMap(([f,h])=>h.map((k,S)=>{let C=`payable-fee-${S}`,T=La(k);return X.createElement(ii,{key:C},X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Na(f,Nt.t)),X.createElement(pT,{content:k.amount,container:g},X.createElement(yt,{variant:"label",size:"medium"},B(k.amount,2,2)," ",k.asset.symbol," ($",B(T,4,4),")")))})),X.createElement(ii,{className:"total_payable_fee"},X.createElement(yt,{variant:"label",size:"medium"},Nt.t("Total Payable Fee")),X.createElement(yt,{variant:"label",size:"medium"},"$",B(l,4,4))),X.createElement(Ps,null),Object.keys(d.nonePayable).length&&X.createElement(Yr,{triggerAnchor:"bottom",onClickTrigger:()=>r(f=>!f),trigger:X.createElement("div",{className:ed()},X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?Nt.t("Hide non-payable fees"):Nt.t("Show non-payable fees")),X.createElement(ai,{size:4,direction:"horizontal"}),X.createElement(jr,{orientation:n?"up":"down"},X.createElement(aT,{size:12,color:"gray"}))),open:n},X.createElement(yt,{size:"small",variant:"title"},Nt.t("Description")),X.createElement(ai,{size:4}),X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},Nt.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),X.createElement(ai,{size:10}),Object.entries(d.nonePayable).map(([f,h],k)=>{let S=$c(h),C=Na(f,Nt.t),T=`non-payable-fee-${k}`;return X.createElement(uT,{key:T,fee:S,label:C})}),X.createElement(Ps,null)))))}i(od,"QuoteCostDetails");import{i18n as id}from"@lingui/core";import{TokenAmount as ad}from"@rango-dev/ui";import si from"react";import{css as mT,styled as dT}from"@rango-dev/ui";var nd=dT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),rd=mT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function En(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return si.createElement(nd,null,si.createElement(ad,{direction:"horizontal",label:id.t("Swap input"),type:"input",tooltipContainer:A(),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:rd()}),si.createElement(ad,{direction:"horizontal",tooltipContainer:A(),label:id.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(En,"QuoteSummary");import{i18n as ud}from"@lingui/core";import{ChevronDownIcon as hT,ChevronRightIcon as yT,Divider as Ds,Image as ST,Tooltip as mi,Typography as pi}from"@rango-dev/ui";import O from"react";import{useLayoutEffect as fT,useState as In}from"react";var sd=480,ld=768,pd=1024,cd=1200,gT=i(()=>{let[t,e]=In(!1),[o,n]=In(!1),[r,a]=In(!1),[s,l]=In(!1),[p,u]=In(!1),c=i(()=>{e(window.innerWidth<=sd),n(window.innerWidth>sd&&window.innerWidth<=ld),a(window.innerWidth>ld&&window.innerWidth<=pd),l(window.innerWidth>pd&&window.innerWidth<=cd),u(window.innerWidth>cd)},"handleResize");return fT(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),li=gT;var ci=4,ui=6,An=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||A();return O.createElement(mi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},O.createElement(Vm,{className:n,state:a},O.createElement(ST,{src:o,size:16})))},"ImageComponent");function md(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||A(),u=r.length,c=tu(r),{isTablet:m,isMobile:g}=li();return O.createElement(Gm,{listItem:s==="list-item",ref:d=>e.current=d,selected:o,onClick:d=>{d.stopPropagation(),n(f=>!f)}},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},ud.t("Via:")),O.createElement(Ds,{direction:"horizontal",size:4}),r.map((d,f)=>{let h=`item-${f}`,k=O.createElement(Ms,null,O.createElement(yT,{size:12,color:"black"}));return g||m?O.createElement(O.Fragment,{key:h},O.createElement(An,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&O.createElement(O.Fragment,null,k)):O.createElement(O.Fragment,{key:h},u<=ci||u>ci&&f<ci-1?O.createElement(O.Fragment,null,O.createElement(An,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&O.createElement(O.Fragment,null,k)):f===ci-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},k,r.map((S,C)=>{let T=`image-${C}`;return C>=f&&O.createElement(O.Fragment,{key:T},O.createElement(An,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),C!==u-1&&O.createElement(O.Fragment,null,k))}))},O.createElement(Ls,{state:r.find((S,C)=>C>=f&&(S.state==="error"||S.state==="warning"))?.state},O.createElement(pi,{size:"xsmall",variant:"body"},"+",u-f))))})),O.createElement("div",{className:jo()},O.createElement("div",{className:"blockchains_section"},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},ud.t("Chains:")),O.createElement(Ds,{direction:"horizontal",size:4}),c.map((d,f)=>O.createElement(O.Fragment,{key:d.displayName},c.length<=ui||c.length>ui&&f<ui-1?O.createElement(mi,{container:p,side:"bottom",content:d.displayName,sideOffset:4},O.createElement(An,{content:"",src:d.image,open:!1,className:f!==0?"blockchainImage":""})):f===ui-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},c.map((h,k)=>k>=f&&O.createElement(An,{key:h.displayName,content:"",src:h.image,open:!1,className:k>f?"blockchainImage":"",container:l})))},O.createElement(Ls,{className:"blockchainImage"},O.createElement(pi,{size:"xsmall",variant:"body"},"+",c.length-f))))),O.createElement(Ds,{direction:"horizontal",size:32}))),O.createElement(Ms,{orientation:a?"up":"down"},O.createElement(hT,{size:12,color:"black"}))))}i(md,"QuoteTrigger");function $s(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:g}=t,d=y().blockchains(),{findToken:f}=y(),h=y().swappers(),{customSlippage:k,slippage:S}=y(),C=k||S,[T,v]=ET(t.expanded),x=bT(null),N=B(o.value,6,6),M=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",E=ut(o.usdValue,n.usdValue??null),b=B(E,2,2),W=Lt(E??0),$=i((ge,ve)=>ge.map((U,Ke)=>{let xt,lt=r?.type===3&&r.swap.swapperId===U.swapperId,wt=r?.type===4&&r.recommendedSlippages?.has(Ke),_=a?.type===2&&a.recommendedSlippages?.has(Ke),Q=lt||wt,G=_;Q?xt="error":G&&(xt="warning");let pe=Q?vo.t("Slippage Error"):vo.t("Slippage Warning");return lt&&(pe=vo.t("Bridge Limit Error")),{swapper:{displayName:on(U.swapperId,h)??"",image:U.swapperLogo},from:{token:{displayName:U.from.symbol,image:U.from.logo},chain:{displayName:pt(U.from.blockchain,d)??"",image:U.from.blockchainLogo},price:{value:Ke===0&&!ve?B(o.value,6,6):B(U.fromAmount,6,6),usdValue:B((U.from.usdPrice??0)*parseFloat(U.fromAmount),4,4),realValue:Ke===0?o.value:U.fromAmount,realUsdValue:new _s(U.from.usdPrice??0).multipliedBy(U.fromAmount).toString()}},to:{token:{displayName:U.to.symbol,image:U.to.logo},chain:{displayName:pt(U.to.blockchain,d)||"",image:U.to.blockchainLogo},price:{value:B(U.toAmount,6,6),usdValue:B((U.to.usdPrice??0)*parseFloat(U.toAmount),4,4),realValue:U.toAmount,realUsdValue:new _s(U.to.usdPrice??0).multipliedBy(U.toAmount).toString()}},state:xt,alerts:Q||G?F.createElement(Dm,{dense:m},F.createElement(CT,{variant:"alarm",type:Q?"error":"warning",title:pe,footer:F.createElement(_m,null,lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},vo.t({id:"Yours: {amount} {symbol}",values:{amount:B(U.fromAmount,6,6),symbol:U?.from.symbol}}))),(wt||_)&&!lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},vo.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(Ke)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(Ke)}}})),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},vo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:sn(U.estimatedTimeInSeconds),fee:B(Ba(U,f),2,2),internalSwaps:U.internalSwaps?$(U.internalSwaps):void 0}}),"getQuoteSteps"),I=$(e?.swaps??[]),R=I.length,ee=g||A(),oe=nu(t.quote.tags||[]),L=!!c,V=sn(ar(e?.swaps)),le=Wr(e?.swaps??[],f),Y=B(le,2,2),ae=le.gte(new _s(Mc));return m?F.createElement(kT,{selected:l,fee:Y,time:V,tooltipContainer:an(),steps:I,tags:oe,feeWarning:ae,percentageChange:b,warningLevel:W,outputPrice:{value:M,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(zm,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:Qm()},!p&&oe.length?F.createElement(F.Fragment,null,F.createElement(Zm,null,oe.map((ge,ve)=>{let U=`${ge.value}_${ve}`;return F.createElement(F.Fragment,{key:U},F.createElement(vT,{label:ge.label,value:ge.value}),F.createElement(Xo,{size:4,direction:"horizontal"}))})),F.createElement(ni,null),!L&&F.createElement(Xo,{size:4})):null,F.createElement("div",{id:"portal-root",className:qm()},F.createElement(od,{quote:e,time:V,fee:Y,feeWarning:ae,showModalFee:u,steps:R}),L&&F.createElement(Um,{onClick:ge=>{ge.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Yo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},vo.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Hm()},F.createElement(Xm,null,F.createElement(TT,{size:12,color:"gray"})),F.createElement(Ym,null,F.createElement(Bs,{size:"small",variant:"body"},`${N} ${I[0].from.token.displayName} = `),F.createElement(dd,{content:n.value,container:ee,open:n.value?void 0:!1},F.createElement(Bs,{size:"small",variant:"body"},"\xA0",`${M} ${I[I.length-1].to.token.displayName}`))),F.createElement(dd,{content:n.usdValue,container:ee},F.createElement(Xo,{size:2,direction:"horizontal"}),F.createElement(Yo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(wT,{tooltipContainer:ee,type:"output",direction:"vertical",price:{value:M,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:I[R-1].to.token.displayName,image:I[R-1].to.token.image},chain:{image:I[R-1].to.chain.image},percentageChange:b,warningLevel:W}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(En,{from:I[0].from,to:I[R-1].to,percentageChange:b,warningLevel:W}),F.createElement(Xo,{size:4}))),F.createElement(Fm,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(md,{type:s,quoteRef:x,selected:l,setExpanded:v,container:ee,expanded:T,steps:I}),F.createElement(Km,{open:T},F.createElement(jm,null),F.createElement("div",{className:Om()},I.map((ge,ve)=>{let U=`item-${ve}`;return F.createElement(xT,{type:"quote-details",key:U,tooltipContainer:ee,step:ge,hasSeparator:ve!==I.length-1,state:ge.state})})))))}i($s,"Quote");import{Divider as WT,Skeleton as MT}from"@rango-dev/ui";import $t from"react";import{darkTheme as IT,styled as di}from"@rango-dev/ui";var fd=di("div",{$$color:"$colors$neutral100",[`.${IT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),gd=di("div",{paddingTop:"$2"}),hd=di("div",{paddingLeft:"$8"}),yd=di("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Id,Divider as St,Skeleton as nt}from"@rango-dev/ui";import q from"react";import{css as AT,styled as _t}from"@rango-dev/ui";var Fs=_t("div",{display:"flex"}),Sd=_t("div",{padding:"$10 $0 $20"}),Cd=_t("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),kd=_t("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Td=_t("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),vd=_t("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),xd=_t("div",{width:"65%",display:"flex",justifyContent:"start"}),wd=_t("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),bd=_t("div",{padding:"$15 $0 $15 $0"}),Ed=AT({display:"flex",justifyContent:"space-between",alignItems:"center"});function Nn(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(Td,null,q.createElement(xd,null,q.createElement(Id,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{size:8,direction:"horizontal"}),q.createElement(wd,null,q.createElement(nt,{height:10,width:60,variant:"rounded"}),q.createElement(St,{size:4}),q.createElement(nt,{height:15,variant:"rounded"}))),q.createElement(nt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return q.createElement("div",null,!o&&q.createElement(q.Fragment,null,q.createElement(Fs,null,q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"})),q.createElement(ni,null),!r&&q.createElement(St,{size:4})),q.createElement("div",{className:Ed()},q.createElement(Fs,null,q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"})),r&&q.createElement(nt,{width:85,height:24,variant:"rounded"})),e==="basic"&&q.createElement(Sd,null,q.createElement(nt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&q.createElement(Cd,null,q.createElement(kd,null,q.createElement(Id,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{direction:"horizontal",size:4}),q.createElement(nt,{height:15,width:150,variant:"rounded"})),q.createElement(St,{size:10}),q.createElement(nt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&q.createElement(q.Fragment,null,q.createElement(St,{size:4}),q.createElement(bd,null,n,q.createElement(vd,null),n),q.createElement(St,{size:12})))}i(Nn,"QuoteSummarySkeleton");import{ChainToken as Bd,Divider as Us,NextIcon as NT,Skeleton as fi}from"@rango-dev/ui";import Ee from"react";import{styled as Wn}from"@rango-dev/ui";var Ad=Wn("div",{display:"flex",alignItems:"start"}),Nd=Wn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Os=Wn("div",{display:"flex",alignItems:"center",flexGrow:1}),Wd=Wn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Md=Wn("div",{display:"flex",alignItems:"center"});function Wt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Md,null,Ee.createElement(fi,{height:22,width:22,variant:"circular"}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:15,width:148,variant:"rounded"})),Ee.createElement(Ad,null,Ee.createElement(yd,{hideSeparator:!e}),Ee.createElement(Nd,{extraSpace:e},Ee.createElement(Os,null,Ee.createElement(Bd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:12,variant:"rounded"})),Ee.createElement(Wd,null,Ee.createElement(NT,{color:"gray",size:16})),Ee.createElement(Os,null,Ee.createElement(Bd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:12,variant:"rounded"})))))}i(Wt,"StepSkeleton");function Mn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return $t.createElement(fd,{expanded:o,rounded:e!=="basic"},$t.createElement(Nn,{type:e,tagHidden:n}),$t.createElement(gd,null,$t.createElement(MT,{height:15,variant:"rounded"})),o&&$t.createElement(hd,null,$t.createElement(WT,{size:24}),$t.createElement(Wt,null),$t.createElement(Wt,null),$t.createElement(Wt,{separator:!1})))}i(Mn,"QuoteSkeleton");function xo(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:p,showModalFee:u,selected:c,onClickAllRoutes:m,fullExpandedMode:g=!1,container:d}=t,{inputAmount:f,inputUsdValue:h,toToken:k}=z(),S=e?.outputAmount?new BT(e?.outputAmount):null,C=e?.outputAmount?jt(e?.outputAmount,ho(e)||k?.usdPrice):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?gi.createElement(Ws,null,gi.createElement(Mn,{tagHidden:l,type:o,expanded:s})):v?gi.createElement(Ws,{onClick:()=>p?.(e)},gi.createElement($s,{quote:e,error:r,container:d,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:g,input:{value:f,usdValue:h?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(xo,"QuoteInfo");import{calculatePendingSwap as _T}from"@rango-dev/queue-manager-rango-preset";import{useEffect as $T}from"react";import{useRef as LT,useState as PT}from"react";var DT=2e3;function hi({request:t}){let[e,o]=PT(!1),n=LT(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,DT)),await s(l,!1)),"retryFetch"),s=i(async(l,p=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(p)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(hi,"useFetch");function Ld(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Ht().confirmRouteRequest(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Ld,"useFetchConfirmQuote");function yi(t){if(!t.swaps)throw new Error(te().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=zs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(yi,"throwErrorIfResponseIsNotValid");function zs(t){if(Pc(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=Dc(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Oc(t);if(o){let n=Mr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(zs,"getQuoteError");function Pd(t,e,o){let n=!1;t&&(n=eu(t,e));let r={quote:null,quoteUpdate:null,balance:null},a=Fo(e,{fromToken:o.fromToken,toToken:o.toToken,findToken:o.findToken,userSlippage:o.userSlippage});a&&(r.quote=a),t&&n&&(Gc(t,e)?r.quoteUpdate={type:3,newOutputAmount:B($o(e)),percentageChange:B(ut($o(t)??"",$o(e)??""),null,2)}:Pa(t,e)?r.quoteUpdate={type:0}:Da(t,e)?r.quoteUpdate={type:1}:_a(t,e)&&(r.quoteUpdate={type:2}));let s=Vc(e,o.selectedWallets,o.meta.blockchains);return s.length===0||(r.balance={messages:s}),r}i(Pd,"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}:{swap:null,error:{type:1},warnings:null}}i(Si,"handleQuoteErrors");function Qs(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=z(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),g=y().tokens(),{findToken:d}=y(),f=u||p,{fetch:h,cancelFetch:k,loading:S}=Ld();return $T(()=>k,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,x=T?.customDestination??a;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=v.reduce((w,E)=>(w[E.chain]=E.address,w),{}),M={requestId:r?.requestId||"",selectedWallets:N,destination:x||void 0};try{return await h(M,!0).then(w=>{let{result:E}=w;yi({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let b={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};n(b);let W={slippage:f.toString(),disabledSwappersGroups:c},$=Pd(r??void 0,b,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:d,selectedWallets:v,userSlippage:f});$.quoteUpdate&&s(!1),l();let I=!!$.balance,R=_T(o.toString(),E,qc(v),W,!I,{blockchains:m,tokens:g});return{quote:b,swap:R,error:null,warnings:$}})}catch(w){return Si(w)}},"fetch"),cancelFetch:k}}i(Qs,"useConfirmSwap");var VT=UT("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${_d}`]:{width:"$48",height:"$48"}}),KT=Gs({flexGrow:1,paddingRight:"$10"}),jT=Gs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),XT=Gs({display:"flex",justifyContent:"space-between",alignItems:"center"});function $d(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=z(),s=GT(),[l,p]=Bn(""),u=!n,[c,m]=Bn(!1),[g,d]=Bn(!1),{isActiveTab:f}=se(),h=y().getDisabledLiquiditySources(),k=HT(h),{manager:S}=FT(),{fetch:C,loading:T,cancelFetch:v}=Qs(),[x,N]=Bn({swap:null,error:null,warnings:null}),[M,w]=Bn(!1),E=i(async({selectedWallets:L,customDestination:V})=>{let le=await C?.({selectedWallets:L,customDestination:V});return N(le),le},"onConfirmSwap"),b=i(async()=>{if(x.swap&&n)try{await S?.create("swap",{swapDetails:x.swap},{id:x.swap.requestId});let L=`../${D.swaps}/${x.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){p("Error: "+L?.message)}},"addNewSwap"),W=i(async()=>{d(!0),await b(),d(!1)},"onConfirm"),$=i(async()=>{x?.warnings?.quote&&!a?w(!0):await W()},"onStartConfirmSwap"),I=i(async()=>{N({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(L=>{N(L)}).catch(L=>console.error(L))},"onRefresh");Ci(()=>{!!k.current.length&&!h.length&&I(),k.current=h},[h.length]),Ci(()=>{u&&v()},[u]),Ci(()=>{u&&m(u)},[u]),Ci(()=>{u||C({selectedWallets:o,customDestination:r}).then(L=>N(L)).catch(L=>console.error(L))},[]),qT(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let R=x.warnings?.quote??null,ee=x.error,oe=[];if(l&&oe.push(Ie.createElement(Dd,{type:"error",variant:"alarm",title:l})),x.warnings?.quoteUpdate&&oe.push(Ie.createElement(Dd,{variant:"alarm",type:"warning",title:x.warnings.quoteUpdate&&Gr(x.warnings.quoteUpdate)})),R||ee){let L=`../${D.settings}`;oe.push(Ie.createElement(wn,{warning:R,error:ee,couldChangeSettings:!1,refetchQuote:I,showWarningModal:M,confirmationDisabled:!f,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await b()},onChangeSettings:()=>s(L)}))}return Ie.createElement(ne,{header:{title:qs.t("Confirm Swap"),onWallet:()=>{let L=`../${D.wallets}`;s(L)}},footer:Ie.createElement(VT,null,Ie.createElement("div",{className:KT()},Ie.createElement(OT,{variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||g,disabled:!!x.error||!f,onClick:$},qs.t("Start Swap"))),Ie.createElement(_d,{variant:"contained",type:"primary",size:"large",loading:T||g,disabled:!f,onClick:m.bind(null,!0)},Ie.createElement(QT,{size:24})))},c&&Ie.createElement(hm,{open:c,onClose:()=>m(!1),onCancel:v,loading:T,onCheckBalance:E}),Ie.createElement(ie,null,Ie.createElement("div",{className:XT()},Ie.createElement(zT,{variant:"title",size:"small"},qs.t("You get")),Ie.createElement("div",{className:jT()},Ie.createElement(Or,{onClick:!T&&!c&&!M?I:void 0}))),Ie.createElement(Hs,{size:"12"}),yu(oe.map((L,V)=>({element:L,key:`alert-${V}`})),Ie.createElement(Hs,{size:10})),oe.length>0?Ie.createElement(Hs,{size:10}):null,Ie.createElement(xo,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:x.error,loading:T,warning:x.warnings?.quote??null})))}i($d,"ConfirmSwapPage");import{i18n as Ft}from"@lingui/core";import{Button as rl,CustomTokensZeroStateDarkIcon as fv,CustomTokensZeroStateIcon as gv,DeleteIcon as hv,Divider as _n,IconButton as yv,MessageBox as Sv,NotFound as Cv,styled as al}from"@rango-dev/ui";import fe,{useState as il}from"react";import{useNavigate as kv}from"react-router-dom";import{CloseIcon as ZT,IconButton as JT,SearchIcon as RT,TextField as ev}from"@rango-dev/ui";import Ln from"react";import{styled as YT}from"@rango-dev/ui";var Fd=YT("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return Ln.createElement(ev,{prefix:Ln.createElement(Fd,null,Ln.createElement(RT,{color:"black"})),suffix:!!s.length&&Ln.createElement(JT,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Ln.createElement(ZT,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Ct,"SearchInput");import{i18n as ol}from"@lingui/core";import{darkTheme as Xd,Divider as Jo,ExternalLinkIcon as sv,Image as lv,ListItemButton as pv,NotFound as cv,PinIcon as uv,Skeleton as Yd,Typography as vi,VirtualizedList as mv}from"@rango-dev/ui";import H,{useEffect as Zd,useState as Jd}from"react";import{useWallets as tv}from"@rango-dev/wallets-react";import{useEffect as ov,useRef as nv,useState as rv}from"react";function Vs(t){let{connectedWallets:e}=Z(),{getWalletInfo:o}=tv(),n=nv([]),[r,a]=rv(0);return ov(()=>{let s=i(p=>{p.type==="disconnect"&&o(p.payload.walletType).supportedChains.some(m=>m.name===t)&&a(m=>m+1)},"handleWalletEvent");return yr.on("walletEvent",s),t?(e.filter(p=>p.chain===t).forEach(p=>{let{walletType:u}=p,c=n.current.includes(u);p.loading&&!c?n.current=n.current.concat(u):!p.loading&&c&&(n.current=n.current.filter(m=>m!==u),a(m=>m+1))}),()=>yr.off("walletEvent",s)):a(p=>p+1)},[e,t,o]),{balanceKey:r}}i(Vs,"useObserveBalanceChanges");import{Divider as Kd,ListItem as av,Skeleton as Pn}from"@rango-dev/ui";import kt from"react";import{css as Zo,darkTheme as Od,ImageContainer as iv,styled as dt,Typography as Ud}from"@rango-dev/ui";var Ks=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),js=Zo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Xs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Ys=Zo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Od} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Zs=Zo({}),Js=Zo(),zd=dt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Rs=dt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),ki=dt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${js}`]:{[`& .${Ys}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Zs}`]:{bottom:"-15px"},[`& .${Ks}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Xs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),el=dt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),tl=dt(Ud,{}),Qd=dt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Js}`]:{$$color:"$colors$neutral600",[`.${Od} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ti=dt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),fU=dt("div",{display:"flex",alignItems:"center"}),qd=dt("div",{position:"relative",[`& ${iv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Hd=dt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Gd=dt(Ud,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Vd=dt("a",{"& svg:hover":{color:"$colors$info"}});function jd(t){return kt.createElement(ki,null,Array.from(Array(t.size),e=>kt.createElement(av,{key:e,hasDivider:!0,start:kt.createElement(Pn,{variant:"circular",width:35,height:35}),end:kt.createElement(Ti,null,kt.createElement(Pn,{variant:"text",size:"large",width:70}),kt.createElement(Kd,{size:4}),kt.createElement(Pn,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Pn,{variant:"text",size:"large",width:90}),kt.createElement(Kd,{size:4}),kt.createElement(Pn,{variant:"text",size:"medium",width:90}))})))}i(jd,"LoadingTokenList");var nl=20,dv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:js()},o?H.createElement("div",{className:Ks()},o):H.createElement(Rs,{className:Xs()},H.createElement(vi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:a},H.createElement(tl,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Ys()} ${!o&&Zs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Jo,{size:4,direction:"horizontal"}),H.createElement(Vd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},H.createElement(sv,{size:12}))))},"renderDesc");function Dn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,[l,p]=Jd(e),u=y().fetchStatus,c=y().blockchains(),[m,g]=Jd(!0),{getBalanceFor:d,loading:f}=Z(),{isTokenPinned:h}=y(),{balanceKey:k}=Vs(r),S=i(()=>{p(e.slice(0,l.length+nl))},"loadNextPage");Zd(()=>{g(e.length>l.length)},[l.length]),Zd(()=>{p(e.slice(0,nl))},[e.length,r,k]);let C=i(v=>{let x=mr(d(v));return s?s(v):f?H.createElement(Ti,null,H.createElement(Yd,{variant:"text",size:"large",width:70}),H.createElement(Jo,{size:4}),H.createElement(Yd,{variant:"text",size:"medium",width:50})):x&&H.createElement(Qd,null,H.createElement(Gd,{variant:"title",size:"small"},x.amount),H.createElement("div",null),x.usdValue&&H.createElement(vi,{variant:"body",className:Js(),size:"xsmall"},`$${x.usdValue}`))},"endRenderer"),T=i(()=>H.createElement(mv,{endReached:m?S:void 0,itemContent:v=>{let x=l[v],N=x.address||"",M=c.find(W=>W.name===x.blockchain),w=Xa(M.color,"main"),E={$$color:w.main150,[`.${Xd} &`]:{$$color:w.main750},backgroundColor:"$$color"},b={$$color:w.main750,[`.${Xd} &`]:{$$color:w.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(pv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":v,key:`${x.symbol}${x.address}`,id:`${x.symbol}${x.address}`,hasDivider:!0,onClick:()=>n&&n(l[v]),start:H.createElement(qd,null,H.createElement(lv,{src:x.image,size:30}),t.type!=="custom-token"&&h(x,t.type)&&H.createElement(Hd,null,H.createElement(uv,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||x.name||!x.name&&!N?H.createElement(Rs,null,H.createElement(vi,{variant:"title",size:"xmedium"},x.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:E},H.createElement(tl,{variant:"body",size:"xsmall",css:b},x.blockchain))):void 0,description:M?.info&&N&&M.type!=="COSMOS"?dv({address:N,token:l[v],customCssForTag:E,customCssForTagTitle:b,name:x.name,url:M.info.addressUrl.split("{wallet}").join(N)}):x.name||void 0,end:C(x)}))},totalCount:l.length,key:`${r}-${o}-${k}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(vi,{variant:"label",size:"large"},ol.t("Select Token")),H.createElement(Jo,{size:4})),H.createElement(zd,null,H.createElement(Jo,{size:4}),u==="loading"&&H.createElement(jd,{size:nl}),u==="success"&&(l.length?H.createElement(ki,{as:"ul"},T()):!!o&&H.createElement(cv,{title:ol.t("No results found"),description:ol.t("Try using different keywords")}))))}i(Dn,"TokenList");var Tv=al("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),vv=al("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),xv=al(yv,{"&:hover":{"& svg":{color:"$secondary550"}}});function Rd(){let[t,e]=il(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=z(),{mode:p}=Qo({}),u=kv(),[c,m]=il(!1),[g,d]=il(),f=i(C=>{let T=C.target.value;e(T)},"handleSearch"),h=p==="dark",k=n.filter(C=>et(C.symbol,t)||et(C.address||"",t)||et(C.name||"",t)),S=i(()=>{if(g){let C=a?_e(a):null,T=r?_e(r):null,v=_e(g);C===v?l({token:null}):T===v&&s({token:null}),o(g)}m(!1)},"handleDeleteCustomToken");return fe.createElement(ne,{header:{title:Ft.t("Custom Tokens")}},fe.createElement(ie,null,fe.createElement(Tv,null,n.length?fe.createElement(fe.Fragment,null,fe.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ft.t("Search Token"),onChange:f}),fe.createElement(_n,{size:16}),fe.createElement(Dn,{list:k,type:"custom-token",searchedFor:t,showTitle:!1,action:C=>fe.createElement(xv,{variant:"ghost",onClick:()=>{m(!0),d(C)}},fe.createElement(hv,{size:12,color:"gray"}))})):fe.createElement(vv,null,fe.createElement(Cv,{icon:h?fe.createElement(fv,{size:200}):fe.createElement(gv,{size:200}),title:Ft.t("No custom tokens"),description:Ft.t("press the button to add your custom token")})),fe.createElement(_n,{size:20}),fe.createElement(rl,{type:"primary",variant:"contained",size:"large",onClick:()=>u(D.addCustomTokens)},Ft.t("Add Custom Token"))),fe.createElement(J,{open:c,dismissible:!0,onClose:()=>m(!1),container:A()},fe.createElement(Sv,{title:Ft.t("Delete Custom Token"),type:"error",description:Ft.t("Are you sure you want to Delete this Token?")},fe.createElement(_n,{size:40}),fe.createElement(_n,{size:10}),fe.createElement(rl,{fullWidth:!0,variant:"contained",type:"primary",size:"large",onClick:S},Ft.t("Yes, Delete it")),fe.createElement(_n,{size:12}),fe.createElement(rl,{fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ft.t("No, Continue"))))))}i(Rd,"CustomTokensPage");import{i18n as Ge}from"@lingui/core";import{useManager as Qv}from"@rango-dev/queue-manager-react";import{Button as dl,darkTheme as qv,Divider as Rt,MessageBox as Hv,NotFound as Gv,styled as fl,Typography as bi}from"@rango-dev/ui";import{TransactionStatus as On}from"rango-types";import re,{useMemo as Cf,useState as Ei}from"react";import{useNavigate as Vv}from"react-router-dom";import{FilterIcon as Wv,Popover as Mv}from"@rango-dev/ui";import wo from"react";import{css as wv,darkTheme as xi,IconButton as bv,styled as $n}from"@rango-dev/ui";var sl=$n("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),ef=$n(bv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"},[`& ${sl}::before`]:{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),tf=$n("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),of=$n("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),nf=wv({display:"flex",justifyContent:"space-between",alignItems:"center"}),rf=$n("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as af}from"@lingui/core";import{Button as Ev,Divider as sf,ListItemButton as Iv,Radio as Av,RadioRoot as Nv,Typography as lf}from"@rango-dev/ui";import rt from"react";function pf(t){let{filterBy:e,onClickItem:o}=t;return rt.createElement(of,null,rt.createElement("div",{className:nf()},rt.createElement(lf,{size:"small",variant:"body"},af.t("Status")),rt.createElement(Ev,{variant:"ghost",size:"xxsmall",onClick:()=>o("")},af.t("Reset"))),rt.createElement(sf,{size:10}),rt.createElement(Nv,{value:e},rt.createElement(rf,null,t.list.map((n,r)=>rt.createElement(Iv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:rt.createElement(rt.Fragment,null,rt.createElement(sf,{direction:"horizontal",size:4}),rt.createElement(lf,{size:"medium",variant:"body"},n.title)),start:rt.createElement(Av,{value:n.id}),onClick:o})))))}i(pf,"FilterSelectorContent");function ll(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return wo.createElement("div",null,wo.createElement(Mv,{open:a,align:"end",onOpenChange:o,container:A(),content:wo.createElement(pf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},wo.createElement(ef,{variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},wo.createElement(sl,{isSelect:!!n},wo.createElement(Wv,{size:16,color:"black"}),!!n&&wo.createElement(tf,null)))))}i(ll,"FilterSelector");import{i18n as Pv}from"@lingui/core";import{Divider as ff,GroupedVirtualizedList as Dv,Skeleton as _v,SwapListItem as gf,Typography as $v}from"@rango-dev/ui";import He,{useCallback as hf,useEffect as Fv,useRef as Ov,useState as Uv}from"react";function cf(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(cf,"calculateGroupsSoFar");import{css as Bv,darkTheme as Lv,styled as Fn}from"@rango-dev/ui";var pl=Bv(),uf=Fn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),cl=Fn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${pl}`]:{$$color:"$colors$neutral600",[`.${Lv} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ul=Fn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),mf=Fn("div",{gap:"$10",display:"flex",flexDirection:"column"}),df=Fn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var zv=10;function ml(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Uv([]),l=Ov(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=hf(cf,[]),g=hf(()=>{let d=e.length-l.current;d&&(l.current+=Math.min(d,zv),s(m(u,l.current)))},[e.length]);if(Fv(()=>{r||g()},[r,g]),r){let d=[1,2];return He.createElement(He.Fragment,null,[d,d].map((h,k)=>He.createElement(cl,{key:k},He.createElement(ul,null,He.createElement(_v,{variant:"text",width:60,size:"small"}),He.createElement(ff,{size:16})),He.createElement(ff,{size:4}),He.createElement(mf,null,h.map((C,T)=>He.createElement(gf,{isLoading:!0,key:T}))))))}return He.createElement(Dv,{endReached:()=>{l.current<e.length&&g()},groupCounts:a,groupContent:d=>He.createElement(cl,null,He.createElement(ul,null,He.createElement($v,{variant:"label",size:"medium",className:pl()},c[d]))),itemContent:(d,f)=>{let h=p[d];if(!h)return null;let k=h.steps[0],S=h.steps[h.steps.length-1];return He.createElement(uf,{key:h.requestId},He.createElement(gf,{requestId:h.requestId,creationTime:h.creationTime,status:h.status,onClick:o,tooltipContainer:A(),onlyShowTime:c[f]===Pv.t("Today"),swapTokenData:{from:{token:{image:k.fromLogo,displayName:k.fromSymbol},blockchain:{image:k.fromBlockchainLogo||""},amount:B(h.inputAmount,6,6),realAmount:h.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(ml,"HistoryGroupedList");import{i18n as wi}from"@lingui/core";import yf from"dayjs";var Sf=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(p,u){e.has(p)||e.set(p,{title:p,swaps:[]}),e.get(p)?.swaps.push(u)}i(o,"addYearsToOutput");let n=yf();t.forEach(p=>{let u=Number(p.creationTime),c=yf(u);if(n.isSame(c,"day"))e.get("today")?.swaps.push(p);else if(n.isSame(c,"week"))e.get("week")?.swaps.push(p);else if(n.isSame(c,"month"))e.get("month")?.swaps.push(p);else if(n.isSame(c,"year"))e.get("year")?.swaps.push(p);else{let m=new Date(u).getFullYear().toString();o(m,p)}});let r=Array.from(e.values()).filter(p=>p.swaps.length>0),a=r.flatMap(p=>p.swaps),s=r.map(p=>p.swaps.length),l=r.map(p=>p.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Kv=fl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),jv=fl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Xv=fl("div",{"._typography":{color:"$neutral700",[`.${qv}&`]:{color:"$neutral900"}}}),Yv=[{id:On.SUCCESS,title:Ge.t("Complete")},{id:On.RUNNING,title:Ge.t("Running")},{id:On.FAILED,title:Ge.t("Failed")}],Zv=i((t,e)=>t?.length?t.filter(o=>bt(o.fromBlockchain,e)||bt(o.toBlockchain,e)||bt(o.toSymbol,e)||bt(o.fromSymbol,e)).length:!1,"isStepContainsText");function kf(){let t=Vv(),{manager:e,state:o}=Qv(),n=mt(e).map(({swap:T})=>T),[r,a]=Ei(""),[s,l]=Ei(!1),p=!o.loadedFromPersistor,[u,c]=Ei(""),[m,g]=Ei(!1),d=i(T=>{let v=T.target.value;a(v)},"handleSearch"),f=Cf(()=>!r&&!u?n:n.filter(T=>{let{inputAmount:v,status:x,steps:N,requestId:M}=T;return(!r||bt(v,r)||bt(x,r)||Zv(N,r)||bt(M,r))&&(!u||u===x)}),[n,r,u]),h=!f?.length&&!p,k=i(()=>g(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),g(!1)}catch(T){console.log(T)}},"onClear"),C=Cf(()=>!n.some(T=>T.status===On.SUCCESS||T.status===On.FAILED),[n]);return re.createElement(ne,{header:{title:Ge.t("History"),suffix:re.createElement(Vt,null,re.createElement(dl,{disabled:C,variant:"ghost",size:"xsmall",onClick:()=>g(!0)},re.createElement(bi,{size:"medium",variant:"label",color:"error"},Ge.t("Clear all Txs"))))}},re.createElement(ie,null,re.createElement(jv,null,re.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Ge.t("Search Transaction"),autoFocus:!0,onChange:d,style:{height:36},value:r}),re.createElement(Rt,{size:10,direction:"horizontal"}),re.createElement(ll,{filterBy:u,open:s,onOpenChange:T=>l(T),onClickItem:T=>c(T),list:Yv})),re.createElement(Rt,{size:"16"}),re.createElement(Kv,null,h&&re.createElement(df,null,re.createElement(Rt,{size:32}),re.createElement(Gv,{title:r?Ge.t("No results found"):Ge.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Ge.t("Try using different keywords"):Ge.t("Your transaction history is stored locally and will appear here after you start a swap")})),!h&&re.createElement(ml,{list:f,onSwapClick:t,groupBy:Sf,isLoading:p}))),re.createElement(J,{open:m,onClose:k,container:A()},re.createElement(Rt,{size:20}),re.createElement(Hv,{type:"warning",title:Ge.t("Clear History"),description:re.createElement(Xv,null,re.createElement(bi,{variant:"body",size:"medium"},Ge.t("This would clear all succeeded/failed transactions from widget. Do you wish to proceed?")),re.createElement(Rt,{size:"24"}),re.createElement(bi,{variant:"body",size:"small"},Ge.t("Hint: This does not clear your transaction history on blockchain. Only hides them in this page.")))}),re.createElement(Rt,{size:40}),re.createElement(Rt,{size:10}),re.createElement(dl,{variant:"contained",type:"primary",size:"large",onClick:S},Ge.t("Yes, Clear history")),re.createElement(Rt,{size:10}),re.createElement(dl,{variant:"outlined",type:"primary",size:"large",onClick:k},re.createElement(bi,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(kf,"HistoryPage");import{i18n as hx}from"@lingui/core";import{Button as yx,Divider as Of,styled as Sx,WarningIcon as Cx}from"@rango-dev/ui";import kx from"bignumber.js";import Je,{useEffect as Uf,useState as zf}from"react";import{useNavigate as Tx}from"react-router-dom";import{i18n as nx}from"@lingui/core";import{Header as rx}from"@rango-dev/ui";import eo,{useEffect as ix,useState as ax}from"react";import{i18n as Rv}from"@lingui/core";import{Divider as hl,FullExpandedQuote as ex,Typography as tx}from"@rango-dev/ui";import Ce from"react";import{styled as gl}from"@rango-dev/ui";var Tf=gl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),vf=gl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),xf=gl("div",{width:"146px"});import{i18n as Un}from"@lingui/core";import{Select as Jv}from"@rango-dev/ui";import wf from"react";function Ii(t){let{updateQuotePartialState:e,sortStrategy:o}=z(),n=[{value:"SMART",label:Un.t("Smart Routing")},{value:"FEE",label:Un.t("Lowest Fee")},{value:"SPEED",label:Un.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Un.t("Maximum Return")},{value:"PRICE",label:Un.t("Maximum Output")}];return wf.createElement(xf,null,wf.createElement(Jv,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ii,"SelectStrategy");var bf=3;function zn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:g,sortStrategy:d,error:f}=z(),{slippage:h,customSlippage:k}=y(),{findToken:S}=y(),C=l||A(),T=!!u&&u.results.length,v=k??h,x=i(w=>{if(!m||!g||!u)return null;let E={requestAmount:u.requestAmount,...w};return Fo(E,{fromToken:m,toToken:g,userSlippage:v,findToken:S})},"getQuoteWarning"),N=f?.type===0||f?.type===1,M=u?.results?Pr(d,u?.results):[];return Ce.createElement(Ce.Fragment,null,a&&Ce.createElement(Ce.Fragment,null,Ce.createElement(vf,null,Ce.createElement(tx,{size:"xmedium",variant:"title"},Rv.t("Sort by")),Ce.createElement(Ii,{container:C})),Ce.createElement(hl,{size:"10"})),e&&Array.from({length:bf},(w,E)=>Ce.createElement(Ce.Fragment,{key:E},s?Ce.createElement(ex,{loading:!0}):Ce.createElement(Mn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==bf-1&&Ce.createElement(hl,{size:16}))),!e&&Ce.createElement(Ce.Fragment,null,T?M.map((w,E)=>{let b=x(w),W=zs(w.swaps),$=M.length-1===E;return Ce.createElement(Ce.Fragment,{key:w.requestId},Ce.createElement(xo,{showModalFee:r,container:C,selected:p?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:u.requestAmount},loading:e,error:W?.options||null,warning:b,fullExpandedMode:s,onClick:I=>{W||c("warning",b),c("error",W?.options||null),o(I)},type:"list-item"}),!$&&Ce.createElement(hl,{size:16}))}):N&&Ce.createElement(Tf,null,Ce.createElement(vn,{size:s?"large":"small",error:f,fetch:n}))))}i(zn,"Quotes");import{darkTheme as ox,styled as Ef}from"@rango-dev/ui";var If=Ef("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${ox} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Af=Ef("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var sx=100;function yl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=ax(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=an();return ix(()=>{let g=null;return a?g=setTimeout(()=>{l(!0)},sx):(l(!1),g&&clearTimeout(g)),()=>{g&&clearTimeout(g)}},[a]),eo.createElement(If,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${Qr()}`,id:$e.EXPANDED_BOX_ID},eo.createElement(rx,{title:nx.t("Routes"),suffix:eo.createElement(eo.Fragment,null,eo.createElement(Ii,{container:m}),eo.createElement(So,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),eo.createElement(Af,null,eo.createElement(zn,{showModalFee:!1,fetch:e,hasSort:!1,loading:o,container:an(),onClickOnQuote:n,fullExpandedMode:c})))}i(yl,"ExpandedQuotes");import{i18n as Df}from"@lingui/core";import{SwapInput as _f}from"@rango-dev/ui";import Qn from"react";import{ReverseIcon as cx}from"@rango-dev/ui";import Cl from"react";import{keyframes as lx,styled as Nf}from"@rango-dev/ui";var Sl=450,px=lx({"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)"}}),Wf=Nf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Mf=Nf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${px} ${Sl}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 kl(){let t=z.use.switchFromAndTo();return Cl.createElement(Wf,null,Cl.createElement(Mf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Sl),t()}},Cl.createElement(cx,{size:12})))}i(kl,"SwitchFromAndToButton");import{styled as Bf}from"@rango-dev/ui";var Lf=Bf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Pf=Bf("div",{position:"relative"});function Tl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:g,outputUsdValue:d,selectedQuote:f}=z(),{connectedWallets:h,getBalanceFor:k}=Z(),S=a?k(a):null,C=mr(S)?.amount??"0",T=s&&a?B(S?.amount,S?.decimals):"0",v=!!s&&$p(h,s.name),x=!Ma(f,c,m),N=!Ma(f,c,d),M=!m||!d||!d.gt(0)?null:ut(m.toString(),d.toString());return Qn.createElement(Lf,null,Qn.createElement(Pf,null,Qn.createElement(_f,{label:Df.t("From"),mode:"From",onInputChange:u,balance:C,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue:x?void 0:B(m,4,4),realUsdValue:x?void 0:m?.toString(),error:x?te().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:A(),onSelectMaxBalance:()=>{u(T.split(",").join(""))},anyWalletConnected:h.length>0}),Qn.createElement(kl,null)),Qn.createElement(_f,{sharpBottomStyle:!r&&(!!f||e),label:Df.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(ut(m,d),2,2),warningLevel:Lt(M??0),price:{value:B(g,6,6),usdValue:N?void 0:B(d,4,4),realValue:g?.toString(),realUsdValue:N?void 0:d?.toString(),error:N?te().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:A()}))}i(Tl,"Inputs");import{useCallback as ux,useEffect as mx,useRef as dx,useState as fx}from"react";function $f(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Ht().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i($f,"useFetchAllQuotes");var gx=600;function Ai({refetchQuote:t}){let{fetch:e,cancelFetch:o}=$f(),{excludeLiquiditySources:n,features:r,enableCentralizedSwappers:a}=y().config,s=Z.use.connectedWallets(),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:c,selectedQuote:m,sortStrategy:g,resetQuote:d,error:f,warning:h,setSelectedQuote:k,updateQuotePartialState:S}=z(),{slippage:C,customSlippage:T,affiliatePercent:v,affiliateRef:x,affiliateWallets:N,fetchStatus:M}=y(),w=y().getLiquiditySources(),E=y().getDisabledLiquiditySources(),b=y().excludeLiquiditySources(),{findToken:W}=y(),[$,I]=fx(!0),R=dx(u),ee=T??C,L=!l||!p||so(l,p)||!ln(u),V=i(ae=>{I(ae)},"resetState"),le=i(ae=>{let{fromToken:ge,toToken:ve,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:xt,disabledLiquiditySources:lt,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G}=ae;if($||V(!0),!L&&ge&&ve){d();let pe=Qc({fromToken:ge,toToken:ve,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:xt,disabledLiquiditySources:lt,wallets:s,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G,enableCentralizedSwappers:a});Vp("experimentalRoute",r)&&(pe.experimental=!0),e(pe).then(ce=>{let de=Pr(g,ce.results),he=ou(m,de,ce.requestAmount);I(!1),S("quotes",ce),k(he),yi({diagnosisMessages:ce.diagnosisMessages,requestId:he?.requestId||"",swaps:he?.swaps});let Rn=ho(he)||ve?.usdPrice,io=hn(he)||ge?.usdPrice,ea=he&&Fo(he,{fromToken:{...ge,usdPrice:io},toToken:{...ve,usdPrice:Rn},userSlippage:ee,findToken:W});S("warning",ea)}).catch(ce=>{let{error:de}=Si(ce);(de?.type===0||de?.type===1)&&d(),de?.type!==2&&(S("error",de),I(!1))})}},"fetch"),Y=ux(xp(ae=>{le(ae)},gx),[L]);return mx(()=>{if(!t){I(!1);return}if(M!=="success")return;if(L){I(!1),(m||f||h)&&d();return}if(!ln(u)||c?.eq(0)){V(!1),o();return}d(),V(!0);let ae=le;return R.current&&R.current!=u&&(ae=Y),R.current=u,ae({inputAmount:u,fromToken:l,toToken:p,liquiditySources:w,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:x,affiliatePercent:v,affiliateWallets:N}),o},[M,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,L,w?.length,n,E.length,ee,x,v,JSON.stringify(N)]),{fetch:()=>le({inputAmount:u,fromToken:l,toToken:p,liquiditySources:w,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:x,affiliatePercent:v,affiliateWallets:N}),loading:$}}i(Ai,"useSwapInput");function Ff(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(Ff,"emitPreventableEvent");var vx=Sx("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),xx=300;function Qf(){let t=Tx(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:g}=z(),[d,f]=zf(!1),{isLargeScreen:h,isExtraLargeScreen:k}=li(),{fetch:S,loading:C}=Ai({refetchQuote:a}),{config:T,fetchStatus:v}=y(),{connectedWallets:x}=Z(),{isActiveTab:N}=se(),[M,w]=zf(!1),b=_c({fetchMetaStatus:v,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:x.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),W=Hp(h,k,T?.variant),$=!!n&&!!e&&!!o&&new kx(n).gt(0)&&!Zc(e,o),I=$&&v==="success"&&C,oe=(!W||W&&p?.results.length)&&(l||s);Uf(()=>{c(),g("refetchQuote",!0)},[]),Uf(()=>{f($)},[$]);let L=(r||s)&&!M?S:void 0,V=i(Y=>{W&&d?(f(!1),setTimeout(()=>{t(Y)},xx)):t(Y)},"onHandleNavigation"),le=i(Y=>{r?.requestId!==Y.requestId&&(w(!1),u(Y))},"onClickOnQuote");return Je.createElement(vx,null,Je.createElement(ne,{height:"auto",footer:Je.createElement(yx,{type:"primary",size:"large",disabled:b.disabled||!N,prefix:b.action==="confirm-warning"&&Je.createElement(Cx,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?Ff({type:"clickConnectWallet"},()=>V(D.wallets)):b.action==="confirm-warning"?w(!0):V(D.confirmSwap)}},b.title),header:{onWallet:()=>{V(D.wallets)},hasBackButton:!1,title:T.title||hx.t("Swap"),suffix:Je.createElement(So,{hidden:W?["refresh"]:void 0,onClickRefresh:L,onClickHistory:()=>V(D.swaps),onClickSettings:()=>{V(D.settings)}})}},Je.createElement(ie,null,Je.createElement(Tl,{fetchingQuote:I,fetchMetaStatus:v,isExpandable:W,onClickToken:Y=>{V(Y==="from"?D.fromSwap:D.toSwap)}}),Je.createElement(Of,{size:"2"}),W?null:Je.createElement(xo,{quote:r,loading:I,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{g("refetchQuote",!1),V(D.routes)}:void 0}),oe?Je.createElement(Je.Fragment,null,Je.createElement(Of,{size:"10"}),Je.createElement(wn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!N,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),m(!0),V(D.confirmSwap)},onChangeSettings:()=>V(D.settings)})):null)),W?Je.createElement(yl,{loading:I,onClickOnQuote:le,fetch:S,onClickRefresh:L,isVisible:d}):null)}i(Qf,"Home");import{i18n as qf}from"@lingui/core";import{Alert as wx,Divider as bx,List as Ex,ListItemButton as Ix,Radio as Ax,RadioRoot as Nx,Typography as Wx}from"@rango-dev/ui";import Mt from"react";function to(){let{setLanguage:t,language:e,config:o}=y(),n=Xp,r=o?.language||Mo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Mo),resetLanguage:()=>t(null)}}i(to,"useLanguage");function Hf(){let{activeLanguage:t,changeLanguage:e,languages:o}=to(),n=Ye(),r=o.map(a=>{let{local:s,label:l,SVGFlag:p}=a;return{id:s,value:s,title:Mt.createElement(Wx,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Mt.createElement(Ax,{value:s}),start:Mt.createElement(p,null)}});return Mt.createElement(ne,{header:{title:qf.t("Language")}},Mt.createElement(ie,null,Mt.createElement(wx,{type:"warning",variant:"alarm",title:"Important Notice: Machine translations are in use"}),Mt.createElement(bx,{size:"8"}),Mt.createElement(Nx,{value:t},Mt.createElement(Ex,{type:Mt.createElement(Ix,{title:qf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Hf,"LanguagePage");import{i18n as Ot}from"@lingui/core";import{Button as Dx,Checkbox as _x,Image as $x,ListItemButton as Fx,NotFound as Ox,Typography as Ux}from"@rango-dev/ui";import Ve,{useState as zx}from"react";import{Checkbox as Lx,Skeleton as Vf}from"@rango-dev/ui";import Hn from"react";import{styled as vl}from"@rango-dev/ui";var qn=vl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),xl=vl("div",{width:80,display:"flex",justifyContent:"flex-end"}),wl=vl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as Mx,styled as Bx}from"@rango-dev/ui";var Gf=Bx(Mx,{height:61});var Px=30;function bl(){return Hn.createElement(qn,null,Array.from(Array(Px),(t,e)=>Hn.createElement(Gf,{hasDivider:!0,key:e,start:Hn.createElement(Vf,{variant:"circular",width:35,height:35}),title:Hn.createElement(Vf,{variant:"text",size:"large",width:90}),end:Hn.createElement(Lx,{checked:!1})})))}i(bl,"LoadingLiquiditySourceList");function El({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=zx(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=hr(o,n),u={Exchanges:Ot.t("Exchanges"),Bridges:Ot.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(S=>c.includes(S.type)),g=m.length===m.filter(S=>S.selected).length,d=i(()=>{m.forEach(S=>{g?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),f=m.map(S=>{let{selected:C,groupTitle:T,logo:v}=S;return{start:Ve.createElement($x,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ve.createElement(_x,{checked:C,disabled:l}),title:Ve.createElement(Ux,{variant:"title",size:"xmedium"},Ot.t(T)),...S}}),h=i(S=>{let C=S.target.value;a(C)},"handleSearch"),k=f;return r&&(k=f.filter(S=>bt(S.groupTitle,r))),Ve.createElement(ne,{header:{title:Ot.t(t),suffix:Ve.createElement(xl,null,Ve.createElement(Dx,{variant:"ghost",size:"xsmall",onClick:d},g?Ot.t("Deselect all"):Ot.t("Select all")))}},Ve.createElement(ie,{view:!0},Ve.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Ot.t("Search {sourceType}",{sourceType:u[t]}),onChange:h}),e==="loading"&&Ve.createElement(bl,null),!k.length&&r?Ve.createElement(wl,null,Ve.createElement(Ox,{title:Ot.t("No results found"),description:Ot.t("Try using different keywords")})):e==="success"&&Ve.createElement(qn,{disabled:l},k.map(S=>{let{groupTitle:C,...T}=S;return Ve.createElement(Ve.Fragment,{key:S.id},Ve.createElement(Fx,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(El,"LiquiditySourcePage");import{i18n as Qx}from"@lingui/core";import Ni from"react";import{useNavigate as qx}from"react-router-dom";function Kf(){let t=qx(),e=Ye(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=z(),{fetch:l,loading:p}=Ai({refetchQuote:n}),u=i(g=>{r(g),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${D.settings}`,m=`../${D.wallets}`;return Ni.createElement(ne,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Qx.t("Routes"),suffix:Ni.createElement(So,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Ni.createElement(ie,null,Ni.createElement(zn,{fetch:l,loading:p,onClickOnQuote:u})))}i(Kf,"RoutesPage");import{i18n as eg}from"@lingui/core";import{Divider as tg,getCategoriesCount as Rx,SelectableCategoryList as ew}from"@rango-dev/ui";import Ut,{useState as og}from"react";import{useNavigate as tw}from"react-router-dom";import{i18n as Il}from"@lingui/core";import{Divider as Kx,Image as jx,ListItemButton as Xx,NotFound as Yx,Typography as Rf}from"@rango-dev/ui";import it,{useEffect as Zx,useState as Jx}from"react";var jf=i((t,e,o)=>t.filter(n=>ir(n.type,o)).filter(n=>et(n.name,e)||et(n.displayName,e)),"filterBlockchains");import{ImageContainer as Hx,styled as Xf}from"@rango-dev/ui";var Yf=Xf("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Wi=Xf(Sn,{padding:0,margin:0,listStyle:"none",[`& ${Hx}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Gx,Skeleton as Zf}from"@rango-dev/ui";import Mi from"react";var Vx=20;function Jf(){return Mi.createElement(Wi,null,Array.from(Array(Vx),t=>Mi.createElement(Gx,{key:t,hasDivider:!0,start:Mi.createElement(Zf,{variant:"circular",width:35,height:35}),title:Mi.createElement(Zf,{variant:"text",size:"large",width:90})})))}i(Jf,"LoadingBlockchainList");function Al(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Jx(e),{fetchStatus:p}=y();Zx(()=>{l([...jf(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?it.createElement(Yx,{title:Il.t("No results found"),description:Il.t("Try using different keywords")}):it.createElement(Wi,{as:"ul",key:`${r}-${o}`},s.map(c=>it.createElement(Xx,{key:`${c.name}-${c.chainId}`,hasDivider:!0,onClick:()=>n(c),start:it.createElement(jx,{src:c.logo,size:30}),title:it.createElement(Rf,{variant:"title",size:"medium"},c.displayName),id:c.chainId}))),"renderList");return it.createElement(it.Fragment,null,a&&it.createElement(it.Fragment,null,it.createElement(Rf,{variant:"label",size:"large"},Il.t("Select Blockchain")),it.createElement(Kx,{size:4})),it.createElement(Yf,null,p==="loading"&&it.createElement(Jf,null),p==="success"&&u()))}i(Al,"BlockchainList");function Bi(t){let{type:e}=t,o=Ye(),[n,r]=og(""),[a,s]=og("ALL"),l=z.use.setToBlockchain(),p=z.use.setFromBlockchain(),{fetchStatus:u}=y(),c=tw(),m=y().blockchains({type:e}),g=Rx(m),d=!t.hideCategory&&g!==1;return Ut.createElement(ne,{header:{title:eg.t("Select Blockchain")}},Ut.createElement(ie,{view:!0},d&&Ut.createElement(Ut.Fragment,null,Ut.createElement(ew,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),Ut.createElement(tg,{size:24})),Ut.createElement(Ct,{value:n,autoFocus:!0,placeholder:eg.t("Search Blockchain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Ut.createElement(tg,{size:16}),Ut.createElement(Al,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?c(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?p(f):l(f),o())}})))}i(Bi,"SelectBlockchainPage");import{i18n as Pi}from"@lingui/core";import{Divider as lg}from"@rango-dev/ui";import bo,{useState as pw}from"react";import{useNavigate as cw}from"react-router-dom";import{i18n as Ml}from"@lingui/core";import{BlockchainsChip as Li,Divider as ag,Image as sg,Skeleton as aw,Tooltip as sw,Typography as Bl}from"@rango-dev/ui";import Pe from"react";import{useEffect as rw}from"react";var ng=["ETH","COSMOS","OSMOSIS"];function Nl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(ow),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(nw(s)),r=n.splice(a)}return{list:n,more:r}}i(Nl,"prepare");function ow(t,e){let o=ng,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(ow,"sortByMostUsedBlockchains");function nw(t){return i(function(o,n){let r=t.findIndex(p=>p===o.name),a=t.findIndex(p=>p===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(nw,"generateSortByPreferredBlockchainsFor");function rg(t,e){return!!e.list.find(o=>o.name===t)}i(rg,"isInVisibleList");function Wl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();rw(()=>{if(e?.selected){let a=Nl(t,o,e);rg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Nl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Wl,"usePrepareBlockchainList");import{styled as iw}from"@rango-dev/ui";var ig=iw("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var lw=12;function Ll(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Wl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=z.use.resetToBlockchain(),u=z.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,g=!m&&c;return Pe.createElement(Pe.Fragment,null,Pe.createElement(ag,{size:12}),Pe.createElement(Bl,{variant:"label",size:"large"},Ml.t("Select Blockchain")),Pe.createElement(ag,{size:12}),Pe.createElement(ig,null,l==="loading"&&Array.from(Array(lw),d=>Pe.createElement(aw,{key:d,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Li,{selected:!n,onClick:()=>{o==="from"?u():p()}},Pe.createElement(Bl,{variant:"body",size:"xsmall",color:"secondary500"},Ml.t("All"))),s.list.map(d=>Pe.createElement(sw,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:A()},Pe.createElement(Li,{key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},Pe.createElement(sg,{src:d.logo,size:30})))),m?Pe.createElement(Li,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(sg,{src:s.more[0].logo,size:30})):null,g?Pe.createElement(Li,{onClick:a,key:"more-blockchains"},Pe.createElement(Bl,{variant:"body",size:"xsmall",color:"secondary500"},Ml._("More +{count}",{count:s.more.length}))):null)))}i(Ll,"BlockchainsSection");function Pl(t){let{type:e}=t,o=cw(),n=Ye(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=z(),c=Z.use.getBalanceFor(),[m,g]=pw(""),f=(e==="source"?r:a)?.name??"",h=y().blockchains({type:e}),k=y().tokens({type:e,blockchain:f,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),C=i(v=>{e==="source"?s({token:v,meta:{blockchains:h,tokens:k}}):l({token:v,meta:{blockchains:h,tokens:k}})},"updateToken"),T={source:Pi.t("Source"),destination:Pi.t("Destination")};return bo.createElement(ne,{header:{title:Pi.t("Swap {type}",{type:T[e]})}},bo.createElement(ie,null,bo.createElement(Ll,{blockchains:h,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(D.blockchains),onChange:v=>{S(v)}}),bo.createElement(lg,{size:24}),bo.createElement(Ct,{value:m,autoFocus:!0,placeholder:Pi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>g(""),onChange:v=>g(v.target.value)}),bo.createElement(lg,{size:16}),bo.createElement(Dn,{list:k,selectedBlockchain:f,searchedFor:m,type:e,onChange:v=>{C(v);let x=h.find(N=>v.blockchain===N.name);x&&S(x),n()}})))}i(Pl,"SelectSwapItemsPage");import{i18n as $l}from"@lingui/core";import{Alert as _w,Button as $w,styled as Fw}from"@rango-dev/ui";import Eo from"react";import{useInRouterContext as Ow,useSearchParams as Uw}from"react-router-dom";import{i18n as fg}from"@lingui/core";import{Divider as gg,InfoIcon as fw,SlippageIcon as gw,TextField as hw,Tooltip as yw,Typography as hg}from"@rango-dev/ui";import at from"react";import{Chip as uw,styled as Gn,TextField as mw}from"@rango-dev/ui";var pg=Gn("div",{paddingTop:"$5",padding:"$10 $5"}),cg=Gn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${mw}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),ug=Gn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Di=Gn("div",{maxWidth:"280px",padding:"$10"}),mg=Gn(uw,{width:"61px",flexShrink:0});import{i18n as Dl}from"@lingui/core";import{Typography as dw}from"@rango-dev/ui";import Vn from"react";function dg(){return Vn.createElement(Di,null,Vn.createElement(dw,{variant:"label",size:"medium",color:"neutral700"},Dl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage"),Vn.createElement("br",null),Vn.createElement("br",null),Vn.createElement("b",null,Dl.t("Warning")),":",Dl.t("This setting is applied per step (e.g. 1Inch, Thorchain, etc) which means only the step will be reverted, not the whole transaction.")))}i(dg,"SlippageTooltipContent");function _l(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return at.createElement(pg,null,at.createElement(ug,null,at.createElement(gw,{size:16,color:"gray"}),at.createElement(gg,{direction:"horizontal",size:4}),at.createElement(hg,{variant:"title",size:"xmedium"},fg.t("Slippage tolerance per swap")),at.createElement(gg,{direction:"horizontal",size:4}),at.createElement(yw,{container:A(),side:"top",sideOffset:4,content:at.createElement(dg,null)},at.createElement(fw,{color:"gray"}))),at.createElement(cg,null,Yp.map((r,a)=>{let s=`slippage-${a}`;return at.createElement(mg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),at.createElement(hw,{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>=ec&&s<=Rp?n(s):n(null)},suffix:o&&at.createElement(hg,{variant:"body",size:"small"},"%"),placeholder:fg.t("Custom")})))}i(_l,"Slippage");import{i18n as Tt}from"@lingui/core";import{AutoThemeIcon as yg,BridgesIcon as Sw,ChevronRightIcon as _i,DarkModeIcon as Sg,Divider as Kn,ExchangeIcon as Cw,InfinityIcon as kw,InfoIcon as Tw,LanguageIcon as vw,LightModeIcon as Cg,List as xw,ListItem as ww,ListItemButton as bw,Skeleton as Ew,styled as Iw,Switch as Aw,Tabs as Nw,TargetIcon as Ww,Tooltip as Mw,Typography as Re}from"@rango-dev/ui";import P from"react";import{useNavigate as Bw}from"react-router-dom";var Lw=Iw("div",{width:"202px",height:"$40"}),Pw=[{id:"light",icon:P.createElement(Cg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},Tt.t("Light"))},{id:"dark",icon:P.createElement(Sg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},Tt.t("Dark"))},{id:"auto",icon:P.createElement(yg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},Tt.t("Auto"))}],Dw=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return P.createElement(yg,{...e});case"dark":return P.createElement(Sg,{...e});default:return P.createElement(Cg,{...e})}},"getThemeIcon");function kg(){let t=Bw(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=to(),s=a.find(L=>L.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),g=je("theme",c),d=je("liquiditySource",c),f=je("language",c),h=je("customTokens",c),k=y().infiniteApprove,S=y().toggleInfiniteApprove,C=hr(p,u),T=C.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),v=T.length,x=T.filter(L=>L.selected).length,N=C.filter(L=>L.type==="DEX"),M=N.length,w=N.filter(L=>L.selected).length,E=i((L,V)=>{switch(l){case"loading":return P.createElement(Ew,{variant:"text",size:"medium",width:50});case"failed":return P.createElement(Re,{variant:"body",size:"medium",color:"$error500"},Tt.t("Loading failed"));default:return P.createElement(Re,{variant:"body",size:"medium"},`${L} / ${V}`)}},"handleSwapperEndItem"),b={id:"bridge-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Bridges")),end:P.createElement(P.Fragment,null,E(x,v),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.bridges),start:P.createElement(Sw,{color:"gray",size:16})},W={id:"exchange-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Exchanges")),end:P.createElement(P.Fragment,null,E(w,M),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Cw,{color:"gray",size:16}),onClick:()=>t(D.exchanges)},$={id:"custom-tokens-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Custom Tokens")),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},`${m.length}`),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Ww,{color:"gray",size:16}),onClick:()=>t(D.customTokens)},I={id:"language-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Language")),start:P.createElement(vw,{color:"gray",size:16}),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},s),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.languages)},R={id:"infinite-approval-item",title:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Infinite approval")),P.createElement(Kn,{direction:"horizontal",size:4}),P.createElement(Mw,{side:"top",sideOffset:4,container:A(),content:P.createElement(Di,null,P.createElement(Re,{variant:"label",size:"medium",color:"neutral700"},Tt.t("Enabling the 'Infinite approval' mode grants unrestricted access to smart contracts of DEXes/Bridges, allowing them to utilize the approved token amount without limitations.")))},P.createElement(Tw,{color:"gray"}))),start:P.createElement(kw,{color:"gray",size:16}),end:P.createElement(Aw,{checked:k}),onClick:S},ee={id:"theme-item",type:P.createElement(ww,null),title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Theme")),end:P.createElement(Lw,null,P.createElement(Nw,{container:A(),items:Pw,value:n,onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:Dw(n)},oe=d?[]:[b,W];return h||oe.push($),f||oe.push(I),oe.push(R),!e?.singleTheme&&!g&&oe.push(ee),P.createElement(xw,{type:P.createElement(bw,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:oe})}i(kg,"SettingsLists");var zw=Fw("div",{paddingLeft:"$8"});function Tg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Uw(),r=Ow(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Eo.createElement(ne,{header:{title:$l.t("Settings")}},Eo.createElement(ie,null,o&&Eo.createElement(_w,{type:"info",variant:"alarm",title:$l.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Eo.createElement(zw,null,Eo.createElement($w,{type:"secondary",size:"small",onClick:a},$l.t("Reset")))}),Eo.createElement(_l,null),Eo.createElement(kg,null)))}i(Tg,"SettingsPage");import{i18n as Ab}from"@lingui/core";import{cancelSwap as Nb}from"@rango-dev/queue-manager-rango-preset";import{useManager as Wb}from"@rango-dev/queue-manager-react";import{Alert as Mb}from"@rango-dev/ui";import ep from"react";import{useParams as Bb}from"react-router-dom";import{i18n as st}from"@lingui/core";import{getCurrentBlockchainOfOrNull as pb,getCurrentStep as cb,getRelatedWalletOrNull as ub}from"@rango-dev/queue-manager-rango-preset";import{Button as Jg,CopyIcon as mb,Divider as db,DoneIcon as fb,IconButton as gb,QuoteCost as hb,RangoExplorerIcon as yb,StepDetails as Sb,Tooltip as Rg,Typography as Io,useCopyToClipboard as Cb}from"@rango-dev/ui";import{useWallets as kb}from"@rango-dev/wallets-react";import eh from"bignumber.js";import{PendingSwapNetworkStatus as Gi}from"rango-types";import K,{useEffect as th,useRef as Tb,useState as oh}from"react";import{useNavigate as vb}from"react-router-dom";import{i18n as oo}from"@lingui/core";var Qw=[oo.t("Sunday"),oo.t("Monday"),oo.t("Tuesday"),oo.t("Wednesday"),oo.t("Thursday"),oo.t("Friday"),oo.t("Saturday")];function vg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?oo.t("Today"):`${Qw[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(vg,"timeSince");function xg(t){return t.finishTime?vg(parseInt(t.finishTime)):vg(parseInt(t.creationTime))}i(xg,"getSwapDate");import{PendingSwapNetworkStatus as Oi}from"rango-types";import Ui from"react";import{i18n as $i}from"@lingui/core";import{Button as wg,Divider as Fl,MessageBox as qw}from"@rango-dev/ui";import no from"react";var bg=i(({onCancel:t,onClose:e})=>no.createElement(no.Fragment,null,no.createElement(Fl,{size:20}),no.createElement(qw,{type:"error",title:$i.t("Cancel Swap"),description:$i.t("Are you sure you want to cancel this swap?")}),no.createElement(Fl,{size:32}),no.createElement(wg,{variant:"contained",type:"primary",size:"large",onClick:t},$i.t("Yes, Cancel it")),no.createElement(Fl,{size:12}),no.createElement(wg,{variant:"outlined",type:"primary",size:"large",onClick:e},$i.t("No, Continue"))),"CancelContent");import{i18n as Fi}from"@lingui/core";import{Button as Eg,Divider as Ol,MessageBox as Hw,Typography as Gw}from"@rango-dev/ui";import zt from"react";var Ig=i(({onDelete:t,onClose:e})=>zt.createElement(zt.Fragment,null,zt.createElement(Ol,{size:20}),zt.createElement(Hw,{type:"error",title:Fi.t("Delete Transaction"),description:Fi.t("Are you sure you want to delete this swap?")}),zt.createElement(Ol,{size:32}),zt.createElement(Eg,{variant:"contained",type:"primary",size:"large",onClick:t},Fi.t("Yes, Delete it")),zt.createElement(Ol,{size:12}),zt.createElement(Eg,{variant:"outlined",type:"primary",size:"large",onClick:e},zt.createElement(Gw,{variant:"title",size:"medium",color:"primary"},Fi.t("No, Cancel")))),"DeleteContent");import{i18n as Ul}from"@lingui/core";import{PendingSwapNetworkStatus as zl}from"rango-types";var Ql={[zl.WaitingForNetworkChange]:{type:"loading",title:Ul.t("Change Network")},[zl.WaitingForConnectingWallet]:{type:"warning",title:Ul.t("Connect Wallet")},[zl.NetworkChanged]:{type:"success",title:Ul.t("Network Changed")}};import{warn as Vw}from"@rango-dev/logging-core";import{MessageBox as Kw,Wallet as jw}from"@rango-dev/ui";import{useWallets as Xw}from"@rango-dev/wallets-react";import Ro,{useState as Yw}from"react";import{styled as Ag}from"@rango-dev/ui";var Ng=Ag("div",{display:"flex",justifyContent:"center"}),F2=Ag("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Wg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=Yw(),{getWalletInfo:u,state:c}=Xw(),m=n?.walletType,g=m?pn(c(m)):null,d=m?u(m):null,f=a&&!!m&&!!g&&!!d,{list:h}=ft(),k=i(()=>{if(m){let S=h.find(C=>C.type===m);S?p(S):Vw(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return Ro.createElement(Ro.Fragment,null,Ro.createElement(Kw,{type:e,title:o,description:r}),f&&Ro.createElement(Ng,null,Ro.createElement(jw,{container:A(),title:d.name,image:d.img,type:m,state:g,link:d.installLink,disabled:s,onClick:k})),Ro.createElement(fo,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function ql(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===Oi.WaitingForNetworkChange||e===Oi.WaitingForConnectingWallet||e===Oi.NetworkChanged;return Ui.createElement(J,{open:!!e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},p&&Ui.createElement(Wg,{type:Ql[e].type,title:Ql[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Oi.WaitingForNetworkChange}),e==="delete"&&Ui.createElement(Ig,{onClose:o,onDelete:n}),e==="cancel"&&Ui.createElement(bg,{onClose:o,onCancel:r}))}i(ql,"SwapDetailsModal");import{i18n as jn}from"@lingui/core";import{Button as Hl,Divider as zi,MessageBox as Mg,TokenAmount as Zw,Typography as Gl}from"@rango-dev/ui";import Oe from"react";import{useNavigate as Jw}from"react-router-dom";function Vl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:g}=t,d=Jw();return Oe.createElement(J,{open:e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},n==="success"?Oe.createElement(Mg,{type:"success",title:jn.t("Swap Successful")},Oe.createElement(Zw,{direction:"vertical",tooltipContainer:A(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),Oe.createElement(zi,{size:12}),Oe.createElement(Gl,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Oe.createElement(Mg,{type:"error",title:jn.t("Transaction Failed"),description:m}),Oe.createElement(zi,{size:32}),n==="success"&&Oe.createElement(Hl,{variant:"contained",type:"primary",size:"large",onClick:()=>{d("../../")}},Oe.createElement(Gl,{variant:"title",size:"medium",color:"neutral100"},jn.t("Done"))),Oe.createElement(zi,{size:12}),g&&Oe.createElement(Oe.Fragment,null,Oe.createElement(Hl,{variant:"contained",type:"primary",size:"large",onClick:()=>window.open(g,"_blank")},jn.t("Diagnosis")),Oe.createElement(zi,{size:12})),Oe.createElement(Hl,{variant:"outlined",type:"primary",size:"large",onClick:o},Oe.createElement(Gl,{variant:"title",size:"medium",color:"primary"},jn.t("See Details"))))}i(Vl,"SwapDetailsCompleteModal");import lb from"react";import{i18n as rb}from"@lingui/core";import{Alert as jg,IconButton as ib,LinkIcon as ab}from"@rango-dev/ui";import ro,{Fragment as sb}from"react";import{Alert as eb,ChevronDownIcon as tb,IconButton as ob}from"@rango-dev/ui";import tn,{useState as nb}from"react";import{css as Xn,darkTheme as Bg,styled as Qt,Typography as Rw}from"@rango-dev/ui";var Lg=Qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Qi=Qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Bg} &`]:{color:"$secondary500"}}}}}),Pg=Qt(Sn,{padding:"$0 $20 $20 $20"}),T5=Qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Dg=Qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),v5=Qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),en=Xn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Bg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),_g=Xn({padding:"$5 0"}),qi=Xn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),$g=Xn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Fg=Xn({width:"100%",padding:"0 $20 $10"}),Og=Qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Ug=Qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Hi=Qt(Rw,{wordBreak:"break-word"});import{styled as Kl}from"@rango-dev/ui";var zg=Kl("div",{display:"flex",flexDirection:"column",gap:"$10"}),Qg=Kl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),qg=Kl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Hg(t){let{message:e}=t,[o,n]=nb(!1);return tn.createElement(eb,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&tn.createElement(ob,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},tn.createElement(Qg,{rotated:o},tn.createElement(tb,{size:12,color:"gray"}))),footer:tn.createElement(qg,{open:o},tn.createElement(Hi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Hg,"FailedAlert");import{i18n as Gg}from"@lingui/core";import{Alert as jl,Button as Vg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Xl}from"rango-types";import Yn from"react";function Kg(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(Vg,{size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Gg.t("Change"))}):r===Xl.WaitingForConnectingWallet?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(Vg,{size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForConnectingWallet)}},Gg.t("Connect"))}):Yn.createElement(jl,{type:"warning",title:n.shortMessage})}i(Kg,"WarningAlert");function Yl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=gn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return ro.createElement(zg,null,a.explorerUrl?.map((m,g,d)=>{let f=g+m.url,h=g===d.length-1,k=(h&&u||p)&&!c,S=h&&a.status==="failed";return ro.createElement(sb,{key:f},ro.createElement(jg,{type:h&&(k&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:rb.t("View transaction"),action:m.url&&ro.createElement(ib,{variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},ro.createElement(ab,{size:12}))}))}),c&&ro.createElement(jg,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&ro.createElement(Kg,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&ro.createElement(Hg,{message:r}))}i(Yl,"SwapDetailsAlerts");var Xg=2e3;var Yg=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:pt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:pt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:on(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(p=>({from:{chain:{displayName:pt(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:pt(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:on(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:lb.createElement(Yl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function Zg(t){if(gn(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(Zg,"getStepState");function Zl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=kb(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=z.use.retry(),g=se.use.isActiveTab(),d=vb(),[f,h]=Cb(Xg),k=Tb(null),[S,C]=oh(null),[T,v]=oh(null),x=i(()=>{r(),C(null)},"onCancel"),N=we.use.getNotifications(),M=we.use.removeNotification(),w=N(),E=cb(e),b=E?.networkStatus;th(()=>{w.find(he=>he.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):T&&v(null))},[e.status,e.requestId]),th(()=>{L?C(Gi.WaitingForNetworkChange):b===Gi.WaitingForConnectingWallet||b===Gi.NetworkChanged?C(b):C(null)},[b]);let W=jc(e),$=E?pb(e,E):null,I=E?ub(e,E):null,R=xg(e),ee=Xc(e),oe=i(de=>!!l(de)?.mobileWallet,"isMobileWallet"),L=b===Gi.WaitingForNetworkChange&&!!$&&!!I?.walletType&&(oe(I.walletType)||a(I.walletType,$)),V=L?s.bind(null,I.walletType,$):void 0,le=Kc(e,E),Y=Yg({swap:e,switchNetwork:V,showNetworkModal:b,setNetworkModal:C,message:le,blockchains:p,swappers:u}),ae=Y.length,[ge,ve]=[e.steps[0],e.steps[ae-1]],U=ve.outputAmount||ve.expectedOutputAmountHumanReadable,Ke=e.steps.reduce((de,he)=>de+parseFloat(he.feeInUsd||""),0),xt=e.steps.find(de=>de.diagnosisUrl)?.diagnosisUrl,lt=B(parseFloat(U||"0")*(ve.toUsdPrice||0),4,4),wt=B(parseFloat(e.inputAmount)*(ge.fromUsdPrice||0),4,4),_=U?new eh(U).multipliedBy(ve.toUsdPrice||0).toString():"",Q=new eh(e.inputAmount).multipliedBy(ge.fromUsdPrice||0).toString(),G=ut(wt,lt),pe=le.detailedMessage.content||le.shortMessage,ce=e.status==="success"?st.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:B(U,6,6),token:Y[ae-1].to.token.displayName,conciseAddress:dr(e.wallets[Y[ae-1].to.chain.displayName]?.address||""),chain:Y[ae-1].to.chain.displayName}}):K.createElement(Ug,null,K.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},pe?"":st.t("Transaction was not sent."),W?`${st.t({id:"{amount} {symbol} on {blockchain} remain in your wallet",values:{amount:W.outputAmount,symbol:W.symbol,blockchain:W.blockchain}})}`:""),pe&&K.createElement(Hi,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",pe));return K.createElement(ne,{header:{title:st.t("Swap Details"),onCancel:e.status==="running"?()=>C("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(Jg,{variant:"ghost",type:"error",size:"xsmall",onClick:()=>C("delete")},K.createElement(Io,{size:"medium",variant:"label",color:"error"},st.t("Delete"))))},footer:ee&&!T&&K.createElement(Jg,{fullWidth:!0,variant:"contained",type:"primary",size:"large",onClick:()=>{let de=Lr(e,p,c);m(de),setTimeout(()=>{d("../../")},0)}},st.t("Try again"))},K.createElement(ie,{compact:!0,view:!0},K.createElement(Qi,null,K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${st.t("Request ID")}:`),K.createElement("div",{className:qi()},K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(Rg,{container:A(),content:f?st.t("Copied To Clipboard"):st.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(gb,{variant:"ghost",onClick:h.bind(null,o||"")},f?K.createElement(fb,{size:16,color:"secondary"}):K.createElement(mb,{size:16,color:"gray"}))),K.createElement(Og,{target:"_blank",href:`${gp}/swap/${o}`},K.createElement(Rg,{container:A(),content:st.t("View on Rango Explorer"),side:"bottom"},K.createElement(yb,{size:20}))))),K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?st.t("Finished at"):st.t("Created at")),K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},R))),K.createElement("div",{className:$g()},K.createElement(hb,{fee:B(String(Ke),2,2),time:sn(ar(e.steps)),steps:ae}),K.createElement(En,{from:{price:{value:B(e.inputAmount,6,6),usdValue:wt,realUsdValue:Q,realValue:e.inputAmount},token:{displayName:Y[0].from.token.displayName,image:Y[0].from.token.image},chain:{image:Y[0].from.chain.image,displayName:Y[0].from.chain.displayName}},to:{price:{value:B(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||""},token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image,displayName:Y[ae-1].to.chain.displayName}},percentageChange:B(G,2,2),warningLevel:Lt(G??0)})),K.createElement("div",{className:Fg()},K.createElement(Io,{variant:"title",size:"small"},st.t("Swaps steps"))),K.createElement(db,{size:8}),K.createElement(Pg,{ref:k},Y.map((de,he)=>{let Rn=he,io=Zg(e.steps[he]),ea=io==="error"||io==="in-progress"||io==="warning"||io==="completed"&&he===Y.length-1;return K.createElement(Sb,{key:Rn,step:de,type:"swap-progress",ref:k,state:io,hasSeparator:he!==0,tabIndex:Rn,isFocused:ea,tooltipContainer:A()})}))),K.createElement(ql,{state:S,onClose:()=>C(null),onCancel:x,onDelete:n,message:le.detailedMessage.content,currentStepWallet:I,walletButtonDisabled:!g}),K.createElement(Vl,{open:!!T,diagnosisUrl:xt,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||"",percentageChange:B(G,2,2),token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image},description:ce}))}i(Zl,"SwapDetails");import{i18n as Ki}from"@lingui/core";import{Divider as ih,NotFound as Ib,Skeleton as Jn,Typography as ji}from"@rango-dev/ui";import ke from"react";import{i18n as xb}from"@lingui/core";import{Divider as wb,Skeleton as bb,Typography as Eb}from"@rango-dev/ui";import Te from"react";import{css as vt,styled as Jl}from"@rango-dev/ui";var nh=Jl("div",{width:"100%",height:"100%",padding:"$10 $20"}),Zn=Jl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Vi=Jl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),P4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),D4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),_4=vt({paddingTop:"$15",display:"flex"}),$4=vt({padding:"$15 $0"}),F4=vt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),O4=vt({paddingBottom:"$10"}),U4=vt({display:"flex",justifyContent:"start",alignItems:"center"}),z4=vt({paddingTop:"$5",display:"flex",alignItems:"center"}),Q4=vt({display:"flex",alignItems:"center"}),q4=vt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),rh=vt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Rl(){return Te.createElement(nh,null,Te.createElement(Nn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(Eb,{variant:"title",size:"small"},xb.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1}),Te.createElement("div",{className:rh()},Te.createElement(wb,{direction:"horizontal",size:20}),Te.createElement(bb,{height:22,variant:"rectangular"}))),Te.createElement(Vi,null),Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1})),Te.createElement(Vi,null),Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1})),Te.createElement(Vi,null),Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1}))))}i(Rl,"LoadingSwapDetails");function ah(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(ne,{header:{title:Ki.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Lg,null,ke.createElement(Qi,null,ke.createElement("div",{className:en()},ke.createElement(ji,{variant:"label",size:"large",color:"neutral700"},`${Ki.t("Request ID")}:`),ke.createElement("div",{className:qi()},ke.createElement(ji,{variant:"label",size:"small",color:"neutral700"},ke.createElement(Jn,{width:60,height:10,variant:"rounded"})),ke.createElement(ih,{direction:"horizontal",size:4}),ke.createElement(Jn,{width:16,height:16,variant:"rectangular"}),ke.createElement(ih,{direction:"horizontal",size:4}),ke.createElement(Jn,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:en()},ke.createElement(ji,{className:_g(),variant:"label",size:"large",color:"neutral700"},ke.createElement(Jn,{width:60,height:10,variant:"rounded"})),ke.createElement(ji,{variant:"label",size:"small",color:"neutral700"},ke.createElement(Jn,{width:60,height:10,variant:"rounded"})))),ke.createElement(Rl,null)),!o&&ke.createElement(Dg,null,ke.createElement(Ib,{title:Ki.t("Not found"),description:Ki.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(ah,"SwapDetailsPlaceholder");function sh(){let{manager:t,state:e}=Wb(),o=!e.loadedFromPersistor,n=mt(t),{requestId:r}=Bb(),a=Ye(),{fetchStatus:s}=y();if(!r)return ep.createElement(Mb,{containerStyles:{margin:"20px"},type:"error",title:Ab.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:g})=>g.requestId===r):void 0,u=i(()=>{if(p?.id){let g=t?.get(p.id);g&&Nb(g)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(g){console.log(g)}},"onDelete"),m=p?.swap;return!m||l?ep.createElement(ah,{requestId:r,showSkeleton:l}):ep.createElement(Zl,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(sh,"SwapDetailsPage");import{i18n as lh}from"@lingui/core";import{Divider as Lb,getCategoriesCount as Pb,SelectableCategoryList as Db,styled as ch,Typography as _b,Wallet as $b}from"@rango-dev/ui";import Bt,{useState as ph}from"react";var Fb=ch("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),Ob=ch(ie,{textAlign:"center"});function uh(){let{fetchStatus:t}=y(),[e,o]=ph("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=ph(),l=se.use.isActiveTab(),{list:p}=ft(),u=Op(p,n),m=Pb(u)!==1,g=Up(p,e),d=i(f=>{Ep(p,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(ne,{header:{title:lh.t("Connect Wallets")}},Bt.createElement(Ob,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(Db,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(Lb,{size:24})),Bt.createElement(_b,{variant:"title",size:"xmedium",align:"center"},lh.t("Choose a wallet to connect.")),Bt.createElement(Fb,null,g.map((f,h)=>{let k=`wallet-${h}-${f.type}`;return Bt.createElement($b,{key:k,...f,container:A(),onClick:()=>d(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(fo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(uh,"WalletsPage");function mh(){return iu(),za(),Ub([{path:D.home,element:De.createElement(Qf,null)},{path:D.routes,element:De.createElement(Kf,null)},{path:D.fromSwap,children:[{index:!0,element:De.createElement(Pl,{type:"source"})},{path:D.blockchains,element:De.createElement(Bi,{type:"source"})}]},{path:D.toSwap,children:[{index:!0,element:De.createElement(Pl,{type:"destination"})},{path:D.blockchains,element:De.createElement(Bi,{type:"destination"})}]},{path:D.settings,children:[{index:!0,element:De.createElement(Tg,null)},{path:D.languages,element:De.createElement(Hf,null)},{path:D.exchanges,element:De.createElement(El,{sourceType:"Exchanges"})},{path:D.bridges,element:De.createElement(El,{sourceType:"Bridges"})},{path:D.customTokens,children:[{index:!0,element:De.createElement(Rd,null)},{path:D.addCustomTokens,children:[{index:!0,element:De.createElement(Uu,null)},{path:D.blockchains,element:De.createElement(Bi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:D.swaps,children:[{index:!0,element:De.createElement(kf,null)},{path:D.swapDetails,element:De.createElement(sh,null)}]},{path:D.wallets,element:De.createElement(uh,null)},{path:D.confirmSwap,element:De.createElement($d,null)}])}i(mh,"AppRoutes");import{useQueueManager as Xb}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as Yb}from"@rango-dev/wallets-shared";import{isEvmBlockchain as Zb}from"rango-sdk";import{useContext as Jb,useEffect as Ch,useState as kh}from"react";import{globalCss as zb}from"@rango-dev/ui";var dh=i(()=>zb({"@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 fh(){let{setWatermark:t}=se();return{fetchApiConfig:i(async()=>{let o=await fetch(`${ct("BASE_URL")}/meta/dapp/config?apiKey=${ct("API_KEY")}`);if(!o.ok)throw new Error(`Request failed with status: ${o.status} `);let n=await o.json();t(n.config.watermark)},"fetchApiConfig")}}i(fh,"useFetchApiConfig");import{useWallets as Qb}from"@rango-dev/wallets-react";import{useEffect as qb,useRef as Hb}from"react";function gh(){let{connect:t,state:e}=Qb(),o=Hb({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);qb(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(gh,"useForceAutoConnect");import{isApprovalTX as Gb,RouteEventType as hh,StepEventType as yh,StepExecutionEventStatus as Vb,WidgetEvents as Xi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Sh}from"react";function tp(){let t=Z.use.connectedWallets(),e=Z.use.getWalletsDetails(),o=we.use.setNotification(),{findToken:n}=y();Sh(()=>{let r=i(a=>{let{event:s,step:l,route:p}=a;if(s.type===yh.TX_EXECUTION&&s.status===Vb.TX_SENT&&!Gb(l)||s.type===yh.SUCCEEDED){let c=t.find(g=>g.chain===l?.fromBlockchain),m=l?.fromBlockchain!==l?.toBlockchain&&t.find(g=>g.chain===l?.toBlockchain);c&&e([c],n),m&&e([m],n)}o(s,p)},"handleStepEvent");return ye.on(Xi.StepEvent,r),()=>ye.off(Xi.StepEvent,r)},[ye,t]),Sh(()=>{let r=i(a=>{let{event:s,route:l}=a;(s.type===hh.FAILED||s.type===hh.SUCCEEDED)&&o(s,l)},"handleRouteEvent");return ye.on(Xi.RouteEvent,r),()=>ye.off(Xi.RouteEvent,r)},[ye])}i(tp,"useSubscribeToWidgetEvents");import{useManager as Kb}from"@rango-dev/queue-manager-react";import{useEffect as jb}from"react";function op(){let{isSynced:t,syncNotifications:e}=we(),{manager:o,state:n}=Kb();jb(()=>{we.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(mt(o))},[we.persist.hasHydrated(),n.loadedFromPersistor,t])}i(op,"useSyncNotifications");function np(){gh(),dh(),tp(),op();let t=y().blockchains(),{canSwitchNetworkTo:e}=Zr(),[o,n]=kh(""),[r,a]=kh(),s=Jb(Er),l=t.filter(Zb),{fetchApiConfig:p}=fh();Ch(()=>()=>ru(),[]),Xb({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Ch(()=>(po.init(),we.persist.hasHydrated()||we.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===Yb(o)?.[0]&&n("")}),p().catch(console.log),po.destroy),[])}i(np,"useBootstrap");import{styled as Rb}from"@rango-dev/ui";var Th=Rb("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Yi(){np();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=to();return rp.createElement(eE,{language:o},rp.createElement(Th,{id:"swap-container",className:e()},rp.createElement(mh,null)))}i(Yi,"Main");import{setSolanaSignerConfig as kE}from"@rango-dev/signer-solana";import ap,{useEffect as Ih,useMemo as TE}from"react";import{useState as tE}from"react";var oE=i(()=>{let[t,e]=tE(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=bp(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),vh=oE;import{checkWaitingForNetworkChange as nE,makeQueueDefinition as rE}from"@rango-dev/queue-manager-rango-preset";import{Provider as iE}from"@rango-dev/queue-manager-react";import{useWallets as aE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as sE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as lE}from"rango-types";import pE,{useMemo as cE}from"react";function uE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=aE(),l=cE(()=>rE({API_KEY:t.apiKey||ct("API_KEY"),BASE_URL:ct("BASE_URL"),emitter:{emit:ye.emit}}),[t.apiKey]),p=y().blockchains(),c={blockchains:Z.use.connectedWallets().map(T=>({accounts:[T],name:T.chain}))},m=i(async(T,v)=>{if(a(T,v))return r(T,v)},"switchNetwork"),g=i(T=>!!s(T).mobileWallet,"isMobileWallet"),d=p.filter(T=>T.enabled).reduce((T,v)=>(T[v.name]=v,T),{}),f=p.filter(lE),h=i(T=>{let{supportedChains:v}=s(T);return pr(v)},"getSupportedChainNames"),k=e(),S={meta:{blockchains:d,evmBasedChains:f,evmNetworkChainInfo:sE(f),getSupportedChainNames:h},getSigners:o,wallets:c,providers:k,switchNetwork:m,canSwitchNetworkTo:a,connect:r,state:n,isMobileWallet:g},C=se.use.isActiveTab();return pE.createElement(iE,{queuesDefs:[l],context:S,onPersistedDataLoaded:T=>{nE(T)},isPaused:!C},t.children)}i(uE,"QueueManager");var xh=uE;import{useManager as hE}from"@rango-dev/queue-manager-react";import yE,{createContext as SE,useContext as CE}from"react";function wh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=z();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:g,toToken:d,requestAmount:f}=u,h={blockchains:e,tokens:o};if(c!==void 0){let k=e.find(S=>S.name===c)??null;n(k)}if(m!==void 0){let k=m?t(m)??null:null;r({meta:h,token:k})}if(g!==void 0){let k=e.find(S=>S.name===g)??null;a(k)}if(d!==void 0){let k=d?t(d)??null:null;s({meta:h,token:k})}f!==void 0&&l(f)},"updateQuoteInputs")}i(wh,"useUpdateQuoteInputs");import{cancelSwap as mE,getCurrentBlockchainOfOrNull as dE,getCurrentStep as fE,getRelatedWalletOrNull as gE}from"@rango-dev/queue-manager-rango-preset";var Zi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return mt(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=Lr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&mE(o)}getCurrentStepInfo(e){let o=fE(e);return{step:o,wallet:o?gE(e,o):null,network:o?dE(e,o):null}}};var bh=SE(void 0);function ip(t){let{manager:e}=hE(),o=se.use.isActiveTab(),n=z.use.retry(),{findToken:r}=y(),a=new Zi(e,{retrySwap:n,findToken:r}),s=Z.use.connectedWallets(),l=Z.use.loading(),p=Lp(s),u=Z.use.getWalletsDetails(),c=y().blockchains(),m=y().tokens(),g=y().swappers(),d=y().fetchStatus,f=to().resetLanguage,h=we().getNotifications(),k=we().clearNotifications,S=wh(),{fromBlockchain:C,toBlockchain:T,fromToken:v,toToken:x,inputAmount:N}=z(),M={isActiveTab:o,setCurrentTabAsActive:po.forceClaim,history:a,wallets:{isLoading:l,details:s,totalBalance:p,refetch:w=>u(w,r)},meta:{blockchains:c,tokens:m,swappers:g,loadingStatus:d,findToken:r},resetLanguage:f,notifications:{list:h,clearAll:k},quote:{quoteInputs:{fromBlockchain:C?.name??null,fromToken:v?{symbol:v.symbol,blockchain:v.blockchain,address:v.address}:null,toBlockchain:T?.name??null,toToken:x?{symbol:x.symbol,blockchain:x.blockchain,address:x.address}:null,requestAmount:N},updateQuoteInputs:S}};return yE.createElement(bh.Provider,{value:M},t.children)}i(ip,"WidgetInfo");function Eh(){let t=CE(bh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Eh,"useWidget");function Ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=vh();return Ih(()=>{n&&r(n)},[n]),TE(()=>{zp({API_KEY:o?.apiKey||nr,BASE_URL:o?.apiUrl||fp})},[o.apiKey,o.apiUrl]),Ih(()=>{t.config?.signers?.customSolanaRPC&&kE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),ap.createElement(Ir,{config:o,onUpdateState:e},ap.createElement(xh,{apiKey:o.apiKey},ap.createElement(ip,null,t.children)))}i(Ji,"WidgetProvider");function Ah(t){let e=t.config?.externalWallets;return Ri.createElement(Wc,null,e?Ri.createElement(Yi,null):Ri.createElement(Ji,{config:t.config??ra},Ri.createElement(Yi,null)))}i(Ah,"Widget");function Nh(){let{on:t,off:e}=ye;return{on:t,off:e}}i(Nh,"useWidgetEvents");var Rj={DerivationPath:mn,Namespaces:un,isOnDerivationPath:fn,isOnNamespace:dn};export{bj as EventSeverity,lo as MainEvents,Dj as Networks,Fj as PendingSwapNetworkStatus,ha as QuoteEventTypes,Ej as RouteEventType,ia as SUPPORTED_FONTS,Rj as StatefulConnect,Ij as StepEventType,Aj as StepExecutionBlockedEventStatus,Nj as StepExecutionEventStatus,$e as UI_ID,ya as UiEventTypes,Sr as WalletEventTypes,Lj as WalletEvents,_j as WalletTypes,Ah as Widget,lo as WidgetEvents,Ji as WidgetProvider,Ir as WidgetWallets,Ra as customizedThemeTokens,Mj as readAccountAddress,qt as useStatefulConnect,ft as useWalletList,Zr as useWallets,Eh as useWidget,Nh as useWidgetEvents,yr as widgetEventEmitter};
1
+ var Mh=Object.defineProperty;var i=(t,e)=>Mh(t,"name",{value:e,configurable:!0});import{EventSeverity as w3,RouteEventType as b3,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 B3}from"@rango-dev/wallets-react";import{Networks as P3,WalletTypes as D3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as $3}from"rango-types";import{Divider as lS}from"@rango-dev/ui";import uo,{useEffect as pS,useRef as cS,useState as Ec}from"react";import{WalletState as Bh}from"@rango-dev/ui";import{useWallets as Lh}from"@rango-dev/wallets-react";import{useReducer as Ph}from"react";function sp(t){return!!t.derivationPath}i(sp,"isStateOnDerivationPathStep");function lp(t){return!!t.namespace}i(lp,"isStateOnNamespace");var er={status:"init",namespace:null,derivationPath:null};function pp(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return er;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:er;default:throw new Error("Action hasn't been defined.")}}i(pp,"reducer");function qt(){let{state:t,disconnect:e,connect:o}=Lh(),[n,r]=Ph(pp,er),a=i(async(c,m,g)=>{r({type:"reset"});try{return await o(c,void 0,m),{status:"connected"}}catch(d){let f=d?.message?`Error: ${d.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:d})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Bh.DISCONNECTED){if(!c.namespaces)return await a(c.type,void 0,m);let d=c.namespaces.length>1,f=c.needsDerivationPath;return d?(r({type:"needsNamespace",payload:{providerType:c.type,providerImage:c.image,availableNamespaces:c.namespaces,singleNamespace:c.singleNamespace}}),{status:"namespace"}):f?(r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:c.namespaces[0]}}),{status:"derivation-path"}):await a(c.type,c.namespaces.map(h=>({namespace:h})),m)}return m?.disconnectIfConnected?(await u(c.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(c,m)=>{let g=c.singleNamespace,d=c.needsDerivationPath,f=m[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(g&&d)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:f}}),{status:"derivation-path"};if(!lp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let h=n.namespace.providerType,T=m.map(S=>({namespace:S}));return await a(h,T)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!sp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,d)},"handleDerivationPath"),u=i(async c=>{let m=t(c);return m.connected||m.connecting?(await e(c),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:p,getState:()=>n,resetState:c=>{r(c==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(qt,"useStatefulConnect");import{WalletState as Sa}from"@rango-dev/ui";import{useWallets as by}from"@rango-dev/wallets-react";import{detectMobileScreens as Ey,KEPLR_COMPATIBLE_WALLETS as Iy,WalletTypes as Bo}from"@rango-dev/wallets-shared";import{useCallback as Ay,useEffect as Ny}from"react";import gy,{createContext as hy,useContext as yy,useEffect as Sy,useRef as Cy}from"react";import{create as dy}from"zustand";import{persist as fy}from"zustand/middleware";var oa=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},Ao=new oa;function tr(t,e){return e.find(o=>o.name===t)?.displayName}i(tr,"getBlockchainDisplayNameFor");function pt(t,e){return e.find(o=>o.name===t)?.shortName}i(pt,"getBlockchainShortNameFor");function cp(t,e){return e.find(o=>o.name===t)?.logo}i(cp,"getBlockchainImage");function on(t,e){return e.find(o=>o.id===t)?.title}i(on,"getSwapperDisplayName");function nn(t,e){return e.find(o=>o.name===t)??null}i(nn,"findBlockchain");function na(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(na,"isTokenNative");function _e(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(_e,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");function rn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=_e(p));let u=o.tokensMapByTokenHash.get(p);u&&(n[p]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(p=>{l.has(p)||a(o.tokensMapByBlockchainName[p])})}return s.forEach(l=>{let p=r[l];if(!p&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}p&&(p.isExcluded?(a(o.tokensMapByBlockchainName[l]),p.tokens.forEach(u=>{let c=_e(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(rn,"matchTokensFromConfigWithMeta");function or(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(or,"getSupportedBlockchainsFromConfig");var ra={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"}},Dh={clientUrl:void 0},_h={liquiditySources:void 0},up=i((t,e,o)=>({config:{...ra,...t},iframe:Dh,campaignMode:_h,getLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?r.liquiditySources:n.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:n,campaignMode:r}=o();return r.liquiditySources?.length?[]:n},excludeLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?!1:!!n.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:n}=o();return!!n.liquiditySources?.length},updateConfig:n=>{let r=o().config,{_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s}=o(),l=rn({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=rn({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});Ao.set("supportedSourceTokens",l),Ao.set("supportedDestinationTokens",p),e({config:{...r,...n}})},updateCampaignMode:(n,r)=>{let a=o().campaignMode;e({campaignMode:{...a,[n]:r}})},updateIframe:(n,r)=>{let a=o().iframe;e({iframe:{...a,[n]:r}})}}),"createConfigSlice");import{TransactionType as mp}from"rango-types";var dp=[mp.EVM,mp.SOLANA];import{RangoClient as Zh}from"rango-sdk";import{UI_ID as $h}from"@rango-dev/ui";var nr="c6381a79-2817-4602-83bf-6a641a409e32",fp="https://api.rango.exchange",gp="https://explorer.rango.exchange",$e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...$h};import{BlockchainCategories as Hh,WalletState as Et}from"@rango-dev/ui";import{legacyReadAccountAddress as Gh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as Vh,getCosmosExperimentalChainInfo as Kh,isEvmAddress as jh,KEPLR_COMPATIBLE_WALLETS as vI,Networks as Ap}from"@rango-dev/wallets-shared";import ca from"bignumber.js";import{isCosmosBlockchain as Xh}from"rango-types";import Fh from"bignumber.js";var Ue=new Fh(0);import{WalletTypes as Oh}from"@rango-dev/wallets-shared";var hp=[Oh.LEAP];import{BlockchainCategories as aa,WalletState as qh}from"@rango-dev/ui";import{TransactionType as rr}from"rango-sdk";var yp="Roboto",ia=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function Wo(t){return Array.from(new Set(t))}i(Wo,"removeDuplicateFrom");function pa(t,e){return t.length===e.length&&t.every((o,n)=>o===e[n])}i(pa,"areEqual");function xp(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(xp,"debounce");function et(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(et,"containsText");function Tp(t,e){return t.toLowerCase()===e.toLowerCase()}i(Tp,"exactText");function kp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(kp,"startWithText");var A=i(()=>document.getElementById($e.SWAP_BOX_ID),"getContainer"),an=i(()=>document.getElementById($e.EXPANDED_BOX_ID),"getExpanded");function vp(t,e,o){let n=!!e&&Tp(e,t),r=!!o&&Tp(o,t);return n!==r?n?-1:1:0}i(vp,"compareExactMatchText");function sa(t,e,o){let n=!!e&&et(e,t),r=!!o&&et(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(sa,"compareContainsText");function la(t,e,o){let n=!!e&&kp(e,t),r=!!o&&kp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(la,"compareStartWithText");function wp(t,e,o){if(!o)return 0;let n=vp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=vp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=la(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=sa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=la(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=sa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=la(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=sa(o,t.address,e.address);if(r!==0)return r}return 0}i(wp,"compareWithSearchFor");var ir=i((t,e)=>{switch(e){case aa.ALL:return!0;case aa.UTXO:return t===rr.TRANSFER;case aa.OTHER:return t!==rr.TRANSFER&&t!==rr.COSMOS&&t!==rr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),bp=i(t=>ia.find(o=>o.value===t)?.url,"getFontUrlByName");function Ep(t,e){let o=!!t.find(n=>n.state===qh.CONNECTED);return e===!1&&o}i(Ep,"isSingleWalletActive");import{BigNumber as Ip}from"bignumber.js";var sn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),B=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Ip(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Ip(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var ar=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var bt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),ln=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function pn(t){switch(!0){case t.connected:return Et.CONNECTED;case t.connecting:return Et.CONNECTING;case!t.installed:return Et.NOT_INSTALLED;default:return Et.DISCONNECTED}}i(pn,"mapStatusToWalletState");function Np(t,e,o,n){return o.filter(r=>!hp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,namespaces:u,singleNamespace:c,supportedChains:m,needsDerivationPath:g}=e(r),d=Wo(m.map(h=>h.type)),f=pn(t(r));return{title:a,image:s,link:Vh(l),state:f,type:r,showOnMobile:p,namespaces:u,singleNamespace:c,blockchainTypes:d,needsDerivationPath:g}})}i(Np,"mapWalletTypesToWalletInfo");function pr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(pr,"walletAndSupportedChainsNames");function Wp(t,e,o,n,r){let a=[];function s(p,u){if(!!!a.find(m=>m.chain===p)){let m={address:u,chain:p,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(p=>{let{address:u,network:c}=Gh(p),m=l.length>0,g=l.includes(c),d=c===Ap.Unknown;if(m&&!g&&!d)return;let h=c===Ap.Unknown&&jh(u);if(d&&!h)return;o.includes(c)||h?r?s(c,u.toLowerCase()):l.filter(C=>o.includes(C)).forEach(C=>{s(C,u.toLowerCase())}):s(c,u)}),a}i(Wp,"prepareAccountsForWalletStore");function io(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,g=u.to.blockchain,d=a===o.swaps.length-1,f=c===p.length-1;(!d&&!f||d&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(g)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function cr(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(cr,"isAccountAndWalletMatched");function Mp(t,e){let{blockChain:o,balances:n=[]}=t;return n?.map(r=>({chain:o,symbol:r.asset.symbol,ticker:r.asset.symbol,address:r.asset.address||null,rawAmount:r.amount.amount,decimal:r.amount.decimals,amount:new ca(r.amount.amount).shiftedBy(-r.amount.decimals).toFixed(),logo:"",usdPrice:e(r.asset)?.usdPrice||null}))||[]}i(Mp,"makeBalanceFor");function Bp(t){return{...t,loading:!1,error:!0}}i(Bp,"resetConnectedWalletState");var Lp=i(t=>{let e=new Set,n=t?.reduce((a,s)=>a.findIndex(l=>l.address===s.address&&l.chain===s.chain)===-1?[...a,s]:a,[])?.map(a=>{let s={name:a.chain,accounts:[]};return e.has(a.address)||e.add(a.address),e.forEach(l=>{a.address===l&&s.accounts.push(a)}),s}),r=B(n?.flatMap(a=>a.accounts)?.flatMap(a=>a?.balances)?.map(a=>new ca(a?.amount||Ue).multipliedBy(a?.usdPrice||0))?.reduce((a,s)=>a.plus(s),Ue)||Ue).toString();return Yh(r)},"calculateWalletUsdValue");function Yh(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(Yh,"numberWithThousandSeparator");var ur=i((t,e)=>{let o=Kh(Object.entries(t).map(([,n])=>n).filter(Xh));return o&&o[e]?.experimental},"isExperimentalChain");function mr(t){return t?{...t,amount:B(t.amount,8,8),usdValue:B(t.usdValue,4,4)}:null}i(mr,"formatBalance");function Pp(t,e){return t?.usdValue||e?.usdValue?parseFloat(e?.usdValue||"0")-parseFloat(t?.usdValue||"0"):t?.amount||e?.amount?parseFloat(e?.amount||"0")-parseFloat(t?.amount||"0"):0}i(Pp,"compareTokenBalance");function ao(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(ao,"areTokensEqual");function Dp(t){return t.sort((e,o)=>+(o.state===Et.CONNECTED)-+(e.state===Et.CONNECTED)||+(o.state===Et.DISCONNECTED||o.state===Et.CONNECTING)-+(e.state===Et.DISCONNECTED||e.state===Et.CONNECTING))}i(Dp,"sortWalletsBasedOnConnectionState");function dr(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(dr,"getConciseAddress");function _p({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(_p,"getAddress");function fr(t){return t.flatMap(e=>e.balances).reduce((e,o)=>{let n={amount:o?.amount??"",decimals:o?.decimal??0,usdValue:o?.usdPrice?new ca(o?.usdPrice??Ue).multipliedBy(o?.amount).toString():""},r=o?_e({symbol:o.symbol,blockchain:o.chain,address:o.address}):null,a=r?e[r]:null;return r&&(!a||a&&a.amount<n.amount)&&(e[r]=n),e},{})}i(fr,"makeTokensBalance");var $p=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Fp(t){return t.map(e=>e.state).join("-")}i(Fp,"hashWalletsState");function Op(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(Op,"filterBlockchainsByWalletTypes");function Up(t,e){return e===Hh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ir(n,e))return!0;return!1})}i(Up,"filterWalletsByCategory");var ua={API_KEY:nr};function ct(t){return ua[t]||""}i(ct,"getConfig");function zp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ua=e,ua}i(zp,"initConfig");var Qp=20,qp=25,ma="theme-widget",da=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>ao(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>ao(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),fa=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Hp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var gr,Ht=i(()=>gr||(gr=new Zh(ct("API_KEY"),ct("BASE_URL")),gr),"httpService");function hr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Wo(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(p=>p===s.swapperGroup)),l&&s.types.map(p=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:p,selected:!e.includes(s.swapperGroup)})})}}),n}i(hr,"getUniqueSwappersGroups");function Gp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Gp,"sortLiquiditySourcesByGroupTitle");function je(t,e){return e?.[t]==="hidden"}i(je,"isFeatureHidden");function Vp(t,e){return e?.[t]==="enabled"}i(Vp,"isFeatureEnabled");var Kp=i((t,e,o)=>je("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var jp=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let p=or({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>dp.includes(c.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(p=>!(s.length>0&&!s.includes(p.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),p=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",c=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=Ao.get(c);m?.length||(m=rn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Ao.set(c,m)),m=Kp(m,s,a.features);let g=e().blockchains({type:o.type});return m.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!g.some(h=>h.name===f.blockchain)?!1:o.searchFor?!!(et(f.symbol,o.searchFor)||et(f.address||"",o.searchFor)||et(f.name||"",o.searchFor)):!0).sort((f,h)=>{let T=e().isTokenPinned(f,o.type),S=e().isTokenPinned(h,o.type);if(T!==S)return T?-1:1;if(o.getBalanceFor){let N=o.getBalanceFor(f),M=o.getBalanceFor(h),w=Pp(N,M);if(w!==0)return w}let C=p.get(f.blockchain),k=p.get(h.blockchain),v=na(f,C),x=na(h,k);if(v!==x)return v?-1:1;if(f.isPopular!==h.isPopular)return f.isPopular?-1:1;if(o.searchFor){let N=wp(f,h,o.searchFor);if(N)return N}return f.isSecondaryCoin!==h.isSecondaryCoin?f.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=_e(o),s=n.get(a);return s||(s=r.find(l=>_e(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>ao(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let c=a?.includes(u.swapperGroup);return s||!a||a.length===0?!c:c}).sort(Gp)},fetch:async()=>{try{let{enableCentralizedSwappers:o}=e().config,n=await Ht().getAllMetadata({enableCentralizedSwappers:o});t({fetchStatus:"success"});let r=new Map,a=new Map,s={},l=[],p=n.popularTokens,u=n.swappers,c=new Set;n.tokens.forEach(g=>{c.add(g.blockchain),l.push(g)}),n.blockchains.sort((g,d)=>g.sort-d.sort).forEach(g=>{g.enabled&&c.has(g.name)&&r.set(g.name,g)}),l.forEach(g=>{let d=_e(g);s[g.blockchain]||(s[g.blockchain]=[]),a.set(d,g),s[g.blockchain].push(d)}),t({_blockchainsMapByName:r,_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Chinese as Jh,English as Rh,Finland as ey,French as ty,German as oy,Greece as ny,Italian as ry,Japanese as iy,Netherlands as ay,Poland as sy,Portuguese as ly,Russian as py,Spanish as cy,Swedish as uy,Ukrainian as my}from"@rango-dev/ui";var Xp=[{title:"English",label:"English",local:"en",SVGFlag:Rh},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:cy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ty},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:iy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:ly},{title:"Chinese",label:"\u4E2D\u56FD\u4EBA",local:"zh",SVGFlag:Jh},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:py},{title:"German",label:"Deutsch",local:"de",SVGFlag:oy},{title:"Ukrainian",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:my},{title:"Swedish",label:"svenska",local:"sv",SVGFlag:uy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:ey},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:ay},{title:"Greek",label:"Grieks",local:"el",SVGFlag:ny},{title:"Italian",label:"Italiana",local:"it",SVGFlag:ry},{title:"Polish",label:"Polski",local:"pl",SVGFlag:sy}],Mo="en";var Yp=[.5,1,3],Zp=1,Jp=5,Rp=100,ec=0;var tc=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Zp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let p=s===o,u=l<=9;return p&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Wo(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=je("theme",n),s=je("language",n),l=je("liquiditySource",n),p=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...p&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Mo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Mo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=or({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");function oc(t){return dy()(fy((...e)=>({...jp(...e),...tc(...e),...up(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(oc,"createAppStore");var nc=hy(null);function y(){let t=yy(nc);if(Sy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function rc(t){let e=Cy();return e.current||(e.current=oc(t.config)),gy.createElement(nc.Provider,{value:e.current},t.children)}i(rc,"AppStoreProvider");import{create as vy}from"zustand";import{subscribeWithSelector as xy}from"zustand/middleware";import Ty from"mitt";var ye=Ty(),yr={on:ye.on,off:ye.off};import{WidgetEvents as ic}from"@rango-dev/queue-manager-rango-preset";var ha=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ha||{}),Sr=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Sr||{}),ya=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ya||{}),so=(a=>(a[a.RouteEvent=ic.RouteEvent]="RouteEvent",a[a.StepEvent=ic.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(so||{});var ky=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"),Gt=ky;var Z=Gt(vy()(xy((t,e)=>({connectedWallets:[],balances:{},loading:!1,connectWallet:(o,n)=>{ye.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}});let r=e().getWalletsDetails;t(a=>({loading:!0,connectedWallets:a.connectedWallets.filter(s=>s.walletType!==o[0].walletType).concat(o.map(s=>{let l=!a.connectedWallets.some(p=>p.chain===s.chain&&p.selected&&p.walletType!==s.walletType);return{balances:[],address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!0,error:!1}}))})),r(o,n)},disconnectWallet:o=>{t(n=>{n.connectedWallets.find(l=>l.walletType===o)&&ye.emit("walletEvent",{type:"disconnect",payload:{walletType:o}});let r=n.connectedWallets.filter(l=>l.selected&&l.walletType!==o).map(l=>l.chain),a=n.connectedWallets.filter(l=>l.walletType!==o).map(l=>r.includes(l.chain)?l:(r.push(l.chain),{...l,selected:!0}));return{balances:fr(a),connectedWallets:a}})},selectWallets:o=>t(n=>({connectedWallets:n.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})})),clearConnectedWallet:()=>t(()=>({connectedWallets:[],selectedWallets:[]})),getWalletsDetails:async(o,n,r=!0)=>{let a=e().getWalletsDetails;t(s=>({loading:!0,connectedWallets:s.connectedWallets.map(l=>o.find(p=>cr(p,l))?{...l,loading:!0}:l)}));try{let s=o.map(({address:u,chain:c})=>({address:u,blockchain:c})),p=(await Ht().getWalletsDetails(s)).wallets;if(p)t(u=>{let c=u.connectedWallets.map(g=>{let d=o.find(h=>cr(h,g)),f=p.find(h=>h.address===g.address&&h.blockChain===g.chain);return f?.failed&&d&&r&&a([d],n,!1),d&&f?{...g,explorerUrl:f.explorerUrl,balances:Mp(f,n),loading:!1,error:!1}:g});return{loading:!1,balances:fr(c),connectedWallets:c}});else throw new Error("Wallet not found")}catch{t(l=>{let p=l.connectedWallets.map(c=>o.find(m=>cr(m,c))?Bp(c):c);return{loading:!1,balances:fr(p),connectedWallets:p}})}},getBalanceFor:o=>{let{balances:n}=e(),r=_e(o);return n[r]??null}}))));import{allProviders as wy}from"@rango-dev/provider-all";function Cr(t,e){let o=wy({walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0});if(t){let n=[];return t.forEach(r=>{if(typeof r=="string"){let a=o.find(s=>s.config.type===r);a?n.push(a):console.warn(`Couldn't find ${r} provider. Please make sure you are passing the correct name.`)}else n.push(r)}),n}return o}i(Cr,"matchAndGenerateProviders");function ac(t,e){return Cr(t,e).map(r=>r.config.type)}i(ac,"configWalletsToWalletName");var Wy=Object.values(Bo);function gt(t){let{chain:e}=t||{},{config:o}=y(),{state:n,getWalletInfo:r}=by(),{connectedWallets:a}=Z(),s=y().blockchains(),{handleDisconnect:l}=qt(),p=ac(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink})||Wy,u=Np(n,r,p,e);u=Ey()?u.filter(h=>h.showOnMobile!==!1&&n(h.type).installed):u;let c=Dp(u),m=i(h=>!a.find(T=>T.walletType===h&&T.chain===e),"isExperimentalChainNotAdded"),g=Ay(()=>{let h=u?.filter(T=>T.state===Sa.CONNECTING)||[];for(let T of h)l(T.type)},[Fp(u)]);Ny(()=>()=>{g()},[]);let d=i(h=>{let T=h.find(C=>C.type===Bo.DEFAULT);return!T||T.state===Sa.NOT_INSTALLED?!1:h.filter(C=>C.state!=Sa.NOT_INSTALLED&&![Bo.DEFAULT,Bo.WALLET_CONNECT_2,Bo.LEDGER].includes(C.type)&&r(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((h,T,S)=>ur(S,T)&&m(h)&&!Iy.includes(h)||h==Bo.DEFAULT&&!d(u),"shouldExcludeWallet");return{list:c.filter(h=>!f(h.type,e??"",s)),terminateConnectingWallets:g}}i(gt,"useWalletList");import{Modal as Ly}from"@rango-dev/ui";import Py from"react";import{create as By}from"zustand";var sc="rango-widget";var cn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(sc),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var se=Gt(By()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})}}))),lo=new cn({onInit:()=>se.setState({tabManagerInitiated:!0}),onClaim:()=>se.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>se.setState({isActiveTab:!1})});function J(t){let{watermark:e}=se();return Py.createElement(Ly,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Ca}from"@lingui/core";import{Button as Uy,Checkbox as zy,Divider as Qy,Image as yc,ListItemButton as qy,MessageBox as Hy,Radio as Gy,RadioRoot as Vy}from"@rango-dev/ui";import{namespaces as Sc}from"@rango-dev/wallets-shared";import xe,{useMemo as Ky,useState as jy}from"react";import{css as Dy,darkTheme as pc,IconButton as _y,styled as po}from"@rango-dev/ui";var It=po(_y,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${pc} &`]:{backgroundColor:"$neutral"}}}),cc=po("div",{position:"absolute",background:"$secondary500",[`.${pc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=po("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),uc=po("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"}}}}),mc=po("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),dc=po("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),fc=Dy({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Tr=po("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as $y,styled as kr}from"@rango-dev/ui";var bA=kr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Lo=kr("div",{position:"relative"}),Fy=$y({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Po=kr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Fy} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vr=kr("div",{"& img":{borderRadius:"50%"}});function gc(t,e){return t.find(o=>o.name===e)?.logo}i(gc,"getBlockchainLogo");import{styled as Oy}from"@rango-dev/ui";var hc=Oy("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function un(t){let{singleNamespace:e,availableNamespaces:o,providerImage:n}=t.value,[r,a]=jy([]),s=y().blockchains(),l=Ky(()=>o?.map(c=>({name:c,logo:gc(s,Sc[c].mainBlockchain),title:Sc[c].title})),[o]),p=i(c=>{a(e?[c]:m=>m.includes(c)?m.filter(g=>g!==c):m.concat(c))},"onSelect"),u=i(c=>e?xe.createElement(Vy,{value:r?.[0]},c):xe.createElement(xe.Fragment,null,c),"wrapRadioRoot");return xe.createElement(xe.Fragment,null,xe.createElement(Qy,{size:20}),xe.createElement(Hy,{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:xe.createElement(Lo,null,xe.createElement(Tr,null,xe.createElement(yc,{src:n,size:45})),xe.createElement(Po,null))}),xe.createElement(hc,null,u(xe.createElement(xe.Fragment,null,l?.map(c=>xe.createElement(qy,{key:c.name,id:c.name,title:c.title,hasDivider:!0,style:{height:60},onClick:()=>p(c.name),start:xe.createElement(yc,{src:c.logo,size:22}),end:e?xe.createElement(Gy,{value:c.name}):xe.createElement(zy,{checked:r.includes(c.name)})}))))),xe.createElement(Uy,{type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ca.t("Confirm")))}i(un,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as Zy,Divider as kc,Image as Jy,MessageBox as Ry,Select as eS,TextField as tS}from"@rango-dev/ui";import ze,{useEffect as oS,useState as vc}from"react";import{namespaces as Xy}from"@rango-dev/wallets-shared";var xr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ta(t){let e=t?Xy[t].derivationPaths:null;return e?[...e,xr]:[]}i(Ta,"getDerivationPaths");import{styled as Cc,Typography as Yy}from"@rango-dev/ui";var Tc=Cc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),ka=Cc(Yy,{paddingLeft:"$10"}),va={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var xc="0";function mn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=vc(null),[l,p]=vc(xc),u=a===xr.id,c=Ta(o),m=i(({value:d})=>{let f=c?.find(h=>h.id===d);f&&(a===xr.id&&Number.isNaN(Number(l))&&p(xc),s(f.id))},"handleDerivationPathItemClick"),g=i(()=>{let d=c.find(f=>f.id===a);if(d)e(d.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return oS(()=>{s(Ta(o)[0]?.id||null)},[o]),ze.createElement(ze.Fragment,null,ze.createElement(kc,{size:20}),ze.createElement(Ry,{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:ze.createElement(Lo,null,ze.createElement(vr,null,ze.createElement(Jy,{src:n,size:45})),ze.createElement(Po,null))}),ze.createElement(Tc,null,ze.createElement(ka,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),ze.createElement(eS,{value:a||"",options:c.map(d=>({value:d.id,label:d.label})),variant:"filled",handleItemClick:m,styles:{trigger:va}}),ze.createElement(kc,{size:20}),ze.createElement(ka,{variant:"body",size:"xsmall",color:"$neutral600"},u?Do.t("Enter Path"):Do.t("Enter Index")),ze.createElement(tS,{type:u?"text":"number",variant:"contained",value:l,onChange:d=>p(d.target.value),style:va})),ze.createElement(Zy,{type:"primary",onClick:g,disabled:!c||!a||!l},Do.t("Confirm")))}i(mn,"DerivationPath");import{i18n as _o}from"@lingui/core";import{Image as nS,MessageBox as xa,WalletState as rS}from"@rango-dev/ui";import{useWallets as iS}from"@rango-dev/wallets-react";import co from"react";function wa(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=iS();return pn(a(n))===rS.CONNECTED?co.createElement(xa,{type:"success",title:_o.t("Wallet Connected"),description:_o.t("Your wallet is connected, you can use it to swap.")}):o?co.createElement(xa,{type:"error",title:_o.t("Failed to Connect"),description:o||_o.t("Your wallet is not connected. Please try again.")}):co.createElement(xa,{type:"loading",title:_o.t("Connecting to your wallet"),description:_o.t("Click connect in your wallet popup."),icon:co.createElement(Lo,null,co.createElement(vr,null,co.createElement(nS,{src:r,size:45})),co.createElement(Po,null))})}i(wa,"ConnectStatus");import{i18n as ba}from"@lingui/core";import{Button as aS,Divider as wc,MessageBox as sS}from"@rango-dev/ui";import wr from"react";function Ea(t){let{displayName:e,onConfirm:o}=t;return wr.createElement(sS,{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}})},wr.createElement(wc,{size:18}),wr.createElement(wc,{size:32}),wr.createElement(aS,{onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},ba.t("Confirm")))}i(Ea,"ExperimentalChain");function bc(t,e){return t().status==="init"&&!!e}i(bc,"isOnStatus");function dn(t){return t().status==="namespace"}i(dn,"isOnNamespace");function fn(t){return t().status==="derivationPath"}i(fn,"isOnDerivationPath");var uS=3e3,mS=300;function mo(t){let e=cS(),[o,n]=Ec(!1),[r,a]=Ec(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=gt(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:g}=qt(),d=i(S=>{c(t.wallet,S).catch(s)},"handleConfirmNamespaces"),f=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(S).catch(s)},"handleDerivationPathConfirm"),h=i(()=>{n(!1)},"handleClosingModal"),T=i(()=>{a(void 0),g(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return pS(()=>{if(t.wallet){T();let S=!1,C=!0,k=i(()=>{setTimeout(()=>{C=!1,S||n(!0)},mS)},"beforeConnecting"),v=i(x=>{let N=x.status==="connected",M=["disconnected","disconnected-unhandled"].includes(x.status);["namespace","derivation-path"].includes(x.status)||(S=!0),N&&!C?e.current=setTimeout(h,uS):M&&h(),t.onConnect&&t.onConnect(x)},"afterConnected");k(),p(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),uo.createElement(J,{open:o,onClose:h,onExit:()=>{T(),l(),t.onClose&&t.onClose()},container:A()},bc(m,t.wallet)&&uo.createElement(uo.Fragment,null,uo.createElement(wa,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),uo.createElement(lS,{direction:"vertical",size:32})),dn(m)&&uo.createElement(un,{onConfirm:d,value:m().namespace}),fn(m)&&uo.createElement(mn,{onConfirm:f,value:m().derivationPath}))}i(mo,"StatefulConnectModal");import{Events as Aa,Provider as fS}from"@rango-dev/wallets-react";import{isEvmBlockchain as gS}from"rango-sdk";import br,{createContext as hS,useEffect as Ac,useMemo as yS,useRef as Nc}from"react";import{useEffect as dS}from"react";function Ic(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Ic,"hashProviders");function Ia(t,e){let o=Z.use.clearConnectedWallet(),n=Cr(t,e);return dS(()=>{o(),n=Cr(t,e)},[Ic(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(Ia,"useWalletProviders");var Er=hS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function SS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),{findToken:s}=y(),l=y().config,p={walletConnectProjectId:l?.walletConnectProjectId,trezorManifest:l?.trezorManifest,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:u}=Ia(l.wallets,p),{connectWallet:c,disconnectWallet:m}=Z(),g=Nc(),d=Nc();Ac(()=>{n().catch(console.log)},[]),Ac(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:l,dappConfig:t.config})},[t.config,r]);let f=a.filter(gS).map(C=>C.name),h=i((C,k,v,x,N)=>{if(k===Aa.ACCOUNTS)if(v){let M=pr(N.supportedBlockchains),w=Wp(C,v,f,M,N.isContractWallet);w.length&&c(w,s)}else m(C),d.current?d.current(C):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?");if(k===Aa.ACCOUNTS&&x.connected){let M=`${C}-${x.network}-${v}`;x.connected&&(g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?"))}if(k===Aa.NETWORK&&x.network){let M=`${C}-${x.network}`;g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(C,k,v,x,N)},"onUpdateState"),T=se.use.isActiveTab(),S=yS(()=>({onConnectWallet:C=>{g.current=C},onDisconnectWallet:C=>{d.current=C}}),[]);return br.createElement(Er.Provider,{value:S},br.createElement(fS,{allBlockChains:a,providers:u,onUpdateState:h,autoConnect:!!T},t.children))}i(SS,"Main");function Ir(t){let{config:e,...o}=t;return br.createElement(rc,{config:e},br.createElement(SS,{...o,config:e}))}i(Ir,"WidgetWallets");import Ri from"react";import CS,{Fragment as TS}from"react";import{MemoryRouter as kS,useInRouterContext as vS}from"react-router";function Wc({children:t}){let o=vS()?TS:kS;return CS.createElement(o,null,t)}i(Wc,"AppRouter");import{I18nManager as eE}from"@rango-dev/ui";import rp from"react";import De from"react";import{useRoutes as Ub}from"react-router-dom";var D={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Oo,useRef as _r}from"react";import Xe from"bignumber.js";import{create as bS}from"zustand";import{subscribeWithSelector as ES}from"zustand/middleware";import{getLastSuccessfulStep as wS}from"@rango-dev/queue-manager-rango-preset";import LW from"bignumber.js";function Na(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(Na,"getFeeLabel");var Wa=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Mc=30;import{i18n as ht}from"@lingui/core";import{RouteEventType as SW}from"@rango-dev/queue-manager-rango-preset";import Qe from"bignumber.js";import{PendingSwapNetworkStatus as Nr}from"rango-types";import{i18n as Fe}from"@lingui/core";var te=i(()=>({genericServerError:Fe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Fe.t("Please reset your liquidity sources."),description:Fe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Fe.t("No Routes Found."),description:Fe.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:Fe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Fe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Fe.t("High Price Impact"),title:Fe.t("Price impact is too high!"),description:Fe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Fe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Fe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Fe.t("USD Price Unknown"),title:Fe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Fe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Fe.t("Confirm USD Price Unknown")}}),"errorMessages");function Bc(t){switch(t.type){case 0:return t.diagnosisMessage??te().noResultError.title;case 1:return te().genericServerError;default:return""}}i(Bc,"getQuoteErrorMessage");import{i18n as Ar}from"@lingui/core";var fo=i(()=>({connectWallet:Ar.t("Connect Wallet"),swap:Ar.t("Swap"),swapAnyway:Ar.t("Swap anyway"),ethWarning:Ar.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Lc(t,e){return(parseInt(e.toFixed(2)||"0")<=-10&&t?.gte(new Qe(400))||parseInt(e.toFixed(2)||"0")<=-5&&t?.gte(new Qe(1e3)))??!1}i(Lc,"hasHighValueLoss");function Pc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(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(Pc,"hasLimitError");function Dc(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new Qe(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Qe(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?p?.gte(l.fromAmount)||u?.lte(l.fromAmount):p?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=ht.t({id:"Required: >= {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=ht.t({id:"Required: > {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=ht.t({id:"Required: <= {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=ht.t({id:"Required: < {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Dc,"getLimitErrorMessage");function _c(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:fo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:fo().swap,action:"confirm-swap",disabled:!0}:s?{title:fo().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:fo().ethWarning,action:"confirm-warning",disabled:!1}:{title:fo().swap,action:"confirm-swap",disabled:!1}:{title:fo().connectWallet,action:"connect-wallet",disabled:!1}}i(_c,"getSwapButtonState");function Ma(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(Ue))&&e&&e!=="0"&&n!==0)}i(Ma,"canComputePriceImpact");function Ba(t,e){let o=Ue;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 Qe(r.amount).multipliedBy(a||0))}return o}i(Ba,"getUsdFeeOfStep");function Wr(t,e){return t.reduce((o,n)=>o.plus(Ba(n,e)),Ue)}i(Wr,"getTotalFeeInUsd");function La(t){let e=Ue;return e=e.plus(new Qe(t.amount).multipliedBy(t.price||0)),e}i(La,"getUsdFee");function $c(t){return t.reduce((e,o)=>e.plus(La(o)),Ue)}i($c,"getTotalFeesInUsd");function Fc(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(Fc,"getFeesGroup");function Oc(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(Oc,"checkSlippageErrors");function Uc(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(Uc,"checkSlippageWarnings");function Mr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Mr,"getMinRequiredSlippage");function zc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(zc,"hasProperSlippage");function Qc(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:g,destination:d,enableCentralizedSwappers:f}=t,h=a?.reduce((C,k)=>(C[k.chain]=k.address,C),{}),T=[];return r?.forEach(C=>{T.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:g??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:T,selectedWallets:h??{},slippage:u.toString(),...d&&{destination:d},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1},enableCentralizedSwappers:f}}i(Qc,"createQuoteRequestBody");function qc(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(qc,"getWalletsForNewSwap");function $o(t){return t?.outputAmount||null}i($o,"getQuoteOutputAmount");function Hc(t,e){return new Qe(e).div(new Qe(t)).minus(1).multipliedBy(100).toNumber()}i(Hc,"getPercentageChange");function Gc(t,e){let o=$o(t),n=$o(e);if(!o||!n)return!1;let r=ut(o,n);return r?r<=-1:!0}i(Gc,"isOutputAmountChangedALot");function Vc(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=>Jc(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=B(new Qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=B(new Qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=ht.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=ht.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=ht.t(" for input and network fee")),ht.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:c,currentAmount:p,blockchain:pt(s.asset.blockchain,o)}})})}i(Vc,"generateBalanceWarnings");function jt(t,e){return(t?new Qe(t):Ue).multipliedBy(e||0)}i(jt,"calcOutputUsdValue");function gn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Nr.NetworkChanged}i(gn,"isNetworkStatusInWarningState");function Kc(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),gn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Nr.WaitingForConnectingWallet:n=n||ht.t("Waiting for connecting wallet");break;case Nr.WaitingForQueue:n=n||ht.t("Waiting for other running tasks to be finished");break;case Nr.WaitingForNetworkChange:n=n||ht.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(Kc,"getSwapMessages");function jc(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(jc,"getLastConvertedTokenInFailedSwap");function Xc(t){return t.status==="failed"}i(Xc,"shouldRetrySwap");function Yc(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),p=s.every(m=>r.some(g=>g.chain===m)),u=l.every(m=>r.some(g=>g.chain===m)),c=o&&a?No(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(Yc,"isConfirmSwapDisabled");function Zc(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Zc,"isTokensIdentical");function go(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(go,"getQuoteToTokenUsdPrice");function hn(t){return(t?.swaps||[])[0].from.usdPrice}i(hn,"getQuoteFromTokenUsdPrice");function Pa(t,e){let o=t?.swaps||[],n=e?.swaps||[];return o.length!==n.length}i(Pa,"isNumberOfSwapsChanged");function Da(t,e){let o=t?.swaps.map(r=>r.swapperId)||[],n=e?.swaps.map(r=>r.swapperId)||[];return!pa(o,n)}i(Da,"isQuoteSwappersUpdated");function _a(t,e){let o=t?.swaps.map(r=>r.to.symbol)||[],n=e?.swaps.map(r=>r.to.symbol)||[];return!pa(o,n)}i(_a,"isQuoteInternalCoinsUpdated");function eu(t,e){return Pa(t,e)||Da(t,e)||_a(t,e)}i(eu,"isQuoteChanged");function Jc(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(Jc,"getRequiredBalanceOfWallet");function Lt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Lt,"getPriceImpactLevel");function Lr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=wS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=nn(a?a.toBlockchain:n.fromBlockchain,e),p=nn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(Lr,"createRetryQuote");function Fo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=jt(t.requestAmount,hn(t)||o?.usdPrice),l=jt(t.outputAmount,go(t)||n?.usdPrice);if(t&&s&&l){let c=ut(s.toString(),l.toString());if(!!c&&Lc(s,c)){let g=Wr(t?.swaps,r),d=Lt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:g,warningLevel:d}}}else if(t&&(!s||!l))return{type:1};let p=Mr(t.swaps),u=a>Jp;if(zc(e.userSlippage.toString(),p)){if(u&&parseFloat(p??"0")<a)return{type:3,slippage:a.toString()}}else return{type:2,recommendedSlippages:Uc(t,a),minRequiredSlippage:p};return null}i(Fo,"generateQuoteWarnings");function ut(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Hc(t.toString(),e.toString());return n&&n<0?n:null}i(ut,"getPriceImpact");var tu=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"),Pr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(c=>c.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),p=n.requestId.toLowerCase();return l.localeCompare(p)}),"sortQuotesBy"),ou=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,...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,...r||e[0]}},"getDefaultQuote"),nu=i(t=>{let e=i((o,n)=>{let r=Wa.indexOf(o.value),a=Wa.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");var Dr=i((t,e)=>t?.usdPrice?new Xe(e||Ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),z=Gt(bS()(ES(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Xe(0),outputUsdValue:new Xe(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=Ue,a=o.inputUsdValue;return ln(o.inputAmount)?(e&&(n=e?.outputAmount?new Xe(e?.outputAmount):null,a=jt(o.inputAmount,hn(e)||o.fromToken?.usdPrice),r=jt(e.outputAmount,go(e)||o.toToken?.usdPrice)),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Xe(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Xe(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue: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 Xe(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue: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 Xe(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Dr(e.toToken,e.outputAmount?.toString()||""):new Xe(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Xe(0),inputUsdValue:new Xe(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),ru=z.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 iu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=z(),c=y().config,m=y().fetchStatus,g=y().blockchains(),d=y().tokens(),{findToken:f}=y(),{setAffiliateRef:h,setAffiliatePercent:T,setAffiliateWallets:S}=y(),C=c?.from?.tokens,k=c?.from?.blockchains,v=c?.to?.tokens,x=c?.to?.blockchains,N=_r(void 0),M=_r(void 0),w=_r(void 0),E=_r(void 0);Oo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Oo(()=>{if(m==="success"){r();let b=g.find(I=>I.name===c?.from?.blockchain),W=c?.from?.token,$=W&&f(W);(b||!b&&w.current)&&n(b??null),$?a({token:$,meta:{blockchains:g,tokens:d}}):!$&&N.current&&a({token:null}),w.current=c?.from?.blockchain,N.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Oo(()=>{da(s,C)&&a({token:null}),fa(p,k)&&n(null)},[C,k]),Oo(()=>{da(l,v)&&a({token:null}),fa(u,x)&&o(null)},[v,x]),Oo(()=>{if(m==="success"){r();let b=g.find(I=>I.name===c?.to?.blockchain),W=c?.to?.token,$=W&&f(W);(b||!b&&E.current)&&o(b??null),$?e({token:$,meta:{blockchains:g,tokens:d}}):!$&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Oo(()=>{h(c?.affiliate?.ref??null),T(c?.affiliate?.percent??null),S(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(iu,"useSyncStoresWithConfig");import{useEffect as Oa,useRef as IS}from"react";import{useInRouterContext as AS,useLocation as NS,useSearchParams as WS}from"react-router-dom";function $a(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i($a,"convertTokenSearchParamToAsset");function Fa(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Fa,"tokenToSearchParam");function za(){let t=NS(),[e,o]=WS(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:g}=z(),d=y().fetchStatus,f=y().blockchains(),h=y().tokens(),T=AS(),{updateIframe:S,updateCampaignMode:C}=y(),k=y().isInCampaignMode(),v=IS(),{findToken:x}=y(),N=i(()=>{let w={};for(let[V,le]of e.entries())V.startsWith("utm_")&&(w[V]=le);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),W=e.get("fromToken"),$=e.get("toBlockchain"),I=e.get("toToken"),R=e.get("autoConnect"),ee=e.get("clientUrl"),oe=e.get("liquiditySources"),L=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:W,toBlockchain:$,toToken:I,autoConnect:R,clientUrl:ee,liquiditySources:oe,utmQueryParams:w,blockchain:L}},"getUrlSearchParams"),M=i(w=>{for(let E in w)w[E]||delete w[E];o(w,{replace:!0})},"updateUrlSearchParams");Oa(()=>{let{autoConnect:w,clientUrl:E,utmQueryParams:b,blockchain:W}=N();T&&d==="success"&&M({fromBlockchain:n?.name,fromToken:Fa(a),toBlockchain:r?.name,toToken:Fa(s),fromAmount:l,autoConnect:w??void 0,clientUrl:E??void 0,blockchain:W??void 0,liquiditySources:k?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,k]),Oa(()=>{if(!T)return;let w=N();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&g(w.fromAmount),d==="success"){let E=f.find(I=>I.name===w.fromBlockchain),b=w.fromToken&&E?x($a(w.fromToken,E)):void 0,W=f.find(I=>I.name===w.toBlockchain),$=w.toToken&&W?x($a(w.toToken,W)):void 0;E&&(p(E),b&&c({token:b,meta:{blockchains:f,tokens:h}})),W&&(u(W),$&&m({token:$,meta:{blockchains:f,tokens:h}}))}},[d]),Oa(()=>{let{clientUrl:w,liquiditySources:E}=N();S("clientUrl",w||void 0),C("liquiditySources",E?.split(",")??void 0)},[])}i(za,"useSyncUrlAndStore");import{i18n as At}from"@lingui/core";import{Alert as HC,Button as Ou,darkTheme as GC,Divider as Cn,DoneIcon as VC,MessageBox as KC,styled as jC,TextField as XC,Typography as YC}from"@rango-dev/ui";import Se,{useEffect as ZC,useState as qr}from"react";import{useNavigate as JC,useSearchParams as RC}from"react-router-dom";import{ChevronRightIcon as MS,Divider as cu,Image as BS,Typography as uu}from"@rango-dev/ui";import yt from"react";import{darkTheme as au,styled as Qa}from"@rango-dev/ui";var su=Qa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${au} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${au} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),lu=Qa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),pu=Qa("div",{display:"flex"});function qa(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return yt.createElement(lu,null,yt.createElement(uu,{size:"large",variant:"label"},n),yt.createElement(cu,{size:10}),yt.createElement(su,{onClick:s?void 0:e,disabled:s},yt.createElement(pu,null,r&&yt.createElement(yt.Fragment,null,yt.createElement(BS,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),yt.createElement(cu,{size:4,direction:"horizontal"})),yt.createElement(uu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),yt.createElement(MS,{size:12,color:"black"})))}i(qa,"BlockchainSelectorButton");import{i18n as Ga}from"@lingui/core";import{Button as LS,Divider as yn,ExternalLinkIcon as PS,Image as DS,Typography as zo}from"@rango-dev/ui";import We from"react";function mu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(mu,"generateExplorerLink");import{darkTheme as Uo,styled as du}from"@rango-dev/ui";var Ha=du("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:{}}}}),fu=du("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 Va(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=mu(n.address,a);return We.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},We.createElement(fu,null,We.createElement(DS,{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(yn,{size:4}),We.createElement(zo,{variant:"body",size:"medium"},s?We.createElement(Ha,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,We.createElement(PS,{size:12,color:"gray"})):We.createElement(Ha,null,n.address)),We.createElement(yn,{size:4}),n.coinSource&&We.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},Ga.t("via")," ",We.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),We.createElement(yn,{size:"32"}),We.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},Ga.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(yn,{size:40}),We.createElement(yn,{size:10}),We.createElement(LS,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ga.t("Import")))}i(Va,"CustomTokenModal");import{useManager as FC}from"@rango-dev/queue-manager-react";import{BottomLogo as OC,Divider as Pu,Header as UC}from"@rango-dev/ui";import Be,{useEffect as fs,useRef as Du,useState as zC}from"react";import{useRef as _S}from"react";function $r(){return window.self!==window.top}i($r,"isAppLoadedIntoIframe");function Ka(){let t=_S(null),{iframe:e}=y(),o=$r()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let p of l)n({type:"widget_height",data:{height:p.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ka,"useIframe");import{useNavigate as $S}from"react-router-dom";function Ye(){let t=$S();return()=>t(-1)}i(Ye,"useNavigateBack");import{createTheme as es,darkTheme as ZS,lightTheme as JS}from"@rango-dev/ui";import{useEffect as RS,useState as eC}from"react";import{theme as XS,darkColors as YS}from"@rango-dev/ui";import Ja from"react";function FS(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(FS,"expandShortHexColor");function OS(t){return/[0-9]+$/.test(t)}i(OS,"isOverridingColor");function US(t,e){return t.padStart(e,"0")}i(US,"pad");function ja(t){let e=Math.min(Math.max(Math.round(t),0),255);return US(e.toString(16),2)}i(ja,"intToHex");function zS(t){return`#${ja(t.red)}${ja(t.green)}${ja(t.blue)}`}i(zS,"rgbToHex");function QS(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(QS,"hexToRGB");function qS(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(qS,"generateShade");function HS(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(HS,"generateTint");function GS(t){return gu(t,qS)}i(GS,"calculateShades");function VS(t){return gu(t,HS)}i(VS,"calculateTints");function gu(t,e){let o=QS(t),n=[];for(let r=1;r<9;r++)n.push(zS(e(o,r)));return n}i(gu,"calculateColors");function Xa(t,e,o){let a=VS(t).reverse().concat(t),s=GS(t),l=a.concat(s),p={},u=l.length;for(let c=0;c<u;c++){let m=100+(o?u-1-c:c)*50;p[`${e}${m}`]=l[c]}return p}i(Xa,"createTintsAndShades");function Ya(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)&&!OS(r)){let p=FS(a);Object.assign(n,Xa(p,r,s))}}return{...n,...e}}i(Ya,"expandToGenerateThemeColors");var hu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),KS=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=hu(o%52)+e;return hu(o%52)+e},"toAlphabeticName"),jS=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Za=i(t=>KS(jS(5381,JSON.stringify(t))>>>0),"toHash");function Ra(t){let e=XS.colors,o={...e,...YS},n,r;if(t?.light){let s={colors:Ya(e,t.light)};n={id:`${ma}-light-${Za(s)}`,tokens:s}}if(t?.dark){let s={colors:Ya(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ma}-dark-${Za(s)}`,tokens:s}}return{light:n,dark:r}}i(Ra,"customizedThemeTokens");function yu(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(yu,"joinList");function Su(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Su,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=yp,borderRadius:n=Qp,secondaryBorderRadius:r=qp}=t,[a,s]=eC(Su()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=Ra(e),c=es({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,JS.className],g=[c.className,ZS.className];if(u){let f=es(u.id,u.tokens);m.push(f.className)}if(p){let f=es(p.id,p.tokens);g.push(f.className)}return RS(()=>{let f=i(h=>{h.matches?s("dark"):s("light")},"switchThemeListener");return Su()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=m.join(" "),h=g.join(" ");return l==="auto"?a==="dark"?h:f:l==="dark"?h:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var mt=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 Cu}from"@lingui/core";import{Alert as tC,Button as oC}from"@rango-dev/ui";import Tu from"react";function ts(t){return Tu.createElement(tC,{action:Tu.createElement(oC,{onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Cu.t("Activate this tab")),type:"warning",variant:"alarm",title:Cu.t("Another tab is open and handles transactions.")})}i(ts,"ActivateTabAlert");import{i18n as os}from"@lingui/core";import{Button as nC,Divider as rC,MessageBox as iC}from"@rango-dev/ui";import Fr from"react";function ns(t){let{open:e,onClose:o,onConfirm:n}=t;return Fr.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},Fr.createElement(iC,{title:os.t("Activate current tab"),type:"warning",description:os.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.")},Fr.createElement(rC,{size:20}),Fr.createElement(nC,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},os.t("Confirm"))))}i(ns,"ActivateTabModal");import{ChevronLeftIcon as aC}from"@rango-dev/ui";import ku from"react";function rs(t){return ku.createElement(It,{variant:"ghost",size:"small",onClick:t.onClick},ku.createElement(aC,{color:"black",size:16}))}i(rs,"BackButton");import{i18n as sC}from"@lingui/core";import{Button as lC,Typography as pC}from"@rango-dev/ui";import is from"react";function as(t){return is.createElement(Vt,null,is.createElement(lC,{variant:"ghost",onClick:t.onClick,size:"xsmall"},is.createElement(pC,{variant:"label",size:"medium",color:"error500"},sC.t("Cancel"))))}i(as,"CancelButton");import{i18n as cC}from"@lingui/core";import{Image as uC,Tooltip as mC,WalletIcon as dC}from"@rango-dev/ui";import ho from"react";function ss(t){let{list:e}=gt(),o=e.filter(r=>r.state==="connected"),n=o.length?ho.createElement("div",{className:fc()},o.map(r=>ho.createElement(Tr,{key:r.title},ho.createElement(uC,{src:r.image,size:14})))):cC.t("Connect Wallet");return ho.createElement(mC,{container:t.container,side:"bottom",content:n},ho.createElement(It,{variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&ho.createElement(cc,null),ho.createElement(dC,{size:18,color:"black"})))}i(ss,"WalletButton");import{i18n as Ur}from"@lingui/core";import{NotificationsIcon as NC,Popover as WC,SettingsIcon as MC,Tooltip as zr,TransactionIcon as BC}from"@rango-dev/ui";import Me from"react";import{Notifications as yC}from"@rango-dev/ui";import SC from"react";import{useNavigate as CC}from"react-router-dom";import{create as fC}from"zustand";import{persist as gC,subscribeWithSelector as hC}from"zustand/middleware";var we=Gt(fC()(gC(hC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(p=>p.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(p=>p.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function ls(){let t=CC(),{getNotifications:e,clearNotifications:o}=we(),n=e(),r=y().blockchains(),{findToken:a}=y();return SC.createElement(yC,{list:n,getBlockchainImage:l=>cp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${D.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ls,"NotificationContent");import{useManager as TC}from"@rango-dev/queue-manager-react";import{InProgressIcon as kC}from"@rango-dev/ui";import vu from"react";var vC=i(()=>{let{manager:t}=TC();return mt(t).map(({swap:o})=>o).find(o=>o.status==="running")?vu.createElement(dc,null,vu.createElement(kC,{color:"info",size:6})):null},"InProgressTransactionBadge"),xu=vC;import{EventSeverity as xC}from"@rango-dev/queue-manager-rango-preset";import{Typography as wC}from"@rango-dev/ui";import wu from"react";function bu(){let{getNotifications:t}=we(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===xC.WARNING);return o?wu.createElement(uc,{isSever:n},wu.createElement(wC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(bu,"NotificationsBadge");import{RefreshProgressButton as bC}from"@rango-dev/ui";import ps,{useEffect as EC,useState as Eu}from"react";var IC=1e3,Iu=60,AC=100;function Or({onClick:t}){let[e,o]=Eu(0),[n,r]=Eu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");EC(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Iu&&l()},IC):s(p),document.addEventListener("visibilitychange",()=>a(p)),()=>{document.removeEventListener("visibilitychange",()=>a(p)),p&&clearInterval(p)}},[e,t]);let s=i(p=>{p&&clearInterval(p),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return ps.createElement(It,{variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},ps.createElement(mc,{onTransitionEnd:()=>r(!1),isRefetched:n},ps.createElement(bC,{size:22,color:t?"black":"gray",progress:e/Iu*AC})))}i(Or,"RefreshButton");function yo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=je("notification",s)||r.includes("notifications");return Me.createElement(Me.Fragment,null,!r.includes("refresh")&&Me.createElement(zr,{container:a||A(),side:"top",content:Ur.t("Refresh")},Me.createElement(Or,{onClick:e})),!l&&Me.createElement(WC,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:A(),content:Me.createElement(ls,null)},Me.createElement("div",null,Me.createElement(zr,{container:A(),side:"top",content:Ur.t("Notifications")},Me.createElement(It,{size:"small",variant:"ghost"},Me.createElement(NC,{size:18,color:"black"}),Me.createElement(bu,null))))),!r.includes("settings")&&Me.createElement(zr,{container:A(),side:"top",content:Ur.t("Settings")},Me.createElement(It,{size:"small",variant:"ghost",onClick:n},Me.createElement(MC,{size:18,color:"black"}))),!r.includes("history")&&Me.createElement(zr,{container:A(),side:"top",content:Ur.t("History")},Me.createElement(It,{size:"small",variant:"ghost",onClick:o},Me.createElement(BC,{size:18,color:"black"}),Me.createElement(xu,null))))}i(yo,"HeaderButtons");import{i18n as cs}from"@lingui/core";import{Divider as Nu,MessageBox as DC,RefreshIcon as _C}from"@rango-dev/ui";import qo from"react";import{Button as LC,styled as PC}from"@rango-dev/ui";var Au=PC(LC,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function us(t){let{open:e,onClose:o}=t;return qo.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},qo.createElement(DC,{title:cs.t("Something went wrong"),type:"error",description:cs.t("Something went wrong. Please refresh the app.")},qo.createElement(Nu,{size:30}),qo.createElement(Au,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},qo.createElement(_C,{size:20,color:"primary"}),qo.createElement(Nu,{size:4,direction:"horizontal"}),cs.t("Refresh"))))}i(us,"RefreshModal");function ms(t){let e=t.target;if(e){let o=e.scrollTop,n=A();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(ms,"onScrollContentAttachStatusToContainer");import{css as $C,styled as ds}from"@rango-dev/ui";var Wu="700px",Qr=$C({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Mu=ds("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Wu},fixed:{height:Wu}}}}),Bu=ds("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Lu=ds("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 ne(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Ka(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l}=y(),[p,u]=zC(!1),c=Z.use.connectedWallets(),{config:{features:m,theme:g}}=y(),{watermark:d}=se(),f=d==="FULL",{activeTheme:h}=Qo(g||{}),T=je("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:C,showActivateTabModal:k,setShowActivateTabModal:v,activateCurrentTab:x}=se(),N=Ye(),{manager:M}=FC(),E=mt(M).map(({swap:ee})=>ee).some(ee=>ee.status==="running"),b=i(()=>x(lo.forceClaim,E),"onActivateTab"),W=i(()=>{r.onWallet?.()},"onConnectWallet"),$=typeof r.hasBackButton>"u"||r.hasBackButton,I=Du(null),R=Du(null);return fs(()=>($r()&&R.current&&e(R.current),()=>{o()}),[]),fs(()=>(I.current?.addEventListener("scroll",ms),()=>{I.current?.removeEventListener("scroll",ms)}),[]),fs(()=>{u(l==="failed")},[l]),Be.createElement(Mu,{height:s,id:$e.SWAP_BOX_ID,className:`${h()} ${Qr()}`,ref:R},Be.createElement(UC,{prefix:$?Be.createElement(rs,{onClick:()=>{N(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!T&&Be.createElement(ss,{container:A(),onClick:W,isConnected:!!c?.length}),r.onCancel&&Be.createElement(as,{onClick:r.onCancel}))}),Be.createElement(Bu,{ref:I},n),Be.createElement(ns,{open:k,onClose:()=>v(!1),onConfirm:b}),Be.createElement(Lu,null,Be.createElement("div",{className:"footer__content"},C&&!S&&Be.createElement("div",{className:"footer__alert"},Be.createElement(ts,{onActivateTab:b}),Be.createElement(Pu,{size:10})),a),Be.createElement(Pu,{size:12}),Be.createElement("div",{className:`footer__logo ${f?"logo__show":"logo__hidden"}`},Be.createElement(OC,null))),Be.createElement(us,{open:p,onClose:()=>u(!1)}))}i(ne,"Layout");import{styled as QC}from"@rango-dev/ui";var _u="$20 $20 $10 $20",Sn=QC("div",{padding:_u,overflowY:"auto",flexGrow:1});import{styled as qC}from"@rango-dev/ui";var re=qC("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 Ho}from"@lingui/core";import{useState as $u}from"react";function Fu(){let[t,e]=$u(!1),[o,n]=$u(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Ho.t("Duplicate Token"),message:Ho.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Ho.t("Token Already Exists"),message:Ho.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Ho.t("Token Not Found"),message:Ho.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:u}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:p,tokenAddress:u})=>{e(!0);try{if(a.some(h=>h.address?.toLowerCase()===u.toLowerCase())){let h=s("duplicated");n(h);return}let m=await fetch(`${ct("BASE_URL")}/meta/token?apiKey=${ct("API_KEY")}&blockchain=${p}&address=${u}`),g=m.headers.get("content-type"),d=g&&g.includes("application/json")&&await m.json();if(!d||d.error){let h=s("not-found",p);n(h);return}if(r({blockchain:d.blockchain,address:d.address,symbol:d.symbol})){let h=s("token-exist");n(h);return}return d}catch(c){throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Fu,"useFetchCustomToken");var eT=jC("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${GC} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),tT=1e3;function Uu(){let t=JC(),[e]=RC(),o=Ye(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=nn(a,r),[l,p]=qr(""),[u,c]=qr(!1),[m,g]=qr(),{fetchCustomToken:d,loading:f,error:h}=Fu(),[T,S]=qr(""),C=!!s&&No(s,l),k=!s||!l||!C,v=i(async()=>{if(s)try{let M=await d({blockchain:a,tokenAddress:l});S(""),M&&g(M)}catch(M){M.message==="Failed to fetch"&&(S(At.t("Network Error")),c(!0))}},"getCustomToken"),x=i(()=>{h&&p(""),c(!1)},"closeErrorModal"),N=i(async()=>{T&&setTimeout(async()=>{await v()},tT),x()},"handleErrorModalButtonClick");return ZC(()=>{h&&c(!0)},[h]),Se.createElement(ne,{header:{title:At.t("Add Custom Token")}},Se.createElement(re,null,Se.createElement(eT,null,Se.createElement("div",null,Se.createElement(qa,{onClick:()=>t(D.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:At.t("Select chain"),placeholder:At.t("Select chain")}),Se.createElement(Cn,{size:"24"}),Se.createElement(YC,{size:"large",variant:"label"},At.t("Enter Address")),Se.createElement(Cn,{size:10}),Se.createElement(XC,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:At.t("Enter token address"),size:"large",value:l,suffix:!!l&&C&&Se.createElement(VC,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!C&&!!l&&Se.createElement(Se.Fragment,null,Se.createElement(Cn,{size:4}),Se.createElement(HC,{type:"error",variant:"alarm",title:"Invalid Address"}))),Se.createElement(Ou,{disabled:k,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},At.t("Import"))),Se.createElement(J,{open:u,dismissible:!0,onClose:x,container:A()},Se.createElement(KC,{title:h?.title||T,type:"error",description:h?.message||At.t("Failed Network, Please retry.")},Se.createElement(Cn,{size:40}),Se.createElement(Cn,{size:10}),Se.createElement(Ou,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:N},T?At.t("Retry"):At.t("Add another custom token")))),s&&m&&Se.createElement(Va,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),g(void 0),o())},onClose:()=>g(void 0),open:!!s&&!!m})))}i(Uu,"AddCustomTokenPage");import{i18n as qs}from"@lingui/core";import{useManager as Fk}from"@rango-dev/queue-manager-react";import{Alert as _d,Button as Ok,css as Gs,Divider as Hs,IconButton as $d,styled as Uk,Typography as zk,WalletIcon as Qk}from"@rango-dev/ui";import Ie,{useEffect as Ci,useLayoutEffect as qk,useRef as Hk,useState as Bn}from"react";import{useNavigate as Gk}from"react-router-dom";import{i18n as So}from"@lingui/core";import{Alert as fm,BalanceErrors as IT,Button as gm,ChevronLeftIcon as AT,Divider as Jr,MessageBox as NT,Typography as vs}from"@rango-dev/ui";import j,{useCallback as WT,useEffect as hm,useMemo as MT,useState as Co}from"react";import{useNavigate as BT}from"react-router-dom";import{i18n as Hr}from"@lingui/core";function Gr(t){switch(t.type){case 0:return Hr.t("Route has been updated.");case 3:return Hr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Hr.t("Route swappers has been updated.");case 2:return Hr.t("Route internal coins has been updated.");default:return""}}i(Gr,"getQuoteUpdateWarningMessage");import{i18n as Ss}from"@lingui/core";import{Alert as sT,ChevronDownIcon as lT,CloseIcon as pT,Divider as Ku,IconButton as ju,PasteIcon as cT,Typography as uT,WalletIcon as mT}from"@rango-dev/ui";import Le,{useEffect as dT,useRef as fT}from"react";import Xr,{useRef as iT}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as zu,styled as Vr}from"@rango-dev/ui";var gs=300,nT=zu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),rT=zu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Qu=Vr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),hs=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:`${nT} ${gs}ms ease-out`},false:{animation:`${rT} ${gs}ms ease-out`}}}}),jr=Vr("div",{transition:`all ${gs}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,p=iT(null);return Xr.createElement(Qu,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s),Xr.createElement(Kr,{className:"collapsible_content",open:e},r),l==="bottom"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s))}i(Yr,"CustomCollapsible");import{darkTheme as qu,styled as ys,TextField as aT}from"@rango-dev/ui";var Hu=ys("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Gu=ys(aT,{backgroundColor:"$neutral100",padding:"$15"}),Vu=ys("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${qu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${qu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Xu(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=z(),{config:s}=y(),l=y().blockchains(),p=tr(e.name,l),u=fT(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),d=n&&!!r&&e&&!No(e,r),f=i(()=>{a("")},"handleClear"),h=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),u?.current?.focus()}},"handlePaste"),T=i(()=>r?Le.createElement(ju,{onClick:f,variant:"ghost"},Le.createElement(pT,{size:12,color:"gray"})):m?null:Le.createElement(ju,{onClick:h,variant:"ghost"},Le.createElement(cT,{size:16})),"renderSuffix");return dT(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Le.createElement(Hu,null,Le.createElement(Yr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Le.createElement(Vu,null,Le.createElement("div",{className:"button__content"},Le.createElement(mT,{size:18,color:"info"}),Le.createElement(Ku,{size:4,direction:"horizontal"}),Le.createElement(uT,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ss.t("Send to a different address"))),Le.createElement(jr,{orientation:n?"up":"down"},Le.createElement(lT,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Le.createElement(Gu,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ss.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:T(),onChange:S=>{let C=S.target.value;a(C)}})),d&&Le.createElement(Le.Fragment,null,Le.createElement(Ku,{size:4}),Le.createElement(sT,{variant:"alarm",type:"error",title:Ss.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Xu,"CustomDestination");import{css as gT,darkTheme as Cs,IconButton as hT,styled as Pt}from"@rango-dev/ui";var Yu=Pt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Zu=Pt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),yT=Pt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${Cs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),Ju=Pt(yT,{alignSelf:"stretch",minHeight:"93px"}),Ru=Pt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),em=Pt(hT,{position:"absolute",left:"$20"}),tm=Pt("div",{paddingTop:"$20"}),om=gT({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),nm=Pt("div",{display:"flex"}),rm=Pt("div",{overflow:"visible",width:"100%"});import{i18n as cm}from"@lingui/core";import{warn as vT}from"@rango-dev/logging-core";import{Divider as xT,SelectableWallet as wT,Typography as um,WalletState as mm}from"@rango-dev/ui";import Ze,{useEffect as dm,useState as kn}from"react";import{Image as TT,MessageBox as kT}from"@rango-dev/ui";import Tn from"react";import{keyframes as ST,styled as Ts}from"@rango-dev/ui";var im=Ts("div",{position:"relative"}),CT=ST({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),am=Ts("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${CT} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),sm=Ts("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function lm(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(lm,"generateMessageByStatus");function pm(t){let{status:e,displayName:o,image:n}=t,r=lm(e,o),a=e=="in-progress";return Tn.createElement(kT,{type:r.type,title:r.title,description:r.description,icon:a?Tn.createElement(im,null,Tn.createElement(sm,null,Tn.createElement(TT,{src:n,size:45})),Tn.createElement(am,null)):void 0})}i(pm,"ExperimentalChainStatus");var bT=7,ET=3e3;function ks(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=se.use.isActiveTab(),l=Z.use.connectedWallets(),{blockchains:p}=y(),[u,c]=kn(),[m,g]=kn(null),[d,f]=kn(!1),[h,T]=kn(null),{suggestAndConnect:S}=Zr(),{handleDisconnect:C}=qt(),{list:k}=gt({chain:e}),[v,x]=kn(k),N=k.length,M=r&&N-r>0,w=i(async b=>{f(!1),T("in-progress");try{await S(b.walletType,b.chain),T("completed")}catch{T("rejected")}},"addExperimentalChain");dm(()=>{x(b=>{let W=k.findIndex($=>o($.type,e));return M&&W>1?[k[W]].concat(k.filter(($,I)=>I!==W)):b.map($=>k.find(I=>I.type===$.type)??$)})},[JSON.stringify(k)]);let E=document.getElementById($e.SWAP_BOX_ID);return dm(()=>{let b=null;return(h==="completed"||h==="rejected")&&(b=setTimeout(()=>T(null),ET)),()=>{b&&clearTimeout(b)}},[h]),Ze.createElement(Ze.Fragment,null,v.slice(0,r).map(b=>{let W=_p({connectedWallets:l,walletType:b.type,chain:e}),$=W?dr(W,bT):"",I=ur(p(),e),R=!l.find(le=>le.walletType===b.type&&le.chain===e),ee=I&&R&&b.state===mm.CONNECTED,oe=ee?cm.t({id:"Add {chain} chain",values:{chain:e}}):$,L=i(async()=>{b.state===mm.DISCONNECTED?c(b):b.namespaces&&!$?(await C(b.type),c(b)):ee?(g({walletType:b.type,chain:e,address:W??""}),f(!0)):n({walletType:b.type,chain:e,address:W??""})},"onSelectableWalletClick"),V=m?.chain?tr(m.chain,p()):void 0;return Ze.createElement(Ze.Fragment,{key:`${b.title}_${V}`},!!m&&Ze.createElement(J,{open:!!m&&d,container:E,onClose:()=>{g(null)}},Ze.createElement(Ea,{displayName:V,onConfirm:()=>{w(m)}})),h&&Ze.createElement(J,{open:!!h,onClose:T.bind(null,null),container:E},Ze.createElement(pm,{status:h,displayName:V,image:b.image}),Ze.createElement(xT,{direction:"vertical",size:32})),Ze.createElement(wT,{key:b.type,description:oe,onClick:L,selected:o(b.type,e),disabled:!s,...b}))}),Ze.createElement(mo,{wallet:u,onClose:()=>{c(void 0)},onConnect:b=>{t.onConnect&&b.status==="connected"&&(u?.type?t.onConnect(u.type):vT(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Ze.createElement(Ju,{selected:!1,onClick:a},Ze.createElement(um,{variant:"label",size:"medium"},cm.t("Show more wallets"),Ze.createElement(um,{variant:"label",size:"medium",color:"$primary"},"\xA0+",N-(r??0)))))}i(ks,"WalletList");var LT=2;function ym(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=BT(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:g,setCustomDestination:d}=z(),{connectedWallets:f,selectWallets:h}=Z(),{config:T}=y(),[S,C]=Co(""),[k,v]=Co([]),[x,N]=Co(""),[M,w]=Co(null),[E,b]=Co(!!g),W=MT(()=>io({filter:"all",quote:p}),[p]),$=io({filter:"required",quote:p}),I=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),R=i(_=>$.includes(_),"isWalletRequiredFor"),ee=WT(()=>f.filter(_=>_.selected&&W.includes(_.chain)),[f,W]),[oe,L]=Co(ee()),[V,le]=Co([]),Y=i((_,Q)=>le(G=>G.concat({blockchain:_,walletType:Q})),"addNextSelectedWallets"),ae=k.length>0,ge=i((_,Q)=>!!oe.find(G=>G.walletType===_&&G.chain===Q&&G.selected&&(R(Q)||!R(Q)&&!g)),"isSelected"),ve=i((_,Q,G)=>{let pe=!1;return _.map(ce=>{if(ce.chain===Q){let de=ce.selected;return!pe&&G?(pe=!0,de=!0):G||(de=!1),{...ce,selected:de}}return ce})},"updateSelectableWallets"),U=i(_=>{b(_),_?R(I?.name??"")||L(Q=>ve(Q,I?.name||"",!1)):(d(""),L(Q=>ve(Q,I?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ke=i(_=>{if(S&&C(""),ge(_.walletType,_.chain))return;let G=f.find(pe=>pe.walletType===_.walletType&&pe.chain===_.chain);G&&(n(),_.chain===I?.name&&E&&!R(I.name)&&(b(!1),d(null)),L(pe=>pe.filter(ce=>ce.chain!==_.chain).concat({...G,selected:!0})))},"onChange"),xt=i(()=>{let _=oe.filter(Q=>Q.selected);h(_),u(_),m(!0),o()},"onConfirmBalance"),lt=i(async()=>{v([]),N(""),w(null);let _=await r?.({selectedWallets:oe.filter(G=>G.selected),customDestination:g}),Q=_.warnings;Q?.balance?.messages&&v(Q.balance.messages),Q?.quoteUpdate&&w(Q.quoteUpdate),_.error&&N(Bc(_.error)),!_.error&&!Q?.balance?.messages.length?xt():v(Q?.balance?.messages??[])},"onConfirmWallets");hm(()=>{L(_=>{let Q=[];return _.forEach(G=>{!f.some(ce=>ce.chain===G.chain&&ce.walletType===G.walletType&&ce.address===G.address)||Q.push(G)}),Q=Q.concat(f.filter(G=>!!!Q.find(ce=>ce.chain===G.chain)&&G.selected&&W.includes(G.chain))),Q})},[f,W]),hm(()=>{let _=[];V.length>0&&(V.forEach(Q=>{let G=f.find(pe=>pe.chain===Q.blockchain&&pe.walletType===Q.walletType);G?Ke(G):_.push(Q)}),le(_))},[f,V]);let wt=document.getElementById($e.SWAP_BOX_ID);return j.createElement(J,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:wt,...!S&&{styles:{container:{height:"100%"}},footer:j.createElement(nm,null,j.createElement(gm,{loading:a,disabled:Yc(a,E,g,p,oe,I),onClick:lt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},So.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:j.createElement(Ru,null,j.createElement(em,{variant:"ghost",onClick:C.bind(null,"")},j.createElement(AT,{size:16})),j.createElement(vs,{variant:"headline",size:"small"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:pt(S,l)}})))},anchor:"center"},j.createElement(J,{open:ae,onClose:v.bind(null,[]),container:wt},j.createElement(NT,{title:So.t("Insufficient account balance"),type:"error",description:j.createElement(IT,{messages:k??[]})},j.createElement(gm,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:xt},So.t("Proceed anyway")))),S&&j.createElement(tm,null,j.createElement("div",{className:om()},j.createElement(ks,{chain:S,isSelected:ge,selectWallet:Ke,onShowMore:()=>C(S),onConnect:_=>{Y(S,_)}}))),!S&&j.createElement(j.Fragment,null,x&&j.createElement(j.Fragment,null,j.createElement(fm,{variant:"alarm",type:"error",title:So.t(x)}),j.createElement(Jr,{size:12})),M&&j.createElement(j.Fragment,null,j.createElement(fm,{variant:"alarm",type:"warning",title:Gr(M)}),j.createElement(Jr,{size:12})),j.createElement(rm,null,W.map((_,Q)=>{let G=l.find(he=>he.name===_),pe=`wallet-${Q}`,ce=Q===W.length-1,de=ce&&I&&T?.customDestination!==!1;return j.createElement("div",{key:pe},j.createElement(Yu,null,j.createElement(vs,{variant:"title",size:"xmedium"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:G?.shortName}})),j.createElement(vs,{variant:"label",color:"$neutral700",size:"medium"},So.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:G?.shortName}}))),j.createElement(Jr,{size:24}),j.createElement(Zu,null,j.createElement(ks,{chain:_,isSelected:ge,selectWallet:Ke,limit:LT,onShowMore:()=>C(G?.name??""),onConnect:he=>{Y(_,he)}})),!ce&&j.createElement(Jr,{size:32}),de&&j.createElement(Xu,{blockchain:I,open:E,handleOpenChange:U}))}))))}i(ym,"ConfirmWalletsModal");import{i18n as JT}from"@lingui/core";import{Alert as RT,Button as ek,InfoIcon as tk}from"@rango-dev/ui";import ot from"react";import{Alert as _T,Button as $T,Divider as bs,NoRouteIcon as FT,RefreshIcon as OT,Typography as wm}from"@rango-dev/ui";import tt from"react";import{i18n as Sm}from"@lingui/core";var PT=24,DT=60;function Cm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:te().genericServerError,action:{onClick:n,title:Sm.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:te().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Sm.t("Reset")}},description:te().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:te().noResultError.description}}i(Cm,"makeInfo");var xs=(o=>(o[o.small=PT]="small",o[o.large=DT]="large",o))(xs||{}),ws=(o=>(o.small="small",o.large="medium",o))(ws||{});import{styled as Rr}from"@rango-dev/ui";var Tm=Rr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),km=Rr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),vm=Rr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),xm=Rr("div",{padding:"$6 $0"});function vn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Cm(o,r,()=>a(s,!0),e);return tt.createElement(Tm,null,tt.createElement(FT,{size:xs[n],color:"gray"}),tt.createElement(bs,{size:4}),tt.createElement(wm,{variant:"title",size:ws[n]},te().noResultError.title),n==="large"&&tt.createElement(bs,{size:4}),!!l.description&&tt.createElement(km,{size:n},tt.createElement(wm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),tt.createElement(bs,{size:n==="large"?"24":"4"}),!!l.alert&&tt.createElement(vm,{size:n},tt.createElement(_T,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&tt.createElement($T,{size:"xsmall",type:l.alert.type,prefix:tt.createElement(xm,null,tt.createElement(OT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(vn,"NoResult");import{i18n as xn}from"@lingui/core";import{Button as zT,Divider as QT,MessageBox as qT,Typography as HT,WarningIcon as GT}from"@rango-dev/ui";import Dt from"react";import{Typography as Am}from"@rango-dev/ui";import Is from"react";import{darkTheme as UT,styled as ei}from"@rango-dev/ui";var bm=ei("div",{width:"100%"}),Es=ei("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Em=ei("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${UT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Im=ei("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Nm(t){let{title:e,value:o,valueColor:n}=t;return Is.createElement(Em,null,Is.createElement(Am,{size:"medium",variant:"label",className:"_title"},e),Is.createElement(Am,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Nm,"QuoteErrorsModalItem");function Wm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:xn.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:xn.t("Gas cost"),value:B(r.totalFee,2,2)},{title:xn.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:xn.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return Dt.createElement(J,{footer:Dt.createElement(zT,{type:"primary",size:"large",prefix:Dt.createElement(GT,null),fullWidth:!0,disabled:a,onClick:n},te().highValueLossError.confirmMessage),open:e,onClose:o,container:A()},Dt.createElement(qT,{type:s,title:te().highValueLossError.impactTitle,description:te().highValueLossError.description}),Dt.createElement(Es,null,Dt.createElement(QT,{size:"4"}),Dt.createElement(HT,{size:"small",variant:"title"},xn.t("Details")),Dt.createElement(Es,null,l.map((p,u)=>Dt.createElement(Nm,{key:u,...p})))))}i(Wm,"HighValueLossWarningModal");import{i18n as As}from"@lingui/core";function Mm(t,e){let o={alertType:"warning",title:"",action:null};return e?(o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=As.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o):t?(t.type===0&&(Lt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=te().highValueLossError.title),t.type===1&&(o.title=te().unknownPriceError.title),t.type===2&&(o.title=As.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings"),t.type===3&&(o.title=As.t("Caution, your slippage is high."),o.action="change-settings"),o):null}i(Mm,"makeAlerts");import{i18n as Ko}from"@lingui/core";import{Button as Bm,Divider as Lm,MessageBox as VT,Typography as KT}from"@rango-dev/ui";import To from"react";import{useNavigate as jT}from"react-router-dom";function Pm(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=jT(),u=e??o;return To.createElement(J,{anchor:"bottom",open:n,prefix:To.createElement(Bm,{size:"small",variant:"ghost",onClick:()=>p("../"+D.settings)},To.createElement(KT,{variant:"label",size:"medium",color:"$neutral900"},Ko.t("Change settings"))),container:A(),onClose:r},To.createElement(VT,{type:"warning",title:s.type===3?Ko.t("High slippage"):Ko.t("Low slippage"),description:s.type===3?Ko.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Ko.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},To.createElement(Lm,{size:18}),To.createElement(Lm,{size:32}),To.createElement(Bm,{size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Ko.t("Confirm anyway"))))}i(Pm,"SlippageWarningModal");import{Button as XT,MessageBox as YT,WarningIcon as ZT}from"@rango-dev/ui";import ti from"react";function Dm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ti.createElement(J,{footer:ti.createElement(XT,{type:"primary",size:"large",prefix:ti.createElement(ZT,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:A()},ti.createElement(YT,{type:"warning",title:te().unknownPriceError.impactTitle,description:te().unknownPriceError.description}))}i(Dm,"UnknownPriceWarningModal");function wn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,d=Mm(e,o?.type===3||o?.type===4?o:null);return d&&!n&&(d.action=null),ot.createElement(ot.Fragment,null,g&&ot.createElement(vn,{error:o,fetch:s}),!!d&&ot.createElement(bm,null,ot.createElement(RT,{title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:ot.createElement(Im,{onClick:l},ot.createElement(tk,{size:12,color:"gray"}))},...d.action==="change-settings"&&{action:ot.createElement(ek,{size:"xxsmall",type:d.alertType,onClick:c},JT.t("Change"))}})),e&&ot.createElement(ot.Fragment,null,e.type===0&&ot.createElement(Wm,{...m,warning:e}),(e.type===3||e.type===2)&&ot.createElement(Pm,{...m,warning:e}),e.type===1&&ot.createElement(Dm,{...m,warning:e})))}i(wn,"QuoteWarningsAndErrors");import Bk from"bignumber.js";import gi from"react";import{i18n as ko}from"@lingui/core";import{Alert as Ck,Divider as Xo,FullExpandedQuote as Tk,InfoIcon as kk,NumericTooltip as fd,QuoteTag as vk,StepDetails as xk,TokenAmount as wk,Typography as Yo}from"@rango-dev/ui";import _s from"bignumber.js";import F,{useRef as bk,useState as Ek}from"react";import{styled as Ns}from"@rango-dev/ui";var Ws=Ns("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),_m=Ns("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),$m=Ns("div",{width:"100%",display:"flex"});import*as oi from"@radix-ui/react-collapsible";import{Button as ok,css as bn,darkTheme as be,Image as Fm,styled as qe,Typography as nk}from"@rango-dev/ui";var rk=300,Om=qe(oi.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${be} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Um=bn({padding:"$10 $15"}),zm=qe(ok,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${be} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${be} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${be} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),Qm=qe("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",[`.${be} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${be} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${be} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${be} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${be} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${be} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${be} &`]:{backgroundColor:"$neutral400"}}}}]}),qm=bn({width:"100%",padding:"$15 $15 $10 $15"}),Hm=bn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),jo=bn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Gm=bn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${be} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Vm=qe(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:{[`& ${Fm}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Fm}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${be} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),Km=qe("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"}}}}),jm=qe(Kr,{width:"100%",background:"inherit"}),Ms=qe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${rk}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),l1=qe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),Xm=qe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${be} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Ym=qe("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Bs=qe(nk,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),Zm=qe("div",{display:"flex",flexWrap:"wrap"}),Ls=qe("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"}}}}),Jm=qe("div",{display:"flex"}),ni=qe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${be} &`]:{borderTopColor:"$neutral800"}});import{i18n as Nt}from"@lingui/core";import{ChevronDownIcon as ak,CloseIcon as sk,Divider as ai,IconButton as lk,NumericTooltip as pk,QuoteCost as ck,Typography as St}from"@rango-dev/ui";import X,{useState as od}from"react";import{css as ik,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"}}),Ps=ri("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Rm=ri("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),ed=ri("div",{padding:"$20 $20 $10",textAlign:"center",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),td=ik({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var uk=i(t=>t.fee.isZero()?null:X.createElement(ii,null,X.createElement(St,{variant:"label",size:"medium",color:"neutral600"},t.label),X.createElement(St,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function nd(t){let[e,o]=od(!1),[n,r]=od(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,showModalFee:c}=t,m=s?.swaps??[],g=A(),d=Fc(m);return X.createElement(X.Fragment,null,X.createElement(ck,{onClickFee:c?f=>{f.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,time:p,steps:a,tooltipGas:c?Nt.t("View more info"):void 0,tooltipContainer:g}),X.createElement(J,{container:g,open:e,header:X.createElement(ed,null,X.createElement(St,{variant:"title",size:"medium"},Nt.t("Gas & Fee Explanation")),X.createElement(lk,{onClick:()=>o(!1),variant:"ghost"},X.createElement(sk,{color:"gray",size:14}))),onClose:()=>{o(!1)}},X.createElement(Rm,null,X.createElement(St,{variant:"title",size:"small"},Nt.t("Details")),X.createElement(ai,{size:10}),Object.entries(d.payable).flatMap(([f,h])=>h.map((T,S)=>{let C=`payable-fee-${S}`,k=La(T);return X.createElement(ii,{key:C},X.createElement(St,{variant:"label",size:"medium",color:"neutral600"},Na(f,Nt.t)),X.createElement(pk,{content:T.amount,container:g},X.createElement(St,{variant:"label",size:"medium"},B(T.amount,2,2)," ",T.asset.symbol," ($",B(k,4,4),")")))})),X.createElement(ii,{className:"total_payable_fee"},X.createElement(St,{variant:"label",size:"medium"},Nt.t("Total Payable Fee")),X.createElement(St,{variant:"label",size:"medium"},"$",B(l,4,4))),X.createElement(Ps,null),Object.keys(d.nonePayable).length&&X.createElement(Yr,{triggerAnchor:"bottom",onClickTrigger:()=>r(f=>!f),trigger:X.createElement("div",{className:td()},X.createElement(St,{size:"small",variant:"body",color:"neutral700"},n?Nt.t("Hide non-payable fees"):Nt.t("Show non-payable fees")),X.createElement(ai,{size:4,direction:"horizontal"}),X.createElement(jr,{orientation:n?"up":"down"},X.createElement(ak,{size:12,color:"gray"}))),open:n},X.createElement(St,{size:"small",variant:"title"},Nt.t("Description")),X.createElement(ai,{size:4}),X.createElement(St,{size:"small",variant:"body",color:"neutral700"},Nt.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),X.createElement(ai,{size:10}),Object.entries(d.nonePayable).map(([f,h],T)=>{let S=$c(h),C=Na(f,Nt.t),k=`non-payable-fee-${T}`;return X.createElement(uk,{key:k,fee:S,label:C})}),X.createElement(Ps,null)))))}i(nd,"QuoteCostDetails");import{i18n as ad}from"@lingui/core";import{TokenAmount as sd}from"@rango-dev/ui";import si from"react";import{css as mk,styled as dk}from"@rango-dev/ui";var rd=dk("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),id=mk({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function En(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return si.createElement(rd,null,si.createElement(sd,{direction:"horizontal",label:ad.t("Swap input"),type:"input",tooltipContainer:A(),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:id()}),si.createElement(sd,{direction:"horizontal",tooltipContainer:A(),label:ad.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(En,"QuoteSummary");import{i18n as md}from"@lingui/core";import{ChevronDownIcon as hk,ChevronRightIcon as yk,Divider as Ds,Image as Sk,Tooltip as mi,Typography as pi}from"@rango-dev/ui";import O from"react";import{useLayoutEffect as fk,useState as In}from"react";var ld=480,pd=768,cd=1024,ud=1200,gk=i(()=>{let[t,e]=In(!1),[o,n]=In(!1),[r,a]=In(!1),[s,l]=In(!1),[p,u]=In(!1),c=i(()=>{e(window.innerWidth<=ld),n(window.innerWidth>ld&&window.innerWidth<=pd),a(window.innerWidth>pd&&window.innerWidth<=cd),l(window.innerWidth>cd&&window.innerWidth<=ud),u(window.innerWidth>ud)},"handleResize");return fk(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),li=gk;var ci=4,ui=6,An=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||A();return O.createElement(mi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},O.createElement(Km,{className:n,state:a},O.createElement(Sk,{src:o,size:16})))},"ImageComponent");function dd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||A(),u=r.length,c=tu(r),{isTablet:m,isMobile:g}=li();return O.createElement(Vm,{listItem:s==="list-item",ref:d=>e.current=d,selected:o,onClick:d=>{d.stopPropagation(),n(f=>!f)}},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},md.t("Via:")),O.createElement(Ds,{direction:"horizontal",size:4}),r.map((d,f)=>{let h=`item-${f}`,T=O.createElement(Ms,null,O.createElement(yk,{size:12,color:"black"}));return g||m?O.createElement(O.Fragment,{key:h},O.createElement(An,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&O.createElement(O.Fragment,null,T)):O.createElement(O.Fragment,{key:h},u<=ci||u>ci&&f<ci-1?O.createElement(O.Fragment,null,O.createElement(An,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&O.createElement(O.Fragment,null,T)):f===ci-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},T,r.map((S,C)=>{let k=`image-${C}`;return C>=f&&O.createElement(O.Fragment,{key:k},O.createElement(An,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),C!==u-1&&O.createElement(O.Fragment,null,T))}))},O.createElement(Ls,{state:r.find((S,C)=>C>=f&&(S.state==="error"||S.state==="warning"))?.state},O.createElement(pi,{size:"xsmall",variant:"body"},"+",u-f))))})),O.createElement("div",{className:jo()},O.createElement("div",{className:"blockchains_section"},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},md.t("Chains:")),O.createElement(Ds,{direction:"horizontal",size:4}),c.map((d,f)=>O.createElement(O.Fragment,{key:d.displayName},c.length<=ui||c.length>ui&&f<ui-1?O.createElement(mi,{container:p,side:"bottom",content:d.displayName,sideOffset:4},O.createElement(An,{content:"",src:d.image,open:!1,className:f!==0?"blockchainImage":""})):f===ui-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},c.map((h,T)=>T>=f&&O.createElement(An,{key:h.displayName,content:"",src:h.image,open:!1,className:T>f?"blockchainImage":"",container:l})))},O.createElement(Ls,{className:"blockchainImage"},O.createElement(pi,{size:"xsmall",variant:"body"},"+",c.length-f))))),O.createElement(Ds,{direction:"horizontal",size:32}))),O.createElement(Ms,{orientation:a?"up":"down"},O.createElement(hk,{size:12,color:"black"}))))}i(dd,"QuoteTrigger");function $s(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:g}=t,d=y().blockchains(),{findToken:f}=y(),h=y().swappers(),{customSlippage:T,slippage:S}=y(),C=T||S,[k,v]=Ek(t.expanded),x=bk(null),N=B(o.value,6,6),M=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",E=ut(o.usdValue,n.usdValue??null),b=B(E,2,2),W=Lt(E??0),$=i((ge,ve)=>ge.map((U,Ke)=>{let xt,lt=r?.type===3&&r.swap.swapperId===U.swapperId,wt=r?.type===4&&r.recommendedSlippages?.has(Ke),_=a?.type===2&&a.recommendedSlippages?.has(Ke),Q=lt||wt,G=_;Q?xt="error":G&&(xt="warning");let pe=Q?ko.t("Slippage Error"):ko.t("Slippage Warning");return lt&&(pe=ko.t("Bridge Limit Error")),{swapper:{displayName:on(U.swapperId,h)??"",image:U.swapperLogo},from:{token:{displayName:U.from.symbol,image:U.from.logo},chain:{displayName:pt(U.from.blockchain,d)??"",image:U.from.blockchainLogo},price:{value:Ke===0&&!ve?B(o.value,6,6):B(U.fromAmount,6,6),usdValue:B((U.from.usdPrice??0)*parseFloat(U.fromAmount),4,4),realValue:Ke===0?o.value:U.fromAmount,realUsdValue:new _s(U.from.usdPrice??0).multipliedBy(U.fromAmount).toString()}},to:{token:{displayName:U.to.symbol,image:U.to.logo},chain:{displayName:pt(U.to.blockchain,d)||"",image:U.to.blockchainLogo},price:{value:B(U.toAmount,6,6),usdValue:B((U.to.usdPrice??0)*parseFloat(U.toAmount),4,4),realValue:U.toAmount,realUsdValue:new _s(U.to.usdPrice??0).multipliedBy(U.toAmount).toString()}},state:xt,alerts:Q||G?F.createElement(_m,{dense:m},F.createElement(Ck,{variant:"alarm",type:Q?"error":"warning",title:pe,footer:F.createElement($m,null,lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},ko.t({id:"Yours: {amount} {symbol}",values:{amount:B(U.fromAmount,6,6),symbol:U?.from.symbol}}))),(wt||_)&&!lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},ko.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(Ke)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(Ke)}}})),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},ko.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:sn(U.estimatedTimeInSeconds),fee:B(Ba(U,f),2,2),internalSwaps:U.internalSwaps?$(U.internalSwaps):void 0}}),"getQuoteSteps"),I=$(e?.swaps??[]),R=I.length,ee=g||A(),oe=nu(t.quote.tags||[]),L=!!c,V=sn(ar(e?.swaps)),le=Wr(e?.swaps??[],f),Y=B(le,2,2),ae=le.gte(new _s(Mc));return m?F.createElement(Tk,{selected:l,fee:Y,time:V,tooltipContainer:an(),steps:I,tags:oe,feeWarning:ae,percentageChange:b,warningLevel:W,outputPrice:{value:M,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(Qm,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:qm()},!p&&oe.length?F.createElement(F.Fragment,null,F.createElement(Jm,null,oe.map((ge,ve)=>{let U=`${ge.value}_${ve}`;return F.createElement(F.Fragment,{key:U},F.createElement(vk,{label:ge.label,value:ge.value}),F.createElement(Xo,{size:4,direction:"horizontal"}))})),F.createElement(ni,null),!L&&F.createElement(Xo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Hm()},F.createElement(nd,{quote:e,time:V,fee:Y,feeWarning:ae,showModalFee:u,steps:R}),L&&F.createElement(zm,{onClick:ge=>{ge.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Yo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},ko.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Gm()},F.createElement(Ym,null,F.createElement(kk,{size:12,color:"gray"})),F.createElement(Zm,null,F.createElement(Bs,{size:"small",variant:"body"},`${N} ${I[0].from.token.displayName} = `),F.createElement(fd,{content:n.value,container:ee,open:n.value?void 0:!1},F.createElement(Bs,{size:"small",variant:"body"},"\xA0",`${M} ${I[I.length-1].to.token.displayName}`))),F.createElement(fd,{content:n.usdValue,container:ee},F.createElement(Xo,{size:2,direction:"horizontal"}),F.createElement(Yo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(wk,{tooltipContainer:ee,type:"output",direction:"vertical",price:{value:M,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:I[R-1].to.token.displayName,image:I[R-1].to.token.image},chain:{image:I[R-1].to.chain.image},percentageChange:b,warningLevel:W}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(En,{from:I[0].from,to:I[R-1].to,percentageChange:b,warningLevel:W}),F.createElement(Xo,{size:4}))),F.createElement(Om,{selected:l,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:v},F.createElement(dd,{type:s,quoteRef:x,selected:l,setExpanded:v,container:ee,expanded:k,steps:I}),F.createElement(jm,{open:k},F.createElement(Xm,null),F.createElement("div",{className:Um()},I.map((ge,ve)=>{let U=`item-${ve}`;return F.createElement(xk,{type:"quote-details",key:U,tooltipContainer:ee,step:ge,hasSeparator:ve!==I.length-1,state:ge.state})})))))}i($s,"Quote");import{Divider as Wk,Skeleton as Mk}from"@rango-dev/ui";import $t from"react";import{darkTheme as Ik,styled as di}from"@rango-dev/ui";var gd=di("div",{$$color:"$colors$neutral100",[`.${Ik} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),hd=di("div",{paddingTop:"$2"}),yd=di("div",{paddingLeft:"$8"}),Sd=di("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Ad,Divider as Ct,Skeleton as nt}from"@rango-dev/ui";import q from"react";import{css as Ak,styled as _t}from"@rango-dev/ui";var Fs=_t("div",{display:"flex"}),Cd=_t("div",{padding:"$10 $0 $20"}),Td=_t("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),kd=_t("div",{display:"flex",justifyContent:"start",alignItems:"center"}),vd=_t("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),xd=_t("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),wd=_t("div",{width:"65%",display:"flex",justifyContent:"start"}),bd=_t("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Ed=_t("div",{padding:"$15 $0 $15 $0"}),Id=Ak({display:"flex",justifyContent:"space-between",alignItems:"center"});function Nn(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(vd,null,q.createElement(wd,null,q.createElement(Ad,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(Ct,{size:8,direction:"horizontal"}),q.createElement(bd,null,q.createElement(nt,{height:10,width:60,variant:"rounded"}),q.createElement(Ct,{size:4}),q.createElement(nt,{height:15,variant:"rounded"}))),q.createElement(nt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return q.createElement("div",null,!o&&q.createElement(q.Fragment,null,q.createElement(Fs,null,q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(Ct,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(Ct,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"})),q.createElement(ni,null),!r&&q.createElement(Ct,{size:4})),q.createElement("div",{className:Id()},q.createElement(Fs,null,q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(Ct,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(Ct,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"})),r&&q.createElement(nt,{width:85,height:24,variant:"rounded"})),e==="basic"&&q.createElement(Cd,null,q.createElement(nt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&q.createElement(Td,null,q.createElement(kd,null,q.createElement(Ad,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(Ct,{direction:"horizontal",size:4}),q.createElement(nt,{height:15,width:150,variant:"rounded"})),q.createElement(Ct,{size:10}),q.createElement(nt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&q.createElement(q.Fragment,null,q.createElement(Ct,{size:4}),q.createElement(Ed,null,n,q.createElement(xd,null),n),q.createElement(Ct,{size:12})))}i(Nn,"QuoteSummarySkeleton");import{ChainToken as Ld,Divider as Us,NextIcon as Nk,Skeleton as fi}from"@rango-dev/ui";import Ee from"react";import{styled as Wn}from"@rango-dev/ui";var Nd=Wn("div",{display:"flex",alignItems:"start"}),Wd=Wn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Os=Wn("div",{display:"flex",alignItems:"center",flexGrow:1}),Md=Wn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Bd=Wn("div",{display:"flex",alignItems:"center"});function Wt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Bd,null,Ee.createElement(fi,{height:22,width:22,variant:"circular"}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:15,width:148,variant:"rounded"})),Ee.createElement(Nd,null,Ee.createElement(Sd,{hideSeparator:!e}),Ee.createElement(Wd,{extraSpace:e},Ee.createElement(Os,null,Ee.createElement(Ld,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:12,variant:"rounded"})),Ee.createElement(Md,null,Ee.createElement(Nk,{color:"gray",size:16})),Ee.createElement(Os,null,Ee.createElement(Ld,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:12,variant:"rounded"})))))}i(Wt,"StepSkeleton");function Mn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return $t.createElement(gd,{expanded:o,rounded:e!=="basic"},$t.createElement(Nn,{type:e,tagHidden:n}),$t.createElement(hd,null,$t.createElement(Mk,{height:15,variant:"rounded"})),o&&$t.createElement(yd,null,$t.createElement(Wk,{size:24}),$t.createElement(Wt,null),$t.createElement(Wt,null),$t.createElement(Wt,{separator:!1})))}i(Mn,"QuoteSkeleton");function vo(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:p,showModalFee:u,selected:c,onClickAllRoutes:m,fullExpandedMode:g=!1,container:d}=t,{inputAmount:f,inputUsdValue:h,toToken:T}=z(),S=e?.outputAmount?new Bk(e?.outputAmount):null,C=e?.outputAmount?jt(e?.outputAmount,go(e)||T?.usdPrice):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?gi.createElement(Ws,null,gi.createElement(Mn,{tagHidden:l,type:o,expanded:s})):v?gi.createElement(Ws,{onClick:()=>p?.(e)},gi.createElement($s,{quote:e,error:r,container:d,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:g,input:{value:f,usdValue:h?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(vo,"QuoteInfo");import{calculatePendingSwap as _k}from"@rango-dev/queue-manager-rango-preset";import{useEffect as $k}from"react";import{useRef as Lk,useState as Pk}from"react";var Dk=2e3;function hi({request:t}){let[e,o]=Pk(!1),n=Lk(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,Dk)),await s(l,!1)),"retryFetch"),s=i(async(l,p=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(p)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(hi,"useFetch");function Pd(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Ht().confirmRouteRequest(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Pd,"useFetchConfirmQuote");function yi(t){if(!t.swaps)throw new Error(te().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=zs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(yi,"throwErrorIfResponseIsNotValid");function zs(t){if(Pc(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=Dc(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Oc(t);if(o){let n=Mr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(zs,"getQuoteError");function Dd(t,e,o){let n=!1;t&&(n=eu(t,e));let r={quote:null,quoteUpdate:null,balance:null},a=Fo(e,{fromToken:o.fromToken,toToken:o.toToken,findToken:o.findToken,userSlippage:o.userSlippage});a&&(r.quote=a),t&&n&&(Gc(t,e)?r.quoteUpdate={type:3,newOutputAmount:B($o(e)),percentageChange:B(ut($o(t)??"",$o(e)??""),null,2)}:Pa(t,e)?r.quoteUpdate={type:0}:Da(t,e)?r.quoteUpdate={type:1}:_a(t,e)&&(r.quoteUpdate={type:2}));let s=Vc(e,o.selectedWallets,o.meta.blockchains);return s.length===0||(r.balance={messages:s}),r}i(Dd,"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}:{swap:null,error:{type:1},warnings:null}}i(Si,"handleQuoteErrors");function Qs(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=z(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),g=y().tokens(),{findToken:d}=y(),f=u||p,{fetch:h,cancelFetch:T,loading:S}=Pd();return $k(()=>T,[]),{loading:S,fetch:i(async k=>{let v=k.selectedWallets,x=k?.customDestination??a;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=v.reduce((w,E)=>(w[E.chain]=E.address,w),{}),M={requestId:r?.requestId||"",selectedWallets:N,destination:x||void 0};try{return await h(M,!0).then(w=>{let{result:E}=w;yi({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let b={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};n(b);let W={slippage:f.toString(),disabledSwappersGroups:c},$=Dd(r??void 0,b,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:d,selectedWallets:v,userSlippage:f});$.quoteUpdate&&s(!1),l();let I=!!$.balance,R=_k(o.toString(),E,qc(v),W,!I,{blockchains:m,tokens:g});return{quote:b,swap:R,error:null,warnings:$}})}catch(w){return Si(w)}},"fetch"),cancelFetch:T}}i(Qs,"useConfirmSwap");var Vk=Uk("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${$d}`]:{width:"$48",height:"$48"}}),Kk=Gs({flexGrow:1,paddingRight:"$10"}),jk=Gs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Xk=Gs({display:"flex",justifyContent:"space-between",alignItems:"center"});function Fd(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=z(),s=Gk(),[l,p]=Bn(""),u=!n,[c,m]=Bn(!1),[g,d]=Bn(!1),{isActiveTab:f}=se(),h=y().getDisabledLiquiditySources(),T=Hk(h),{manager:S}=Fk(),{fetch:C,loading:k,cancelFetch:v}=Qs(),[x,N]=Bn({swap:null,error:null,warnings:null}),[M,w]=Bn(!1),E=i(async({selectedWallets:L,customDestination:V})=>{let le=await C?.({selectedWallets:L,customDestination:V});return N(le),le},"onConfirmSwap"),b=i(async()=>{if(x.swap&&n)try{await S?.create("swap",{swapDetails:x.swap},{id:x.swap.requestId});let L=`../${D.swaps}/${x.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){p("Error: "+L?.message)}},"addNewSwap"),W=i(async()=>{d(!0),await b(),d(!1)},"onConfirm"),$=i(async()=>{x?.warnings?.quote&&!a?w(!0):await W()},"onStartConfirmSwap"),I=i(async()=>{N({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(L=>{N(L)}).catch(L=>console.error(L))},"onRefresh");Ci(()=>{!!T.current.length&&!h.length&&I(),T.current=h},[h.length]),Ci(()=>{u&&v()},[u]),Ci(()=>{u&&m(u)},[u]),Ci(()=>{u||C({selectedWallets:o,customDestination:r}).then(L=>N(L)).catch(L=>console.error(L))},[]),qk(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let R=x.warnings?.quote??null,ee=x.error,oe=[];if(l&&oe.push(Ie.createElement(_d,{type:"error",variant:"alarm",title:l})),x.warnings?.quoteUpdate&&oe.push(Ie.createElement(_d,{variant:"alarm",type:"warning",title:x.warnings.quoteUpdate&&Gr(x.warnings.quoteUpdate)})),R||ee){let L=`../${D.settings}`;oe.push(Ie.createElement(wn,{warning:R,error:ee,couldChangeSettings:!1,refetchQuote:I,showWarningModal:M,confirmationDisabled:!f,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await b()},onChangeSettings:()=>s(L)}))}return Ie.createElement(ne,{header:{title:qs.t("Confirm Swap"),onWallet:()=>{let L=`../${D.wallets}`;s(L)}},footer:Ie.createElement(Vk,null,Ie.createElement("div",{className:Kk()},Ie.createElement(Ok,{variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||g,disabled:!!x.error||!f,onClick:$},qs.t("Start Swap"))),Ie.createElement($d,{variant:"contained",type:"primary",size:"large",loading:k||g,disabled:!f,onClick:m.bind(null,!0)},Ie.createElement(Qk,{size:24})))},c&&Ie.createElement(ym,{open:c,onClose:()=>m(!1),onCancel:v,loading:k,onCheckBalance:E}),Ie.createElement(re,null,Ie.createElement("div",{className:Xk()},Ie.createElement(zk,{variant:"title",size:"small"},qs.t("You get")),Ie.createElement("div",{className:jk()},Ie.createElement(Or,{onClick:!k&&!c&&!M?I:void 0}))),Ie.createElement(Hs,{size:"12"}),yu(oe.map((L,V)=>({element:L,key:`alert-${V}`})),Ie.createElement(Hs,{size:10})),oe.length>0?Ie.createElement(Hs,{size:10}):null,Ie.createElement(vo,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:x.error,loading:k,warning:x.warnings?.quote??null})))}i(Fd,"ConfirmSwapPage");import{i18n as Ft}from"@lingui/core";import{Button as rl,CustomTokensZeroStateDarkIcon as fv,CustomTokensZeroStateIcon as gv,DeleteIcon as hv,Divider as _n,IconButton as yv,MessageBox as Sv,NotFound as Cv,styled as al}from"@rango-dev/ui";import fe,{useState as il}from"react";import{useNavigate as Tv}from"react-router-dom";import{CloseIcon as Zk,IconButton as Jk,SearchIcon as Rk,TextField as ev}from"@rango-dev/ui";import Ln from"react";import{styled as Yk}from"@rango-dev/ui";var Od=Yk("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Tt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return Ln.createElement(ev,{prefix:Ln.createElement(Od,null,Ln.createElement(Rk,{color:"black"})),suffix:!!s.length&&Ln.createElement(Jk,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Ln.createElement(Zk,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Tt,"SearchInput");import{i18n as ol}from"@lingui/core";import{darkTheme as Yd,Divider as Jo,ExternalLinkIcon as sv,Image as lv,ListItemButton as pv,NotFound as cv,PinIcon as uv,Skeleton as Zd,Typography as vi,VirtualizedList as mv}from"@rango-dev/ui";import H,{useEffect as Jd,useState as Rd}from"react";import{useWallets as tv}from"@rango-dev/wallets-react";import{useEffect as ov,useRef as nv,useState as rv}from"react";function Vs(t){let{connectedWallets:e}=Z(),{getWalletInfo:o}=tv(),n=nv([]),[r,a]=rv(0);return ov(()=>{let s=i(p=>{p.type==="disconnect"&&o(p.payload.walletType).supportedChains.some(m=>m.name===t)&&a(m=>m+1)},"handleWalletEvent");return yr.on("walletEvent",s),t?(e.filter(p=>p.chain===t).forEach(p=>{let{walletType:u}=p,c=n.current.includes(u);p.loading&&!c?n.current=n.current.concat(u):!p.loading&&c&&(n.current=n.current.filter(m=>m!==u),a(m=>m+1))}),()=>yr.off("walletEvent",s)):a(p=>p+1)},[e,t,o]),{balanceKey:r}}i(Vs,"useObserveBalanceChanges");import{Divider as jd,ListItem as av,Skeleton as Pn}from"@rango-dev/ui";import kt from"react";import{css as Zo,darkTheme as Ud,ImageContainer as iv,styled as dt,Typography as zd}from"@rango-dev/ui";var Ks=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),js=Zo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Xs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Ys=Zo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Ud} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Zs=Zo({}),Js=Zo(),Qd=dt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Rs=dt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ti=dt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${js}`]:{[`& .${Ys}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Zs}`]:{bottom:"-15px"},[`& .${Ks}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Xs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),el=dt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),tl=dt(zd,{}),qd=dt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Js}`]:{$$color:"$colors$neutral600",[`.${Ud} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ki=dt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),dU=dt("div",{display:"flex",alignItems:"center"}),Hd=dt("div",{position:"relative",[`& ${iv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Gd=dt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Vd=dt(zd,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Kd=dt("a",{"& svg:hover":{color:"$colors$info"}});function Xd(t){return kt.createElement(Ti,null,Array.from(Array(t.size),e=>kt.createElement(av,{key:e,hasDivider:!0,start:kt.createElement(Pn,{variant:"circular",width:35,height:35}),end:kt.createElement(ki,null,kt.createElement(Pn,{variant:"text",size:"large",width:70}),kt.createElement(jd,{size:4}),kt.createElement(Pn,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Pn,{variant:"text",size:"large",width:90}),kt.createElement(jd,{size:4}),kt.createElement(Pn,{variant:"text",size:"medium",width:90}))})))}i(Xd,"LoadingTokenList");var nl=20,dv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:js()},o?H.createElement("div",{className:Ks()},o):H.createElement(Rs,{className:Xs()},H.createElement(vi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:a},H.createElement(tl,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Ys()} ${!o&&Zs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Jo,{size:4,direction:"horizontal"}),H.createElement(Kd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},H.createElement(sv,{size:12}))))},"renderDesc");function Dn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,[l,p]=Rd(e),u=y().fetchStatus,c=y().blockchains(),[m,g]=Rd(!0),{getBalanceFor:d,loading:f}=Z(),{isTokenPinned:h}=y(),{balanceKey:T}=Vs(r),S=i(()=>{p(e.slice(0,l.length+nl))},"loadNextPage");Jd(()=>{g(e.length>l.length)},[l.length]),Jd(()=>{p(e.slice(0,nl))},[e.length,r,T]);let C=i(v=>{let x=mr(d(v));return s?s(v):f?H.createElement(ki,null,H.createElement(Zd,{variant:"text",size:"large",width:70}),H.createElement(Jo,{size:4}),H.createElement(Zd,{variant:"text",size:"medium",width:50})):x&&H.createElement(qd,null,H.createElement(Vd,{variant:"title",size:"small"},x.amount),H.createElement("div",null),x.usdValue&&H.createElement(vi,{variant:"body",className:Js(),size:"xsmall"},`$${x.usdValue}`))},"endRenderer"),k=i(()=>H.createElement(mv,{endReached:m?S:void 0,itemContent:v=>{let x=l[v],N=x.address||"",M=c.find(W=>W.name===x.blockchain),w=Xa(M.color,"main"),E={$$color:w.main150,[`.${Yd} &`]:{$$color:w.main750},backgroundColor:"$$color"},b={$$color:w.main750,[`.${Yd} &`]:{$$color:w.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(pv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":v,key:`${x.symbol}${x.address}`,id:`${x.symbol}${x.address}`,hasDivider:!0,onClick:()=>n&&n(l[v]),start:H.createElement(Hd,null,H.createElement(lv,{src:x.image,size:30}),t.type!=="custom-token"&&h(x,t.type)&&H.createElement(Gd,null,H.createElement(uv,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||x.name||!x.name&&!N?H.createElement(Rs,null,H.createElement(vi,{variant:"title",size:"xmedium"},x.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:E},H.createElement(tl,{variant:"body",size:"xsmall",css:b},x.blockchain))):void 0,description:M?.info&&N&&M.type!=="COSMOS"?dv({address:N,token:l[v],customCssForTag:E,customCssForTagTitle:b,name:x.name,url:M.info.addressUrl.split("{wallet}").join(N)}):x.name||void 0,end:C(x)}))},totalCount:l.length,key:`${r}-${o}-${T}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(vi,{variant:"label",size:"large"},ol.t("Select Token")),H.createElement(Jo,{size:4})),H.createElement(Qd,null,H.createElement(Jo,{size:4}),u==="loading"&&H.createElement(Xd,{size:nl}),u==="success"&&(l.length?H.createElement(Ti,{as:"ul"},k()):!!o&&H.createElement(cv,{title:ol.t("No results found"),description:ol.t("Try using different keywords")}))))}i(Dn,"TokenList");var kv=al("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),vv=al("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),xv=al(yv,{"&:hover":{"& svg":{color:"$secondary550"}}});function ef(){let[t,e]=il(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=z(),{mode:p}=Qo({}),u=Tv(),[c,m]=il(!1),[g,d]=il(),f=i(C=>{let k=C.target.value;e(k)},"handleSearch"),h=p==="dark",T=n.filter(C=>et(C.symbol,t)||et(C.address||"",t)||et(C.name||"",t)),S=i(()=>{if(g){let C=a?_e(a):null,k=r?_e(r):null,v=_e(g);C===v?l({token:null}):k===v&&s({token:null}),o(g)}m(!1)},"handleDeleteCustomToken");return fe.createElement(ne,{header:{title:Ft.t("Custom Tokens")}},fe.createElement(re,null,fe.createElement(kv,null,n.length?fe.createElement(fe.Fragment,null,fe.createElement(Tt,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ft.t("Search Token"),onChange:f}),fe.createElement(_n,{size:16}),fe.createElement(Dn,{list:T,type:"custom-token",searchedFor:t,showTitle:!1,action:C=>fe.createElement(xv,{variant:"ghost",onClick:()=>{m(!0),d(C)}},fe.createElement(hv,{size:12,color:"gray"}))})):fe.createElement(vv,null,fe.createElement(Cv,{icon:h?fe.createElement(fv,{size:200}):fe.createElement(gv,{size:200}),title:Ft.t("No custom tokens"),description:Ft.t("press the button to add your custom token")})),fe.createElement(_n,{size:20}),fe.createElement(rl,{type:"primary",variant:"contained",size:"large",onClick:()=>u(D.addCustomTokens)},Ft.t("Add Custom Token"))),fe.createElement(J,{open:c,dismissible:!0,onClose:()=>m(!1),container:A()},fe.createElement(Sv,{title:Ft.t("Delete Custom Token"),type:"error",description:Ft.t("Are you sure you want to Delete this Token?")},fe.createElement(_n,{size:40}),fe.createElement(_n,{size:10}),fe.createElement(rl,{fullWidth:!0,variant:"contained",type:"primary",size:"large",onClick:S},Ft.t("Yes, Delete it")),fe.createElement(_n,{size:12}),fe.createElement(rl,{fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ft.t("No, Continue"))))))}i(ef,"CustomTokensPage");import{i18n as Ge}from"@lingui/core";import{useManager as Qv}from"@rango-dev/queue-manager-react";import{Button as dl,darkTheme as qv,Divider as wo,MessageBox as Hv,NotFound as Gv,styled as fl,Typography as bi}from"@rango-dev/ui";import{TransactionStatus as On}from"rango-types";import ie,{useMemo as Tf,useState as Ei}from"react";import{useNavigate as Vv}from"react-router-dom";import{FilterIcon as Wv,Popover as Mv}from"@rango-dev/ui";import xo from"react";import{css as wv,darkTheme as xi,IconButton as bv,styled as $n}from"@rango-dev/ui";var sl=$n("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),tf=$n(bv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"},[`& ${sl}::before`]:{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),of=$n("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),nf=$n("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),rf=wv({display:"flex",justifyContent:"space-between",alignItems:"center"}),af=$n("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as sf}from"@lingui/core";import{Button as Ev,Divider as lf,ListItemButton as Iv,Radio as Av,RadioRoot as Nv,Typography as pf}from"@rango-dev/ui";import rt from"react";function cf(t){let{filterBy:e,onClickItem:o}=t;return rt.createElement(nf,null,rt.createElement("div",{className:rf()},rt.createElement(pf,{size:"small",variant:"body"},sf.t("Status")),rt.createElement(Ev,{variant:"ghost",size:"xxsmall",onClick:()=>o("")},sf.t("Reset"))),rt.createElement(lf,{size:10}),rt.createElement(Nv,{value:e},rt.createElement(af,null,t.list.map((n,r)=>rt.createElement(Iv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:rt.createElement(rt.Fragment,null,rt.createElement(lf,{direction:"horizontal",size:4}),rt.createElement(pf,{size:"medium",variant:"body"},n.title)),start:rt.createElement(Av,{value:n.id}),onClick:o})))))}i(cf,"FilterSelectorContent");function ll(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return xo.createElement("div",null,xo.createElement(Mv,{open:a,align:"end",onOpenChange:o,container:A(),content:xo.createElement(cf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},xo.createElement(tf,{variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},xo.createElement(sl,{isSelect:!!n},xo.createElement(Wv,{size:16,color:"black"}),!!n&&xo.createElement(of,null)))))}i(ll,"FilterSelector");import{i18n as Pv}from"@lingui/core";import{Divider as gf,GroupedVirtualizedList as Dv,Skeleton as _v,SwapListItem as hf,Typography as $v}from"@rango-dev/ui";import He,{useCallback as yf,useEffect as Fv,useRef as Ov,useState as Uv}from"react";function uf(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(uf,"calculateGroupsSoFar");import{css as Bv,darkTheme as Lv,styled as Fn}from"@rango-dev/ui";var pl=Bv(),mf=Fn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),cl=Fn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${pl}`]:{$$color:"$colors$neutral600",[`.${Lv} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ul=Fn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),df=Fn("div",{gap:"$10",display:"flex",flexDirection:"column"}),ff=Fn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var zv=10;function ml(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Uv([]),l=Ov(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=yf(uf,[]),g=yf(()=>{let d=e.length-l.current;d&&(l.current+=Math.min(d,zv),s(m(u,l.current)))},[e.length]);if(Fv(()=>{r||g()},[r,g]),r){let d=[1,2];return He.createElement(He.Fragment,null,[d,d].map((h,T)=>He.createElement(cl,{key:T},He.createElement(ul,null,He.createElement(_v,{variant:"text",width:60,size:"small"}),He.createElement(gf,{size:16})),He.createElement(gf,{size:4}),He.createElement(df,null,h.map((C,k)=>He.createElement(hf,{isLoading:!0,key:k}))))))}return He.createElement(Dv,{endReached:()=>{l.current<e.length&&g()},groupCounts:a,groupContent:d=>He.createElement(cl,null,He.createElement(ul,null,He.createElement($v,{variant:"label",size:"medium",className:pl()},c[d]))),itemContent:(d,f)=>{let h=p[d];if(!h)return null;let T=h.steps[0],S=h.steps[h.steps.length-1];return He.createElement(mf,{key:h.requestId},He.createElement(hf,{requestId:h.requestId,creationTime:h.creationTime,status:h.status,onClick:o,tooltipContainer:A(),onlyShowTime:c[f]===Pv.t("Today"),swapTokenData:{from:{token:{image:T.fromLogo,displayName:T.fromSymbol},blockchain:{image:T.fromBlockchainLogo||""},amount:B(h.inputAmount,6,6),realAmount:h.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(ml,"HistoryGroupedList");import{i18n as wi}from"@lingui/core";import Sf from"dayjs";var Cf=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(p,u){e.has(p)||e.set(p,{title:p,swaps:[]}),e.get(p)?.swaps.push(u)}i(o,"addYearsToOutput");let n=Sf();t.forEach(p=>{let u=Number(p.creationTime),c=Sf(u);if(n.isSame(c,"day"))e.get("today")?.swaps.push(p);else if(n.isSame(c,"week"))e.get("week")?.swaps.push(p);else if(n.isSame(c,"month"))e.get("month")?.swaps.push(p);else if(n.isSame(c,"year"))e.get("year")?.swaps.push(p);else{let m=new Date(u).getFullYear().toString();o(m,p)}});let r=Array.from(e.values()).filter(p=>p.swaps.length>0),a=r.flatMap(p=>p.swaps),s=r.map(p=>p.swaps.length),l=r.map(p=>p.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Kv=fl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),jv=fl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Xv=fl("div",{"._typography":{color:"$neutral700",[`.${qv}&`]:{color:"$neutral900"}}}),Yv=[{id:On.SUCCESS,title:Ge.t("Complete")},{id:On.RUNNING,title:Ge.t("Running")},{id:On.FAILED,title:Ge.t("Failed")}],Zv=i((t,e)=>t?.length?t.filter(o=>bt(o.fromBlockchain,e)||bt(o.toBlockchain,e)||bt(o.toSymbol,e)||bt(o.fromSymbol,e)).length:!1,"isStepContainsText");function kf(){let t=Vv(),{manager:e,state:o}=Qv(),n=mt(e).map(({swap:k})=>k),[r,a]=Ei(""),[s,l]=Ei(!1),p=!o.loadedFromPersistor,[u,c]=Ei(""),[m,g]=Ei(!1),d=i(k=>{let v=k.target.value;a(v)},"handleSearch"),f=Tf(()=>!r&&!u?n:n.filter(k=>{let{inputAmount:v,status:x,steps:N,requestId:M}=k;return(!r||bt(v,r)||bt(x,r)||Zv(N,r)||bt(M,r))&&(!u||u===x)}),[n,r,u]),h=!f?.length&&!p,T=i(()=>g(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),g(!1)}catch(k){console.log(k)}},"onClear"),C=Tf(()=>!n.some(k=>k.status===On.SUCCESS||k.status===On.FAILED),[n]);return ie.createElement(ne,{header:{title:Ge.t("History"),suffix:ie.createElement(Vt,null,ie.createElement(dl,{disabled:C,variant:"ghost",size:"xsmall",onClick:()=>g(!0)},ie.createElement(bi,{size:"medium",variant:"label",color:"error"},Ge.t("Clear"))))}},ie.createElement(re,null,ie.createElement(jv,null,ie.createElement(Tt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Ge.t("Search Transaction"),autoFocus:!0,onChange:d,style:{height:36},value:r}),ie.createElement(wo,{size:10,direction:"horizontal"}),ie.createElement(ll,{filterBy:u,open:s,onOpenChange:k=>l(k),onClickItem:k=>c(k),list:Yv})),ie.createElement(wo,{size:"16"}),ie.createElement(Kv,null,h&&ie.createElement(ff,null,ie.createElement(wo,{size:32}),ie.createElement(Gv,{title:r?Ge.t("No results found"):Ge.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Ge.t("Try using different keywords"):Ge.t("Your transaction history is stored locally and will appear here after you start a swap")})),!h&&ie.createElement(ml,{list:f,onSwapClick:t,groupBy:Cf,isLoading:p}))),ie.createElement(J,{open:m,onClose:T,container:A()},ie.createElement(wo,{size:20}),ie.createElement(Hv,{type:"warning",title:Ge.t("Clear Transaction History"),description:ie.createElement(Xv,null,ie.createElement(bi,{variant:"body",size:"medium"},Ge.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ie.createElement(wo,{size:"24"}),ie.createElement(bi,{variant:"body",size:"small"},Ge.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ie.createElement(wo,{size:30}),ie.createElement(dl,{variant:"contained",type:"primary",size:"large",onClick:S},Ge.t("Yes, Clear the history")),ie.createElement(wo,{size:10}),ie.createElement(dl,{variant:"outlined",type:"primary",size:"large",onClick:T},ie.createElement(bi,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(kf,"HistoryPage");import{i18n as hx}from"@lingui/core";import{Button as yx,Divider as Uf,styled as Sx,WarningIcon as Cx}from"@rango-dev/ui";import Tx from"bignumber.js";import Je,{useEffect as zf,useState as Qf}from"react";import{useNavigate as kx}from"react-router-dom";import{i18n as nx}from"@lingui/core";import{Header as rx}from"@rango-dev/ui";import Rt,{useEffect as ix,useState as ax}from"react";import{i18n as Rv}from"@lingui/core";import{Divider as hl,FullExpandedQuote as ex,Typography as tx}from"@rango-dev/ui";import Ce from"react";import{styled as gl}from"@rango-dev/ui";var vf=gl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),xf=gl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),wf=gl("div",{width:"146px"});import{i18n as Un}from"@lingui/core";import{Select as Jv}from"@rango-dev/ui";import bf from"react";function Ii(t){let{updateQuotePartialState:e,sortStrategy:o}=z(),n=[{value:"SMART",label:Un.t("Smart Routing")},{value:"FEE",label:Un.t("Lowest Fee")},{value:"SPEED",label:Un.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Un.t("Maximum Return")},{value:"PRICE",label:Un.t("Maximum Output")}];return bf.createElement(wf,null,bf.createElement(Jv,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ii,"SelectStrategy");var Ef=3;function zn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:g,sortStrategy:d,error:f}=z(),{slippage:h,customSlippage:T}=y(),{findToken:S}=y(),C=l||A(),k=!!u&&u.results.length,v=T??h,x=i(w=>{if(!m||!g||!u)return null;let E={requestAmount:u.requestAmount,...w};return Fo(E,{fromToken:m,toToken:g,userSlippage:v,findToken:S})},"getQuoteWarning"),N=f?.type===0||f?.type===1,M=u?.results?Pr(d,u?.results):[];return Ce.createElement(Ce.Fragment,null,a&&Ce.createElement(Ce.Fragment,null,Ce.createElement(xf,null,Ce.createElement(tx,{size:"xmedium",variant:"title"},Rv.t("Sort by")),Ce.createElement(Ii,{container:C})),Ce.createElement(hl,{size:"10"})),e&&Array.from({length:Ef},(w,E)=>Ce.createElement(Ce.Fragment,{key:E},s?Ce.createElement(ex,{loading:!0}):Ce.createElement(Mn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Ef-1&&Ce.createElement(hl,{size:16}))),!e&&Ce.createElement(Ce.Fragment,null,k?M.map((w,E)=>{let b=x(w),W=zs(w.swaps),$=M.length-1===E;return Ce.createElement(Ce.Fragment,{key:w.requestId},Ce.createElement(vo,{showModalFee:r,container:C,selected:p?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:u.requestAmount},loading:e,error:W?.options||null,warning:b,fullExpandedMode:s,onClick:I=>{W||c("warning",b),c("error",W?.options||null),o(I)},type:"list-item"}),!$&&Ce.createElement(hl,{size:16}))}):N&&Ce.createElement(vf,null,Ce.createElement(vn,{size:s?"large":"small",error:f,fetch:n}))))}i(zn,"Quotes");import{darkTheme as ox,styled as If}from"@rango-dev/ui";var Af=If("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${ox} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Nf=If("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var sx=100;function yl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=ax(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=an();return ix(()=>{let g=null;return a?g=setTimeout(()=>{l(!0)},sx):(l(!1),g&&clearTimeout(g)),()=>{g&&clearTimeout(g)}},[a]),Rt.createElement(Af,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${Qr()}`,id:$e.EXPANDED_BOX_ID},Rt.createElement(rx,{title:nx.t("Routes"),suffix:Rt.createElement(Rt.Fragment,null,Rt.createElement(Ii,{container:m}),Rt.createElement(yo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Rt.createElement(Nf,null,Rt.createElement(zn,{showModalFee:!1,fetch:e,hasSort:!1,loading:o,container:an(),onClickOnQuote:n,fullExpandedMode:c})))}i(yl,"ExpandedQuotes");import{i18n as _f}from"@lingui/core";import{SwapInput as $f}from"@rango-dev/ui";import Qn from"react";import{ReverseIcon as cx}from"@rango-dev/ui";import Cl from"react";import{keyframes as lx,styled as Wf}from"@rango-dev/ui";var Sl=450,px=lx({"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)"}}),Mf=Wf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Bf=Wf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${px} ${Sl}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 Tl(){let t=z.use.switchFromAndTo();return Cl.createElement(Mf,null,Cl.createElement(Bf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Sl),t()}},Cl.createElement(cx,{size:12})))}i(Tl,"SwitchFromAndToButton");import{styled as Lf}from"@rango-dev/ui";var Pf=Lf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Df=Lf("div",{position:"relative"});function kl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:g,outputUsdValue:d,selectedQuote:f}=z(),{connectedWallets:h,getBalanceFor:T}=Z(),S=a?T(a):null,C=mr(S)?.amount??"0",k=s&&a?B(S?.amount,S?.decimals):"0",v=!!s&&$p(h,s.name),x=!Ma(f,c,m),N=!Ma(f,c,d),M=!m||!d||!d.gt(0)?null:ut(m.toString(),d.toString());return Qn.createElement(Pf,null,Qn.createElement(Df,null,Qn.createElement($f,{label:_f.t("From"),mode:"From",onInputChange:u,balance:C,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue:x?void 0:B(m,4,4),realUsdValue:x?void 0:m?.toString(),error:x?te().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:A(),onSelectMaxBalance:()=>{u(k.split(",").join(""))},anyWalletConnected:h.length>0}),Qn.createElement(Tl,null)),Qn.createElement($f,{sharpBottomStyle:!r&&(!!f||e),label:_f.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(ut(m,d),2,2),warningLevel:Lt(M??0),price:{value:B(g,6,6),usdValue:N?void 0:B(d,4,4),realValue:g?.toString(),realUsdValue:N?void 0:d?.toString(),error:N?te().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:A()}))}i(kl,"Inputs");import{useCallback as ux,useEffect as mx,useRef as dx,useState as fx}from"react";function Ff(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Ht().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Ff,"useFetchAllQuotes");var gx=600;function Ai({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Ff(),{excludeLiquiditySources:n,features:r,enableCentralizedSwappers:a}=y().config,s=Z.use.connectedWallets(),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:c,selectedQuote:m,sortStrategy:g,resetQuote:d,error:f,warning:h,setSelectedQuote:T,updateQuotePartialState:S}=z(),{slippage:C,customSlippage:k,affiliatePercent:v,affiliateRef:x,affiliateWallets:N,fetchStatus:M}=y(),w=y().getLiquiditySources(),E=y().getDisabledLiquiditySources(),b=y().excludeLiquiditySources(),{findToken:W}=y(),[$,I]=fx(!0),R=dx(u),ee=k??C,L=!l||!p||ao(l,p)||!ln(u),V=i(ae=>{I(ae)},"resetState"),le=i(ae=>{let{fromToken:ge,toToken:ve,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:xt,disabledLiquiditySources:lt,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G}=ae;if($||V(!0),!L&&ge&&ve){d();let pe=Qc({fromToken:ge,toToken:ve,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:xt,disabledLiquiditySources:lt,wallets:s,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G,enableCentralizedSwappers:a});Vp("experimentalRoute",r)&&(pe.experimental=!0),e(pe).then(ce=>{let de=Pr(g,ce.results),he=ou(m,de,ce.requestAmount);I(!1),S("quotes",ce),T(he),yi({diagnosisMessages:ce.diagnosisMessages,requestId:he?.requestId||"",swaps:he?.swaps});let Rn=go(he)||ve?.usdPrice,ro=hn(he)||ge?.usdPrice,ea=he&&Fo(he,{fromToken:{...ge,usdPrice:ro},toToken:{...ve,usdPrice:Rn},userSlippage:ee,findToken:W});S("warning",ea)}).catch(ce=>{let{error:de}=Si(ce);(de?.type===0||de?.type===1)&&d(),de?.type!==2&&(S("error",de),I(!1))})}},"fetch"),Y=ux(xp(ae=>{le(ae)},gx),[L]);return mx(()=>{if(!t){I(!1);return}if(M!=="success")return;if(L){I(!1),(m||f||h)&&d();return}if(!ln(u)||c?.eq(0)){V(!1),o();return}d(),V(!0);let ae=le;return R.current&&R.current!=u&&(ae=Y),R.current=u,ae({inputAmount:u,fromToken:l,toToken:p,liquiditySources:w,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:x,affiliatePercent:v,affiliateWallets:N}),o},[M,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,L,w?.length,n,E.length,ee,x,v,JSON.stringify(N)]),{fetch:()=>le({inputAmount:u,fromToken:l,toToken:p,liquiditySources:w,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:x,affiliatePercent:v,affiliateWallets:N}),loading:$}}i(Ai,"useSwapInput");function Of(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(Of,"emitPreventableEvent");var vx=Sx("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),xx=300;function qf(){let t=kx(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:g}=z(),[d,f]=Qf(!1),{isLargeScreen:h,isExtraLargeScreen:T}=li(),{fetch:S,loading:C}=Ai({refetchQuote:a}),{config:k,fetchStatus:v}=y(),{connectedWallets:x}=Z(),{isActiveTab:N}=se(),[M,w]=Qf(!1),b=_c({fetchMetaStatus:v,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:x.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),W=Hp(h,T,k?.variant),$=!!n&&!!e&&!!o&&new Tx(n).gt(0)&&!Zc(e,o),I=$&&v==="success"&&C,oe=(!W||W&&p?.results.length)&&(l||s);zf(()=>{c(),g("refetchQuote",!0)},[]),zf(()=>{f($)},[$]);let L=(r||s)&&!M?S:void 0,V=i(Y=>{W&&d?(f(!1),setTimeout(()=>{t(Y)},xx)):t(Y)},"onHandleNavigation"),le=i(Y=>{r?.requestId!==Y.requestId&&(w(!1),u(Y))},"onClickOnQuote");return Je.createElement(vx,null,Je.createElement(ne,{height:"auto",footer:Je.createElement(yx,{type:"primary",size:"large",disabled:b.disabled||!N,prefix:b.action==="confirm-warning"&&Je.createElement(Cx,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?Of({type:"clickConnectWallet"},()=>V(D.wallets)):b.action==="confirm-warning"?w(!0):V(D.confirmSwap)}},b.title),header:{onWallet:()=>{V(D.wallets)},hasBackButton:!1,title:k.title||hx.t("Swap"),suffix:Je.createElement(yo,{hidden:W?["refresh"]:void 0,onClickRefresh:L,onClickHistory:()=>V(D.swaps),onClickSettings:()=>{V(D.settings)}})}},Je.createElement(re,null,Je.createElement(kl,{fetchingQuote:I,fetchMetaStatus:v,isExpandable:W,onClickToken:Y=>{V(Y==="from"?D.fromSwap:D.toSwap)}}),Je.createElement(Uf,{size:"2"}),W?null:Je.createElement(vo,{quote:r,loading:I,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{g("refetchQuote",!1),V(D.routes)}:void 0}),oe?Je.createElement(Je.Fragment,null,Je.createElement(Uf,{size:"10"}),Je.createElement(wn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!N,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),m(!0),V(D.confirmSwap)},onChangeSettings:()=>V(D.settings)})):null)),W?Je.createElement(yl,{loading:I,onClickOnQuote:le,fetch:S,onClickRefresh:L,isVisible:d}):null)}i(qf,"Home");import{i18n as Hf}from"@lingui/core";import{Alert as wx,Divider as bx,List as Ex,ListItemButton as Ix,Radio as Ax,RadioRoot as Nx,Typography as Wx}from"@rango-dev/ui";import Mt from"react";function eo(){let{setLanguage:t,language:e,config:o}=y(),n=Xp,r=o?.language||Mo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Mo),resetLanguage:()=>t(null)}}i(eo,"useLanguage");function Gf(){let{activeLanguage:t,changeLanguage:e,languages:o}=eo(),n=Ye(),r=o.map(a=>{let{local:s,label:l,SVGFlag:p}=a;return{id:s,value:s,title:Mt.createElement(Wx,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Mt.createElement(Ax,{value:s}),start:Mt.createElement(p,null)}});return Mt.createElement(ne,{header:{title:Hf.t("Language")}},Mt.createElement(re,null,Mt.createElement(wx,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Mt.createElement(bx,{size:"8"}),Mt.createElement(Nx,{value:t},Mt.createElement(Ex,{type:Mt.createElement(Ix,{title:Hf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Gf,"LanguagePage");import{i18n as Ot}from"@lingui/core";import{Button as Dx,Checkbox as _x,Image as $x,ListItemButton as Fx,NotFound as Ox,Typography as Ux}from"@rango-dev/ui";import Ve,{useState as zx}from"react";import{Checkbox as Lx,Skeleton as Kf}from"@rango-dev/ui";import Hn from"react";import{styled as vl}from"@rango-dev/ui";var qn=vl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),xl=vl("div",{width:80,display:"flex",justifyContent:"flex-end"}),wl=vl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as Mx,styled as Bx}from"@rango-dev/ui";var Vf=Bx(Mx,{height:61});var Px=30;function bl(){return Hn.createElement(qn,null,Array.from(Array(Px),(t,e)=>Hn.createElement(Vf,{hasDivider:!0,key:e,start:Hn.createElement(Kf,{variant:"circular",width:35,height:35}),title:Hn.createElement(Kf,{variant:"text",size:"large",width:90}),end:Hn.createElement(Lx,{checked:!1})})))}i(bl,"LoadingLiquiditySourceList");function El({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=zx(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=hr(o,n),u={Exchanges:Ot.t("Exchanges"),Bridges:Ot.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(S=>c.includes(S.type)),g=m.length===m.filter(S=>S.selected).length,d=i(()=>{m.forEach(S=>{g?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),f=m.map(S=>{let{selected:C,groupTitle:k,logo:v}=S;return{start:Ve.createElement($x,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(k)},end:Ve.createElement(_x,{checked:C,disabled:l}),title:Ve.createElement(Ux,{variant:"title",size:"xmedium"},Ot.t(k)),...S}}),h=i(S=>{let C=S.target.value;a(C)},"handleSearch"),T=f;return r&&(T=f.filter(S=>bt(S.groupTitle,r))),Ve.createElement(ne,{header:{title:Ot.t(t),suffix:Ve.createElement(xl,null,Ve.createElement(Dx,{variant:"ghost",size:"xsmall",onClick:d},g?Ot.t("Deselect all"):Ot.t("Select all")))}},Ve.createElement(re,{view:!0},Ve.createElement(Tt,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Ot.t("Search {sourceType}",{sourceType:u[t]}),onChange:h}),e==="loading"&&Ve.createElement(bl,null),!T.length&&r?Ve.createElement(wl,null,Ve.createElement(Ox,{title:Ot.t("No results found"),description:Ot.t("Try using different keywords")})):e==="success"&&Ve.createElement(qn,{disabled:l},T.map(S=>{let{groupTitle:C,...k}=S;return Ve.createElement(Ve.Fragment,{key:S.id},Ve.createElement(Fx,{style:{height:"61px"},...k,selected:!1,hasDivider:!0}))}))))}i(El,"LiquiditySourcePage");import{i18n as Qx}from"@lingui/core";import Ni from"react";import{useNavigate as qx}from"react-router-dom";function jf(){let t=qx(),e=Ye(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=z(),{fetch:l,loading:p}=Ai({refetchQuote:n}),u=i(g=>{r(g),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${D.settings}`,m=`../${D.wallets}`;return Ni.createElement(ne,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Qx.t("Routes"),suffix:Ni.createElement(yo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Ni.createElement(re,null,Ni.createElement(zn,{fetch:l,loading:p,onClickOnQuote:u})))}i(jf,"RoutesPage");import{i18n as tg}from"@lingui/core";import{Divider as og,getCategoriesCount as Rx,SelectableCategoryList as ew}from"@rango-dev/ui";import Ut,{useState as ng}from"react";import{useNavigate as tw}from"react-router-dom";import{i18n as Il}from"@lingui/core";import{Divider as Kx,Image as jx,ListItemButton as Xx,NotFound as Yx,Typography as eg}from"@rango-dev/ui";import it,{useEffect as Zx,useState as Jx}from"react";var Xf=i((t,e,o)=>t.filter(n=>ir(n.type,o)).filter(n=>et(n.name,e)||et(n.displayName,e)),"filterBlockchains");import{ImageContainer as Hx,styled as Yf}from"@rango-dev/ui";var Zf=Yf("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Wi=Yf(Sn,{padding:0,margin:0,listStyle:"none",[`& ${Hx}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Gx,Skeleton as Jf}from"@rango-dev/ui";import Mi from"react";var Vx=20;function Rf(){return Mi.createElement(Wi,null,Array.from(Array(Vx),t=>Mi.createElement(Gx,{key:t,hasDivider:!0,start:Mi.createElement(Jf,{variant:"circular",width:35,height:35}),title:Mi.createElement(Jf,{variant:"text",size:"large",width:90})})))}i(Rf,"LoadingBlockchainList");function Al(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Jx(e),{fetchStatus:p}=y();Zx(()=>{l([...Xf(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?it.createElement(Yx,{title:Il.t("No results found"),description:Il.t("Try using different keywords")}):it.createElement(Wi,{as:"ul",key:`${r}-${o}`},s.map(c=>it.createElement(Xx,{key:`${c.name}-${c.chainId}`,hasDivider:!0,onClick:()=>n(c),start:it.createElement(jx,{src:c.logo,size:30}),title:it.createElement(eg,{variant:"title",size:"medium"},c.displayName),id:c.chainId}))),"renderList");return it.createElement(it.Fragment,null,a&&it.createElement(it.Fragment,null,it.createElement(eg,{variant:"label",size:"large"},Il.t("Select Chain")),it.createElement(Kx,{size:4})),it.createElement(Zf,null,p==="loading"&&it.createElement(Rf,null),p==="success"&&u()))}i(Al,"BlockchainList");function Bi(t){let{type:e}=t,o=Ye(),[n,r]=ng(""),[a,s]=ng("ALL"),l=z.use.setToBlockchain(),p=z.use.setFromBlockchain(),{fetchStatus:u}=y(),c=tw(),m=y().blockchains({type:e}),g=Rx(m),d=!t.hideCategory&&g!==1;return Ut.createElement(ne,{header:{title:tg.t("Select Chain")}},Ut.createElement(re,{view:!0},d&&Ut.createElement(Ut.Fragment,null,Ut.createElement(ew,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),Ut.createElement(og,{size:24})),Ut.createElement(Tt,{value:n,autoFocus:!0,placeholder:tg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Ut.createElement(og,{size:16}),Ut.createElement(Al,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?c(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?p(f):l(f),o())}})))}i(Bi,"SelectBlockchainPage");import{i18n as Pi}from"@lingui/core";import{Divider as pg}from"@rango-dev/ui";import bo,{useState as pw}from"react";import{useNavigate as cw}from"react-router-dom";import{i18n as Ml}from"@lingui/core";import{BlockchainsChip as Li,Divider as sg,Image as lg,Skeleton as aw,Tooltip as sw,Typography as Bl}from"@rango-dev/ui";import Pe from"react";import{useEffect as rw}from"react";var rg=["ETH","COSMOS","OSMOSIS"];function Nl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(ow),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(nw(s)),r=n.splice(a)}return{list:n,more:r}}i(Nl,"prepare");function ow(t,e){let o=rg,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(ow,"sortByMostUsedBlockchains");function nw(t){return i(function(o,n){let r=t.findIndex(p=>p===o.name),a=t.findIndex(p=>p===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(nw,"generateSortByPreferredBlockchainsFor");function ig(t,e){return!!e.list.find(o=>o.name===t)}i(ig,"isInVisibleList");function Wl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();rw(()=>{if(e?.selected){let a=Nl(t,o,e);ig(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Nl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Wl,"usePrepareBlockchainList");import{styled as iw}from"@rango-dev/ui";var ag=iw("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var lw=12;function Ll(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Wl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=z.use.resetToBlockchain(),u=z.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,g=!m&&c;return Pe.createElement(Pe.Fragment,null,Pe.createElement(sg,{size:12}),Pe.createElement(Bl,{variant:"label",size:"large"},Ml.t("Select Chain")),Pe.createElement(sg,{size:12}),Pe.createElement(ag,null,l==="loading"&&Array.from(Array(lw),d=>Pe.createElement(aw,{key:d,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Li,{selected:!n,onClick:()=>{o==="from"?u():p()}},Pe.createElement(Bl,{variant:"body",size:"xsmall",color:"secondary500"},Ml.t("All"))),s.list.map(d=>Pe.createElement(sw,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:A()},Pe.createElement(Li,{key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},Pe.createElement(lg,{src:d.logo,size:30})))),m?Pe.createElement(Li,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(lg,{src:s.more[0].logo,size:30})):null,g?Pe.createElement(Li,{onClick:a,key:"more-blockchains"},Pe.createElement(Bl,{variant:"body",size:"xsmall",color:"secondary500"},Ml._("More +{count}",{count:s.more.length}))):null)))}i(Ll,"BlockchainsSection");function Pl(t){let{type:e}=t,o=cw(),n=Ye(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=z(),c=Z.use.getBalanceFor(),[m,g]=pw(""),f=(e==="source"?r:a)?.name??"",h=y().blockchains({type:e}),T=y().tokens({type:e,blockchain:f,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),C=i(v=>{e==="source"?s({token:v,meta:{blockchains:h,tokens:T}}):l({token:v,meta:{blockchains:h,tokens:T}})},"updateToken"),k={source:Pi.t("Source"),destination:Pi.t("Destination")};return bo.createElement(ne,{header:{title:Pi.t("Swap {type}",{type:k[e]})}},bo.createElement(re,null,bo.createElement(Ll,{blockchains:h,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(D.blockchains),onChange:v=>{S(v)}}),bo.createElement(pg,{size:24}),bo.createElement(Tt,{value:m,autoFocus:!0,placeholder:Pi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>g(""),onChange:v=>g(v.target.value)}),bo.createElement(pg,{size:16}),bo.createElement(Dn,{list:T,selectedBlockchain:f,searchedFor:m,type:e,onChange:v=>{C(v);let x=h.find(N=>v.blockchain===N.name);x&&S(x),n()}})))}i(Pl,"SelectSwapItemsPage");import{i18n as $l}from"@lingui/core";import{Alert as _w,Button as $w,styled as Fw}from"@rango-dev/ui";import Eo from"react";import{useInRouterContext as Ow,useSearchParams as Uw}from"react-router-dom";import{i18n as gg}from"@lingui/core";import{Divider as hg,InfoIcon as fw,SlippageIcon as gw,TextField as hw,Tooltip as yw,Typography as yg}from"@rango-dev/ui";import at from"react";import{Chip as uw,styled as Gn,TextField as mw}from"@rango-dev/ui";var cg=Gn("div",{paddingTop:"$5",padding:"$10 $5"}),ug=Gn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${mw}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),mg=Gn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Di=Gn("div",{maxWidth:"280px",padding:"$10"}),dg=Gn(uw,{width:"61px",flexShrink:0});import{i18n as Dl}from"@lingui/core";import{Typography as dw}from"@rango-dev/ui";import Vn from"react";function fg(){return Vn.createElement(Di,null,Vn.createElement(dw,{variant:"label",size:"medium",color:"neutral700"},Dl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Vn.createElement("br",null),Vn.createElement("br",null),Vn.createElement("b",null,Dl.t("Warning")),":\xA0",Dl.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(fg,"SlippageTooltipContent");function _l(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return at.createElement(cg,null,at.createElement(mg,null,at.createElement(gw,{size:16,color:"gray"}),at.createElement(hg,{direction:"horizontal",size:4}),at.createElement(yg,{variant:"title",size:"xmedium"},gg.t("Slippage tolerance per swap")),at.createElement(hg,{direction:"horizontal",size:4}),at.createElement(yw,{container:A(),side:"top",sideOffset:4,content:at.createElement(fg,null)},at.createElement(fw,{color:"gray"}))),at.createElement(ug,null,Yp.map((r,a)=>{let s=`slippage-${a}`;return at.createElement(dg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),at.createElement(hw,{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>=ec&&s<=Rp?n(s):n(null)},suffix:o&&at.createElement(yg,{variant:"body",size:"small"},"%"),placeholder:gg.t("Custom")})))}i(_l,"Slippage");import{i18n as ft}from"@lingui/core";import{AutoThemeIcon as Sg,BridgesIcon as Sw,ChevronRightIcon as _i,DarkModeIcon as Cg,Divider as Kn,ExchangeIcon as Cw,InfinityIcon as Tw,InfoIcon as kw,LanguageIcon as vw,LightModeIcon as Tg,List as xw,ListItem as ww,ListItemButton as bw,Skeleton as Ew,styled as Iw,Switch as Aw,Tabs as Nw,TargetIcon as Ww,Tooltip as Mw,Typography as Re}from"@rango-dev/ui";import P from"react";import{useNavigate as Bw}from"react-router-dom";var Lw=Iw("div",{width:"202px",height:"$40"}),Pw=[{id:"light",icon:P.createElement(Tg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},ft.t("Light"))},{id:"dark",icon:P.createElement(Cg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},ft.t("Dark"))},{id:"auto",icon:P.createElement(Sg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},ft.t("Auto"))}],Dw=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return P.createElement(Sg,{...e});case"dark":return P.createElement(Cg,{...e});default:return P.createElement(Tg,{...e})}},"getThemeIcon");function kg(){let t=Bw(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=eo(),s=a.find(L=>L.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),g=je("theme",c),d=je("liquiditySource",c),f=je("language",c),h=je("customTokens",c),T=y().infiniteApprove,S=y().toggleInfiniteApprove,C=hr(p,u),k=C.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),v=k.length,x=k.filter(L=>L.selected).length,N=C.filter(L=>L.type==="DEX"),M=N.length,w=N.filter(L=>L.selected).length,E=i((L,V)=>{switch(l){case"loading":return P.createElement(Ew,{variant:"text",size:"medium",width:50});case"failed":return P.createElement(Re,{variant:"body",size:"medium",color:"$error500"},ft.t("Loading failed"));default:return P.createElement(Re,{variant:"body",size:"medium"},`${L} / ${V}`)}},"handleSwapperEndItem"),b={id:"bridge-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Bridges")),end:P.createElement(P.Fragment,null,E(x,v),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.bridges),start:P.createElement(Sw,{color:"gray",size:16})},W={id:"exchange-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Exchanges")),end:P.createElement(P.Fragment,null,E(w,M),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Cw,{color:"gray",size:16}),onClick:()=>t(D.exchanges)},$={id:"custom-tokens-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Custom Tokens")),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},`${m.length}`),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Ww,{color:"gray",size:16}),onClick:()=>t(D.customTokens)},I={id:"language-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Language")),start:P.createElement(vw,{color:"gray",size:16}),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},s),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.languages)},R={id:"infinite-approval-item",title:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Infinite approval")),P.createElement(Kn,{direction:"horizontal",size:4}),P.createElement(Mw,{side:"top",sideOffset:4,container:A(),content:P.createElement(Di,null,P.createElement(Re,{variant:"label",size:"medium",color:"neutral700"},P.createElement("b",null,ft.t("Warning")),":\xA0",ft.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},P.createElement(kw,{color:"gray"}))),start:P.createElement(Tw,{color:"gray",size:16}),end:P.createElement(Aw,{checked:T}),onClick:S},ee={id:"theme-item",type:P.createElement(ww,null),title:P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Theme")),end:P.createElement(Lw,null,P.createElement(Nw,{container:A(),items:Pw,value:n,onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:Dw(n)},oe=d?[]:[b,W];return h||oe.push($),f||oe.push(I),oe.push(R),!e?.singleTheme&&!g&&oe.push(ee),P.createElement(xw,{type:P.createElement(bw,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:oe})}i(kg,"SettingsLists");var zw=Fw("div",{paddingLeft:"$8"});function vg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Uw(),r=Ow(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Eo.createElement(ne,{header:{title:$l.t("Settings")}},Eo.createElement(re,null,o&&Eo.createElement(_w,{type:"info",variant:"alarm",title:$l.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Eo.createElement(zw,null,Eo.createElement($w,{type:"secondary",size:"small",onClick:a},$l.t("Reset")))}),Eo.createElement(_l,null),Eo.createElement(kg,null)))}i(vg,"SettingsPage");import{i18n as Ab}from"@lingui/core";import{cancelSwap as Nb}from"@rango-dev/queue-manager-rango-preset";import{useManager as Wb}from"@rango-dev/queue-manager-react";import{Alert as Mb}from"@rango-dev/ui";import ep from"react";import{useParams as Bb}from"react-router-dom";import{i18n as st}from"@lingui/core";import{getCurrentBlockchainOfOrNull as pb,getCurrentStep as cb,getRelatedWalletOrNull as ub}from"@rango-dev/queue-manager-rango-preset";import{Button as Rg,CopyIcon as mb,Divider as db,DoneIcon as fb,IconButton as gb,QuoteCost as hb,RangoExplorerIcon as yb,StepDetails as Sb,Tooltip as eh,Typography as Io,useCopyToClipboard as Cb}from"@rango-dev/ui";import{useWallets as Tb}from"@rango-dev/wallets-react";import th from"bignumber.js";import{PendingSwapNetworkStatus as Gi}from"rango-types";import K,{useEffect as oh,useRef as kb,useState as nh}from"react";import{useNavigate as vb}from"react-router-dom";import{i18n as to}from"@lingui/core";var Qw=[to.t("Sunday"),to.t("Monday"),to.t("Tuesday"),to.t("Wednesday"),to.t("Thursday"),to.t("Friday"),to.t("Saturday")];function xg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?to.t("Today"):`${Qw[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(xg,"timeSince");function wg(t){return t.finishTime?xg(parseInt(t.finishTime)):xg(parseInt(t.creationTime))}i(wg,"getSwapDate");import{PendingSwapNetworkStatus as Oi}from"rango-types";import Ui from"react";import{i18n as $i}from"@lingui/core";import{Button as bg,Divider as Fl,MessageBox as qw}from"@rango-dev/ui";import oo from"react";var Eg=i(({onCancel:t,onClose:e})=>oo.createElement(oo.Fragment,null,oo.createElement(Fl,{size:20}),oo.createElement(qw,{type:"error",title:$i.t("Cancel Swap"),description:$i.t("Are you sure you want to cancel this swap?")}),oo.createElement(Fl,{size:32}),oo.createElement(bg,{variant:"contained",type:"primary",size:"large",onClick:t},$i.t("Yes, Cancel it")),oo.createElement(Fl,{size:12}),oo.createElement(bg,{variant:"outlined",type:"primary",size:"large",onClick:e},$i.t("No, Continue"))),"CancelContent");import{i18n as Fi}from"@lingui/core";import{Button as Ig,Divider as Ol,MessageBox as Hw,Typography as Gw}from"@rango-dev/ui";import zt from"react";var Ag=i(({onDelete:t,onClose:e})=>zt.createElement(zt.Fragment,null,zt.createElement(Ol,{size:20}),zt.createElement(Hw,{type:"error",title:Fi.t("Delete Transaction"),description:Fi.t("Are you sure you want to delete this swap?")}),zt.createElement(Ol,{size:32}),zt.createElement(Ig,{variant:"contained",type:"primary",size:"large",onClick:t},Fi.t("Yes, Delete it")),zt.createElement(Ol,{size:12}),zt.createElement(Ig,{variant:"outlined",type:"primary",size:"large",onClick:e},zt.createElement(Gw,{variant:"title",size:"medium",color:"primary"},Fi.t("No, Cancel")))),"DeleteContent");import{i18n as Ul}from"@lingui/core";import{PendingSwapNetworkStatus as zl}from"rango-types";var Ql={[zl.WaitingForNetworkChange]:{type:"loading",title:Ul.t("Change Network")},[zl.WaitingForConnectingWallet]:{type:"warning",title:Ul.t("Connect Wallet")},[zl.NetworkChanged]:{type:"success",title:Ul.t("Network Changed")}};import{warn as Vw}from"@rango-dev/logging-core";import{MessageBox as Kw,Wallet as jw}from"@rango-dev/ui";import{useWallets as Xw}from"@rango-dev/wallets-react";import Ro,{useState as Yw}from"react";import{styled as Ng}from"@rango-dev/ui";var Wg=Ng("div",{display:"flex",justifyContent:"center"}),$2=Ng("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Mg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=Yw(),{getWalletInfo:u,state:c}=Xw(),m=n?.walletType,g=m?pn(c(m)):null,d=m?u(m):null,f=a&&!!m&&!!g&&!!d,{list:h}=gt(),T=i(()=>{if(m){let S=h.find(C=>C.type===m);S?p(S):Vw(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return Ro.createElement(Ro.Fragment,null,Ro.createElement(Kw,{type:e,title:o,description:r}),f&&Ro.createElement(Wg,null,Ro.createElement(jw,{container:A(),title:d.name,image:d.img,type:m,state:g,link:d.installLink,disabled:s,onClick:T})),Ro.createElement(mo,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function ql(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===Oi.WaitingForNetworkChange||e===Oi.WaitingForConnectingWallet||e===Oi.NetworkChanged;return Ui.createElement(J,{open:!!e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},p&&Ui.createElement(Mg,{type:Ql[e].type,title:Ql[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Oi.WaitingForNetworkChange}),e==="delete"&&Ui.createElement(Ag,{onClose:o,onDelete:n}),e==="cancel"&&Ui.createElement(Eg,{onClose:o,onCancel:r}))}i(ql,"SwapDetailsModal");import{i18n as jn}from"@lingui/core";import{Button as Hl,Divider as zi,MessageBox as Bg,TokenAmount as Zw,Typography as Gl}from"@rango-dev/ui";import Oe from"react";import{useNavigate as Jw}from"react-router-dom";function Vl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:g}=t,d=Jw();return Oe.createElement(J,{open:e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},n==="success"?Oe.createElement(Bg,{type:"success",title:jn.t("Swap Successful")},Oe.createElement(Zw,{direction:"vertical",tooltipContainer:A(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),Oe.createElement(zi,{size:12}),Oe.createElement(Gl,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Oe.createElement(Bg,{type:"error",title:jn.t("Transaction Failed"),description:m}),Oe.createElement(zi,{size:32}),n==="success"&&Oe.createElement(Hl,{variant:"contained",type:"primary",size:"large",onClick:()=>{d("../../")}},Oe.createElement(Gl,{variant:"title",size:"medium",color:"neutral100"},jn.t("Done"))),Oe.createElement(zi,{size:12}),g&&Oe.createElement(Oe.Fragment,null,Oe.createElement(Hl,{variant:"contained",type:"primary",size:"large",onClick:()=>window.open(g,"_blank")},jn.t("Diagnosis")),Oe.createElement(zi,{size:12})),Oe.createElement(Hl,{variant:"outlined",type:"primary",size:"large",onClick:o},Oe.createElement(Gl,{variant:"title",size:"medium",color:"primary"},jn.t("See Details"))))}i(Vl,"SwapDetailsCompleteModal");import lb from"react";import{i18n as rb}from"@lingui/core";import{Alert as Xg,IconButton as ib,LinkIcon as ab}from"@rango-dev/ui";import no,{Fragment as sb}from"react";import{Alert as eb,ChevronDownIcon as tb,IconButton as ob}from"@rango-dev/ui";import tn,{useState as nb}from"react";import{css as Xn,darkTheme as Lg,styled as Qt,Typography as Rw}from"@rango-dev/ui";var Pg=Qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Qi=Qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Lg} &`]:{color:"$secondary500"}}}}}),Dg=Qt(Sn,{padding:"$0 $20 $20 $20"}),T5=Qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),_g=Qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),k5=Qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),en=Xn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Lg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),$g=Xn({padding:"$5 0"}),qi=Xn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Fg=Xn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Og=Xn({width:"100%",padding:"0 $20 $10"}),Ug=Qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),zg=Qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Hi=Qt(Rw,{wordBreak:"break-word"});import{styled as Kl}from"@rango-dev/ui";var Qg=Kl("div",{display:"flex",flexDirection:"column",gap:"$10"}),qg=Kl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Hg=Kl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Gg(t){let{message:e}=t,[o,n]=nb(!1);return tn.createElement(eb,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&tn.createElement(ob,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},tn.createElement(qg,{rotated:o},tn.createElement(tb,{size:12,color:"gray"}))),footer:tn.createElement(Hg,{open:o},tn.createElement(Hi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Gg,"FailedAlert");import{i18n as Vg}from"@lingui/core";import{Alert as jl,Button as Kg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Xl}from"rango-types";import Yn from"react";function jg(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(Kg,{size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Vg.t("Change"))}):r===Xl.WaitingForConnectingWallet?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(Kg,{size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForConnectingWallet)}},Vg.t("Connect"))}):Yn.createElement(jl,{type:"warning",title:n.shortMessage})}i(jg,"WarningAlert");function Yl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=gn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return no.createElement(Qg,null,a.explorerUrl?.map((m,g,d)=>{let f=g+m.url,h=g===d.length-1,T=(h&&u||p)&&!c,S=h&&a.status==="failed";return no.createElement(sb,{key:f},no.createElement(Xg,{type:h&&(T&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:rb.t("View transaction"),action:m.url&&no.createElement(ib,{variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},no.createElement(ab,{size:12}))}))}),c&&no.createElement(Xg,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&no.createElement(jg,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&no.createElement(Gg,{message:r}))}i(Yl,"SwapDetailsAlerts");var Yg=2e3;var Zg=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:pt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:pt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:on(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(p=>({from:{chain:{displayName:pt(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:pt(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:on(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:lb.createElement(Yl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function Jg(t){if(gn(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(Jg,"getStepState");function Zl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Tb(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=z.use.retry(),g=se.use.isActiveTab(),d=vb(),[f,h]=Cb(Yg),T=kb(null),[S,C]=nh(null),[k,v]=nh(null),x=i(()=>{r(),C(null)},"onCancel"),N=we.use.getNotifications(),M=we.use.removeNotification(),w=N(),E=cb(e),b=E?.networkStatus;oh(()=>{w.find(he=>he.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):k&&v(null))},[e.status,e.requestId]),oh(()=>{L?C(Gi.WaitingForNetworkChange):b===Gi.WaitingForConnectingWallet||b===Gi.NetworkChanged?C(b):C(null)},[b]);let W=jc(e),$=E?pb(e,E):null,I=E?ub(e,E):null,R=wg(e),ee=Xc(e),oe=i(de=>!!l(de)?.mobileWallet,"isMobileWallet"),L=b===Gi.WaitingForNetworkChange&&!!$&&!!I?.walletType&&(oe(I.walletType)||a(I.walletType,$)),V=L?s.bind(null,I.walletType,$):void 0,le=Kc(e,E),Y=Zg({swap:e,switchNetwork:V,showNetworkModal:b,setNetworkModal:C,message:le,blockchains:p,swappers:u}),ae=Y.length,[ge,ve]=[e.steps[0],e.steps[ae-1]],U=ve.outputAmount||ve.expectedOutputAmountHumanReadable,Ke=e.steps.reduce((de,he)=>de+parseFloat(he.feeInUsd||""),0),xt=e.steps.find(de=>de.diagnosisUrl)?.diagnosisUrl,lt=B(parseFloat(U||"0")*(ve.toUsdPrice||0),4,4),wt=B(parseFloat(e.inputAmount)*(ge.fromUsdPrice||0),4,4),_=U?new th(U).multipliedBy(ve.toUsdPrice||0).toString():"",Q=new th(e.inputAmount).multipliedBy(ge.fromUsdPrice||0).toString(),G=ut(wt,lt),pe=le.detailedMessage.content||le.shortMessage,ce=e.status==="success"?st.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:B(U,6,6),token:Y[ae-1].to.token.displayName,conciseAddress:dr(e.wallets[Y[ae-1].to.chain.displayName]?.address||""),chain:Y[ae-1].to.chain.displayName}}):K.createElement(zg,null,K.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},pe?"":st.t("Transaction was not sent."),W?`${st.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:W.outputAmount,symbol:W.symbol,blockchain:W.blockchain}})}`:""),pe&&K.createElement(Hi,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",pe));return K.createElement(ne,{header:{title:st.t("Swap Details"),onCancel:e.status==="running"?()=>C("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(Rg,{variant:"ghost",type:"error",size:"xsmall",onClick:()=>C("delete")},K.createElement(Io,{size:"medium",variant:"label",color:"error"},st.t("Delete"))))},footer:ee&&!k&&K.createElement(Rg,{fullWidth:!0,variant:"contained",type:"primary",size:"large",onClick:()=>{let de=Lr(e,p,c);m(de),setTimeout(()=>{d("../../")},0)}},st.t("Try again"))},K.createElement(re,{compact:!0,view:!0},K.createElement(Qi,null,K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${st.t("Request ID")}`),K.createElement("div",{className:qi()},K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(eh,{container:A(),content:f?st.t("Copied To Clipboard"):st.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(gb,{variant:"ghost",onClick:h.bind(null,o||"")},f?K.createElement(fb,{size:16,color:"secondary"}):K.createElement(mb,{size:16,color:"gray"}))),K.createElement(Ug,{target:"_blank",href:`${gp}/swap/${o}`},K.createElement(eh,{container:A(),content:st.t("View on Rango Explorer"),side:"bottom"},K.createElement(yb,{size:20}))))),K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?st.t("Finished at"):st.t("Created at")),K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},R))),K.createElement("div",{className:Fg()},K.createElement(hb,{fee:B(String(Ke),2,2),time:sn(ar(e.steps)),steps:ae}),K.createElement(En,{from:{price:{value:B(e.inputAmount,6,6),usdValue:wt,realUsdValue:Q,realValue:e.inputAmount},token:{displayName:Y[0].from.token.displayName,image:Y[0].from.token.image},chain:{image:Y[0].from.chain.image,displayName:Y[0].from.chain.displayName}},to:{price:{value:B(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||""},token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image,displayName:Y[ae-1].to.chain.displayName}},percentageChange:B(G,2,2),warningLevel:Lt(G??0)})),K.createElement("div",{className:Og()},K.createElement(Io,{variant:"title",size:"small"},st.t("Swaps steps"))),K.createElement(db,{size:8}),K.createElement(Dg,{ref:T},Y.map((de,he)=>{let Rn=he,ro=Jg(e.steps[he]),ea=ro==="error"||ro==="in-progress"||ro==="warning"||ro==="completed"&&he===Y.length-1;return K.createElement(Sb,{key:Rn,step:de,type:"swap-progress",ref:T,state:ro,hasSeparator:he!==0,tabIndex:Rn,isFocused:ea,tooltipContainer:A()})}))),K.createElement(ql,{state:S,onClose:()=>C(null),onCancel:x,onDelete:n,message:le.detailedMessage.content,currentStepWallet:I,walletButtonDisabled:!g}),K.createElement(Vl,{open:!!k,diagnosisUrl:xt,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||"",percentageChange:B(G,2,2),token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image},description:ce}))}i(Zl,"SwapDetails");import{i18n as Ki}from"@lingui/core";import{Divider as ah,NotFound as Ib,Skeleton as Jn,Typography as ji}from"@rango-dev/ui";import Te from"react";import{i18n as xb}from"@lingui/core";import{Divider as wb,Skeleton as bb,Typography as Eb}from"@rango-dev/ui";import ke from"react";import{css as vt,styled as Jl}from"@rango-dev/ui";var rh=Jl("div",{width:"100%",height:"100%",padding:"$10 $20"}),Zn=Jl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Vi=Jl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),L4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),P4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),D4=vt({paddingTop:"$15",display:"flex"}),_4=vt({padding:"$15 $0"}),$4=vt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),F4=vt({paddingBottom:"$10"}),O4=vt({display:"flex",justifyContent:"start",alignItems:"center"}),U4=vt({paddingTop:"$5",display:"flex",alignItems:"center"}),z4=vt({display:"flex",alignItems:"center"}),Q4=vt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),ih=vt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Rl(){return ke.createElement(rh,null,ke.createElement(Nn,{type:"swap-preview"}),ke.createElement("div",{className:"swaps-steps"},ke.createElement(Eb,{variant:"title",size:"small"},xb.t("Swaps steps"))),ke.createElement(ke.Fragment,null,ke.createElement(Zn,null,ke.createElement(Wt,{separator:!1}),ke.createElement("div",{className:ih()},ke.createElement(wb,{direction:"horizontal",size:20}),ke.createElement(bb,{height:22,variant:"rectangular"}))),ke.createElement(Vi,null),ke.createElement(Zn,null,ke.createElement(Wt,{separator:!1})),ke.createElement(Vi,null),ke.createElement(Zn,null,ke.createElement(Wt,{separator:!1})),ke.createElement(Vi,null),ke.createElement(Zn,null,ke.createElement(Wt,{separator:!1}))))}i(Rl,"LoadingSwapDetails");function sh(t){let{requestId:e,showSkeleton:o}=t;return Te.createElement(ne,{header:{title:Ki.t("Swap Details"),suffix:Te.createElement(Vt,null)}},o&&Te.createElement(Pg,null,Te.createElement(Qi,null,Te.createElement("div",{className:en()},Te.createElement(ji,{variant:"label",size:"large",color:"neutral700"},`${Ki.t("Request ID")}`),Te.createElement("div",{className:qi()},Te.createElement(ji,{variant:"label",size:"small",color:"neutral700"},Te.createElement(Jn,{width:60,height:10,variant:"rounded"})),Te.createElement(ah,{direction:"horizontal",size:4}),Te.createElement(Jn,{width:16,height:16,variant:"rectangular"}),Te.createElement(ah,{direction:"horizontal",size:4}),Te.createElement(Jn,{width:16,height:16,variant:"rectangular"}))),Te.createElement("div",{className:en()},Te.createElement(ji,{className:$g(),variant:"label",size:"large",color:"neutral700"},Te.createElement(Jn,{width:60,height:10,variant:"rounded"})),Te.createElement(ji,{variant:"label",size:"small",color:"neutral700"},Te.createElement(Jn,{width:60,height:10,variant:"rounded"})))),Te.createElement(Rl,null)),!o&&Te.createElement(_g,null,Te.createElement(Ib,{title:Ki.t("Not found"),description:Ki.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(sh,"SwapDetailsPlaceholder");function lh(){let{manager:t,state:e}=Wb(),o=!e.loadedFromPersistor,n=mt(t),{requestId:r}=Bb(),a=Ye(),{fetchStatus:s}=y();if(!r)return ep.createElement(Mb,{containerStyles:{margin:"20px"},type:"error",title:Ab.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:g})=>g.requestId===r):void 0,u=i(()=>{if(p?.id){let g=t?.get(p.id);g&&Nb(g)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(g){console.log(g)}},"onDelete"),m=p?.swap;return!m||l?ep.createElement(sh,{requestId:r,showSkeleton:l}):ep.createElement(Zl,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(lh,"SwapDetailsPage");import{i18n as ph}from"@lingui/core";import{Divider as Lb,getCategoriesCount as Pb,SelectableCategoryList as Db,styled as uh,Typography as _b,Wallet as $b}from"@rango-dev/ui";import Bt,{useState as ch}from"react";var Fb=uh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),Ob=uh(re,{textAlign:"center"});function mh(){let{fetchStatus:t}=y(),[e,o]=ch("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=ch(),l=se.use.isActiveTab(),{list:p}=gt(),u=Op(p,n),m=Pb(u)!==1,g=Up(p,e),d=i(f=>{Ep(p,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(ne,{header:{title:ph.t("Connect Wallets")}},Bt.createElement(Ob,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(Db,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(Lb,{size:24})),Bt.createElement(_b,{variant:"title",size:"xmedium",align:"center"},ph.t("Choose a wallet to connect.")),Bt.createElement(Fb,null,g.map((f,h)=>{let T=`wallet-${h}-${f.type}`;return Bt.createElement($b,{key:T,...f,container:A(),onClick:()=>d(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(mo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(mh,"WalletsPage");function dh(){return iu(),za(),Ub([{path:D.home,element:De.createElement(qf,null)},{path:D.routes,element:De.createElement(jf,null)},{path:D.fromSwap,children:[{index:!0,element:De.createElement(Pl,{type:"source"})},{path:D.blockchains,element:De.createElement(Bi,{type:"source"})}]},{path:D.toSwap,children:[{index:!0,element:De.createElement(Pl,{type:"destination"})},{path:D.blockchains,element:De.createElement(Bi,{type:"destination"})}]},{path:D.settings,children:[{index:!0,element:De.createElement(vg,null)},{path:D.languages,element:De.createElement(Gf,null)},{path:D.exchanges,element:De.createElement(El,{sourceType:"Exchanges"})},{path:D.bridges,element:De.createElement(El,{sourceType:"Bridges"})},{path:D.customTokens,children:[{index:!0,element:De.createElement(ef,null)},{path:D.addCustomTokens,children:[{index:!0,element:De.createElement(Uu,null)},{path:D.blockchains,element:De.createElement(Bi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:D.swaps,children:[{index:!0,element:De.createElement(kf,null)},{path:D.swapDetails,element:De.createElement(lh,null)}]},{path:D.wallets,element:De.createElement(mh,null)},{path:D.confirmSwap,element:De.createElement(Fd,null)}])}i(dh,"AppRoutes");import{useQueueManager as Xb}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as Yb}from"@rango-dev/wallets-shared";import{isEvmBlockchain as Zb}from"rango-sdk";import{useContext as Jb,useEffect as Th,useState as kh}from"react";import{globalCss as zb}from"@rango-dev/ui";var fh=i(()=>zb({"@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 gh(){let{setWatermark:t}=se();return{fetchApiConfig:i(async()=>{let o=await fetch(`${ct("BASE_URL")}/meta/dapp/config?apiKey=${ct("API_KEY")}`);if(!o.ok)throw new Error(`Request failed with status: ${o.status} `);let n=await o.json();t(n.config.watermark)},"fetchApiConfig")}}i(gh,"useFetchApiConfig");import{useWallets as Qb}from"@rango-dev/wallets-react";import{useEffect as qb,useRef as Hb}from"react";function hh(){let{connect:t,state:e}=Qb(),o=Hb({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);qb(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(hh,"useForceAutoConnect");import{isApprovalTX as Gb,RouteEventType as yh,StepEventType as Sh,StepExecutionEventStatus as Vb,WidgetEvents as Xi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ch}from"react";function tp(){let t=Z.use.connectedWallets(),e=Z.use.getWalletsDetails(),o=we.use.setNotification(),{findToken:n}=y();Ch(()=>{let r=i(a=>{let{event:s,step:l,route:p}=a;if(s.type===Sh.TX_EXECUTION&&s.status===Vb.TX_SENT&&!Gb(l)||s.type===Sh.SUCCEEDED){let c=t.find(g=>g.chain===l?.fromBlockchain),m=l?.fromBlockchain!==l?.toBlockchain&&t.find(g=>g.chain===l?.toBlockchain);c&&e([c],n),m&&e([m],n)}o(s,p)},"handleStepEvent");return ye.on(Xi.StepEvent,r),()=>ye.off(Xi.StepEvent,r)},[ye,t]),Ch(()=>{let r=i(a=>{let{event:s,route:l}=a;(s.type===yh.FAILED||s.type===yh.SUCCEEDED)&&o(s,l)},"handleRouteEvent");return ye.on(Xi.RouteEvent,r),()=>ye.off(Xi.RouteEvent,r)},[ye])}i(tp,"useSubscribeToWidgetEvents");import{useManager as Kb}from"@rango-dev/queue-manager-react";import{useEffect as jb}from"react";function op(){let{isSynced:t,syncNotifications:e}=we(),{manager:o,state:n}=Kb();jb(()=>{we.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(mt(o))},[we.persist.hasHydrated(),n.loadedFromPersistor,t])}i(op,"useSyncNotifications");function np(){hh(),fh(),tp(),op();let t=y().blockchains(),{canSwitchNetworkTo:e}=Zr(),[o,n]=kh(""),[r,a]=kh(),s=Jb(Er),l=t.filter(Zb),{fetchApiConfig:p}=gh();Th(()=>()=>ru(),[]),Xb({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Th(()=>(lo.init(),we.persist.hasHydrated()||we.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===Yb(o)?.[0]&&n("")}),p().catch(console.log),lo.destroy),[])}i(np,"useBootstrap");import{styled as Rb}from"@rango-dev/ui";var vh=Rb("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Yi(){np();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=eo();return rp.createElement(eE,{language:o},rp.createElement(vh,{id:"swap-container",className:e()},rp.createElement(dh,null)))}i(Yi,"Main");import{setSolanaSignerConfig as TE}from"@rango-dev/signer-solana";import ap,{useEffect as Ah,useMemo as kE}from"react";import{useState as tE}from"react";var oE=i(()=>{let[t,e]=tE(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=bp(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),xh=oE;import{checkWaitingForNetworkChange as nE,makeQueueDefinition as rE}from"@rango-dev/queue-manager-rango-preset";import{Provider as iE}from"@rango-dev/queue-manager-react";import{useWallets as aE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as sE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as lE}from"rango-types";import pE,{useMemo as cE}from"react";function uE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=aE(),l=cE(()=>rE({API_KEY:t.apiKey||ct("API_KEY"),BASE_URL:ct("BASE_URL"),emitter:{emit:ye.emit}}),[t.apiKey]),p=y().blockchains(),c={blockchains:Z.use.connectedWallets().map(k=>({accounts:[k],name:k.chain}))},m=i(async(k,v)=>{if(a(k,v))return r(k,v)},"switchNetwork"),g=i(k=>!!s(k).mobileWallet,"isMobileWallet"),d=p.filter(k=>k.enabled).reduce((k,v)=>(k[v.name]=v,k),{}),f=p.filter(lE),h=i(k=>{let{supportedChains:v}=s(k);return pr(v)},"getSupportedChainNames"),T=e(),S={meta:{blockchains:d,evmBasedChains:f,evmNetworkChainInfo:sE(f),getSupportedChainNames:h},getSigners:o,wallets:c,providers:T,switchNetwork:m,canSwitchNetworkTo:a,connect:r,state:n,isMobileWallet:g},C=se.use.isActiveTab();return pE.createElement(iE,{queuesDefs:[l],context:S,onPersistedDataLoaded:k=>{nE(k)},isPaused:!C},t.children)}i(uE,"QueueManager");var wh=uE;import{useManager as hE}from"@rango-dev/queue-manager-react";import yE,{createContext as SE,useContext as CE}from"react";function bh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=z();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:g,toToken:d,requestAmount:f}=u,h={blockchains:e,tokens:o};if(c!==void 0){let T=e.find(S=>S.name===c)??null;n(T)}if(m!==void 0){let T=m?t(m)??null:null;r({meta:h,token:T})}if(g!==void 0){let T=e.find(S=>S.name===g)??null;a(T)}if(d!==void 0){let T=d?t(d)??null:null;s({meta:h,token:T})}f!==void 0&&l(f)},"updateQuoteInputs")}i(bh,"useUpdateQuoteInputs");import{cancelSwap as mE,getCurrentBlockchainOfOrNull as dE,getCurrentStep as fE,getRelatedWalletOrNull as gE}from"@rango-dev/queue-manager-rango-preset";var Zi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return mt(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=Lr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&mE(o)}getCurrentStepInfo(e){let o=fE(e);return{step:o,wallet:o?gE(e,o):null,network:o?dE(e,o):null}}};var Eh=SE(void 0);function ip(t){let{manager:e}=hE(),o=se.use.isActiveTab(),n=z.use.retry(),{findToken:r}=y(),a=new Zi(e,{retrySwap:n,findToken:r}),s=Z.use.connectedWallets(),l=Z.use.loading(),p=Lp(s),u=Z.use.getWalletsDetails(),c=y().blockchains(),m=y().tokens(),g=y().swappers(),d=y().fetchStatus,f=eo().resetLanguage,h=we().getNotifications(),T=we().clearNotifications,S=bh(),{fromBlockchain:C,toBlockchain:k,fromToken:v,toToken:x,inputAmount:N}=z(),M={isActiveTab:o,setCurrentTabAsActive:lo.forceClaim,history:a,wallets:{isLoading:l,details:s,totalBalance:p,refetch:w=>u(w,r)},meta:{blockchains:c,tokens:m,swappers:g,loadingStatus:d,findToken:r},resetLanguage:f,notifications:{list:h,clearAll:T},quote:{quoteInputs:{fromBlockchain:C?.name??null,fromToken:v?{symbol:v.symbol,blockchain:v.blockchain,address:v.address}:null,toBlockchain:k?.name??null,toToken:x?{symbol:x.symbol,blockchain:x.blockchain,address:x.address}:null,requestAmount:N},updateQuoteInputs:S}};return yE.createElement(Eh.Provider,{value:M},t.children)}i(ip,"WidgetInfo");function Ih(){let t=CE(Eh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Ih,"useWidget");function Ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=xh();return Ah(()=>{n&&r(n)},[n]),kE(()=>{zp({API_KEY:o?.apiKey||nr,BASE_URL:o?.apiUrl||fp})},[o.apiKey,o.apiUrl]),Ah(()=>{t.config?.signers?.customSolanaRPC&&TE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),ap.createElement(Ir,{config:o,onUpdateState:e},ap.createElement(wh,{apiKey:o.apiKey},ap.createElement(ip,null,t.children)))}i(Ji,"WidgetProvider");function Nh(t){let e=t.config?.externalWallets;return Ri.createElement(Wc,null,e?Ri.createElement(Yi,null):Ri.createElement(Ji,{config:t.config??ra},Ri.createElement(Yi,null)))}i(Nh,"Widget");function Wh(){let{on:t,off:e}=ye;return{on:t,off:e}}i(Wh,"useWidgetEvents");var J3={DerivationPath:mn,Namespaces:un,isOnDerivationPath:fn,isOnNamespace:dn};export{w3 as EventSeverity,so as MainEvents,P3 as Networks,$3 as PendingSwapNetworkStatus,ha as QuoteEventTypes,b3 as RouteEventType,ia as SUPPORTED_FONTS,J3 as StatefulConnect,E3 as StepEventType,I3 as StepExecutionBlockedEventStatus,A3 as StepExecutionEventStatus,$e as UI_ID,ya as UiEventTypes,Sr as WalletEventTypes,B3 as WalletEvents,D3 as WalletTypes,Nh as Widget,so as WidgetEvents,Ji as WidgetProvider,Ir as WidgetWallets,Ra as customizedThemeTokens,W3 as readAccountAddress,qt as useStatefulConnect,gt as useWalletList,Zr as useWallets,Ih as useWidget,Wh as useWidgetEvents,yr as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map