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

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 Kh=Object.defineProperty;var i=(t,e)=>Kh(t,"name",{value:e,configurable:!0});import{EventSeverity as b3,RouteEventType as x3,StepEventType as E3,StepExecutionBlockedEventStatus as I3,StepExecutionEventStatus as A3}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as W3}from"@rango-dev/wallets-core/legacy";import{useWallets as Zr,Events as L3}from"@rango-dev/wallets-react";import{Networks as P3,WalletTypes as _3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as $3}from"rango-types";import{Divider as QS}from"@rango-dev/ui";import co,{useEffect as HS,useRef as qS,useState as Mp}from"react";import{WalletState as jh}from"@rango-dev/ui";import{useWallets as Xh}from"@rango-dev/wallets-react";import{useReducer as Yh}from"react";function ic(t){return!!t.derivationPath}i(ic,"isStateOnDerivationPathStep");function ac(t){return!!t.namespace}i(ac,"isStateOnNamespace");var ar={status:"init",namespace:null,derivationPath:null};function sc(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return ar;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ar;default:throw new Error("Action hasn't been defined.")}}i(sc,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=Xh(),[n,r]=Yh(sc,ar),a=i(async(u,d,h)=>{r({type:"reset"});try{let f=d?.map(g=>({...g,network:void 0}));return await o(u,f),{status:"connected"}}catch(f){let g=f?.message?`Error: ${f.message}`:"An unknown error happened during connecting wallet.";throw new Error(g,{cause:f})}},"runConnect"),s=i(async(u,d)=>{if(u.state===jh.DISCONNECTED){if(!!u.isHub&&u.properties?.find(k=>k.name==="detached")&&u.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(!u.needsNamespace)return await a(u.type,void 0,d);let g=u.needsNamespace.data.length>1,m=u.needsDerivationPath;if(g)return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(m){let C=u.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:C.value}}),{status:"derivation-path"}}return await a(u.type,u.needsNamespace?.data.map(C=>({namespace:C.value})),d)}return d?.disconnectIfConnected?(await p(u.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(u,d)=>{let h=u.needsNamespace?.selection==="single",f=u.needsDerivationPath,g=d[0];if(!g)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&f)return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:g}}),{status:"derivation-path"};if(!ac(n))throw new Error("Something went wrong on handling namespace. Please retry.");let m=n.namespace.targetWallet.type,C=d.map(S=>({namespace:S}));return await a(m,C)},"handleNamespace"),c=i(async u=>{if(!u)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!ic(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=n.derivationPath.providerType,f=[{namespace:n.derivationPath.namespace,derivationPath:u}];return await a(d,f)},"handleDerivationPath"),p=i(async u=>{let d=t(u);return d.connected||d.connecting?(await e(u),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:p,handleNamespace:l,handleDerivationPath:c,getState:()=>n,resetState:u=>{r(u==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Gt,"useStatefulConnect");import{WalletState as Sa}from"@rango-dev/ui";import{useWallets as aS}from"@rango-dev/wallets-react";import{detectMobileScreens as sS,KEPLR_COMPATIBLE_WALLETS as lS,WalletTypes as gn}from"@rango-dev/wallets-shared";import{useCallback as cS,useEffect as pS}from"react";import tS,{createContext as oS,useContext as nS,useEffect as rS,useRef as iS}from"react";import{create as Ry}from"zustand";import{persist as eS}from"zustand/middleware";import{allProviders as Zh}from"@rango-dev/provider-all";var Ri=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},Eo=new Ri;import{defineVersions as cc,pickVersion as pc,Provider as ea}from"@rango-dev/wallets-core";function uc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=dc(a);return s instanceof ea?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof ea?o.push(cc().version("1.0.0",n).build()):o.push(cc().version("0.0.0",n).build())}),o}return t}i(uc,"matchAndGenerateProviders");function dc(t){try{return pc(t,"1.0.0")[1]}catch{return pc(t,"0.0.0")[1]}}i(dc,"pickProviderVersionWithFallbackToLegacy");function mc(t){return t.map(o=>dc(o)).map(o=>o instanceof ea?o.id:o.config.type)}i(mc,"configWalletsToWalletName");function sr(t,e){return e.find(o=>o.name===t)?.displayName}i(sr,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function fc(t,e){return e.find(o=>o.name===t)?.logo}i(fc,"getBlockchainImage");function rn(t,e){return e.find(o=>o.id===t)?.title}i(rn,"getSwapperDisplayName");function an(t,e){return e.find(o=>o.name===t)??null}i(an,"findBlockchain");function ta(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(ta,"isTokenNative");function lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function Io(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Io,"isValidTokenAddress");function sn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=lt(c));let p=o.tokensMapByTokenHash.get(c);p&&(n[c]=p)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(c=>{l.has(c)||a(o.tokensMapByBlockchainName[c])})}return s.forEach(l=>{let c=r[l];if(!c&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}c&&(c.isExcluded?(a(o.tokensMapByBlockchainName[l]),c.tokens.forEach(p=>{let u=lt(p);delete n[u]})):a(c.tokens))}),Object.values(n)}i(sn,"matchTokensFromConfigWithMeta");function lr(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(lr,"getSupportedBlockchainsFromConfig");function hc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(hc,"makeProvidersOptionsFromConfig");var cr={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"}},Jh={clientUrl:void 0},Rh={liquiditySources:void 0};function gc(t){let e=hc(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return Zh(o).map(a=>a())}i(gc,"generateProviders");var yc=i((t,e,o)=>{let n=gc({...cr,...t});return{config:{...cr,...t},iframe:Jh,campaignMode:Rh,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l}=o(),c=sn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),p=sn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});Eo.set("supportedSourceTokens",c),Eo.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=gc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=hc(a);return uc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Sc}from"rango-types";var Cc=[Sc.EVM,Sc.SOLANA];import{RangoClient as fy}from"rango-sdk";import{UI_ID as ey}from"@rango-dev/ui";var pr="c6381a79-2817-4602-83bf-6a641a409e32",kc="https://api.rango.exchange",Tc="https://explorer.rango.exchange",De={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...ey};import{BlockchainCategories as sy,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as ly}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as cy,getCosmosExperimentalChainInfo as py,isEvmAddress as uy,KEPLR_COMPATIBLE_WALLETS as fA,Networks as _c}from"@rango-dev/wallets-shared";import No from"bignumber.js";import{isCosmosBlockchain as dy}from"rango-types";import ty from"bignumber.js";var ce=new ty(0);import{WalletTypes as oy}from"@rango-dev/wallets-shared";var no="~",vc=[oy.LEAP];import{BlockchainCategories as na,WalletState as ay}from"@rango-dev/ui";import{TransactionType as ur}from"rango-sdk";var wc="Roboto",oa=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function Ao(t){return Array.from(new Set(t))}i(Ao,"removeDuplicateFrom");function Nc(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Nc,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function Ec(t,e){return t.toLowerCase()===e.toLowerCase()}i(Ec,"exactText");function Ic(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(Ic,"startWithText");var I=i(()=>document.getElementById(De.SWAP_BOX_ID),"getContainer"),ro=i(()=>document.getElementById(De.EXPANDED_BOX_ID),"getExpanded");function Ac(t,e,o){let n=!!e&&Ec(e,t),r=!!o&&Ec(o,t);return n!==r?n?-1:1:0}i(Ac,"compareExactMatchText");function ra(t,e,o){let n=!!e&&Je(e,t),r=!!o&&Je(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ra,"compareContainsText");function ia(t,e,o){let n=!!e&&Ic(e,t),r=!!o&&Ic(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ia,"compareStartWithText");function Wc(t,e,o){if(!o)return 0;let n=Ac(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Ac(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=ia(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ra(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ia(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=ra(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=ia(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=ra(o,t.address,e.address);if(r!==0)return r}return 0}i(Wc,"compareWithSearchFor");var dr=i((t,e)=>{switch(e){case na.ALL:return!0;case na.UTXO:return t===ur.TRANSFER;case na.OTHER:return t!==ur.TRANSFER&&t!==ur.COSMOS&&t!==ur.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Bc=i(t=>oa.find(o=>o.value===t)?.url,"getFontUrlByName");function Lc(t,e){let o=!!t.find(n=>n.state===ay.CONNECTED);return e===!1&&o}i(Lc,"isSingleWalletActive");function Mc(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(Mc,"memoizedResult");import{BigNumber as Pc}from"bignumber.js";var ln=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),B=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Pc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Pc(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var mr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),cn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function pn(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(pn,"mapStatusToWalletState");function Dc(t,e,o,n){return o.filter(r=>!vc.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:c}=t(r);return s&&(!l||!!n&&c!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:c,needsNamespace:p,supportedChains:u,needsDerivationPath:d,properties:h,isHub:f}=e(r),g=Ao(u.map(C=>C.type)),m=pn(t(r));return{title:a,image:s,link:cy(l),state:m,type:r,showOnMobile:c,needsNamespace:p,blockchainTypes:g,needsDerivationPath:d,properties:h,isHub:f}})}i(Dc,"mapWalletTypesToWalletInfo");function un(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(un,"walletAndSupportedChainsNames");function sa(t,e,o,n,r){let a=[];function s(c,p){if(!!!a.find(d=>d.chain===c)){let d={address:p,chain:c,walletType:t};a.push(d)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:p,network:u}=ly(c),d=l.length>0,h=l.includes(u),f=u===_c.Unknown;if(d&&!h&&!f)return;let m=u===_c.Unknown&&uy(p);if(f&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,p.toLowerCase())}):s(u,p)}),a}i(sa,"prepareAccountsForWalletStore");function io(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:c}=r;c.forEach((p,u)=>{let d=p.from.blockchain,h=p.to.blockchain,f=a===o.swaps.length-1,g=u===c.length-1;(!f&&!g||f&&l!==d||e==="all")&&n.add(d),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function dn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(dn,"isAccountAndWalletMatched");var $c=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?aa(n.usdValue,n.decimals):ce.toFixed();return o.plus(r)},new No(ce));return my(e.toString())},"calculateWalletUsdValue");function my(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(my,"numberWithThousandSeparator");var hr=i((t,e)=>{let o=py(Object.entries(t).map(([,n])=>n).filter(dy));return o&&o[e]?.experimental},"isExperimentalChain");function aa(t,e){return new No(t).shiftedBy(-e).toFixed()}i(aa,"representAmountInNumber");function yr(t){if(!t)return null;let e=aa(t.amount,t.decimals),o=t.usdValue?aa(t.usdValue,t.decimals):null,n=B(e,8,8),r=o?B(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(yr,"formatBalance");function Fc(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new No(t.usdValue).shiftedBy(-t.decimals):ce,n=e&&e.usdValue?new No(e.usdValue).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new No(t.amount).shiftedBy(-t.decimals):ce,n=e&&e.amount?new No(e.amount).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Fc,"compareTokenBalance");function Lt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Lt,"areTokensEqual");function Oc(t){return t.sort((e,o)=>+(o.state===bt.CONNECTED)-+(e.state===bt.CONNECTED)||+(o.state===bt.DISCONNECTED||o.state===bt.CONNECTING)-+(e.state===bt.DISCONNECTED||e.state===bt.CONNECTING))}i(Oc,"sortWalletsBasedOnConnectionState");function Sr(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(Sr,"getConciseAddress");function Uc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Uc,"getAddress");var zc=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Qc(t){return t.map(e=>e.state).join("-")}i(Qc,"hashWalletsState");function Hc(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Hc,"filterBlockchainsByWalletTypes");function qc(t,e){return e===sy.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(dr(n,e))return!0;return!1})}i(qc,"filterWalletsByCategory");var la={API_KEY:pr};function Mt(t){return la[t]||""}i(Mt,"getConfig");function Gc(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),la=e,la}i(Gc,"initConfig");var Vc=20,Kc=25,ca="theme-widget",pa=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Lt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Lt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),ua=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),jc=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Cr,xt=i(()=>Cr||(Cr=new fy(Mt("API_KEY"),Mt("BASE_URL")),Cr),"httpService");function kr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Ao(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(c=>c===s.swapperGroup)),l&&s.types.map(c=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:c,selected:!e.includes(s.swapperGroup)})})}}),n}i(kr,"getUniqueSwappersGroups");function Xc(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Xc,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function Wo(t,e){return e?.[t]==="enabled"}i(Wo,"isRoutingEnabled");var Yc=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Zc=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let c=lr({config:a}),p=r;return c.length>0&&(p=p.filter(u=>c.includes(u.name))),p.filter(u=>Cc.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(c=>!(s.length>0&&!s.includes(c.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),c=e()._blockchainsMapByName;if(!o||!o.type)return l;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=Eo.get(u);d?.length||(d=sn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Eo.set(u,d)),d=Yc(d,s,a.features);let h=e().blockchains({type:o.type});return d.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!h.some(m=>m.name===g.blockchain)?!1:o.searchFor?!!(Je(g.symbol,o.searchFor)||Je(g.address||"",o.searchFor)||Je(g.name||"",o.searchFor)):!0).sort((g,m)=>{let C=e().isTokenPinned(g,o.type),S=e().isTokenPinned(m,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let N=o.getBalanceFor(g),D=o.getBalanceFor(m),w=Fc(N,D);if(w!==0)return w}let k=c.get(g.blockchain),T=c.get(m.blockchain),v=ta(g,k),b=ta(m,T);if(v!==b)return v?-1:1;if(g.isPopular!==m.isPopular)return g.isPopular?-1:1;if(o.searchFor){let N=Wc(g,m,o.searchFor);if(N)return N}return g.isSecondaryCoin!==m.isSecondaryCoin?g.isSecondaryCoin?1:-1:k&&T?k.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=lt(o),s=n.get(a);return s||(s=r.find(l=>lt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Lt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort(Xc)},fetch:async()=>{try{let{routing:o}=e().config,n=Wo("enableCentralizedSwappers",o),r=await xt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],p=r.popularTokens,u=r.swappers.filter(f=>f.enabled),d=new Set;r.tokens.forEach(f=>{d.add(f.blockchain),c.push(f)}),r.blockchains.sort((f,g)=>f.sort-g.sort).forEach(f=>{f.enabled&&d.has(f.name)&&a.set(f.name,f)}),c.forEach(f=>{let g=lt(f);l[f.blockchain]||(l[f.blockchain]=[]),s.set(g,f),l[f.blockchain].push(g)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as gy,Catalonia as hy,Chinese as Jc,Denmark as yy,English as Sy,Finland as Cy,French as ky,German as Ty,Greece as vy,Hungary as wy,India as by,Indonesian as xy,Italian as Ey,Japanese as Iy,Korea as Ay,Lithuania as Ny,Malay as Wy,Netherlands as By,Pakistan as Ly,Philippines as My,Poland as Py,Portuguese as _y,Russian as Dy,SaudiArabia as $y,Serbia as Fy,Slovakia as Oy,SouthAfrica as Uy,Spanish as zy,Swahili as Qy,Swedish as Hy,Thai as qy,Turkish as Gy,Ukrainian as Vy,Vietnamese as Ky}from"@rango-dev/ui";var Rc=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:Uy},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:$y},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:gy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:hy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Jc},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Jc},{title:"Danish",label:"Dansk",local:"da",SVGFlag:yy},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:By},{title:"English",label:"English",local:"en",SVGFlag:Sy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:My},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:Cy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ky},{title:"German",label:"Deutsch",local:"de",SVGFlag:Ty},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:vy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:by},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:wy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:xy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:Ey},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Iy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:Ay},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:Ny},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Wy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Py},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:_y},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Dy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Fy},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Oy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:zy},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Qy},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Hy},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:qy},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Gy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Vy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:Ly},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Ky}],Bo="en";var ep=[.5,1,3],tp=1,op=5,np=100,rp=0;var ip=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:tp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let c=s===o,p=l<=9;return c&&p}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Ao(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=Ve("theme",n),s=Ve("language",n),l=Ve("liquiditySource",n),c=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...c&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Bo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||Bo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=lr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import ya from"bignumber.js";import jy from"mitt";var ye=jy(),Xy={on:ye.on,off:ye.off};import{WidgetEvents as ap}from"@rango-dev/queue-manager-rango-preset";var ma=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ma||{}),fa=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(fa||{}),ga=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ga||{}),Lo=(a=>(a[a.RouteEvent=ap.RouteEvent]="RouteEvent",a[a.StepEvent=ap.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Lo||{});var sp=i(t=>(e,o,n)=>t(i((...a)=>{e(s=>({...s,lastUpdatedAt:+new Date})),e(...a)},"modifedSet"),o,n),"keepLastUpdated");import Yy from"bignumber.js";function mn(t){return`${t.blockchain}${no}${t.address}${no}${t.symbol}`}i(mn,"createAssetKey");function ha(t,e){return`${mn(e)}${no}${t}`}i(ha,"createBalanceKey");function fn(t){let[e,o,n]=t.split(no);return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(fn,"extractAssetFromBalanceKey");function lp(t,e){let o={};return t.balances?.forEach(n=>{let r=ha(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,c=l?new Yy(l??ce).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:c};o[r]=p}),o}i(lp,"createBalanceStateForNewAccount");function cp(t,e){for(let o in e){let n=fn(o),r=mn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(cp,"updateAggregatedBalanceStateForNewAccount");function pp(t,e){let o=fn(e),n=mn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(pp,"removeBalanceFromAggregatedBalance");function Zy(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(Zy,"matchWalletDetailsWithConnectedWallet");var Jy=Mc(),up=sp((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>dn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>dn(s,a))?{...a,loading:!1,error:!1,explorerUrl:Zy(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>dn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>dn(s,l)));if(a.length>0){let s=a.map(l=>{let c=!r.some(p=>p.chain===l.chain&&p.selected&&p.walletType!==l.walletType);return{address:l.address,chain:l.chain,explorerUrl:null,walletType:l.walletType,selected:c,namespace:n,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(p=>!s.some(u=>u.walletType===p.walletType&&u.chain===p.chain)),...s]}))}},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n)=>{ye.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o,n),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(p=>p.walletType===o);e().connectedWallets.forEach(p=>{p.walletType!==o&&(r=r.filter(u=>!(u.chain===p.chain&&u.address===p.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(p=>n.chains?.includes(p.chain))),n?.namespaces&&n.namespaces.length>0&&(r=r.filter(p=>p.namespace?n.namespaces?.includes(p.namespace):!1));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(p=>{let u=fn(p);!!r.find(h=>ha(h.address,{address:u.address,blockchain:h.chain,symbol:u.symbol})===p)?s=pp(s,p):a[p]=l[p]}),t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(ye.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(l=>a.includes(l.chain)?(a=a.filter(c=>c!==l.chain),{...l,selected:!0}):l);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(c=>({address:c.address,blockchain:c.chain})),s;try{s=await xt().getWalletsDetails(a)}catch(c){throw e().setConnectedWalletHasError(o),new Error("Request for fetching balances failed.",{cause:c})}let l=s.wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let d=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));d.length>0&&e().fetchBalances(d,{retryOnFailedBalances:!1})}let p={},u=e()._aggregatedBalances;l.forEach(d=>{if(d.failed||(e().removeBalancesForWallet(r,{chains:[d.blockChain]}),!e().connectedWallets.find(f=>f.walletType===r&&f.address===d.address&&f.chain===d.blockChain)))return;let h=lp(d,e);u=cp(u,h),p={...p,...h}}),t(d=>({_balances:{...d._balances,...p},_aggregatedBalances:u})),e().setConnectedWalletRetrievedData(o,l)}else throw e().setConnectedWalletHasError(o),new Error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=mn(o),a=e()._aggregatedBalances[r]||[];if(a.length===0)return null;if(a.length===1){let c=a[0];return n[c]}let l=n[a[0]];return a.forEach(c=>{let p=n[c],u=new ya(p.amount),d=new ya(l.amount);u.isGreaterThan(d)&&(l=p)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,p]=l.split(no);return p===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>Jy(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,l)=>{let c=r[l],p=fn(l);if(p.blockchain===n.chain){let u=e().findToken(p),d=c.amount?new ya(c.amount).shiftedBy(-c.decimals):ce;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:c.amount,decimal:c.decimals,amount:d.toString(),logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function dp(t){return Ry()(eS((...e)=>({...up(...e),...Zc(...e),...ip(...e),...yc(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(dp,"createAppStore");var mp=oS(null);function y(){let t=nS(mp);if(rS(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function fp(t){let e=iS();return e.current||(e.current=dp(t.config)),tS.createElement(mp.Provider,{value:e.current},t.children)}i(fp,"AppStoreProvider");function ft(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=aS(),s=y().blockchains(),{handleDisconnect:l}=Gt(),c=mc(n()),p=Dc(r,a,c,e);p=sS()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Oc(p),d=i(m=>!o.find(C=>C.walletType===m&&C.chain===e),"isExperimentalChainNotAdded"),h=cS(()=>{let m=p?.filter(C=>C.state===Sa.CONNECTING)||[];for(let C of m)l(C.type)},[Qc(p)]);pS(()=>()=>{h()},[]);let f=i(m=>{let C=m.find(k=>k.type===gn.DEFAULT);return!C||C.state===Sa.NOT_INSTALLED?!1:m.filter(k=>k.state!=Sa.NOT_INSTALLED&&![gn.DEFAULT,gn.WALLET_CONNECT_2,gn.LEDGER].includes(k.type)&&a(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((m,C,S)=>hr(S,C)&&d(m)&&!lS.includes(m)||m==gn.DEFAULT&&!f(p),"shouldExcludeWallet");return{list:u.filter(m=>!g(m.type,e??"",s)),terminateConnectingWallets:h}}i(ft,"useWalletList");import{Modal as fS}from"@rango-dev/ui";import gS from"react";import{create as mS}from"zustand";var gp="rango-widget";var hn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(gp),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var dS=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),Mo=dS;var re=Mo(mS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})},setShowProfileBanner:o=>{t({showProfileBanner:o})}}))),ao=new hn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function J(t){let{watermark:e}=re();return gS.createElement(fS,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Ca}from"@lingui/core";import{Button as TS,Checkbox as vS,Divider as wS,Image as xp,ListItemButton as bS,MessageBox as xS,Radio as ES,RadioRoot as IS}from"@rango-dev/ui";import we,{useState as AS}from"react";import{css as hS,darkTheme as yp,IconButton as yS,styled as so}from"@rango-dev/ui";var Et=so(yS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${yp} &`]:{backgroundColor:"$neutral"}}}),Sp=so("div",{position:"absolute",background:"$secondary500",[`.${yp} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=so("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Cp=so("div",{position:"absolute",width:"14px",height:"14px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"7px",top:"$0",right:"$0",variants:{isSever:{true:{backgroundColor:"$error500"},false:{backgroundColor:"$secondary500"}}}}),kp=so("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Tp=so("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),vp=hS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Tr=so("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as SS,styled as vr}from"@rango-dev/ui";var wN=vr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Po=vr("div",{position:"relative"}),CS=SS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),_o=vr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${CS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),wr=vr("div",{"& img":{borderRadius:"50%"}});function wp(t,e){return t.find(o=>o.name===e)?.logo}i(wp,"getBlockchainLogo");import{styled as kS}from"@rango-dev/ui";var bp=kS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function yn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=AS([]),s=y().blockchains(),l=i(p=>{a(o?[p]:u=>u.includes(p)?u.filter(d=>d!==p):u.concat(p))},"onSelect"),c=i(p=>o?we.createElement(IS,{value:r?.[0]},p):we.createElement(we.Fragment,null,p),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(wS,{size:20}),we.createElement(xS,{type:"info",title:Ca.t("Select chain types"),description:Ca.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Po,null,we.createElement(Tr,null,we.createElement(xp,{src:n,size:45})),we.createElement(_o,null))}),we.createElement(bp,null,c(we.createElement(we.Fragment,null,e.needsNamespace?.data.map(p=>we.createElement(bS,{key:p.id,id:p.id,title:p.label,hasDivider:!0,style:{height:60},onClick:()=>l(p.value),start:we.createElement(xp,{src:wp(s,p.id),size:22}),end:o?we.createElement(ES,{value:p.value}):we.createElement(vS,{checked:r.includes(p.value)})}))))),we.createElement(TS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ca.t("Confirm")))}i(yn,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as BS,Divider as Ap,Image as LS,MessageBox as MS,Select as PS,TextField as _S}from"@rango-dev/ui";import Oe,{useEffect as DS,useState as Np}from"react";import{namespaces as NS}from"@rango-dev/wallets-shared";var br={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ka(t){let e=t?NS[t].derivationPaths:null;return e?[...e,br]:[]}i(ka,"getDerivationPaths");import{styled as Ep,Typography as WS}from"@rango-dev/ui";var Ip=Ep("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ta=Ep(WS,{paddingLeft:"$10"}),va={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Wp="0";function Sn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Np(null),[l,c]=Np(Wp),p=a===br.id,u=ka(o),d=i(({value:f})=>{let g=u?.find(m=>m.id===f);g&&(a===br.id&&Number.isNaN(Number(l))&&c(Wp),s(g.id))},"handleDerivationPathItemClick"),h=i(()=>{let f=u.find(g=>g.id===a);if(f)e(f.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return DS(()=>{s(ka(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(Ap,{size:20}),Oe.createElement(MS,{type:"info",title:Do.t("Select Derivation Path"),description:Do.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Po,null,Oe.createElement(wr,null,Oe.createElement(LS,{src:n,size:45})),Oe.createElement(_o,null))}),Oe.createElement(Ip,null,Oe.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),Oe.createElement(PS,{value:a||"",options:u.map(f=>({value:f.id,label:f.label})),variant:"filled",handleItemClick:d,styles:{trigger:va}}),Oe.createElement(Ap,{size:20}),Oe.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},p?Do.t("Enter Path"):Do.t("Enter Index")),Oe.createElement(_S,{type:p?"text":"number",variant:"contained",value:l,onChange:f=>c(f.target.value),style:va})),Oe.createElement(BS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!u||!a||!l},Do.t("Confirm")))}i(Sn,"DerivationPath");import{i18n as $o}from"@lingui/core";import{Image as $S,MessageBox as wa,WalletState as FS}from"@rango-dev/ui";import{useWallets as OS}from"@rango-dev/wallets-react";import lo from"react";function ba(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=OS();return pn(a(n))===FS.CONNECTED?lo.createElement(wa,{type:"success",title:$o.t("Wallet Connected"),description:$o.t("Your wallet is connected, you can use it to swap.")}):o?lo.createElement(wa,{type:"error",title:$o.t("Failed to Connect"),description:o||$o.t("Your wallet is not connected. Please try again.")}):lo.createElement(wa,{type:"loading",title:$o.t("Connecting to your wallet"),description:$o.t("Click connect in your wallet popup."),icon:lo.createElement(Po,null,lo.createElement(wr,null,lo.createElement($S,{src:r,size:45})),lo.createElement(_o,null))})}i(ba,"ConnectStatus");import{i18n as xa}from"@lingui/core";import{Button as US,Divider as Bp,MessageBox as zS}from"@rango-dev/ui";import xr from"react";function Ea(t){let{displayName:e,onConfirm:o}=t;return xr.createElement(zS,{title:xa.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:xa.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},xr.createElement(Bp,{size:18}),xr.createElement(Bp,{size:32}),xr.createElement(US,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},xa.t("Confirm")))}i(Ea,"ExperimentalChain");function Lp(t,e){return t().status==="init"&&!!e}i(Lp,"isOnStatus");function Cn(t){return t().status==="namespace"}i(Cn,"isOnNamespace");function kn(t){return t().status==="derivationPath"}i(kn,"isOnDerivationPath");var GS=3e3,VS=300;function po(t){let e=qS(),[o,n]=Mp(!1),[r,a]=Mp(),s=i(k=>{a(k.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:c,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:h}=Gt(),f=i(k=>{u(t.wallet,k).then(S).catch(s)},"handleConfirmNamespaces"),g=i(k=>{if(!k)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(k).then(S).catch(s)},"handleDerivationPathConfirm"),m=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),S=i((k,T)=>{let v=k.status==="connected",b=["disconnected","disconnected-unhandled"].includes(k.status);v?(t.onConnect?.(),T||(e.current=setTimeout(m,GS))):b&&m()},"afterConnected");return HS(()=>{if(t.wallet){C();let k=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,k||n(!0)},VS)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(b=>{["namespace","derivation-path"].includes(b.status)||(k=!0),S(b,T)}).catch(s)}},[t.wallet]),co.createElement(J,{open:o,onClose:m,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:I()},Lp(d,t.wallet)&&co.createElement(co.Fragment,null,co.createElement(ba,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),co.createElement(QS,{direction:"vertical",size:32})),Cn(d)&&co.createElement(yn,{onConfirm:f,value:d().namespace}),kn(d)&&co.createElement(Sn,{onConfirm:g,value:d().derivationPath}))}i(po,"StatefulConnectModal");import{Provider as ZS}from"@rango-dev/wallets-react";import Er,{createContext as JS,useEffect as Fp,useMemo as RS,useRef as Op}from"react";import{useEffect as KS}from"react";function Pp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Pp,"hashProviders");function Ia(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return KS(()=>{o(),r()},[Pp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Ia,"useWalletProviders");import{legacyFormatAddressWithNetwork as jS,legacyReadAccountAddress as _p}from"@rango-dev/wallets-core/legacy";import{Events as uo}from"@rango-dev/wallets-react";import{isEvmBlockchain as XS}from"rango-sdk";function Dp(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=y(),{onConnectWalletHandler:l,onDisconnectWalletHandler:c}=t,p=s().filter(XS).map(m=>m.name),u=i((m,C)=>{let[S,,k,,T]=m,v=sa(S,k,p,C.supportedChainNames,T.isContractWallet);v.length&&e(v,T.namespace)},"onAccountsEvent"),d=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains);S&&u([m,C,S,k,T],{supportedChainNames:v})}if(C===uo.CONNECTED){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}C===uo.PROVIDER_DISCONNECTED&&(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),C===uo.NAMESPACE_DISCONNECTED&&n(m,S)},"handleUpdatesForHub"),h=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains),b=[],N=[];if(S?.forEach(w=>{let{network:x}=_p(w);p.includes(x)?b.push(w):N.push(w)}),r.filter(w=>w.walletType===m).map(w=>jS(w.address,w.chain)).length>0){if(b.length>0){let w=sa(m,b,p,v,T.isContractWallet);a(m,{chains:w.map(x=>x.chain)})}N.length>0&&a(m,{chains:N.map(w=>{let{network:x}=_p(w);return x})})}S?u([m,C,S,k,T],{supportedChainNames:v}):(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}if(C===uo.ACCOUNTS&&k.connected){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForLegacy"),f=i((m,C,S,k,T)=>{if(C===uo.NETWORK&&k.network){let v=`${m}-${k.network}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,C,S,k,T)=>{T.isHub?d(m,C,S,k,T):h(m,C,S,k,T),f(m,C,S,k,T)},"handler")}}i(Dp,"useUpdates");import{LegacyEvents as YS}from"@rango-dev/wallets-core/legacy";function $p(t,e){let[o,n,r,a,s]=e;n!==YS.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i($p,"propagateEvents");var Ir=JS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function eC(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),s=y().config,l={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:c}=Ia(s.wallets,l),p=Op(),u=Op(),{handler:d}=Dp({onConnectWalletHandler:p,onDisconnectWalletHandler:u});Fp(()=>{n().catch(console.log)},[]),Fp(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let h=re.use.isActiveTab(),f=RS(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return Er.createElement(Ir.Provider,{value:f},Er.createElement(ZS,{allBlockChains:a,providers:c,onUpdateState:(g,m,C,S,k)=>{let T=[g,m,C,S,k];d(...T),t.onUpdateState&&$p(t.onUpdateState,T)},autoConnect:!!h,configs:{wallets:s.wallets}},t.children))}i(eC,"Main");function Ar(t){let{config:e,...o}=t;return Er.createElement(fp,{config:e},Er.createElement(eC,{...o,config:e}))}i(Ar,"WidgetWallets");import Ji from"react";import tC,{Fragment as oC}from"react";import{MemoryRouter as nC,useInRouterContext as rC}from"react-router";function Up({children:t}){let o=rC()?oC:nC;return tC.createElement(o,null,t)}i(Up,"AppRouter");import{I18nManager as zE}from"@rango-dev/ui";import tc from"react";import _e from"react";import{useRoutes as IE}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Oo,useRef as $r}from"react";import Ke from"bignumber.js";import{create as sC}from"zustand";import{subscribeWithSelector as lC}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as FB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as _r}from"rango-types";import{i18n as $e}from"@lingui/core";var R=i(()=>({genericServerError:$e.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:$e.t("Please reset your liquidity sources."),description:$e.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:$e.t("No Routes Found."),description:$e.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:$e.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:$e.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:$e.t("High Price Impact"),title:$e.t("Price impact is too high!"),description:$e.t("The price impact is significantly higher than the allowed amount."),confirmMessage:$e.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:$e.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:$e.t("USD Price Unknown"),title:$e.t("USD Price Unknown, Cannot calculate Price Impact."),description:$e.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:$e.t("Confirm USD Price Unknown")}}),"errorMessages");function zp(t){switch(t.type){case 0:return t.diagnosisMessage??R().noResultError.title;case 1:return R().genericServerError;default:return""}}i(zp,"getQuoteErrorMessage");import{i18n as Nr}from"@lingui/core";var mo=i(()=>({connectWallet:Nr.t("Connect Wallet"),swap:Nr.t("Swap"),swapAnyway:Nr.t("Swap anyway"),ethWarning:Nr.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Aa(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(Aa,"getFeeLabel");var Na=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Qp=100,Hp=30,qp=15,Gp=60;var Vp=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Kp=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as aC}from"@rango-dev/queue-manager-rango-preset";import bB from"bignumber.js";function Xp(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(Xp,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Br(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=aC(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=an(a?a.toBlockchain:n.fromBlockchain,e),c=an(r.toBlockchain,e),p=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:p,toBlockchain:c,toToken:u,inputAmount:d}}i(Br,"createRetryQuote");function Fo(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=Tn(o),s=ct(o);if(o&&a&&s){let p=Pt(a.toString(),s.toString());if(!!p&&eu(a,p)){let d=Mr(o?.swaps,n),h=_t(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:h}}}if(e&&nu(e,o))return{type:4,usdValueChange:B(ct(o)?.minus(ct(e)??0).toString()??"0",null,2),percentageChange:B(Pt(ct(e)??"1",ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Pr(o.swaps),c=r>op;if(ou(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:tu(o,r),minRequiredSlippage:l};return null}i(Fo,"generateQuoteWarnings");function Yp(t){return![4].includes(t.type)}i(Yp,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Wa(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Zp=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Lr=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),c=n.requestId.toLowerCase();return l.localeCompare(c)}),"sortQuotesBy"),Jp=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,validationStatus:null,...e[0]};let n=new Set(t.swaps.map(a=>a.swapperId)),r=e.find(a=>{let s=new Set(a.swaps.map(l=>l.swapperId));return Array.from(n).every(l=>s.has(l))});return{requestAmount:o,validationStatus:null,...r||e[0]}},"getDefaultQuote"),Rp=i(t=>{let e=i((o,n)=>{let r=Na.indexOf(o.value),a=Na.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function eu(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Vp.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(eu,"hasHighValueLoss");function ru(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(ru,"hasLimitError");function iu(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,p=l.fromAmountMaxValue?new Ue(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?c?.gte(l.fromAmount)||p?.lte(l.fromAmount):c?.gt(l.fromAmount)||p?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=gt.t({id:"Required: >= {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=gt.t({id:"Required: > {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=gt.t({id:"Required: <= {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=gt.t({id:"Required: < {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(iu,"getLimitErrorMessage");function au(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=t;return e!=="success"?{title:mo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:mo().swap,action:"confirm-swap",disabled:!0}:s?{title:mo().swapAnyway,action:"confirm-warning",disabled:!1}:c?{title:mo().ethWarning,action:"confirm-warning",disabled:!1}:{title:mo().swap,action:"confirm-swap",disabled:!1}:{title:mo().connectWallet,action:"connect-wallet",disabled:!1}}i(au,"getSwapButtonState");function Ba(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ce))&&e&&e!=="0"&&n!==0)}i(Ba,"canComputePriceImpact");function La(t,e){let o=ce;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Ue(r.amount).multipliedBy(a||0))}return o}i(La,"getUsdFeeOfStep");function Mr(t,e){return t.reduce((o,n)=>o.plus(La(n,e)),ce)}i(Mr,"getTotalFeeInUsd");function Ma(t){let e=ce;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(Ma,"getUsdFee");function su(t){return t.reduce((e,o)=>e.plus(Ma(o)),ce)}i(su,"getTotalFeesInUsd");function lu(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(lu,"getFeesGroup");function cu(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?e:null}i(cu,"checkSlippageErrors");function tu(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?o:null}i(tu,"checkSlippageWarnings");function Pr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Pr,"getMinRequiredSlippage");function ou(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(ou,"hasProperSlippage");function pu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:h,destination:f}=t,g=a?.reduce((S,k)=>(S[k.chain]=k.address,S),{}),m=[];return r?.forEach(S=>{m.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:d??void 0,affiliateWallets:h??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:m,selectedWallets:g??{},slippage:p.toString(),...f&&{destination:f},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(pu,"createQuoteRequestBody");function uu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(uu,"getWalletsForNewSwap");function Tn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(Tn,"getUsdInputFrom");function ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(ct,"getUsdOutputFrom");function Wa(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy(Qp).toNumber()}i(Wa,"getPercentageChange");function nu(t,e){let o=Tn(t),n=ct(t),r=ct(e);if(!o||!n||!r)return!1;let a=Wa(n.toString(),r.toString());return Kp.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(nu,"isOutputAmountChangedExcessively");function du(t,e,o){let n=t.validationStatus,r=io({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>Xp(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=B(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=B(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=gt.t(" for input and network fee")),gt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:p,symbol:l,reason:u,currentAmount:c,blockchain:st(s.asset.blockchain,o)}})})}i(du,"generateBalanceWarnings");function vn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==_r.NetworkChanged}i(vn,"isNetworkStatusInWarningState");function mu(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),vn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case _r.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case _r.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case _r.WaitingForNetworkChange:n=n||gt.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(mu,"getSwapMessages");function fu(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(fu,"getLastConvertedTokenInFailedSwap");function gu(t){return t.status==="failed"}i(gu,"shouldRetrySwap");function hu(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),c=s.every(d=>r.some(h=>h.chain===d)),p=l.every(d=>r.some(h=>h.chain===d)),u=o&&a?Io(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!u||!p)}i(hu,"isConfirmSwapDisabled");function yu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(yu,"isTokensIdentical");var Dr=i((t,e)=>t?.usdPrice?new Ke(e||ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Mo(sC()(lC(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ke(0),outputUsdValue:new Ke(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=ce,a=o.inputUsdValue;return cn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=Tn(e)??ce,r=ct(e)??ce),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ke(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ke(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ke(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:Dr(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Ke(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Ke(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Dr(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Dr(n??null,s),outputUsdValue:new Ke(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Dr(e.toToken,e.outputAmount?.toString()||""):new Ke(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ke(0),inputUsdValue:new Ke(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ke(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),Su=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ye.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&ye.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function Cu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:c,toBlockchain:p}=O(),u=y().config,d=y().fetchStatus,h=y().blockchains(),f=y().tokens(),{findToken:g}=y(),{setAffiliateRef:m,setAffiliatePercent:C,setAffiliateWallets:S}=y(),k=u?.from?.tokens,T=u?.from?.blockchains,v=u?.to?.tokens,b=u?.to?.blockchains,N=$r(void 0),D=$r(void 0),w=$r(void 0),x=$r(void 0);Oo(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Oo(()=>{if(d==="success"){r();let E=h.find(L=>L.name===u?.from?.blockchain),A=u?.from?.token,M=A&&g(A);(E||!E&&w.current)&&n(E??null),M?a({token:M,meta:{blockchains:h,tokens:f}}):!M&&N.current&&a({token:null}),w.current=u?.from?.blockchain,N.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,d]),Oo(()=>{pa(s,k)&&a({token:null}),ua(c,T)&&n(null)},[k,T]),Oo(()=>{pa(l,v)&&a({token:null}),ua(p,b)&&o(null)},[v,b]),Oo(()=>{if(d==="success"){r();let E=h.find(L=>L.name===u?.to?.blockchain),A=u?.to?.token,M=A&&g(A);(E||!E&&x.current)&&o(E??null),M?e({token:M,meta:{blockchains:h,tokens:f}}):!M&&D.current&&e({token:null}),x.current=u?.to?.blockchain,D.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),Oo(()=>{m(u?.affiliate?.ref??null),C(u?.affiliate?.percent??null),S(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(Cu,"useSyncStoresWithConfig");import{useEffect as Da,useRef as cC}from"react";import{useInRouterContext as pC,useLocation as uC,useSearchParams as dC}from"react-router-dom";function Pa(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Pa,"convertTokenSearchParamToAsset");function _a(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(_a,"tokenToSearchParam");function Fa(){let t=uC(),[e,o]=dC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:h}=O(),f=y().fetchStatus,g=y().blockchains(),m=y().tokens(),C=pC(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=cC(),{findToken:b}=y(),N=i(()=>{let w={};for(let[K,se]of e.entries())K.startsWith("utm_")&&(w[K]=se);let x=e.get("fromAmount"),E=e.get("fromBlockchain"),A=e.get("fromToken"),M=e.get("toBlockchain"),L=e.get("toToken"),X=e.get("autoConnect"),oe=e.get("clientUrl"),Y=e.get("liquiditySources"),W=e.get("blockchain");return{fromAmount:x,fromBlockchain:E,fromToken:A,toBlockchain:M,toToken:L,autoConnect:X,clientUrl:oe,liquiditySources:Y,utmQueryParams:w,blockchain:W}},"getUrlSearchParams"),D=i(w=>{for(let x in w)w[x]||delete w[x];o(w,{replace:!0})},"updateUrlSearchParams");Da(()=>{let{autoConnect:w,clientUrl:x,utmQueryParams:E,blockchain:A}=N();C&&f==="success"&&D({fromBlockchain:n?.name,fromToken:_a(a),toBlockchain:r?.name,toToken:_a(s),fromAmount:l,autoConnect:w??void 0,clientUrl:x??void 0,blockchain:A??void 0,liquiditySources:T?v.current:void 0,...E})},[t.pathname,l,n,a,r,s,T]),Da(()=>{if(!C)return;let w=N();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&h(w.fromAmount),f==="success"){let x=g.find(L=>L.name===w.fromBlockchain),E=w.fromToken&&x?b(Pa(w.fromToken,x)):void 0,A=g.find(L=>L.name===w.toBlockchain),M=w.toToken&&A?b(Pa(w.toToken,A)):void 0;x&&(c(x),E&&u({token:E,meta:{blockchains:g,tokens:m}})),A&&(p(A),M&&d({token:M,meta:{blockchains:g,tokens:m}}))}},[f]),Da(()=>{let{clientUrl:w,liquiditySources:x}=N();S("clientUrl",w||void 0),k("liquiditySources",x?.split(",")??void 0)},[])}i(Fa,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as Ik,Button as ed,darkTheme as Ak,Divider as xn,DoneIcon as Nk,MessageBox as Wk,styled as Bk,TextField as Lk,Typography as Mk}from"@rango-dev/ui";import Se,{useEffect as Pk,useState as Gr}from"react";import{useNavigate as _k,useSearchParams as Dk}from"react-router-dom";import{ChevronRightIcon as mC,Divider as bu,Image as fC,Typography as xu}from"@rango-dev/ui";import ht from"react";import{darkTheme as ku,styled as Oa}from"@rango-dev/ui";var Tu=Oa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${ku} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${ku} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),vu=Oa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),wu=Oa("div",{display:"flex"});function Ua(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(vu,null,ht.createElement(xu,{size:"large",variant:"label"},n),ht.createElement(bu,{size:10}),ht.createElement(Tu,{onClick:s?void 0:e,disabled:s},ht.createElement(wu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(fC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(bu,{size:4,direction:"horizontal"})),ht.createElement(xu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(mC,{size:12,color:"black"})))}i(Ua,"BlockchainSelectorButton");import{i18n as Qa}from"@lingui/core";import{Button as gC,Divider as wn,ExternalLinkIcon as hC,Image as yC,Typography as zo}from"@rango-dev/ui";import We from"react";function Eu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Eu,"generateExplorerLink");import{darkTheme as Uo,styled as Iu}from"@rango-dev/ui";var za=Iu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Au=Iu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Uo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}}});function Ha(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=Eu(n.address,a);return We.createElement(J,{open:e,dismissible:!0,onClose:o,container:I()},We.createElement(Au,null,We.createElement(yC,{src:n.image,size:45,type:"circular"}),We.createElement(zo,{variant:"title",size:"medium"},n.name),We.createElement(zo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),We.createElement(wn,{size:4}),We.createElement(zo,{variant:"body",size:"medium"},s?We.createElement(za,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,We.createElement(hC,{size:12,color:"gray"})):We.createElement(za,null,n.address)),We.createElement(wn,{size:4}),n.coinSource&&We.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},Qa.t("via")," ",We.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),We.createElement(wn,{size:"32"}),We.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},Qa.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),We.createElement(wn,{size:40}),We.createElement(wn,{size:10}),We.createElement(gC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Qa.t("Import")))}i(Ha,"CustomTokenModal");import{useManager as kk}from"@rango-dev/queue-manager-react";import{BottomLogo as Tk,Divider as Xu,Header as vk}from"@rango-dev/ui";import xe,{useEffect as ps,useMemo as wk,useRef as Yu,useState as bk}from"react";import{useRef as SC}from"react";function Fr(){return window.self!==window.top}i(Fr,"isAppLoadedIntoIframe");function qa(){let t=SC(null),{iframe:e}=y(),o=Fr()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let c of l)n({type:"widget_height",data:{height:c.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(qa,"useIframe");import{useNavigate as CC}from"react-router-dom";function je(){let t=CC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as Za,darkTheme as MC,lightTheme as PC}from"@rango-dev/ui";import{useEffect as _C,useState as DC}from"react";import{theme as BC,darkColors as LC}from"@rango-dev/ui";import Xa from"react";function kC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(kC,"expandShortHexColor");function TC(t){return/[0-9]+$/.test(t)}i(TC,"isOverridingColor");function vC(t,e){return t.padStart(e,"0")}i(vC,"pad");function Ga(t){let e=Math.min(Math.max(Math.round(t),0),255);return vC(e.toString(16),2)}i(Ga,"intToHex");function wC(t){return`#${Ga(t.red)}${Ga(t.green)}${Ga(t.blue)}`}i(wC,"rgbToHex");function bC(t){let e=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return{red:e,green:o,blue:n}}i(bC,"hexToRGB");function xC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(xC,"generateShade");function EC(t,e){let o=.11*e;return{red:t.red+(255-t.red)*o,green:t.green+(255-t.green)*o,blue:t.blue+(255-t.blue)*o}}i(EC,"generateTint");function IC(t){return Nu(t,xC)}i(IC,"calculateShades");function AC(t){return Nu(t,EC)}i(AC,"calculateTints");function Nu(t,e){let o=bC(t),n=[];for(let r=1;r<9;r++)n.push(wC(e(o,r)));return n}i(Nu,"calculateColors");function Va(t,e,o){let a=AC(t).reverse().concat(t),s=IC(t),l=a.concat(s),c={},p=l.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50;c[`${e}${d}`]=l[u]}return c}i(Va,"createTintsAndShades");function Ka(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!TC(r)){let c=kC(a);Object.assign(n,Va(c,r,s))}}return{...n,...e}}i(Ka,"expandToGenerateThemeColors");var Wu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),NC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Wu(o%52)+e;return Wu(o%52)+e},"toAlphabeticName"),WC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),ja=i(t=>NC(WC(5381,JSON.stringify(t))>>>0),"toHash");function Ya(t){let e=BC.colors,o={...e,...LC},n,r;if(t?.light){let s={colors:Ka(e,t.light)};n={id:`${ca}-light-${ja(s)}`,tokens:s}}if(t?.dark){let s={colors:Ka(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ca}-dark-${ja(s)}`,tokens:s}}return{light:n,dark:r}}i(Ya,"customizedThemeTokens");function Bu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Xa.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Xa.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Xa.cloneElement(e,{key:l}))}}),o}i(Bu,"joinList");function Lu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Lu,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=wc,borderRadius:n=Vc,secondaryBorderRadius:r=Kc}=t,[a,s]=DC(Lu()?"dark":"light"),{theme:l}=y(),{dark:c,light:p}=Ya(e),u=Za({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,PC.className],h=[u.className,MC.className];if(p){let g=Za(p.id,p.tokens);d.push(g.className)}if(c){let g=Za(c.id,c.tokens);h.push(g.className)}return _C(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Lu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=d.join(" "),m=h.join(" ");return l==="auto"?a==="dark"?m:g:l==="dark"?m:g},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var pt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Mu}from"@lingui/core";import{Alert as $C,Button as FC}from"@rango-dev/ui";import Pu from"react";function Ja(t){return Pu.createElement($C,{action:Pu.createElement(FC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Mu.t("Activate this tab")),type:"warning",variant:"alarm",title:Mu.t("Another tab is open and handles transactions.")})}i(Ja,"ActivateTabAlert");import{i18n as Ra}from"@lingui/core";import{Button as OC,Divider as UC,MessageBox as zC}from"@rango-dev/ui";import Or from"react";function es(t){let{open:e,onClose:o,onConfirm:n}=t;return Or.createElement(J,{open:e,dismissible:!0,onClose:o,container:I()},Or.createElement(zC,{title:Ra.t("Activate current tab"),type:"warning",description:Ra.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},Or.createElement(UC,{size:20}),Or.createElement(OC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Ra.t("Confirm"))))}i(es,"ActivateTabModal");import{ChevronLeftIcon as QC}from"@rango-dev/ui";import _u from"react";function ts(t){return _u.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},_u.createElement(QC,{color:"black",size:16}))}i(ts,"BackButton");import{i18n as HC}from"@lingui/core";import{Button as qC,Typography as GC}from"@rango-dev/ui";import os from"react";function ns(t){return os.createElement(Vt,null,os.createElement(qC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},os.createElement(GC,{variant:"label",size:"medium",color:"error500"},HC.t("Cancel"))))}i(ns,"CancelButton");import{i18n as VC}from"@lingui/core";import{Image as KC,Tooltip as jC,WalletIcon as XC}from"@rango-dev/ui";import fo from"react";function rs(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?fo.createElement("div",{className:vp()},o.map(r=>fo.createElement(Tr,{key:r.title},fo.createElement(KC,{src:r.image,size:14})))):VC.t("Connect Wallet");return fo.createElement(jC,{container:t.container,side:"bottom",content:n},fo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&fo.createElement(Sp,null),fo.createElement(XC,{size:18,color:"black"})))}i(rs,"WalletButton");import{i18n as zr}from"@lingui/core";import{NotificationsIcon as uk,Popover as dk,SettingsIcon as mk,Tooltip as Qr,TransactionIcon as fk}from"@rango-dev/ui";import Be from"react";import{Notifications as RC}from"@rango-dev/ui";import ek from"react";import{useNavigate as tk}from"react-router-dom";import{create as YC}from"zustand";import{persist as ZC,subscribeWithSelector as JC}from"zustand/middleware";var be=Mo(YC()(ZC(JC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(c=>c.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(c=>c.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function is(){let t=tk(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return ek.createElement(RC,{list:n,getBlockchainImage:l=>fc(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(is,"NotificationContent");import{useManager as ok}from"@rango-dev/queue-manager-react";import{InProgressIcon as nk}from"@rango-dev/ui";import Du from"react";var rk=i(()=>{let{manager:t}=ok();return pt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Du.createElement(Tp,null,Du.createElement(nk,{color:"info",size:6})):null},"InProgressTransactionBadge"),$u=rk;import{EventSeverity as ik}from"@rango-dev/queue-manager-rango-preset";import{Typography as ak}from"@rango-dev/ui";import Fu from"react";function Ou(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===ik.WARNING);return o?Fu.createElement(Cp,{isSever:n},Fu.createElement(ak,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Ou,"NotificationsBadge");import{RefreshProgressButton as sk}from"@rango-dev/ui";import as,{useEffect as lk,useState as Uu}from"react";var ck=1e3,zu=60,pk=100;function Ur({onClick:t}){let[e,o]=Uu(0),[n,r]=Uu(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");lk(()=>{let c;return t?c=window.setInterval(()=>{o(p=>p+1),e===zu&&l()},ck):s(c),document.addEventListener("visibilitychange",()=>a(c)),()=>{document.removeEventListener("visibilitychange",()=>a(c)),c&&clearInterval(c)}},[e,t]);let s=i(c=>{c&&clearInterval(c),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return as.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},as.createElement(kp,{onTransitionEnd:()=>r(!1),isRefetched:n},as.createElement(sk,{size:22,color:t?"black":"gray",progress:e/zu*pk})))}i(Ur,"RefreshButton");function go(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ve("notification",s)||r.includes("notifications");return Be.createElement(Be.Fragment,null,!r.includes("refresh")&&Be.createElement(Qr,{container:a||I(),side:"top",content:zr.t("Refresh")},Be.createElement(Ur,{onClick:e})),!l&&Be.createElement(dk,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:I(),content:Be.createElement(is,null)},Be.createElement("div",null,Be.createElement(Qr,{container:I(),side:"top",content:zr.t("Notifications")},Be.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Be.createElement(uk,{size:18,color:"black"}),Be.createElement(Ou,null))))),!r.includes("settings")&&Be.createElement(Qr,{container:I(),side:"top",content:zr.t("Settings")},Be.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Be.createElement(mk,{size:18,color:"black"}))),!r.includes("history")&&Be.createElement(Qr,{container:I(),side:"top",content:zr.t("History")},Be.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Be.createElement(fk,{size:18,color:"black"}),Be.createElement($u,null))))}i(go,"HeaderButtons");import{i18n as ss}from"@lingui/core";import{Divider as Hu,MessageBox as yk,RefreshIcon as Sk}from"@rango-dev/ui";import Ho from"react";import{Button as gk,styled as hk}from"@rango-dev/ui";var Qu=hk(gk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function ls(t){let{open:e,onClose:o}=t;return Ho.createElement(J,{open:e,dismissible:!0,onClose:o,container:I()},Ho.createElement(yk,{title:ss.t("Something went wrong"),type:"error",description:ss.t("Something went wrong. Please refresh the app.")},Ho.createElement(Hu,{size:30}),Ho.createElement(Qu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Ho.createElement(Sk,{size:20,color:"primary"}),Ho.createElement(Hu,{size:4,direction:"horizontal"}),ss.t("Refresh"))))}i(ls,"RefreshModal");function cs(t){let e=t.target;if(e){let o=e.scrollTop,n=I();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(cs,"onScrollContentAttachStatusToContainer");import{css as Ck,styled as Hr}from"@rango-dev/ui";var qu="700px",qr=Ck({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Gu=Hr("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:qu},fixed:{height:qu}},showBanner:{true:{overflow:"visible"}}}}),Vu=Hr("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Ku=Hr("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}}),ju=Hr("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)"});function te(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=qa(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c,config:{__UNSTABLE_OR_INTERNAL__:p}}=y(),[u,d]=bk(!1),{config:{features:h,theme:f}}=y(),{watermark:g}=re(),m=g==="FULL",{activeTheme:C}=Qo(f||{}),S=Ve("connectWalletButton",h),{isActiveTab:k,tabManagerInitiated:T,showActivateTabModal:v,setShowActivateTabModal:b,activateCurrentTab:N}=re(),D=je(),{manager:w}=kk(),E=pt(w).map(({swap:W})=>W).some(W=>W.status==="running"),A=i(()=>N(ao.forceClaim,E),"onActivateTab"),M=i(()=>{r.onWallet?.()},"onConnectWallet"),L=typeof r.hasBackButton>"u"||r.hasBackButton,X=Yu(null),oe=Yu(null),Y=wk(()=>{let W=(p?.swapBoxBanner?.routes?.length??0)===0,K=!!p?.swapBoxBanner?.routes?.some(se=>location.pathname.endsWith(se));return p?.swapBoxBanner&&(W||K)},[p?.swapBoxBanner?.routes?.length,location.pathname]);return ps(()=>(Fr()&&oe.current&&e(oe.current),()=>{o()}),[]),ps(()=>(X.current?.addEventListener("scroll",cs),()=>{X.current?.removeEventListener("scroll",cs)}),[]),ps(()=>{d(l==="failed")},[l]),xe.createElement(Gu,{height:s,id:De.SWAP_BOX_ID,className:`${C()} ${qr()}`,ref:oe,showBanner:Y},xe.createElement(vk,{prefix:L?xe.createElement(ts,{onClick:()=>{D(),r.onBack?.()}}):null,title:r.title,suffix:xe.createElement(xe.Fragment,null,r.suffix,r.onWallet&&!S&&xe.createElement(rs,{container:I(),onClick:M,isConnected:!!c?.length}),r.onCancel&&xe.createElement(ns,{onClick:r.onCancel}))}),xe.createElement(Vu,{ref:X},n),xe.createElement(es,{open:v,onClose:()=>b(!1),onConfirm:A}),xe.createElement(Ku,null,xe.createElement("div",{className:"footer__content"},T&&!k&&xe.createElement("div",{className:"footer__alert"},xe.createElement(Ja,{onActivateTab:A}),xe.createElement(Xu,{size:10})),a),xe.createElement(Xu,{size:12}),xe.createElement("div",{className:`footer__logo ${m?"logo__show":"logo__hidden"}`},xe.createElement(Tk,null))),Y&&xe.createElement(ju,null,p?.swapBoxBanner?.element),xe.createElement(ls,{open:u,onClose:()=>d(!1)}))}i(te,"Layout");import{styled as xk}from"@rango-dev/ui";var Zu="$20 $20 $10 $20",bn=xk("div",{padding:Zu,overflowY:"auto",flexGrow:1});import{styled as Ek}from"@rango-dev/ui";var ie=Ek("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as qo}from"@lingui/core";import{useState as Ju}from"react";function Ru(){let[t,e]=Ju(!1),[o,n]=Ju(void 0),{findToken:r}=y(),a=y().customTokens();function s(c,p){switch(c){case"duplicated":return{title:qo.t("Duplicate Token"),message:qo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:qo.t("Token Already Exists"),message:qo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:qo.t("Token Not Found"),message:qo.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:p}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:c,tokenAddress:p})=>{e(!0);try{if(a.some(g=>g.address?.toLowerCase()===p.toLowerCase())){let g=s("duplicated");n(g);return}let d=await xt().getCustomToken({blockchain:c,address:p});if(!d||!d.token||d.error){let g=s("not-found",c);n(g);return}let h=d.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let g=s("token-exist");n(g);return}return h}catch(u){if(u?.code==="ERR_BAD_REQUEST"){let d=s("not-found",c);n(d);return}throw n(void 0),new Error(u.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Ru,"useFetchCustomToken");var $k=Bk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${Ak} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),Fk=1e3;function td(){let t=_k(),[e]=Dk(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=an(a,r),[l,c]=Gr(""),[p,u]=Gr(!1),[d,h]=Gr(),{fetchCustomToken:f,loading:g,error:m}=Ru(),[C,S]=Gr(""),k=!!s&&Io(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let D=await f({blockchain:a,tokenAddress:l});S(""),D&&h(D)}catch(D){D.message==="Failed to fetch"&&(S(It.t("Network Error")),u(!0))}},"getCustomToken"),b=i(()=>{m&&c(""),u(!1)},"closeErrorModal"),N=i(async()=>{C&&setTimeout(async()=>{await v()},Fk),b()},"handleErrorModalButtonClick");return Pk(()=>{m&&u(!0)},[m]),Se.createElement(te,{header:{title:It.t("Add Custom Token")}},Se.createElement(ie,null,Se.createElement($k,null,Se.createElement("div",null,Se.createElement(Ua,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),Se.createElement(xn,{size:"24"}),Se.createElement(Mk,{size:"large",variant:"label"},It.t("Enter Address")),Se.createElement(xn,{size:10}),Se.createElement(Lk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&Se.createElement(Nk,{color:"success",size:12}),onChange:D=>c(D.target.value)}),!k&&!!l&&Se.createElement(Se.Fragment,null,Se.createElement(xn,{size:4}),Se.createElement(Ik,{type:"error",variant:"alarm",title:"Invalid Address"}))),Se.createElement(ed,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:g,size:"large",onClick:v},It.t("Import"))),Se.createElement(J,{open:p,dismissible:!0,onClose:b,container:I()},Se.createElement(Wk,{title:m?.title||C,type:"error",description:m?.message||It.t("Failed Network, Please retry.")},Se.createElement(xn,{size:40}),Se.createElement(xn,{size:10}),Se.createElement(ed,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:N},C?It.t("Retry"):It.t("Add another custom token")))),s&&d&&Se.createElement(Ha,{blockchain:s,token:d,onSubmitClick:()=>{d&&(n(d),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!d})))}i(td,"AddCustomTokenPage");import{i18n as Us}from"@lingui/core";import{useManager as Tv}from"@rango-dev/queue-manager-react";import{Alert as vv,Button as wv,css as Qs,Divider as zs,IconButton as Xm,styled as bv,Typography as xv,WalletIcon as Ev}from"@rango-dev/ui";import Me,{useEffect as Ci,useLayoutEffect as Iv,useRef as Av,useState as Fn}from"react";import{useNavigate as Nv}from"react-router-dom";import{i18n as ho}from"@lingui/core";import{Alert as cT,BalanceErrors as pT,Button as Nd,ChevronLeftIcon as uT,Divider as Ss,MessageBox as dT,Typography as Cs}from"@rango-dev/ui";import ee,{useCallback as mT,useEffect as Wd,useMemo as fT,useState as Ko}from"react";import{useNavigate as gT}from"react-router-dom";import{i18n as fs}from"@lingui/core";import{Alert as Hk,ChevronDownIcon as qk,CloseIcon as Gk,Divider as ld,IconButton as cd,PasteIcon as Vk,Typography as Kk,WalletIcon as jk}from"@rango-dev/ui";import Le,{useEffect as Xk,useRef as Yk}from"react";import Xr,{useRef as zk}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as od,styled as Vr}from"@rango-dev/ui";var us=300,Ok=od({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Uk=od({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),nd=Vr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ds=Vr(Go.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Kr=Vr(Go.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Ok} ${us}ms ease-out`},false:{animation:`${Uk} ${us}ms ease-out`}}}}),jr=Vr("div",{transition:`all ${us}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Yr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=zk(null);return Xr.createElement(nd,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Xr.createElement(ds,{className:"collapsible_trigger",onClick:a},s),Xr.createElement(Kr,{className:"collapsible_content",open:e},r),l==="bottom"&&Xr.createElement(ds,{className:"collapsible_trigger",onClick:a},s))}i(Yr,"CustomCollapsible");import{darkTheme as rd,styled as ms,TextField as Qk}from"@rango-dev/ui";var id=ms("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),ad=ms(Qk,{backgroundColor:"$neutral100",padding:"$15"}),sd=ms("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${rd} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${rd} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function pd(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=sr(e.name,l),p=Yk(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),f=n&&!!r&&e&&!Io(e,r),g=i(()=>{a("")},"handleClear"),m=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),p?.current?.focus()}},"handlePaste"),C=i(()=>r?Le.createElement(cd,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Le.createElement(Gk,{size:12,color:"gray"})):d?null:Le.createElement(cd,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Le.createElement(Vk,{size:16})),"renderSuffix");return Xk(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Le.createElement(id,null,Le.createElement(Yr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Le.createElement(sd,null,Le.createElement("div",{className:"button__content"},Le.createElement(jk,{size:18,color:"info"}),Le.createElement(ld,{size:4,direction:"horizontal"}),Le.createElement(Kk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},fs.t("Send to a different address"))),Le.createElement(jr,{orientation:n?"up":"down"},Le.createElement(qk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Le.createElement(ad,{ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:fs.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),f&&Le.createElement(Le.Fragment,null,Le.createElement(ld,{size:4}),Le.createElement(Hk,{variant:"alarm",type:"error",title:fs.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(pd,"CustomDestination");import{css as Zk,darkTheme as gs,IconButton as Jk,styled as Dt}from"@rango-dev/ui";var ud=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),dd=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Rk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${gs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${gs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${gs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),md=Dt(Rk,{alignSelf:"stretch",minHeight:"93px"}),fd=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),gd=Dt(Jk,{position:"absolute",left:"$20"}),hd=Dt("div",{paddingTop:"$20"}),yd=Zk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Sd=Dt("div",{display:"flex"}),Cd=Dt("div",{overflow:"visible",width:"100%"});import{i18n as xd}from"@lingui/core";import{warn as rT}from"@rango-dev/logging-core";import{Divider as iT,SelectableWallet as aT,Typography as Ed,WalletState as Id}from"@rango-dev/ui";import Xe,{useEffect as Ad,useState as In}from"react";import{Image as oT,MessageBox as nT}from"@rango-dev/ui";import En from"react";import{keyframes as eT,styled as hs}from"@rango-dev/ui";var kd=hs("div",{position:"relative"}),tT=eT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Td=hs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${tT} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vd=hs("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function wd(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Vo.t("Request Rejected"),description:Vo.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(wd,"generateMessageByStatus");function bd(t){let{status:e,displayName:o,image:n}=t,r=wd(e,o),a=e=="in-progress";return En.createElement(nT,{type:r.type,title:r.title,description:r.description,icon:a?En.createElement(kd,null,En.createElement(vd,null,En.createElement(oT,{src:n,size:45})),En.createElement(Td,null)):void 0})}i(bd,"ExperimentalChainStatus");var sT=7,lT=3e3;function ys(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[p,u]=In(),[d,h]=In(null),[f,g]=In(!1),[m,C]=In(null),{suggestAndConnect:S}=Zr(),{handleDisconnect:k}=Gt(),{list:T}=ft({chain:e}),[v,b]=In(T),N=T.length,D=r&&N-r>0,w=i(async E=>{g(!1),C("in-progress");try{await S(E.walletType,E.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");Ad(()=>{b(E=>{let A=T.findIndex(M=>o(M.type,e));return D&&A>1?[T[A]].concat(T.filter((M,L)=>L!==A)):E.map(M=>T.find(L=>L.type===M.type)??M)})},[JSON.stringify(T)]);let x=document.getElementById(De.SWAP_BOX_ID);return Ad(()=>{let E=null;return(m==="completed"||m==="rejected")&&(E=setTimeout(()=>C(null),lT)),()=>{E&&clearTimeout(E)}},[m]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(E=>{let A=Uc({connectedWallets:c,walletType:E.type,chain:e}),M=A?Sr(A,sT):"",L=hr(l(),e),X=!c.find(se=>se.walletType===E.type&&se.chain===e),oe=L&&X&&E.state===Id.CONNECTED,Y=oe?xd.t({id:"Add {chain} chain",values:{chain:e}}):M,W=i(async()=>{let se=E.state===Id.DISCONNECTED,z=(E.isHub||!!E.needsNamespace)&&!M;se?u(E):z?(await k(E.type),u(E)):oe?(h({walletType:E.type,chain:e,address:A??""}),g(!0)):n({walletType:E.type,chain:e,address:A??""})},"onSelectableWalletClick"),K=d?.chain?sr(d.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${E.title}_${K}`},!!d&&Xe.createElement(J,{open:!!d&&f,container:x,onClose:()=>{h(null)}},Xe.createElement(Ea,{displayName:K,onConfirm:()=>{w(d)}})),m&&Xe.createElement(J,{open:!!m,onClose:C.bind(null,null),container:x},Xe.createElement(bd,{status:m,displayName:K,image:E.image}),Xe.createElement(iT,{direction:"vertical",size:32})),Xe.createElement(aT,{key:E.type,description:Y,onClick:W,selected:o(E.type,e),disabled:!s,...E}))}),Xe.createElement(po,{wallet:p,onClose:()=>{u(void 0)},onConnect:()=>{t.onConnect&&(p?.type?t.onConnect(p.type):rT(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),D&&Xe.createElement(md,{selected:!1,onClick:a},Xe.createElement(Ed,{variant:"label",size:"medium"},xd.t("Show more wallets"),Xe.createElement(Ed,{variant:"label",size:"medium",color:"$primary"},"\xA0+",N-(r??0)))))}i(ys,"WalletList");var hT=2;function Bd(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=gT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:h,setCustomDestination:f}=O(),{config:g,connectedWallets:m,setWalletsAsSelected:C}=y(),[S,k]=Ko(""),[T,v]=Ko([]),[b,N]=Ko(""),[D,w]=Ko(!!h),x=fT(()=>io({filter:"all",quote:c}),[c]),E=io({filter:"required",quote:c}),A=l.find(P=>P.name===c?.swaps[c?.swaps.length-1].to.blockchain),M=i(P=>E.includes(P),"isWalletRequiredFor"),L=mT(()=>m.filter(P=>P.selected&&x.includes(P.chain)),[m,x]),[X,oe]=Ko(L()),[Y,W]=Ko([]),K=i((P,q)=>W(V=>V.concat({blockchain:P,walletType:q})),"addNextSelectedWallets"),se=T.length>0,z=i((P,q)=>!!X.find(V=>V.walletType===P&&V.chain===q&&V.selected&&(M(q)||!M(q)&&!h)),"isSelected"),me=i((P,q,V)=>{let ge=!1;return P.map(ne=>{if(ne.chain===q){let he=ne.selected;return!ge&&V?(ge=!0,he=!0):V||(he=!1),{...ne,selected:he}}return ne})},"updateSelectableWallets"),vt=i(P=>{w(P),P?M(A?.name??"")||oe(q=>me(q,A?.name||"",!1)):(f(""),oe(q=>me(q,A?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(P=>{if(S&&k(""),z(P.walletType,P.chain))return;let V=m.find(ge=>ge.walletType===P.walletType&&ge.chain===P.chain);V&&(n(),P.chain===A?.name&&D&&!M(A.name)&&(w(!1),f(null)),oe(ge=>ge.filter(ne=>ne.chain!==P.chain).concat({...V,selected:!0})))},"onChange"),le=i(()=>{let P=X.filter(q=>q.selected);C(P),p(P),d(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),N("");let P=await r?.({selectedWallets:X.filter(V=>V.selected),customDestination:h}),q=P.warnings;q?.balance?.messages&&v(q.balance.messages),P.error&&N(zp(P.error)),!P.error&&!q?.balance?.messages.length?le():v(q?.balance?.messages??[])},"onConfirmWallets");Wd(()=>{oe(P=>{let q=[];return P.forEach(V=>{!m.some(ne=>ne.chain===V.chain&&ne.walletType===V.walletType&&ne.address===V.address)||q.push(V)}),q=q.concat(m.filter(V=>!!!q.find(ne=>ne.chain===V.chain)&&V.selected&&x.includes(V.chain))),q})},[m,x]),Wd(()=>{let P=[];Y.length>0&&(Y.forEach(q=>{let V=m.find(ge=>ge.chain===q.blockchain&&ge.walletType===q.walletType);V?Ze(V):P.push(q)}),W(P))},[m,Y]);let G=document.getElementById(De.SWAP_BOX_ID);return ee.createElement(J,{open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:G,...!S&&{styles:{container:{height:"100%"}},footer:ee.createElement(Sd,null,ee.createElement(Nd,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:hu(a,D,h,c,X,A),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ee.createElement(fd,null,ee.createElement(gd,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},ee.createElement(uT,{size:16})),ee.createElement(Cs,{variant:"headline",size:"small"},ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:st(S,l)}})))},anchor:"center"},ee.createElement(J,{open:se,onClose:v.bind(null,[]),container:G},ee.createElement(dT,{title:ho.t("Insufficient account balance"),type:"error",description:ee.createElement(pT,{messages:T??[]})},ee.createElement(Nd,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},ho.t("Proceed anyway")))),S&&ee.createElement(hd,null,ee.createElement("div",{className:yd()},ee.createElement(ys,{chain:S,isSelected:z,selectWallet:Ze,onShowMore:()=>k(S),onConnect:P=>{K(S,P)}}))),!S&&ee.createElement(ee.Fragment,null,b&&ee.createElement(ee.Fragment,null,ee.createElement(cT,{variant:"alarm",type:"error",title:ho.t(b)}),ee.createElement(Ss,{size:12})),ee.createElement(Cd,null,x.map((P,q)=>{let V=l.find(Fe=>Fe.name===P),ge=`wallet-${q}`,ne=q===x.length-1,he=ne&&A&&g?.customDestination!==!1;return ee.createElement("div",{key:ge},ee.createElement(ud,null,ee.createElement(Cs,{variant:"title",size:"xmedium"},ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ee.createElement(Cs,{variant:"label",color:"$neutral700",size:"medium"},ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ee.createElement(Ss,{size:24}),ee.createElement(dd,null,ee.createElement(ys,{chain:P,isSelected:z,selectWallet:Ze,limit:hT,onShowMore:()=>k(V?.name??""),onConnect:Fe=>{K(P,Fe)}})),!ne&&ee.createElement(Ss,{size:32}),he&&ee.createElement(pd,{blockchain:A,open:D,handleOpenChange:vt}))}))))}i(Bd,"ConfirmWalletsModal");import{i18n as _T}from"@lingui/core";import{Alert as DT,Button as $T,InfoIcon as FT}from"@rango-dev/ui";import et from"react";import{Alert as CT,Button as kT,Divider as vs,NoRouteIcon as TT,RefreshIcon as vT,Typography as Fd}from"@rango-dev/ui";import Re from"react";import{i18n as Ld}from"@lingui/core";var yT=24,ST=60;function Md(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:R().genericServerError,action:{onClick:n,title:Ld.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:R().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Ld.t("Reset")}},description:R().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:R().noResultError.description}}i(Md,"makeInfo");var ks=(o=>(o[o.small=yT]="small",o[o.large=ST]="large",o))(ks||{}),Ts=(o=>(o.small="small",o.large="medium",o))(Ts||{});import{styled as Jr}from"@rango-dev/ui";var Pd=Jr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),_d=Jr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Dd=Jr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),$d=Jr("div",{padding:"$6 $0"});function An(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Md(o,r,()=>a(s,!0),e);return Re.createElement(Pd,null,Re.createElement(TT,{size:ks[n],color:"gray"}),Re.createElement(vs,{size:4}),Re.createElement(Fd,{variant:"title",size:Ts[n]},R().noResultError.title),n==="large"&&Re.createElement(vs,{size:4}),!!l.description&&Re.createElement(_d,{size:n},Re.createElement(Fd,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(vs,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(Dd,{size:n},Re.createElement(CT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(kT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement($d,null,Re.createElement(vT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(An,"NoResult");import{i18n as Nn}from"@lingui/core";import{Button as bT,Divider as xT,MessageBox as ET,Typography as IT,WarningIcon as AT}from"@rango-dev/ui";import $t from"react";import{Typography as Qd}from"@rango-dev/ui";import bs from"react";import{darkTheme as wT,styled as Rr}from"@rango-dev/ui";var Od=Rr("div",{width:"100%"}),ws=Rr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Ud=Rr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${wT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),zd=Rr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Hd(t){let{title:e,value:o,valueColor:n}=t;return bs.createElement(Ud,null,bs.createElement(Qd,{size:"medium",variant:"label",className:"_title"},e),bs.createElement(Qd,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Hd,"QuoteErrorsModalItem");function qd(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:Nn.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:Nn.t("Gas cost"),value:B(r.totalFee,2,2)},{title:Nn.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:Nn.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(J,{footer:$t.createElement(bT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(AT,null),fullWidth:!0,disabled:a,onClick:n},R().highValueLossError.confirmMessage),open:e,onClose:o,container:I()},$t.createElement(ET,{type:s,title:R().highValueLossError.impactTitle,description:R().highValueLossError.description}),$t.createElement(ws,null,$t.createElement(xT,{size:"4"}),$t.createElement(IT,{size:"small",variant:"title"},Nn.t("Details")),$t.createElement(ws,null,l.map((c,p)=>$t.createElement(Hd,{key:p,...c})))))}i(qd,"HighValueLossWarningModal");import{i18n as ei}from"@lingui/core";function Gd(t,e){let o={alertType:"warning",title:"",action:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=ei.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o;if(t){switch(t.type){case 0:{_t(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=R().highValueLossError.title;break}case 4:{o.title=ei.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=R().unknownPriceError.title;break}case 2:{o.title=ei.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings";break}case 3:{o.title=ei.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Gd,"makeAlerts");import{i18n as jo}from"@lingui/core";import{Button as Vd,Divider as Kd,MessageBox as NT,Typography as WT}from"@rango-dev/ui";import yo from"react";import{useNavigate as BT}from"react-router-dom";function jd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=BT(),p=e??o;return yo.createElement(J,{anchor:"bottom",open:n,prefix:yo.createElement(Vd,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+$.settings)},yo.createElement(WT,{variant:"label",size:"medium",color:"$neutral900"},jo.t("Change settings"))),container:I(),onClose:r},yo.createElement(NT,{type:"warning",title:s.type===3?jo.t("High slippage"):jo.t("Low slippage"),description:s.type===3?jo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:p}}):jo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},yo.createElement(Kd,{size:18}),yo.createElement(Kd,{size:32}),yo.createElement(Vd,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},jo.t("Confirm anyway"))))}i(jd,"SlippageWarningModal");import{Button as LT,MessageBox as MT,WarningIcon as PT}from"@rango-dev/ui";import ti from"react";function Xd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ti.createElement(J,{footer:ti.createElement(LT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ti.createElement(PT,null),fullWidth:!0,disabled:r,onClick:n},R().unknownPriceError.confirmMessage),open:e,onClose:o,container:I()},ti.createElement(MT,{type:"warning",title:R().unknownPriceError.impactTitle,description:R().unknownPriceError.description}))}i(Xd,"UnknownPriceWarningModal");function Wn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:p,onChangeSettings:u}=t,d={confirmationDisabled:a,open:r,onClose:c,onConfirm:p},h=o?.type===0||o?.type===1,f=Gd(e,o?.type===3||o?.type===4?o:null);return f&&!n&&(f.action=null),et.createElement(et.Fragment,null,h&&et.createElement(An,{error:o,fetch:s}),!!f&&et.createElement(Od,null,et.createElement(DT,{title:f.title,type:f.alertType,variant:"alarm",...f.action==="show-info"&&{action:et.createElement(zd,{onClick:l},et.createElement(FT,{size:12,color:"gray"}))},...f.action==="change-settings"&&{action:et.createElement($T,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:f.alertType,onClick:u},_T.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement(qd,{...d,warning:e}),(e.type===3||e.type===2)&&et.createElement(jd,{...d,warning:e}),e.type===1&&et.createElement(Xd,{...d,warning:e})))}i(Wn,"QuoteWarningsAndErrors");import gv from"bignumber.js";import gi from"react";import{i18n as So}from"@lingui/core";import{Alert as ov,Divider as Yo,FullExpandedQuote as nv,InfoIcon as rv,NumericTooltip as Im,QuoteTag as iv,StepDetails as av,TokenAmount as sv,Typography as Zo}from"@rango-dev/ui";import Ms from"bignumber.js";import F,{useRef as lv,useState as cv}from"react";import{styled as xs}from"@rango-dev/ui";var Es=xs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Yd=xs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Zd=xs("div",{width:"100%",display:"flex"});import*as oi from"@radix-ui/react-collapsible";import{Button as OT,css as Bn,darkTheme as Ee,Image as Jd,styled as ze,Typography as UT}from"@rango-dev/ui";var zT=300,Rd=ze(oi.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${Ee} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),em=Bn({padding:"$10 $15"}),tm=ze(OT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${Ee} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${Ee} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${Ee} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),om=ze("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${Ee} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${Ee} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${Ee} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${Ee} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${Ee} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${Ee} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${Ee} &`]:{backgroundColor:"$neutral400"}}}}]}),nm=Bn({width:"100%",padding:"$15 $15 $10 $15"}),rm=Bn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Xo=Bn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),im=Bn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${Ee} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),am=ze(oi.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${Jd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Jd}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${Ee} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),sm=ze("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),lm=ze(Kr,{width:"100%",background:"inherit"}),Is=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${zT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),l1=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),cm=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${Ee} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),pm=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),As=ze(UT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),um=ze("div",{display:"flex",flexWrap:"wrap"}),Ns=ze("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),dm=ze("div",{display:"flex"}),ni=ze("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${Ee} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as HT,CloseIcon as qT,Divider as ai,IconButton as GT,NumericTooltip as VT,QuoteCost as KT,Typography as yt}from"@rango-dev/ui";import Z,{useState as hm}from"react";import{css as QT,styled as ri}from"@rango-dev/ui";var ii=ri("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ws=ri("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),mm=ri("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),fm=ri("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),gm=QT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var jT=i(t=>t.fee.isZero()?null:Z.createElement(ii,null,Z.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(yt,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function Bs(t){let[e,o]=hm(!1),[n,r]=hm(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:h=!1}=t,f=s?.swaps??[],g=h?ro():I(),m=lu(f);return Z.createElement(Z.Fragment,null,Z.createElement(KT,{onClickFee:d?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:p,timeWarning:u,time:c,steps:a,tooltipGas:d?At.t("View more info"):void 0,tooltipContainer:g}),Z.createElement(J,{container:g,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Z.createElement(fm,{style:{textAlign:h?"left":"center"}},Z.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Z.createElement(GT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(qT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(mm,null,Z.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Z.createElement(ai,{size:10}),Object.entries(m.payable).flatMap(([C,S])=>S.map((k,T)=>{let v=`payable-fee-${T}`,b=Ma(k);return Z.createElement(ii,{key:v},Z.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Aa(C,At.t)),Z.createElement(VT,{content:k.amount,container:g},Z.createElement(yt,{variant:"label",size:"medium"},B(k.amount,2,2)," ",k.asset.symbol," ($",B(b,4,4),")")))})),Z.createElement(ii,{className:"total_payable_fee"},Z.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Z.createElement(yt,{variant:"label",size:"medium"},"$",B(l,4,4))),Z.createElement(Ws,null),Object.keys(m.nonePayable).length&&Z.createElement(Yr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Z.createElement("div",{className:gm()},Z.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Z.createElement(ai,{size:4,direction:"horizontal"}),Z.createElement(jr,{orientation:n?"up":"down"},Z.createElement(HT,{size:12,color:"gray"}))),open:n},Z.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Z.createElement(ai,{size:4}),Z.createElement(yt,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),Z.createElement(ai,{size:10}),Object.entries(m.nonePayable).map(([C,S],k)=>{let T=su(S),v=Aa(C,At.t),b=`non-payable-fee-${k}`;return Z.createElement(jT,{key:b,fee:T,label:v})}),Z.createElement(Ws,null)))))}i(Bs,"QuoteCostDetails");import{i18n as Cm}from"@lingui/core";import{TokenAmount as km}from"@rango-dev/ui";import si from"react";import{css as XT,styled as YT}from"@rango-dev/ui";var ym=YT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),Sm=XT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Ln(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return si.createElement(ym,null,si.createElement(km,{direction:"horizontal",label:Cm.t("Swap input"),type:"input",tooltipContainer:I(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),si.createElement("div",{className:Sm()}),si.createElement(km,{direction:"horizontal",tooltipContainer:I(),label:Cm.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(Ln,"QuoteSummary");import{i18n as xm}from"@lingui/core";import{ChevronDownIcon as RT,ChevronRightIcon as ev,Divider as Ls,Image as tv,Tooltip as di,Typography as ci}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as ZT,useState as Mn}from"react";var Tm=480,vm=768,wm=1024,bm=1200,JT=i(()=>{let[t,e]=Mn(!1),[o,n]=Mn(!1),[r,a]=Mn(!1),[s,l]=Mn(!1),[c,p]=Mn(!1),u=i(()=>{e(window.innerWidth<=Tm),n(window.innerWidth>Tm&&window.innerWidth<=vm),a(window.innerWidth>vm&&window.innerWidth<=wm),l(window.innerWidth>wm&&window.innerWidth<=bm),p(window.innerWidth>bm)},"handleResize");return ZT(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),li=JT;var pi=4,ui=6,Pn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||I();return U.createElement(di,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(sm,{className:n,state:a},U.createElement(tv,{src:o,size:16})))},"ImageComponent");function Em(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||I(),p=r.length,u=Zp(r),{isTablet:d,isMobile:h}=li();return U.createElement(am,{listItem:s==="list-item",ref:f=>e.current=f,selected:o,onClick:f=>{f.stopPropagation(),n(g=>!g)}},U.createElement("div",{className:Xo()},U.createElement(ci,{variant:"body",size:"xsmall"},xm.t("Via:")),U.createElement(Ls,{direction:"horizontal",size:4}),r.map((f,g)=>{let m=`item-${g}`,C=U.createElement(Is,null,U.createElement(ev,{size:12,color:"black"}));return h||d?U.createElement(U.Fragment,{key:m},U.createElement(Pn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),g!==p-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:m},p<=pi||p>pi&&g<pi-1?U.createElement(U.Fragment,null,U.createElement(Pn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),g!==p-1&&U.createElement(U.Fragment,null,C)):g===pi-1&&U.createElement(di,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=g&&U.createElement(U.Fragment,{key:T},U.createElement(Pn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==p-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Ns,{state:r.find((S,k)=>k>=g&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(ci,{size:"xsmall",variant:"body"},"+",p-g))))})),U.createElement("div",{className:Xo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Xo()},U.createElement(ci,{variant:"body",size:"xsmall"},xm.t("Chains:")),U.createElement(Ls,{direction:"horizontal",size:4}),u.map((f,g)=>U.createElement(U.Fragment,{key:f.displayName},u.length<=ui||u.length>ui&&g<ui-1?U.createElement(di,{container:c,side:"bottom",content:f.displayName,sideOffset:4},U.createElement(Pn,{content:"",src:f.image,open:!1,className:g!==0?"blockchainImage":""})):g===ui-1&&U.createElement(di,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},u.map((m,C)=>C>=g&&U.createElement(Pn,{key:m.displayName,content:"",src:m.image,open:!1,className:C>g?"blockchainImage":"",container:l})))},U.createElement(Ns,{className:"blockchainImage"},U.createElement(ci,{size:"xsmall",variant:"body"},"+",u.length-g))))),U.createElement(Ls,{direction:"horizontal",size:32}))),U.createElement(Is,{orientation:a?"up":"down"},U.createElement(RT,{size:12,color:"black"}))))}i(Em,"QuoteTrigger");function Ps(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:c=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:d=!1,container:h}=t,f=y().blockchains(),{findToken:g}=y(),m=y().swappers(),{customSlippage:C,slippage:S}=y(),k=C||S,[T,v]=cv(t.expanded),b=lv(null),N=B(o.value,6,6),D=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",x=Pt(o.usdValue,n.usdValue??null),E=B(x,2,2),A=_t(x??0),M=i((le,at)=>le.map((G,P)=>{let q,V=r?.type===3&&r.swap.swapperId===G.swapperId,ge=r?.type===4&&r.recommendedSlippages?.has(P),ne=a?.type===2&&a.recommendedSlippages?.has(P),he=V||ge,Fe=ne;he?q="error":Fe&&(q="warning");let ve=he?So.t("Slippage Error"):So.t("Slippage Warning");return V&&(ve=So.t("Bridge Limit Error")),{swapper:{displayName:rn(G.swapperId,m)??"",image:G.swapperLogo},from:{token:{displayName:G.from.symbol,image:G.from.logo},chain:{displayName:st(G.from.blockchain,f)??"",image:G.from.blockchainLogo},price:{value:P===0&&!at?B(o.value,6,6):B(G.fromAmount,6,6),usdValue:B((G.from.usdPrice??0)*parseFloat(G.fromAmount),4,4),realValue:P===0?o.value:G.fromAmount,realUsdValue:new Ms(G.from.usdPrice??0).multipliedBy(G.fromAmount).toString()}},to:{token:{displayName:G.to.symbol,image:G.to.logo},chain:{displayName:st(G.to.blockchain,f)||"",image:G.to.blockchainLogo},price:{value:B(G.toAmount,6,6),usdValue:B((G.to.usdPrice??0)*parseFloat(G.toAmount),4,4),realValue:G.toAmount,realUsdValue:new Ms(G.to.usdPrice??0).multipliedBy(G.toAmount).toString()}},state:q,alerts:he||Fe?F.createElement(Yd,{dense:d},F.createElement(ov,{variant:"alarm",type:he?"error":"warning",title:ve,footer:F.createElement(Zd,null,V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {amount} {symbol}",values:{amount:B(G.fromAmount,6,6),symbol:G?.from.symbol}}))),(ge||ne)&&!V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(P)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(P)}}})),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:ln(G.estimatedTimeInSeconds),fee:B(La(G,g),2,2),internalSwaps:G.internalSwaps?M(G.internalSwaps):void 0}}),"getQuoteSteps"),L=M(e?.swaps??[]),X=L.length,oe=h||I(),Y=Rp(t.quote.tags||[]),W=!!u,K=mr(e?.swaps),se=ln(K),z=Mr(e?.swaps??[],g),me=B(z,2,2),vt=z.gte(new Ms(Hp)),Ze=K/Gp>=qp;return d?F.createElement(nv,{selected:l,fee:me,time:se,tooltipContainer:ro(),steps:L,tags:Y,quoteCost:F.createElement(Bs,{quote:e,fullExpandedMode:!0,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:X}),percentageChange:E,warningLevel:A,outputPrice:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(om,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:nm()},!c&&Y.length?F.createElement(F.Fragment,null,F.createElement(dm,null,Y.map((le,at)=>{let G=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:G},F.createElement(iv,{label:le.label,value:le.value}),F.createElement(Yo,{size:4,direction:"horizontal"}))})),F.createElement(ni,null),!W&&F.createElement(Yo,{size:4})):null,F.createElement("div",{id:"portal-root",className:rm()},F.createElement(Bs,{quote:e,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:X}),W&&F.createElement(tm,{onClick:le=>{le.stopPropagation(),u()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Zo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},So.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:im()},F.createElement(pm,null,F.createElement(rv,{size:12,color:"gray"})),F.createElement(um,null,F.createElement(As,{size:"small",variant:"body"},`${N} ${L[0].from.token.displayName} = `),F.createElement(Im,{content:n.value,container:oe,open:n.value?void 0:!1},F.createElement(As,{size:"small",variant:"body"},"\xA0",`${D} ${L[L.length-1].to.token.displayName}`))),F.createElement(Im,{content:n.usdValue,container:oe},F.createElement(Yo,{size:2,direction:"horizontal"}),F.createElement(Zo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(sv,{tooltipContainer:oe,type:"output",direction:"vertical",price:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:L[X-1].to.token.displayName,image:L[X-1].to.token.image},chain:{image:L[X-1].to.chain.image},percentageChange:E,warningLevel:A}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Ln,{from:L[0].from,to:L[X-1].to,percentageChange:E,warningLevel:A}),F.createElement(Yo,{size:4}))),F.createElement(Rd,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(Em,{type:s,quoteRef:b,selected:l,setExpanded:v,container:oe,expanded:T,steps:L}),F.createElement(lm,{open:T},F.createElement(cm,null),F.createElement("div",{className:em()},L.map((le,at)=>{let G=`item-${at}`;return F.createElement(av,{type:"quote-details",key:G,tooltipContainer:oe,step:le,hasSeparator:at!==L.length-1,state:le.state})})))))}i(Ps,"Quote");import{Divider as mv,Skeleton as fv}from"@rango-dev/ui";import Ot from"react";import{darkTheme as pv,styled as mi}from"@rango-dev/ui";var Am=mi("div",{$$color:"$colors$neutral100",[`.${pv} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Nm=mi("div",{paddingTop:"$2"}),Wm=mi("div",{paddingLeft:"$8"}),Bm=mi("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as zm,Divider as St,Skeleton as tt}from"@rango-dev/ui";import Q from"react";import{css as uv,styled as Ft}from"@rango-dev/ui";var _s=Ft("div",{display:"flex"}),Lm=Ft("div",{padding:"$10 $0 $20"}),Mm=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Pm=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),_m=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Dm=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),$m=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Fm=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Om=Ft("div",{padding:"$15 $0 $15 $0"}),Um=uv({display:"flex",justifyContent:"space-between",alignItems:"center"});function _n(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(_m,null,Q.createElement($m,null,Q.createElement(zm,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{size:8,direction:"horizontal"}),Q.createElement(Fm,null,Q.createElement(tt,{height:10,width:60,variant:"rounded"}),Q.createElement(St,{size:4}),Q.createElement(tt,{height:15,variant:"rounded"}))),Q.createElement(tt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return Q.createElement("div",null,!o&&Q.createElement(Q.Fragment,null,Q.createElement(_s,null,Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"})),Q.createElement(ni,null),!r&&Q.createElement(St,{size:4})),Q.createElement("div",{className:Um()},Q.createElement(_s,null,Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"})),r&&Q.createElement(tt,{width:85,height:24,variant:"rounded"})),e==="basic"&&Q.createElement(Lm,null,Q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(Mm,null,Q.createElement(Pm,null,Q.createElement(zm,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{direction:"horizontal",size:4}),Q.createElement(tt,{height:15,width:150,variant:"rounded"})),Q.createElement(St,{size:10}),Q.createElement(tt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&Q.createElement(Q.Fragment,null,Q.createElement(St,{size:4}),Q.createElement(Om,null,n,Q.createElement(Dm,null),n),Q.createElement(St,{size:12})))}i(_n,"QuoteSummarySkeleton");import{ChainToken as Vm,Divider as $s,NextIcon as dv,Skeleton as fi}from"@rango-dev/ui";import Ie from"react";import{styled as Dn}from"@rango-dev/ui";var Qm=Dn("div",{display:"flex",alignItems:"start"}),Hm=Dn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Ds=Dn("div",{display:"flex",alignItems:"center",flexGrow:1}),qm=Dn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Gm=Dn("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ie.createElement(Ie.Fragment,null,Ie.createElement(Gm,null,Ie.createElement(fi,{height:22,width:22,variant:"circular"}),Ie.createElement($s,{direction:"horizontal",size:8}),Ie.createElement(fi,{height:15,width:148,variant:"rounded"})),Ie.createElement(Qm,null,Ie.createElement(Bm,{hideSeparator:!e}),Ie.createElement(Hm,{extraSpace:e},Ie.createElement(Ds,null,Ie.createElement(Vm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ie.createElement($s,{direction:"horizontal",size:8}),Ie.createElement(fi,{height:12,variant:"rounded"})),Ie.createElement(qm,null,Ie.createElement(dv,{color:"gray",size:16})),Ie.createElement(Ds,null,Ie.createElement(Vm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ie.createElement($s,{direction:"horizontal",size:8}),Ie.createElement(fi,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function $n(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Am,{expanded:o,rounded:e!=="basic"},Ot.createElement(_n,{type:e,tagHidden:n}),Ot.createElement(Nm,null,Ot.createElement(fv,{height:15,variant:"rounded"})),o&&Ot.createElement(Wm,null,Ot.createElement(mv,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i($n,"QuoteSkeleton");function Co(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:p,selected:u,onClickAllRoutes:d,fullExpandedMode:h=!1,container:f}=t,{inputAmount:g,inputUsdValue:m}=O(),C=e?.outputAmount?new gv(e?.outputAmount):null,S=e?ct(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?gi.createElement(Es,null,gi.createElement($n,{tagHidden:l,type:o,expanded:s})):T?gi.createElement(Es,{onClick:()=>c?.(e)},gi.createElement(Ps,{quote:e,error:r,container:f,showModalFee:p,warning:a,tagHidden:l,selected:u,type:o,expanded:s,onClickAllRoutes:d,fullExpandedMode:h,input:{value:g,usdValue:m?.toString()??""},output:{value:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(Co,"QuoteInfo");import{calculatePendingSwap as Cv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as kv}from"react";import{useRef as hv,useState as yv}from"react";var Sv=2e3;function hi({request:t}){let[e,o]=yv(!1),n=hv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,Sv)),await s(l,!1)),"retryFetch"),s=i(async(l,c=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(l,{signal:n.current.signal});return n.current=null,p}catch(p){if(c)return await a(l);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(hi,"useFetch");function Km(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await xt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Km,"useFetchConfirmQuote");function yi(t){if(!t.swaps)throw new Error(R().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Fs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(yi,"throwErrorIfResponseIsNotValid");function Fs(t){if(ru(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=iu(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=cu(t);if(o){let n=Pr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Fs,"getQuoteError");function jm(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Fo({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let p=du(e,r,n.blockchains);return p.length===0||(l.balance={messages:p}),l}i(jm,"generateWarnings");function Si(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(Si,"handleQuoteErrors");function Os(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:c,customSlippage:p}=y(),u=y().getDisabledLiquiditySources(),d=y().blockchains(),h=y().tokens(),{findToken:f}=y(),g=p||c,{fetch:m,cancelFetch:C,loading:S}=Km();return kv(()=>C,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,b=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=v.reduce((w,x)=>(w[x.chain]=x.address,w),{}),D={requestId:a?.requestId||"",selectedWallets:N,destination:b||void 0};try{return await m(D,!0).then(w=>{let{result:x}=w;if(!x)throw new Error("Error fetching updated route");yi({diagnosisMessages:x.diagnosisMessages,requestId:x.requestId,swaps:x.result?.swaps});let E={outputAmount:x.result?.outputAmount,requestId:x.requestId,resultType:x.result?.resultType,swaps:x.result?.swaps||[],validationStatus:x.validationStatus,requestAmount:x.requestAmount};r(E);let A={slippage:g.toString(),disabledSwappersGroups:u},M=jm({previousQuote:a??void 0,currentQuote:E,meta:{blockchains:d},selectedWallets:v,userSlippage:g,inputUsdValue:n,findToken:f});l();let L=!!M.balance,X=Cv(o.toString(),x,uu(v),A,!L,{blockchains:d,tokens:h});return{quote:E,swap:X,error:null,warnings:M}})}catch(w){return Si(w)}},"fetch"),cancelFetch:C}}i(Os,"useConfirmSwap");var Wv=bv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Xm}`]:{width:"$48",height:"$48"}}),Bv=Qs({flexGrow:1,paddingRight:"$10"}),Lv=Qs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Mv=Qs({display:"flex",justifyContent:"space-between",alignItems:"center"});function Ym(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=Nv(),[l,c]=Fn(""),p=!n,[u,d]=Fn(!1),[h,f]=Fn(!1),{isActiveTab:g}=re(),m=y().getDisabledLiquiditySources(),C=Av(m),{manager:S}=Tv(),{fetch:k,loading:T,cancelFetch:v}=Os(),[b,N]=Fn({swap:null,error:null,warnings:null}),[D,w]=Fn(!1),x=i(async({selectedWallets:W,customDestination:K})=>{let se=await k?.({selectedWallets:W,customDestination:K});return N(se),se},"onConfirmSwap"),E=i(async()=>{if(b.swap&&n)try{await S?.create("swap",{swapDetails:b.swap},{id:b.swap.requestId});let W=`../${$.swaps}/${b.swap.requestId}`;s(W,{replace:!0}),setTimeout(()=>{e("")},0)}catch(W){c("Error: "+W?.message)}},"addNewSwap"),A=i(async()=>{f(!0),await E(),f(!1)},"onConfirm"),M=i(async()=>{b.warnings?.quote&&Yp(b.warnings.quote)&&!a?w(!0):await A()},"onStartConfirmSwap"),L=i(async()=>{N({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(W=>{N(W)}).catch(W=>console.error(W))},"onRefresh");Ci(()=>{!!C.current.length&&!m.length&&L(),C.current=m},[m.length]),Ci(()=>{p&&v()},[p]),Ci(()=>{p&&d(p)},[p]),Ci(()=>{p||k({selectedWallets:o,customDestination:r}).then(W=>N(W)).catch(W=>console.error(W))},[]),Iv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let X=b.warnings?.quote??null,oe=b.error,Y=[];if(l&&Y.push(Me.createElement(vv,{type:"error",variant:"alarm",title:l})),X||oe){let W=`../${$.settings}`;Y.push(Me.createElement(Wn,{warning:X,error:oe,couldChangeSettings:!1,refetchQuote:L,showWarningModal:D,confirmationDisabled:!g,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await E()},onChangeSettings:()=>s(W)}))}return Me.createElement(te,{header:{title:Us.t("Confirm Swap"),onWallet:()=>{let W=`../${$.wallets}`;s(W)}},footer:Me.createElement(Wv,null,Me.createElement("div",{className:Bv()},Me.createElement(wv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!b.error||!g,onClick:M},Us.t("Start Swap"))),Me.createElement(Xm,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!g,onClick:d.bind(null,!0)},Me.createElement(Ev,{size:24})))},u&&Me.createElement(Bd,{open:u,onClose:()=>d(!1),onCancel:v,loading:T,onCheckBalance:x}),Me.createElement(ie,null,Me.createElement("div",{className:Mv()},Me.createElement(xv,{variant:"title",size:"small"},Us.t("You get")),Me.createElement("div",{className:Lv()},Me.createElement(Ur,{onClick:!T&&!u&&!D?L:void 0}))),Me.createElement(zs,{size:"12"}),Bu(Y.map((W,K)=>({element:W,key:`alert-${K}`})),Me.createElement(zs,{size:10})),Y.length>0?Me.createElement(zs,{size:10}):null,Me.createElement(Co,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:b.error,loading:T,warning:b.warnings?.quote??null})))}i(Ym,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Rs,CustomTokensZeroStateDarkIcon as Xv,CustomTokensZeroStateIcon as Yv,DeleteIcon as Zv,Divider as Qn,IconButton as Jv,MessageBox as Rv,NotFound as ew,styled as tl}from"@rango-dev/ui";import de,{useState as el}from"react";import{useNavigate as tw}from"react-router-dom";import{CloseIcon as _v,IconButton as Dv,SearchIcon as $v,TextField as Fv}from"@rango-dev/ui";import On from"react";import{styled as Pv}from"@rango-dev/ui";var Zm=Pv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:c,...p}=t;return On.createElement(Fv,{prefix:On.createElement(Zm,null,On.createElement($v,{color:"black"})),suffix:!!s.length&&On.createElement(Dv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},On.createElement(_v,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...p})}i(Ct,"SearchInput");import{i18n as Js}from"@lingui/core";import{darkTheme as cf,Divider as Ro,ExternalLinkIcon as zv,Image as Qv,ListItemButton as Hv,NotFound as qv,PinIcon as Gv,Skeleton as pf,Typography as vi,VirtualizedList as Vv}from"@rango-dev/ui";import H from"react";import{Divider as sf,ListItem as Uv,Skeleton as Un}from"@rango-dev/ui";import kt from"react";import{css as Jo,darkTheme as Jm,ImageContainer as Ov,styled as ut,Typography as Rm}from"@rango-dev/ui";var Hs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),qs=Jo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Gs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Vs=Jo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Jm} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Ks=Jo({}),js=Jo(),ef=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Xs=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),ki=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${qs}`]:{[`& .${Vs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Ks}`]:{bottom:"-15px"},[`& .${Hs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Gs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Ys=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Zs=ut(Rm,{}),tf=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${js}`]:{$$color:"$colors$neutral600",[`.${Jm} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ti=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),oz=ut("div",{display:"flex",alignItems:"center"}),of=ut("div",{position:"relative",[`& ${Ov}`]:{borderRadius:"$xm",overflow:"hidden"}}),nf=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),rf=ut(Rm,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),af=ut("a",{"& svg:hover":{color:"$colors$info"}});function lf(t){return kt.createElement(ki,null,Array.from(Array(t.size),e=>kt.createElement(Uv,{key:e,hasDivider:!0,start:kt.createElement(Un,{variant:"circular",width:35,height:35}),end:kt.createElement(Ti,null,kt.createElement(Un,{variant:"text",size:"large",width:70}),kt.createElement(sf,{size:4}),kt.createElement(Un,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Un,{variant:"text",size:"large",width:90}),kt.createElement(sf,{size:4}),kt.createElement(Un,{variant:"text",size:"medium",width:90}))})))}i(lf,"LoadingTokenList");var Kv=20,jv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:qs()},o?H.createElement("div",{className:Hs()},o):H.createElement(Xs,{className:Gs()},H.createElement(vi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Ys,{css:a},H.createElement(Zs,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Vs()} ${!o&&Ks()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Ro,{size:4,direction:"horizontal"}),H.createElement(af,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},H.createElement(zv,{size:12}))))},"renderDesc");function zn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,c=y().blockchains(),{getBalanceFor:p,fetchingWallets:u}=y(),{isTokenPinned:d}=y(),h=i(g=>{let m=yr(p(g));return s?s(g):u?H.createElement(Ti,null,H.createElement(pf,{variant:"text",size:"large",width:70}),H.createElement(Ro,{size:4}),H.createElement(pf,{variant:"text",size:"medium",width:50})):m&&H.createElement(tf,null,H.createElement(rf,{variant:"title",size:"small"},m.amount),H.createElement("div",null),m.usdValue&&H.createElement(vi,{variant:"body",className:js(),size:"xsmall"},`$${m.usdValue}`))},"endRenderer"),f=i(()=>H.createElement(Vv,{itemContent:g=>{let m=e[g],C=m.address||"",S=c.find(b=>b.name===m.blockchain),k=Va(S.color,"main"),T={$$color:k.main150,[`.${cf} &`]:{$$color:k.main750},backgroundColor:"$$color"},v={$$color:k.main750,[`.${cf} &`]:{$$color:k.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(Hv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":g,key:`${m.symbol}${m.address}`,id:`${m.symbol}${m.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[g]),start:H.createElement(of,null,H.createElement(Qv,{src:m.image,size:30}),t.type!=="custom-token"&&d(m,t.type)&&H.createElement(nf,null,H.createElement(Gv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||m.name||!m.name&&!C?H.createElement(Xs,null,H.createElement(vi,{variant:"title",size:"xmedium"},m.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Ys,{css:T},H.createElement(Zs,{variant:"body",size:"xsmall",css:v},m.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?jv({address:C,token:e[g],customCssForTag:T,customCssForTagTitle:v,name:m.name,url:S.info.addressUrl.split("{wallet}").join(C)}):m.name||void 0,end:h(m)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(vi,{variant:"label",size:"large"},Js.t("Select Token")),H.createElement(Ro,{size:4})),H.createElement(ef,null,H.createElement(Ro,{size:4}),l==="loading"&&H.createElement(lf,{size:Kv}),l==="success"&&(e.length?H.createElement(ki,{as:"ul"},f()):!!o&&H.createElement(qv,{title:Js.t("No results found"),description:Js.t("Try using different keywords")}))))}i(zn,"TokenList");var ow=tl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),nw=tl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),rw=tl(Jv,{"&:hover":{"& svg":{color:"$secondary550"}}});function uf(){let[t,e]=el(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=Qo({}),p=tw(),[u,d]=el(!1),[h,f]=el(),g=i(k=>{let T=k.target.value;e(T)},"handleSearch"),m=c==="dark",C=n.filter(k=>Je(k.symbol,t)||Je(k.address||"",t)||Je(k.name||"",t)),S=i(()=>{if(h){let k=a?lt(a):null,T=r?lt(r):null,v=lt(h);k===v?l({token:null}):T===v&&s({token:null}),o(h)}d(!1)},"handleDeleteCustomToken");return de.createElement(te,{header:{title:Ut.t("Custom Tokens")}},de.createElement(ie,null,de.createElement(ow,null,n.length?de.createElement(de.Fragment,null,de.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:g}),de.createElement(Qn,{size:16}),de.createElement(zn,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>de.createElement(rw,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),f(k)}},de.createElement(Zv,{size:12,color:"gray"}))})):de.createElement(nw,null,de.createElement(ew,{icon:m?de.createElement(Xv,{size:200}):de.createElement(Yv,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),de.createElement(Qn,{size:20}),de.createElement(Rs,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},Ut.t("Add Custom Token"))),de.createElement(J,{open:u,dismissible:!0,onClose:()=>d(!1),container:I()},de.createElement(Rv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},de.createElement(Qn,{size:40}),de.createElement(Qn,{size:10}),de.createElement(Rs,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),de.createElement(Qn,{size:12}),de.createElement(Rs,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},Ut.t("No, Continue"))))))}i(uf,"CustomTokensPage");import{i18n as He}from"@lingui/core";import{useManager as ww}from"@rango-dev/queue-manager-react";import{Button as ll,darkTheme as bw,Divider as To,MessageBox as xw,NotFound as Ew,styled as cl,Typography as xi}from"@rango-dev/ui";import{TransactionStatus as Gn}from"rango-types";import ae,{useMemo as Wf,useState as Ei}from"react";import{useNavigate as Iw}from"react-router-dom";import{FilterIcon as uw,Popover as dw}from"@rango-dev/ui";import ko from"react";import{css as iw,darkTheme as wi,IconButton as aw,styled as Hn}from"@rango-dev/ui";var ol=Hn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${wi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),df=Hn(aw,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${wi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${wi} &`]:{backgroundColor:"$neutral"},[`& ${ol}::before`]:{backgroundColor:"$secondary100",[`.${wi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),mf=Hn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),ff=Hn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),gf=iw({display:"flex",justifyContent:"space-between",alignItems:"center"}),hf=Hn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as yf}from"@lingui/core";import{Button as sw,Divider as Sf,ListItemButton as lw,Radio as cw,RadioRoot as pw,Typography as Cf}from"@rango-dev/ui";import ot from"react";function kf(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(ff,null,ot.createElement("div",{className:gf()},ot.createElement(Cf,{size:"small",variant:"body"},yf.t("Status")),ot.createElement(sw,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},yf.t("Reset"))),ot.createElement(Sf,{size:10}),ot.createElement(pw,{value:e},ot.createElement(hf,null,t.list.map((n,r)=>ot.createElement(lw,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:ot.createElement(ot.Fragment,null,ot.createElement(Sf,{direction:"horizontal",size:4}),ot.createElement(Cf,{size:"medium",variant:"body"},n.title)),start:ot.createElement(cw,{value:n.id}),onClick:o})))))}i(kf,"FilterSelectorContent");function nl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return ko.createElement("div",null,ko.createElement(dw,{open:a,align:"end",onOpenChange:o,container:I(),content:ko.createElement(kf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},ko.createElement(df,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},ko.createElement(ol,{isSelect:!!n},ko.createElement(uw,{size:16,color:"black"}),!!n&&ko.createElement(mf,null)))))}i(nl,"FilterSelector");import{i18n as gw}from"@lingui/core";import{Divider as xf,GroupedVirtualizedList as hw,Skeleton as yw,SwapListItem as Ef,Typography as Sw}from"@rango-dev/ui";import Qe,{useCallback as If,useEffect as Cw,useRef as kw,useState as Tw}from"react";function Tf(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(Tf,"calculateGroupsSoFar");import{css as mw,darkTheme as fw,styled as qn}from"@rango-dev/ui";var rl=mw(),vf=qn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),il=qn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${rl}`]:{$$color:"$colors$neutral600",[`.${fw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),al=qn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),wf=qn("div",{gap:"$10",display:"flex",flexDirection:"column"}),bf=qn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var vw=10;function sl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Tw([]),l=kw(0),{swaps:c,groupCounts:p,groups:u}=n(e),d=If(Tf,[]),h=If(()=>{let f=e.length-l.current;f&&(l.current+=Math.min(f,vw),s(d(p,l.current)))},[e.length]);if(Cw(()=>{r||h()},[r,h]),r){let f=[1,2];return Qe.createElement(Qe.Fragment,null,[f,f].map((m,C)=>Qe.createElement(il,{key:C},Qe.createElement(al,null,Qe.createElement(yw,{variant:"text",width:60,size:"small"}),Qe.createElement(xf,{size:16})),Qe.createElement(xf,{size:4}),Qe.createElement(wf,null,m.map((k,T)=>Qe.createElement(Ef,{isLoading:!0,key:T}))))))}return Qe.createElement(hw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:f=>Qe.createElement(il,null,Qe.createElement(al,null,Qe.createElement(Sw,{variant:"label",size:"medium",className:rl()},u[f]))),itemContent:(f,g)=>{let m=c[f];if(!m)return null;let C=m.steps[0],S=m.steps[m.steps.length-1];return Qe.createElement(vf,{key:m.requestId},Qe.createElement(Ef,{requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,tooltipContainer:I(),onlyShowTime:u[g]===gw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:B(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:B(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(sl,"HistoryGroupedList");import{i18n as bi}from"@lingui/core";import Af from"dayjs";var Nf=i(t=>{let e=new Map([["today",{title:bi.t("Today"),swaps:[]}],["week",{title:bi.t("This week"),swaps:[]}],["month",{title:bi.t("This month"),swaps:[]}],["year",{title:bi.t("This year"),swaps:[]}]]);function o(c,p){e.has(c)||e.set(c,{title:c,swaps:[]}),e.get(c)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Af();t.forEach(c=>{let p=Number(c.creationTime),u=Af(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(c);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(c);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(c);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(c);else{let d=new Date(p).getFullYear().toString();o(d,c)}});let r=Array.from(e.values()).filter(c=>c.swaps.length>0),a=r.flatMap(c=>c.swaps),s=r.map(c=>c.swaps.length),l=r.map(c=>c.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Aw=cl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),Nw=cl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Ww=cl("div",{"._typography":{color:"$neutral700",[`.${bw}&`]:{color:"$neutral900"}}}),Bw=[{id:Gn.SUCCESS,title:He.t("Complete")},{id:Gn.RUNNING,title:He.t("Running")},{id:Gn.FAILED,title:He.t("Failed")}],Lw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Bf(){let t=Iw(),{manager:e,state:o}=ww(),n=pt(e).map(({swap:T})=>T),[r,a]=Ei(""),[s,l]=Ei(!1),c=!o.loadedFromPersistor,[p,u]=Ei(""),[d,h]=Ei(!1),f=i(T=>{let v=T.target.value;a(v)},"handleSearch"),g=Wf(()=>!r&&!p?n:n.filter(T=>{let{inputAmount:v,status:b,steps:N,requestId:D}=T;return(!r||wt(v,r)||wt(b,r)||Lw(N,r)||wt(D,r))&&(!p||p===b)}),[n,r,p]),m=!g?.length&&!c,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),k=Wf(()=>!n.some(T=>T.status===Gn.SUCCESS||T.status===Gn.FAILED),[n]);return ae.createElement(te,{header:{title:He.t("History"),suffix:ae.createElement(Vt,null,ae.createElement(ll,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(xi,{size:"medium",variant:"label",color:"error"},He.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(Nw,null,ae.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:He.t("Search Transaction"),autoFocus:!0,onChange:f,style:{height:36},value:r}),ae.createElement(To,{size:10,direction:"horizontal"}),ae.createElement(nl,{filterBy:p,open:s,onOpenChange:T=>l(T),onClickItem:T=>u(T),list:Bw})),ae.createElement(To,{size:"16"}),ae.createElement(Aw,null,m&&ae.createElement(bf,null,ae.createElement(To,{size:32}),ae.createElement(Ew,{title:r?He.t("No results found"):He.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?He.t("Try using different keywords"):He.t("Your transaction history is stored locally and will appear here after you start a swap")})),!m&&ae.createElement(sl,{list:g,onSwapClick:t,groupBy:Nf,isLoading:c}))),ae.createElement(J,{open:d,onClose:C,container:I()},ae.createElement(To,{size:20}),ae.createElement(xw,{type:"warning",title:He.t("Clear Transaction History"),description:ae.createElement(Ww,null,ae.createElement(xi,{variant:"body",size:"medium"},He.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(To,{size:"24"}),ae.createElement(xi,{variant:"body",size:"small"},He.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(To,{size:30}),ae.createElement(ll,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},He.t("Yes, Clear the history")),ae.createElement(To,{size:10}),ae.createElement(ll,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(xi,{variant:"title",size:"medium",color:"primary"},He.t("No, Cancel")))))}i(Bf,"HistoryPage");import{i18n as ob}from"@lingui/core";import{Button as nb,Divider as Jf,styled as rb,WarningIcon as ib}from"@rango-dev/ui";import ab from"bignumber.js";import qe,{useEffect as Rf,useState as eg}from"react";import{useNavigate as sb}from"react-router-dom";import{i18n as Mf}from"@lingui/core";import{Alert as Pw,Divider as pl,NoRouteIcon as _w,Typography as Dw}from"@rango-dev/ui";import vo from"react";import{styled as Mw}from"@rango-dev/ui";var Lf=Mw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function ul(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Lt(t,e)?vo.createElement(Lf,null,vo.createElement(pl,{size:10}),vo.createElement(_w,{size:24,color:"gray"}),vo.createElement(pl,{size:4}),vo.createElement(Dw,{variant:"title",size:"small"},Mf.t("No Routes Found")),vo.createElement(pl,{size:4}),vo.createElement(Pw,{title:Mf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(ul,"SameTokensWarning");import{i18n as Qw}from"@lingui/core";import{Header as Hw}from"@rango-dev/ui";import Jt,{useEffect as qw,useState as Gw}from"react";import{i18n as Fw}from"@lingui/core";import{Divider as ml,FullExpandedQuote as Ow,Typography as Uw}from"@rango-dev/ui";import Ce from"react";import{styled as dl}from"@rango-dev/ui";var Pf=dl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),_f=dl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Df=dl("div",{width:"146px"});import{i18n as Vn}from"@lingui/core";import{Select as $w}from"@rango-dev/ui";import $f from"react";function Ii(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:Vn.t("Smart Routing")},{value:"FEE",label:Vn.t("Lowest Fee")},{value:"SPEED",label:Vn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Vn.t("Maximum Return")},{value:"PRICE",label:Vn.t("Maximum Output")}];return $f.createElement(Df,null,$f.createElement($w,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ii,"SelectStrategy");var Ff=3;function Kn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:c,quotes:p,updateQuotePartialState:u,fromToken:d,toToken:h,sortStrategy:f,error:g}=O(),{slippage:m,customSlippage:C}=y(),{findToken:S}=y(),k=l||I(),T=!!p&&p.results.length,v=C??m,b=i(w=>{if(!d||!h||!p)return null;let x={requestAmount:p.requestAmount,validationStatus:null,...w};return Fo({currentQuote:x,userSlippage:v,findToken:S})},"getQuoteWarning"),N=g?.type===0||g?.type===1,D=p?.results?Lr(f,p?.results):[];return Ce.createElement(Ce.Fragment,null,a&&Ce.createElement(Ce.Fragment,null,Ce.createElement(_f,null,Ce.createElement(Uw,{size:"xmedium",variant:"title"},Fw.t("Sort by")),Ce.createElement(Ii,{container:k})),Ce.createElement(ml,{size:"10"})),e&&Array.from({length:Ff},(w,x)=>Ce.createElement(Ce.Fragment,{key:x},s?Ce.createElement(Ow,{loading:!0}):Ce.createElement($n,{tagHidden:!1,type:"list-item",expanded:!1}),x!==Ff-1&&Ce.createElement(ml,{size:16}))),!e&&Ce.createElement(Ce.Fragment,null,T?D.map((w,x)=>{let E=b(w),A=Fs(w.swaps),M=D.length-1===x;return Ce.createElement(Ce.Fragment,{key:w.requestId},Ce.createElement(Co,{showModalFee:r,container:k,selected:c?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:A?.options||null,warning:E,fullExpandedMode:s,onClick:L=>{A||u("warning",E),u("error",A?.options||null),o(L)},type:"list-item"}),!M&&Ce.createElement(ml,{size:16}))}):N&&Ce.createElement(Pf,null,Ce.createElement(An,{size:s?"large":"small",error:g,fetch:n}))))}i(Kn,"Quotes");import{darkTheme as zw,styled as Of}from"@rango-dev/ui";var Uf=Of("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${zw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),zf=Of("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Vw=100;function fl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Gw(!1),c=s?"":"is-hidden",{config:p}=y(),u=p?.variant==="full-expanded",d=ro();return qw(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Vw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Uf,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${c} ${qr()}`,id:De.EXPANDED_BOX_ID},Jt.createElement(Hw,{title:Qw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(Ii,{container:d}),Jt.createElement(go,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(zf,null,Jt.createElement(Kn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:ro(),onClickOnQuote:n,fullExpandedMode:u})))}i(fl,"ExpandedQuotes");import{i18n as jf}from"@lingui/core";import{SwapInput as Xf}from"@rango-dev/ui";import Yw from"bignumber.js";import jn from"react";import{ReverseIcon as Xw}from"@rango-dev/ui";import hl from"react";import{keyframes as Kw,styled as Qf}from"@rango-dev/ui";var gl=450,jw=Kw({"0%":{transform:"rotateX(0deg) rotateY(0deg) rotateZ(0deg)"},"33%":{transform:"rotateX(0deg) rotateZ(78deg) rotateY(66deg)"},"66%":{transform:"rotateX(0deg) rotateZ(163deg) rotateY(66deg)"},"100%":{transform:"rotateX(0deg) rotateZ(180deg) rotateY(0deg)"}}),Hf=Qf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),qf=Qf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${jw} ${gl}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function yl(){let t=O.use.switchFromAndTo();return hl.createElement(Hf,null,hl.createElement(qf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},gl),t()}},hl.createElement(Xw,{size:12})))}i(yl,"SwitchFromAndToButton");import{styled as Gf}from"@rango-dev/ui";var Vf=Gf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Kf=Gf("div",{position:"relative"});function Sl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:p,inputAmount:u,inputUsdValue:d,outputAmount:h,outputUsdValue:f,selectedQuote:g}=O(),{connectedWallets:m,getBalanceFor:C}=y(),S=a?C(a):null,k=yr(S)?.amount??"0",T=S?new Yw(S.amount).shiftedBy(-S.decimals):ce,v=!!s&&zc(m,s.name),b=!Ba(g,u,d),N=!Ba(g,u,f),D=!d||!f||!f.gt(0)?null:Pt(d.toString(),f.toString());return jn.createElement(Vf,null,jn.createElement(Kf,null,jn.createElement(Xf,{label:jf.t("From"),mode:"From",onInputChange:p,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:u,usdValue:b?void 0:B(d,4,4),realUsdValue:b?void 0:d?.toString(),error:b?R().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:I(),onSelectMaxBalance:()=>{let w=B(T,S?.decimals),x=S?.amount?w.split(",").join(""):"";p(x)},anyWalletConnected:m.length>0}),jn.createElement(yl,null)),jn.createElement(Xf,{sharpBottomStyle:!r&&(!!g||e),label:jf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(Pt(d,f),2,2),warningLevel:_t(D??0),price:{value:B(h,6,6),usdValue:N?void 0:B(f,4,4),realValue:h?.toString(),realUsdValue:N?void 0:f?.toString(),error:N?R().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:I()}))}i(Sl,"Inputs");import{useCallback as Zw,useEffect as Jw,useRef as Rw,useState as eb}from"react";function Yf(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await xt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Yf,"useFetchAllQuotes");var tb=600;function Ai({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Yf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:c,inputUsdValue:p,selectedQuote:u,sortStrategy:d,resetQuote:h,error:f,warning:g,setSelectedQuote:m,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:b,fetchStatus:N}=y(),D=y().getLiquiditySources(),w=y().getDisabledLiquiditySources(),x=y().excludeLiquiditySources(),{findToken:E}=y(),[A,M]=eb(!0),L=Rw(c),X=k??S,Y=!s||!l||Lt(s,l)||!cn(c),W=i(z=>{M(z)},"resetState"),K=i(z=>{let{fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:ge}=z;if(A||W(!0),!Y&&me&&vt){h();let ne=pu({fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,wallets:a,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:ge});Wo("experimental",r)&&(ne.experimental=!0),Wo("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),Wo("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(he=>{let Fe=Lr(d,he.results),ve=Jp(u,Fe,he.requestAmount);M(!1),C("quotes",he),m(ve),yi({diagnosisMessages:he.diagnosisMessages,requestId:ve?.requestId||"",swaps:ve?.swaps});let mt=ve&&Fo({currentQuote:ve,userSlippage:X,findToken:E});C("warning",mt)}).catch(he=>{let{error:Fe}=Si(he);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),M(!1))})}},"fetch"),se=Zw(Nc(z=>{K(z)},tb),[Y]);return Jw(()=>{if(!t){M(!1);return}if(N!=="success")return;if(Y){M(!1),(u||f||g)&&h();return}if(!cn(c)||p?.eq(0)){W(!1),o();return}h(),W(!0);let z=K;return L.current&&L.current!=c&&(z=se),L.current=c,z({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:X,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),o},[N,c,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,Y,D?.length,n,w.length,X,v,T,JSON.stringify(b)]),{fetch:()=>K({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:X,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),loading:A}}i(Ai,"useSwapInput");function Zf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ye.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Zf,"emitPreventableEvent");var lb=rb("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),cb=300;function tg(){let t=sb(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:h}=O(),[f,g]=eg(!1),{isLargeScreen:m,isExtraLargeScreen:C}=li(),{fetch:S,loading:k}=Ai({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:b}=y(),{isActiveTab:N}=re(),[D,w]=eg(!1),E=au({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:b.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),A=jc(m,C,T?.variant),M=!!n&&!!e&&!!o&&new ab(n).gt(0)&&!yu(e,o),L=M&&v==="success"&&k,Y=(!A||A&&c?.results.length)&&(l||s);Rf(()=>{u(),h("refetchQuote",!0)},[]),Rf(()=>{g(M)},[M]);let W=(r||s)&&!D?S:void 0,K=i(z=>{A&&f?(g(!1),setTimeout(()=>{t(z)},cb)):t(z)},"onHandleNavigation"),se=i(z=>{r?.requestId!==z.requestId&&(w(!1),p(z))},"onClickOnQuote");return qe.createElement(lb,null,qe.createElement(te,{height:"auto",footer:qe.createElement(nb,{id:`widget-swap-${E.action}-btn`,type:"primary",size:"large",disabled:E.disabled||!N,prefix:E.action==="confirm-warning"&&qe.createElement(ib,null),fullWidth:!0,onClick:()=>{E.action==="connect-wallet"?Zf({type:"clickConnectWallet"},()=>K($.wallets)):E.action==="confirm-warning"?w(!0):K($.confirmSwap)}},E.title),header:{onWallet:()=>{K($.wallets)},hasBackButton:!1,title:T.title||ob.t("Swap"),suffix:qe.createElement(go,{hidden:A?["refresh"]:void 0,onClickRefresh:W,onClickHistory:()=>K($.swaps),onClickSettings:()=>{K($.settings)}})}},qe.createElement(ie,null,qe.createElement(Sl,{fetchingQuote:L,fetchMetaStatus:v,isExpandable:A,onClickToken:z=>{K(z==="from"?$.fromSwap:$.toSwap)}}),qe.createElement(Jf,{size:"2"}),A?null:qe.createElement(Co,{quote:r,loading:L,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),K($.routes)}:void 0}),Y?qe.createElement(qe.Fragment,null,qe.createElement(Jf,{size:"10"}),qe.createElement(Wn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:D,confirmationDisabled:!N,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),d(!0),K($.confirmSwap)},onChangeSettings:()=>K($.settings)})):null,qe.createElement(ul,null))),A?qe.createElement(fl,{loading:L,onClickOnQuote:se,fetch:S,onClickRefresh:W,isVisible:f}):null)}i(tg,"Home");import{i18n as og}from"@lingui/core";import{Alert as pb,Divider as ub,List as db,ListItemButton as mb,Radio as fb,RadioRoot as gb,Typography as hb}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Rc,r=o?.language||Bo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Bo),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function ng(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(hb,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(fb,{value:s}),start:Wt.createElement(c,null)}});return Wt.createElement(te,{header:{title:og.t("Language")}},Wt.createElement(ie,null,Wt.createElement(pb,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(ub,{size:"8"}),Wt.createElement(gb,{value:t},Wt.createElement(db,{type:Wt.createElement(mb,{title:og.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(ng,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as Tb,Checkbox as vb,Image as wb,ListItemButton as bb,NotFound as xb,Typography as Eb}from"@rango-dev/ui";import Ge,{useState as Ib}from"react";import{Checkbox as Cb,Skeleton as ig}from"@rango-dev/ui";import Yn from"react";import{styled as Cl}from"@rango-dev/ui";var Xn=Cl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),kl=Cl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Tl=Cl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as yb,styled as Sb}from"@rango-dev/ui";var rg=Sb(yb,{height:61});var kb=30;function vl(){return Yn.createElement(Xn,null,Array.from(Array(kb),(t,e)=>Yn.createElement(rg,{hasDivider:!0,key:e,start:Yn.createElement(ig,{variant:"circular",width:35,height:35}),title:Yn.createElement(ig,{variant:"text",size:"large",width:90}),end:Yn.createElement(Cb,{checked:!1})})))}i(vl,"LoadingLiquiditySourceList");function wl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=Ib(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=kr(o,n),p={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=c.filter(S=>u.includes(S.type)),h=d.length===d.filter(S=>S.selected).length,f=i(()=>{d.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),g=d.map(S=>{let{selected:k,groupTitle:T,logo:v,id:b,...N}=S;return{id:`widget-setting-liquidity-source-${b.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(wb,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ge.createElement(vb,{checked:k,disabled:l}),title:Ge.createElement(Eb,{variant:"title",size:"xmedium"},zt.t(T)),selected:k,groupTitle:T,logo:v,...N}}),m=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=g;return r&&(C=g.filter(S=>wt(S.groupTitle,r))),Ge.createElement(te,{header:{title:zt.t(t),suffix:Ge.createElement(kl,null,Ge.createElement(Tb,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:f},h?zt.t("Deselect all"):zt.t("Select all")))}},Ge.createElement(ie,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ge.createElement(vl,null),!C.length&&r?Ge.createElement(Tl,null,Ge.createElement(xb,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(Xn,{disabled:l},C.map(S=>{let{groupTitle:k,...T}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(bb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(wl,"LiquiditySourcePage");import{i18n as Ab}from"@lingui/core";import Ni from"react";import{useNavigate as Nb}from"react-router-dom";function ag(){let t=Nb(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=Ai({refetchQuote:n}),p=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Ni.createElement(te,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Ab.t("Routes"),suffix:Ni.createElement(go,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ni.createElement(ie,null,Ni.createElement(Kn,{fetch:l,loading:c,onClickOnQuote:p})))}i(ag,"RoutesPage");import{i18n as mg}from"@lingui/core";import{Divider as fg,getCategoriesCount as Ob,SelectableCategoryList as Ub}from"@rango-dev/ui";import Qt,{useState as gg}from"react";import{useNavigate as zb}from"react-router-dom";import{i18n as bl}from"@lingui/core";import{Divider as Mb,Image as Pb,ListItemButton as _b,NotFound as Db,Typography as dg}from"@rango-dev/ui";import nt,{useEffect as $b,useState as Fb}from"react";var sg=i((t,e,o)=>t.filter(n=>dr(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as Wb,styled as lg}from"@rango-dev/ui";var cg=lg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Wi=lg(bn,{padding:0,margin:0,listStyle:"none",[`& ${Wb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Bb,Skeleton as pg}from"@rango-dev/ui";import Bi from"react";var Lb=20;function ug(){return Bi.createElement(Wi,null,Array.from(Array(Lb),t=>Bi.createElement(Bb,{key:t,hasDivider:!0,start:Bi.createElement(pg,{variant:"circular",width:35,height:35}),title:Bi.createElement(pg,{variant:"text",size:"large",width:90})})))}i(ug,"LoadingBlockchainList");function xl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Fb(e),{fetchStatus:c}=y();$b(()=>{l([...sg(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?nt.createElement(Db,{title:bl.t("No results found"),description:bl.t("Try using different keywords")}):nt.createElement(Wi,{as:"ul",key:`${r}-${o}`},s.map(u=>nt.createElement(_b,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:nt.createElement(Pb,{src:u.logo,size:30}),title:nt.createElement(dg,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(dg,{variant:"label",size:"large"},bl.t("Select Chain")),nt.createElement(Mb,{size:4})),nt.createElement(cg,null,c==="loading"&&nt.createElement(ug,null),c==="success"&&p()))}i(xl,"BlockchainList");function Li(t){let{type:e}=t,o=je(),[n,r]=gg(""),[a,s]=gg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:p}=y(),u=zb(),d=y().blockchains({type:e}),h=Ob(d),f=!t.hideCategory&&h!==1;return Qt.createElement(te,{header:{title:mg.t("Select Chain")}},Qt.createElement(ie,{view:!0},f&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Ub,{setCategory:s,category:a,blockchains:d,isLoading:p==="loading"}),Qt.createElement(fg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:mg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:g=>r(g.target.value)}),Qt.createElement(fg,{size:16}),Qt.createElement(xl,{list:d,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:g=>{e==="custom-token"?u(`..?blockchain=${g.name}`,{replace:!0}):(e==="source"?c(g):l(g),o())}})))}i(Li,"SelectBlockchainPage");import{i18n as Pi}from"@lingui/core";import{Divider as Tg}from"@rango-dev/ui";import wo,{useState as Xb}from"react";import{useNavigate as Yb}from"react-router-dom";import{i18n as Al}from"@lingui/core";import{BlockchainsChip as Mi,Divider as Cg,Image as kg,Skeleton as Vb,Tooltip as Kb,Typography as Nl}from"@rango-dev/ui";import Pe from"react";import{useEffect as qb}from"react";var hg=["ETH","COSMOS","OSMOSIS"];function El(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Qb),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let c=0;c<=l;c++){let p=n[c];s=s.filter(u=>p.name!==u)}}n.sort(Hb(s)),r=n.splice(a)}return{list:n,more:r}}i(El,"prepare");function Qb(t,e){let o=hg,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(Qb,"sortByMostUsedBlockchains");function Hb(t){return i(function(o,n){let r=t.findIndex(c=>c===o.name),a=t.findIndex(c=>c===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(Hb,"generateSortByPreferredBlockchainsFor");function yg(t,e){return!!e.list.find(o=>o.name===t)}i(yg,"isInVisibleList");function Il(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();qb(()=>{if(e?.selected){let a=El(t,o,e);yg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=El(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Il,"usePrepareBlockchainList");import{styled as Gb}from"@rango-dev/ui";var Sg=Gb("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var jb=12;function Wl(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Il(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),p=O.use.resetFromBlockchain(),u=s.more.length>0,d=s.more.length===1,h=!d&&u;return Pe.createElement(Pe.Fragment,null,Pe.createElement(Cg,{size:12}),Pe.createElement(Nl,{variant:"label",size:"large"},Al.t("Select Chain")),Pe.createElement(Cg,{size:12}),Pe.createElement(Sg,null,l==="loading"&&Array.from(Array(jb),f=>Pe.createElement(Vb,{key:f,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Mi,{selected:!n,onClick:()=>{o==="from"?p():c()}},Pe.createElement(Nl,{variant:"body",size:"xsmall",color:"secondary500"},Al.t("All"))),s.list.map(f=>Pe.createElement(Kb,{key:f.name,content:f.shortName,side:"bottom",sideOffset:2,container:I()},Pe.createElement(Mi,{key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},Pe.createElement(kg,{src:f.logo,size:30})))),d?Pe.createElement(Mi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(kg,{src:s.more[0].logo,size:30})):null,h?Pe.createElement(Mi,{onClick:a,key:"more-blockchains"},Pe.createElement(Nl,{variant:"body",size:"xsmall",color:"secondary500"},Al._("More +{count}",{count:s.more.length}))):null)))}i(Wl,"BlockchainsSection");function Bl(t){let{type:e}=t,o=Yb(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:p}=O(),{getBalanceFor:u}=y(),[d,h]=Xb(""),g=(e==="source"?r:a)?.name??"",m=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:g,searchFor:d,getBalanceFor:u}),S=i(v=>{e==="source"?c(v):p(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:m,tokens:C}}):l({token:v,meta:{blockchains:m,tokens:C}})},"updateToken"),T={source:Pi.t("Source"),destination:Pi.t("Destination")};return wo.createElement(te,{header:{title:Pi.t("Swap {type}",{type:T[e]})}},wo.createElement(ie,null,wo.createElement(Wl,{blockchains:m,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{S(v)}}),wo.createElement(Tg,{size:24}),wo.createElement(Ct,{value:d,autoFocus:!0,placeholder:Pi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),wo.createElement(Tg,{size:16}),wo.createElement(zn,{list:C,selectedBlockchain:g,searchedFor:d,type:e,onChange:v=>{k(v);let b=m.find(N=>v.blockchain===N.name);b&&S(b),n()}})))}i(Bl,"SelectSwapItemsPage");import{i18n as Pl}from"@lingui/core";import{Alert as vx,Button as wx,styled as bx}from"@rango-dev/ui";import bo from"react";import{useInRouterContext as xx,useSearchParams as Ex}from"react-router-dom";import{i18n as Ig}from"@lingui/core";import{Divider as Ag,InfoIcon as ex,SlippageIcon as tx,TextField as ox,Tooltip as nx,Typography as Ng}from"@rango-dev/ui";import rt from"react";import{Chip as Zb,styled as Zn,TextField as Jb}from"@rango-dev/ui";var vg=Zn("div",{paddingTop:"$5",padding:"$10 $5"}),wg=Zn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Jb}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),bg=Zn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),_i=Zn("div",{maxWidth:"280px",padding:"$10"}),xg=Zn(Zb,{width:"61px",flexShrink:0});import{i18n as Ll}from"@lingui/core";import{Typography as Rb}from"@rango-dev/ui";import Jn from"react";function Eg(){return Jn.createElement(_i,null,Jn.createElement(Rb,{variant:"label",size:"medium",color:"neutral700"},Ll.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Jn.createElement("br",null),Jn.createElement("br",null),Jn.createElement("b",null,Ll.t("Warning")),":\xA0",Ll.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(Eg,"SlippageTooltipContent");function Ml(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(vg,null,rt.createElement(bg,null,rt.createElement(tx,{size:16,color:"gray"}),rt.createElement(Ag,{direction:"horizontal",size:4}),rt.createElement(Ng,{variant:"title",size:"xmedium"},Ig.t("Slippage tolerance per swap")),rt.createElement(Ag,{direction:"horizontal",size:4}),rt.createElement(nx,{container:I(),side:"top",sideOffset:4,content:rt.createElement(Eg,null)},rt.createElement(ex,{color:"gray"}))),rt.createElement(wg,null,ep.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(xg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(ox,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=rp&&s<=np?n(s):n(null)},suffix:o&&rt.createElement(Ng,{variant:"body",size:"small"},"%"),placeholder:Ig.t("Custom")})))}i(Ml,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as Wg,BridgesIcon as rx,ChevronRightIcon as Di,DarkModeIcon as Bg,Divider as Rn,ExchangeIcon as ix,InfinityIcon as ax,InfoIcon as sx,LanguageIcon as lx,LightModeIcon as Lg,List as cx,ListItem as px,ListItemButton as ux,Skeleton as dx,styled as mx,Switch as fx,Tabs as gx,TargetIcon as hx,Tooltip as yx,Typography as Ye}from"@rango-dev/ui";import _ from"react";import{useNavigate as Sx}from"react-router-dom";var Cx=mx("div",{width:"202px",height:"$40"}),kx=[{id:"light",icon:_.createElement(Lg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:_.createElement(Bg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:_.createElement(Wg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Auto"))}],Tx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return _.createElement(Wg,{...e});case"dark":return _.createElement(Bg,{...e});default:return _.createElement(Lg,{...e})}},"getThemeIcon");function Mg(){let t=Sx(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(W=>W.local===r)?.label,l=y().fetchStatus,c=y().swappers(),p=y().getDisabledLiquiditySources(),{config:{features:u}}=y(),d=y().customTokens(),h=Ve("theme",u),f=Ve("liquiditySource",u),g=Ve("language",u),m=Ve("customTokens",u),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=kr(c,p),T=k.filter(W=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(W.type)),v=T.length,b=T.filter(W=>W.selected).length,N=k.filter(W=>W.type==="DEX"),D=N.length,w=N.filter(W=>W.selected).length,x=i((W,K)=>{switch(l){case"loading":return _.createElement(dx,{variant:"text",size:"medium",width:50});case"failed":return _.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return _.createElement(Ye,{variant:"body",size:"medium"},`${W} / ${K}`)}},"handleSwapperEndItem"),E={id:"widget-setting-bridge-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:_.createElement(_.Fragment,null,x(b,v),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(Di,{color:"black"})),onClick:()=>t($.bridges),start:_.createElement(rx,{color:"gray",size:16})},A={id:"widget-setting-exchange-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:_.createElement(_.Fragment,null,x(w,D),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(Di,{color:"black"})),start:_.createElement(ix,{color:"gray",size:16}),onClick:()=>t($.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},`${d.length}`),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(Di,{color:"black"})),start:_.createElement(hx,{color:"gray",size:16}),onClick:()=>t($.customTokens)},L={id:"widget-setting-language-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Language")),start:_.createElement(lx,{color:"gray",size:16}),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},s),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(Di,{color:"black"})),onClick:()=>t($.languages)},X={id:"widget-setting-infinite-approval-item-btn",title:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),_.createElement(Rn,{direction:"horizontal",size:4}),_.createElement(yx,{side:"top",sideOffset:4,container:I(),content:_.createElement(_i,null,_.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},_.createElement("b",null,dt.t("Warning")),":\xA0",dt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},_.createElement(sx,{color:"gray"}))),start:_.createElement(ax,{color:"gray",size:16}),end:_.createElement(fx,{checked:C}),onClick:S},oe={id:"widget-setting-theme-item-btn",type:_.createElement(px,null),title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Theme")),end:_.createElement(Cx,null,_.createElement(gx,{container:I(),items:kx,value:n,onChange:W=>o(W.id),type:"primary",borderRadius:"small"})),start:Tx(n)},Y=f?[]:[E,A];return m||Y.push(M),g||Y.push(L),Y.push(X),!e?.singleTheme&&!h&&Y.push(oe),_.createElement(cx,{type:_.createElement(ux,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Y})}i(Mg,"SettingsLists");var Ix=bx("div",{paddingLeft:"$8"});function Pg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Ex(),r=xx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return bo.createElement(te,{header:{title:Pl.t("Settings")}},bo.createElement(ie,null,o&&bo.createElement(vx,{type:"info",variant:"alarm",title:Pl.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:bo.createElement(Ix,null,bo.createElement(wx,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Pl.t("Reset")))}),bo.createElement(Ml,null),bo.createElement(Mg,null)))}i(Pg,"SettingsPage");import{i18n as gE}from"@lingui/core";import{cancelSwap as hE}from"@rango-dev/queue-manager-rango-preset";import{useManager as yE}from"@rango-dev/queue-manager-react";import{Alert as SE}from"@rango-dev/ui";import Zl from"react";import{useParams as CE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as Yx,getCurrentStep as Zx,getRelatedWalletOrNull as Jx}from"@rango-dev/queue-manager-rango-preset";import{Button as fh,CopyIcon as Rx,Divider as eE,DoneIcon as tE,IconButton as oE,QuoteCost as nE,RangoExplorerIcon as rE,StepDetails as iE,Tooltip as gh,Typography as xo,useCopyToClipboard as aE}from"@rango-dev/ui";import{useWallets as sE}from"@rango-dev/wallets-react";import hh from"bignumber.js";import{PendingSwapNetworkStatus as qi}from"rango-types";import j,{useEffect as yh,useRef as lE,useState as Sh}from"react";import{useNavigate as cE}from"react-router-dom";import{i18n as eo}from"@lingui/core";var Ax=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function _g(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?eo.t("Today"):`${Ax[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(_g,"timeSince");function Dg(t){return t.finishTime?_g(parseInt(t.finishTime)):_g(parseInt(t.creationTime))}i(Dg,"getSwapDate");import{PendingSwapNetworkStatus as Oi}from"rango-types";import Ui from"react";import{i18n as $i}from"@lingui/core";import{Button as $g,Divider as _l,MessageBox as Nx}from"@rango-dev/ui";import to from"react";var Fg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(_l,{size:20}),to.createElement(Nx,{type:"error",title:$i.t("Cancel Swap"),description:$i.t("Are you sure you want to cancel this swap?")}),to.createElement(_l,{size:32}),to.createElement($g,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},$i.t("Yes, Cancel it")),to.createElement(_l,{size:12}),to.createElement($g,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},$i.t("No, Continue"))),"CancelContent");import{i18n as Fi}from"@lingui/core";import{Button as Og,Divider as Dl,MessageBox as Wx,Typography as Bx}from"@rango-dev/ui";import Ht from"react";var Ug=i(({onDelete:t,onClose:e})=>Ht.createElement(Ht.Fragment,null,Ht.createElement(Dl,{size:20}),Ht.createElement(Wx,{type:"error",title:Fi.t("Delete Transaction"),description:Fi.t("Are you sure you want to delete this swap?")}),Ht.createElement(Dl,{size:32}),Ht.createElement(Og,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Fi.t("Yes, Delete it")),Ht.createElement(Dl,{size:12}),Ht.createElement(Og,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Ht.createElement(Bx,{variant:"title",size:"medium",color:"primary"},Fi.t("No, Cancel")))),"DeleteContent");import{i18n as $l}from"@lingui/core";import{PendingSwapNetworkStatus as Fl}from"rango-types";var Ol={[Fl.WaitingForNetworkChange]:{type:"loading",title:$l.t("Change Network")},[Fl.WaitingForConnectingWallet]:{type:"warning",title:$l.t("Connect Wallet")},[Fl.NetworkChanged]:{type:"success",title:$l.t("Network Changed")}};import{warn as Lx}from"@rango-dev/logging-core";import{MessageBox as Mx,Wallet as Px}from"@rango-dev/ui";import{useWallets as _x}from"@rango-dev/wallets-react";import en,{useState as Dx}from"react";import{styled as Ul}from"@rango-dev/ui";var zg=Ul("div",{display:"flex",justifyContent:"center"}),D5=Ul("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}}),Qg=Ul("img",{width:"100%"});var Hg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=Dx(),{getWalletInfo:p,state:u}=_x(),d=n?.walletType,h=d?pn(u(d)):null,f=d?p(d):null,g=a&&!!d&&!!h&&!!f,{list:m}=ft(),C=i(()=>{if(d){let S=m.find(k=>k.type===d);S?c(S):Lx(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return en.createElement(en.Fragment,null,en.createElement(Mx,{type:e,title:o,description:r}),g&&en.createElement(zg,null,en.createElement(Px,{container:I(),title:f.name,image:f.img,type:d,state:h,link:f.installLink,disabled:s,onClick:C})),en.createElement(po,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function zl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===Oi.WaitingForNetworkChange||e===Oi.WaitingForConnectingWallet||e===Oi.NetworkChanged;return Ui.createElement(J,{open:!!e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},c&&Ui.createElement(Hg,{type:Ol[e].type,title:Ol[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Oi.WaitingForNetworkChange}),e==="delete"&&Ui.createElement(Ug,{onClose:o,onDelete:n}),e==="cancel"&&Ui.createElement(Fg,{onClose:o,onCancel:r}))}i(zl,"SwapDetailsModal");import{i18n as er}from"@lingui/core";import{Button as Ql,Divider as tr,MessageBox as Vg,TokenAmount as $x,Typography as Kg}from"@rango-dev/ui";import fe from"react";import{Link as Fx,useNavigate as Ox}from"react-router-dom";var qg="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",Gg="/profile";function Hl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:p,percentageChange:u,description:d,diagnosisUrl:h}=t,f=Ox(),{showProfileBanner:g}=re();return fe.createElement(J,{open:e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},n==="success"?fe.createElement(Vg,{type:"success",title:er.t("Swap Successful")},fe.createElement($x,{direction:"vertical",tooltipContainer:I(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:p,percentageChange:u}),fe.createElement(tr,{size:12}),fe.createElement(Kg,{variant:"body",size:"medium",color:"neutral700",align:"center"},d)):fe.createElement(Vg,{type:"error",title:er.t("Transaction Failed"),description:d}),fe.createElement(tr,{size:30}),n==="success"&&fe.createElement(fe.Fragment,null,g&&fe.createElement(fe.Fragment,null,fe.createElement(Fx,{to:Gg},fe.createElement(Qg,{src:qg,alt:"Profile Banner"})),fe.createElement(tr,{size:30})),fe.createElement(Ql,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{f("../../")}},er.t("Done"))),fe.createElement(tr,{size:12}),h&&fe.createElement(fe.Fragment,null,fe.createElement(Ql,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},er.t("Diagnosis")),fe.createElement(tr,{size:12})),fe.createElement(Ql,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},fe.createElement(Kg,{variant:"title",size:"medium",color:"primary"},er.t("See Details"))))}i(Hl,"SwapDetailsCompleteModal");import Xx from"react";import{i18n as Gx}from"@lingui/core";import{Alert as ph,IconButton as Vx,LinkIcon as Kx}from"@rango-dev/ui";import oo,{Fragment as jx}from"react";import{Alert as zx,ChevronDownIcon as Qx,IconButton as Hx}from"@rango-dev/ui";import on,{useState as qx}from"react";import{css as or,darkTheme as jg,styled as qt,Typography as Ux}from"@rango-dev/ui";var Xg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),zi=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${jg} &`]:{color:"$secondary500"}}}}}),Yg=qt(bn,{padding:"$0 $20 $20 $20"}),wK=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Zg=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),bK=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),tn=or({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${jg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Jg=or({padding:"$5 0"}),Qi=or({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Rg=or({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),eh=or({width:"100%",padding:"0 $20 $10"}),th=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),oh=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Hi=qt(Ux,{wordBreak:"break-word"});import{styled as ql}from"@rango-dev/ui";var nh=ql("div",{display:"flex",flexDirection:"column",gap:"$10"}),rh=ql("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),ih=ql("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function ah(t){let{message:e}=t,[o,n]=qx(!1);return on.createElement(zx,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&on.createElement(Hx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},on.createElement(rh,{rotated:o},on.createElement(Qx,{size:12,color:"gray"}))),footer:on.createElement(ih,{open:o},on.createElement(Hi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(ah,"FailedAlert");import{i18n as sh}from"@lingui/core";import{Alert as Gl,Button as lh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Vl}from"rango-types";import nr from"react";function ch(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?nr.createElement(Gl,{type:"warning",title:n.shortMessage,action:nr.createElement(lh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Vl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},sh.t("Change"))}):r===Vl.WaitingForConnectingWallet?nr.createElement(Gl,{type:"warning",title:n.shortMessage,action:nr.createElement(lh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Vl.WaitingForConnectingWallet)}},sh.t("Connect"))}):nr.createElement(Gl,{type:"warning",title:n.shortMessage})}i(ch,"WarningAlert");function Kl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=vn(a),c=a.status==="waitingForApproval"&&!l,p=a.status==="running"&&!l,u=p&&!s||c&&!a.explorerUrl?.length;return oo.createElement(nh,null,a.explorerUrl?.map((d,h,f)=>{let g=h+d.url,m=h===f.length-1,C=(m&&p||c)&&!u,S=m&&a.status==="failed";return oo.createElement(jx,{key:g},oo.createElement(ph,{type:m&&(C&&"loading"||S&&"error")||"success",title:d.description?`${d.description} Tx`:Gx.t("View transaction"),action:d.url&&oo.createElement(Vx,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(d.url,"_blank")},oo.createElement(Kx,{size:12}))}))}),u&&oo.createElement(ph,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(ch,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(ah,{message:r}))}i(Kl,"SwapDetailsAlerts");var uh=2e3;var dh=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:st(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:rn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:st(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:st(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:rn(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:Xx.createElement(Kl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function mh(t){if(vn(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(mh,"getStepState");function jl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=sE(),c=y().blockchains(),p=y().swappers(),{findToken:u}=y(),d=O.use.retry(),h=re.use.isActiveTab(),f=cE(),[g,m]=aE(uh),C=lE(null),[S,k]=Sh(null),[T,v]=Sh(null),b=i(()=>{r(),k(null)},"onCancel"),N=be.use.getNotifications(),D=be.use.removeNotification(),w=N(),x=Zx(e),E=x?.networkStatus;yh(()=>{w.find(mt=>mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),D(e.requestId)):T&&v(null))},[e.status,e.requestId]),yh(()=>{W?k(qi.WaitingForNetworkChange):E===qi.WaitingForConnectingWallet||E===qi.NetworkChanged?k(E):k(null)},[E]);let A=fu(e),M=x?Yx(e,x):null,L=x?Jx(e,x):null,X=Dg(e),oe=gu(e),Y=i(ve=>!!l(ve)?.mobileWallet,"isMobileWallet"),W=E===qi.WaitingForNetworkChange&&!!M&&!!L?.walletType&&(Y(L.walletType)||a(L.walletType,M.network)),K=W?s.bind(null,L.walletType,[{namespace:M.namespace,network:M.network}]):void 0,se=mu(e,x),z=dh({swap:e,switchNetwork:K,showNetworkModal:E,setNetworkModal:k,message:se,blockchains:c,swappers:p}),me=z.length,[vt,Ze]=[e.steps[0],e.steps[me-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((ve,mt)=>ve+parseFloat(mt.feeInUsd||""),0),G=e.steps.find(ve=>ve.diagnosisUrl)?.diagnosisUrl,P=B(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),q=B(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),V=le?new hh(le).multipliedBy(Ze.toUsdPrice||0).toString():"",ge=new hh(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(q,P),he=se.detailedMessage.content||se.shortMessage,Fe=e.status==="success"?it.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:B(le,6,6),token:z[me-1].to.token.displayName,conciseAddress:Sr(e.wallets[z[me-1].to.chain.displayName]?.address||""),chain:z[me-1].to.chain.displayName}}):j.createElement(oh,null,j.createElement(xo,{variant:"body",size:"medium",color:"neutral700",align:"center"},he?"":it.t("Transaction was not sent."),A?`${it.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:A.outputAmount,symbol:A.symbol,blockchain:A.blockchain}})}`:""),he&&j.createElement(Hi,{align:"center",variant:"body",size:"medium",color:"neutral700"},j.createElement("b",null,"Reason:")," ",he));return j.createElement(te,{header:{title:it.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&j.createElement(Vt,null,j.createElement(fh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},j.createElement(xo,{size:"medium",variant:"label",color:"error"},it.t("Delete"))))},footer:oe&&!T&&j.createElement(fh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ve=Br(e,c,u);d(ve),setTimeout(()=>{f("../../")},0)}},it.t("Try again"))},j.createElement(ie,{compact:!0,view:!0},j.createElement(zi,null,j.createElement("div",{className:tn()},j.createElement(xo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),j.createElement("div",{className:Qi()},j.createElement(xo,{variant:"label",size:"small",color:"neutral700"},o),j.createElement(gh,{container:I(),content:g?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:g||void 0,side:"bottom",alignOffset:-16,align:"end"},j.createElement(oE,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:m.bind(null,o||"")},g?j.createElement(tE,{size:16,color:"secondary"}):j.createElement(Rx,{size:16,color:"gray"}))),j.createElement(th,{target:"_blank",href:`${Tc}/swap/${o}`},j.createElement(gh,{container:I(),content:it.t("View on Rango Explorer"),side:"bottom"},j.createElement(rE,{size:20}))))),j.createElement("div",{className:tn()},j.createElement(xo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?it.t("Finished at"):it.t("Created at")),j.createElement(xo,{variant:"label",size:"small",color:"neutral700"},X))),j.createElement("div",{className:Rg()},j.createElement(nE,{fee:B(String(at),2,2),time:ln(mr(e.steps)),steps:me}),j.createElement(Ln,{from:{price:{value:B(e.inputAmount,6,6),usdValue:q,realUsdValue:ge,realValue:e.inputAmount},token:{displayName:z[0].from.token.displayName,image:z[0].from.token.image},chain:{image:z[0].from.chain.image,displayName:z[0].from.chain.displayName}},to:{price:{value:B(le,6,6),usdValue:P,realUsdValue:V,realValue:le||""},token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image,displayName:z[me-1].to.chain.displayName}},percentageChange:B(ne,2,2),warningLevel:_t(ne??0)})),j.createElement("div",{className:eh()},j.createElement(xo,{variant:"title",size:"small"},it.t("Swaps steps"))),j.createElement(eE,{size:8}),j.createElement(Yg,{ref:C},z.map((ve,mt)=>{let rc=mt,nn=mh(e.steps[mt]),Vh=nn==="error"||nn==="in-progress"||nn==="warning"||nn==="completed"&&mt===z.length-1;return j.createElement(iE,{key:rc,step:ve,type:"swap-progress",ref:C,state:nn,hasSeparator:mt!==0,tabIndex:rc,isFocused:Vh,tooltipContainer:I()})}))),j.createElement(zl,{state:S,onClose:()=>k(null),onCancel:b,onDelete:n,message:se.detailedMessage.content,currentStepWallet:L,walletButtonDisabled:!h}),j.createElement(Hl,{open:!!T,diagnosisUrl:G,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(le,6,6),usdValue:P,realUsdValue:V,realValue:le||"",percentageChange:B(ne,2,2),token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image},description:Fe}))}i(jl,"SwapDetails");import{i18n as Vi}from"@lingui/core";import{Divider as Th,NotFound as fE,Skeleton as ir,Typography as Ki}from"@rango-dev/ui";import ke from"react";import{i18n as pE}from"@lingui/core";import{Divider as uE,Skeleton as dE,Typography as mE}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Xl}from"@rango-dev/ui";var Ch=Xl("div",{width:"100%",height:"100%",padding:"$10 $20"}),rr=Xl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Gi=Xl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),D4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),$4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),F4=Tt({paddingTop:"$15",display:"flex"}),O4=Tt({padding:"$15 $0"}),U4=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),z4=Tt({paddingBottom:"$10"}),Q4=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),H4=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),q4=Tt({display:"flex",alignItems:"center"}),G4=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),kh=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Yl(){return Te.createElement(Ch,null,Te.createElement(_n,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(mE,{variant:"title",size:"small"},pE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(rr,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:kh()},Te.createElement(uE,{direction:"horizontal",size:20}),Te.createElement(dE,{height:22,variant:"rectangular"}))),Te.createElement(Gi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Gi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Gi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1}))))}i(Yl,"LoadingSwapDetails");function vh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(te,{header:{title:Vi.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Xg,null,ke.createElement(zi,null,ke.createElement("div",{className:tn()},ke.createElement(Ki,{variant:"label",size:"large",color:"neutral700"},`${Vi.t("Request ID")}`),ke.createElement("div",{className:Qi()},ke.createElement(Ki,{variant:"label",size:"small",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})),ke.createElement(Th,{direction:"horizontal",size:4}),ke.createElement(ir,{width:16,height:16,variant:"rectangular"}),ke.createElement(Th,{direction:"horizontal",size:4}),ke.createElement(ir,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:tn()},ke.createElement(Ki,{className:Jg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})),ke.createElement(Ki,{variant:"label",size:"small",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})))),ke.createElement(Yl,null)),!o&&ke.createElement(Zg,null,ke.createElement(fE,{title:Vi.t("Not found"),description:Vi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(vh,"SwapDetailsPlaceholder");function wh(){let{manager:t,state:e}=yE(),o=!e.loadedFromPersistor,n=pt(t),{requestId:r}=CE(),a=je(),{fetchStatus:s}=y();if(!r)return Zl.createElement(SE,{containerStyles:{margin:"20px"},type:"error",title:gE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",c=r?n.find(({swap:h})=>h.requestId===r):void 0,p=i(()=>{if(c?.id){let h=t?.get(c.id);h&&hE(h)}},"onCancel"),u=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),d=c?.swap;return!d||l?Zl.createElement(vh,{requestId:r,showSkeleton:l}):Zl.createElement(jl,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(wh,"SwapDetailsPage");import{i18n as bh}from"@lingui/core";import{Divider as kE,getCategoriesCount as TE,SelectableCategoryList as vE,styled as Eh,Typography as wE,Wallet as bE}from"@rango-dev/ui";import Bt,{useState as xh}from"react";var xE=Eh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),EE=Eh(ie,{textAlign:"center"});function Ih(){let{fetchStatus:t}=y(),[e,o]=xh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=xh(),l=re.use.isActiveTab(),{list:c}=ft(),p=Hc(c,n),d=TE(p)!==1,h=qc(c,e),f=i(g=>{Lc(c,r.multiWallets)||s(g)},"handleWalletItemClick");return Bt.createElement(te,{header:{title:bh.t("Connect Wallets")}},Bt.createElement(EE,null,d&&Bt.createElement(Bt.Fragment,null,Bt.createElement(vE,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Bt.createElement(kE,{size:24})),Bt.createElement(wE,{variant:"title",size:"xmedium",align:"center"},bh.t("Choose a wallet to connect.")),Bt.createElement(xE,null,h.map((g,m)=>{let C=`wallet-${m}-${g.type}`;return Bt.createElement(bE,{key:C,...g,container:I(),onClick:()=>f(g),isLoading:t==="loading",disabled:!l})}),Bt.createElement(po,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Ih,"WalletsPage");function Ah(){return Cu(),Fa(),IE([{path:$.home,element:_e.createElement(tg,null)},{path:$.routes,element:_e.createElement(ag,null)},{path:$.fromSwap,children:[{index:!0,element:_e.createElement(Bl,{type:"source"})},{path:$.blockchains,element:_e.createElement(Li,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:_e.createElement(Bl,{type:"destination"})},{path:$.blockchains,element:_e.createElement(Li,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:_e.createElement(Pg,null)},{path:$.languages,element:_e.createElement(ng,null)},{path:$.exchanges,element:_e.createElement(wl,{sourceType:"Exchanges"})},{path:$.bridges,element:_e.createElement(wl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:_e.createElement(uf,null)},{path:$.addCustomTokens,children:[{index:!0,element:_e.createElement(td,null)},{path:$.blockchains,element:_e.createElement(Li,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:_e.createElement(Bf,null)},{path:$.swapDetails,element:_e.createElement(wh,null)}]},{path:$.wallets,element:_e.createElement(Ih,null)},{path:$.confirmSwap,element:_e.createElement(Ym,null)}])}i(Ah,"AppRoutes");import{useQueueManager as DE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as $E}from"@rango-dev/wallets-shared";import{isEvmBlockchain as FE}from"rango-sdk";import{useContext as OE,useEffect as _h,useState as Dh}from"react";import{globalCss as AE}from"@rango-dev/ui";var Nh=i(()=>AE({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");function Wh(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Mt("BASE_URL")}/meta/dapp/config?apiKey=${Mt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(Wh,"useFetchApiConfig");import{useWallets as NE}from"@rango-dev/wallets-react";import{useEffect as WE,useRef as BE}from"react";function Bh(){let{connect:t,state:e}=NE(),o=BE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);WE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Bh,"useForceAutoConnect");import{isApprovalTX as LE,RouteEventType as Lh,StepEventType as Mh,StepExecutionEventStatus as ME,WidgetEvents as ji}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ph}from"react";function Jl(){let t=be.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Ph(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===Mh.TX_EXECUTION&&a.status===ME.TX_SENT&&!LE(s)||a.type===Mh.SUCCEEDED){let p=l.wallets[s?.fromBlockchain],u=e.find(d=>d.address?.toLocaleLowerCase()===p.address?.toLocaleLowerCase()&&d.walletType===p.walletType&&d.chain===s?.fromBlockchain);if(u&&o([u]),s?.fromBlockchain!==s?.toBlockchain){let d=l.wallets[s?.toBlockchain],h=e.find(f=>f.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&f.walletType===d.walletType&&f.chain===s?.toBlockchain);h&&o([h])}}t(a,l)},"handleStepEvent");return ye.on(ji.StepEvent,n),()=>ye.off(ji.StepEvent,n)},[ye,e]),Ph(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===Lh.FAILED||a.type===Lh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return ye.on(ji.RouteEvent,n),()=>ye.off(ji.RouteEvent,n)},[ye])}i(Jl,"useSubscribeToWidgetEvents");import{useManager as PE}from"@rango-dev/queue-manager-react";import{useEffect as _E}from"react";function Rl(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=PE();_E(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(pt(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Rl,"useSyncNotifications");function ec(){Bh(),Nh(),Jl(),Rl();let t=y().blockchains(),{canSwitchNetworkTo:e}=Zr(),[o,n]=Dh(""),[r,a]=Dh(),s=OE(Ir),l=t.filter(FE),{fetchApiConfig:c}=Wh();_h(()=>()=>Su(),[]),DE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),_h(()=>(ao.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(p=>{a(p),p===$E(o)?.[0]&&n("")}),c().catch(console.log),ao.destroy),[])}i(ec,"useBootstrap");import{styled as UE}from"@rango-dev/ui";var $h=UE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Xi(){ec();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=Rt();return tc.createElement(zE,{language:o},tc.createElement($h,{id:"swap-container",className:e()},tc.createElement(Ah,null)))}i(Xi,"Main");import{setSolanaSignerConfig as sI}from"@rango-dev/signer-solana";import nc,{useEffect as Hh,useMemo as lI}from"react";import{useState as QE}from"react";var HE=i(()=>{let[t,e]=QE(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=Bc(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Fh=HE;import{checkWaitingForNetworkChange as qE,makeQueueDefinition as GE}from"@rango-dev/queue-manager-rango-preset";import{Provider as VE}from"@rango-dev/queue-manager-react";import{useWallets as KE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as jE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as XE}from"rango-types";import YE,{useMemo as ZE}from"react";function JE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=KE(),l=ZE(()=>GE({API_KEY:t.apiKey||Mt("API_KEY"),BASE_URL:Mt("BASE_URL"),emitter:{emit:ye.emit}}),[t.apiKey]),{blockchains:c,connectedWallets:p}=y(),u=c(),d={blockchains:p.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,b)=>a(v,b.network)?await r(v,[b]):void 0,"switchNetwork"),f=i(v=>!!s(v).mobileWallet,"isMobileWallet"),g=u.filter(v=>v.enabled).reduce((v,b)=>(v[b.name]=b,v),{}),m=u.filter(XE),C=i(v=>{let{supportedChains:b}=s(v);return un(b)},"getSupportedChainNames"),S=e(),k={meta:{blockchains:g,evmBasedChains:m,evmNetworkChainInfo:jE(m),getSupportedChainNames:C},getSigners:o,wallets:d,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:f},T=re.use.isActiveTab();return YE.createElement(VE,{queuesDefs:[l],context:k,onPersistedDataLoaded:v=>{qE(v)},isPaused:!T},t.children)}i(JE,"QueueManager");var Oh=JE;import{useManager as nI}from"@rango-dev/queue-manager-react";import rI,{createContext as iI,useContext as aI}from"react";function Uh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:h,toToken:f,requestAmount:g}=p,m={blockchains:e,tokens:o};if(u!==void 0){let C=e.find(S=>S.name===u)??null;n(C)}if(d!==void 0){let C=d?t(d)??null:null;r({meta:m,token:C})}if(h!==void 0){let C=e.find(S=>S.name===h)??null;a(C)}if(f!==void 0){let C=f?t(f)??null:null;s({meta:m,token:C})}g!==void 0&&l(g)},"updateQuoteInputs")}i(Uh,"useUpdateQuoteInputs");import{cancelSwap as RE,getCurrentNamespaceOfOrNull as eI,getCurrentStep as tI,getRelatedWalletOrNull as oI}from"@rango-dev/queue-manager-rango-preset";var Yi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return pt(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=Br(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&RE(o)}getCurrentStepInfo(e){let o=tI(e);return{step:o,wallet:o?oI(e,o):null,network:o?eI(e,o)?.network:null}}};var zh=iI(void 0);function oc(t){let{manager:e}=nI(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new Yi(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=y(),u=$c(a()),d=y().blockchains(),h=y().tokens(),f=y().swappers(),g=y().fetchStatus,m=Rt().resetLanguage,C=be().getNotifications(),S=be().clearNotifications,k=Uh(),{fromBlockchain:T,toBlockchain:v,fromToken:b,toToken:N,inputAmount:D}=O(),w={isActiveTab:o,setCurrentTabAsActive:ao.forceClaim,history:c,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async x=>l(x)},meta:{blockchains:d,tokens:h,swappers:f,loadingStatus:g,findToken:r},resetLanguage:m,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:b?{symbol:b.symbol,blockchain:b.blockchain,address:b.address}:null,toBlockchain:v?.name??null,toToken:N?{symbol:N.symbol,blockchain:N.blockchain,address:N.address}:null,requestAmount:D},updateQuoteInputs:k}};return rI.createElement(zh.Provider,{value:w},t.children)}i(oc,"WidgetInfo");function Qh(){let t=aI(zh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Qh,"useWidget");function Zi(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Fh();return Hh(()=>{n&&r(n)},[n]),lI(()=>{Gc({API_KEY:o?.apiKey||pr,BASE_URL:o?.apiUrl||kc})},[o.apiKey,o.apiUrl]),Hh(()=>{t.config?.signers?.customSolanaRPC&&sI("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),nc.createElement(Ar,{config:o,onUpdateState:e},nc.createElement(Oh,{apiKey:o.apiKey},nc.createElement(oc,null,t.children)))}i(Zi,"WidgetProvider");function qh(t){let e=t.config?.externalWallets;return Ji.createElement(Up,null,e?Ji.createElement(Xi,null):Ji.createElement(Zi,{config:t.config??cr},Ji.createElement(Xi,null)))}i(qh,"Widget");function Gh(){let{on:t,off:e}=ye;return{on:t,off:e}}i(Gh,"useWidgetEvents");var J3={DerivationPath:Sn,Namespaces:yn,isOnDerivationPath:kn,isOnNamespace:Cn};export{b3 as EventSeverity,Lo as MainEvents,P3 as Networks,$3 as PendingSwapNetworkStatus,ma as QuoteEventTypes,x3 as RouteEventType,oa as SUPPORTED_FONTS,J3 as StatefulConnect,E3 as StepEventType,I3 as StepExecutionBlockedEventStatus,A3 as StepExecutionEventStatus,De as UI_ID,ga as UiEventTypes,fa as WalletEventTypes,L3 as WalletEvents,_3 as WalletTypes,qh as Widget,Lo as WidgetEvents,Zi as WidgetProvider,Ar as WidgetWallets,Ya as customizedThemeTokens,W3 as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,Zr as useWallets,Qh as useWidget,Gh as useWidgetEvents,Xy as widgetEventEmitter};
1
+ var Kh=Object.defineProperty;var i=(t,e)=>Kh(t,"name",{value:e,configurable:!0});import{EventSeverity as b3,RouteEventType as x3,StepEventType as E3,StepExecutionBlockedEventStatus as I3,StepExecutionEventStatus as A3}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as W3}from"@rango-dev/wallets-core/legacy";import{useWallets as Jr,Events as L3}from"@rango-dev/wallets-react";import{Networks as P3,WalletTypes as _3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as $3}from"rango-types";import{Divider as QS}from"@rango-dev/ui";import uo,{useEffect as HS,useRef as qS,useState as Mp}from"react";import{WalletState as jh}from"@rango-dev/ui";import{useWallets as Xh}from"@rango-dev/wallets-react";import{useReducer as Yh}from"react";function ic(t){return!!t.derivationPath}i(ic,"isStateOnDerivationPathStep");function ac(t){return!!t.namespace}i(ac,"isStateOnNamespace");var sr={status:"init",namespace:null,derivationPath:null};function sc(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return sr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:sr;default:throw new Error("Action hasn't been defined.")}}i(sc,"reducer");function Vt(){let{state:t,disconnect:e,connect:o}=Xh(),[n,r]=Yh(sc,sr),a=i(async(u,d,h)=>{r({type:"reset"});try{let g=d?.map(f=>({...f,network:void 0}));return await o(u,g),{status:"connected"}}catch(g){let f=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:g})}},"runConnect"),s=i(async(u,d)=>{if(u.state===jh.DISCONNECTED){if(!!u.isHub&&u.properties?.find(C=>C.name==="detached")&&u.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(!u.needsNamespace)return await a(u.type,void 0,d);let f=u.needsNamespace.data.length>1,m=u.needsDerivationPath;if(f)return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(m){let S=u.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:S.value}}),{status:"derivation-path"}}return await a(u.type,u.needsNamespace?.data.map(S=>({namespace:S.value})),d)}return d?.disconnectIfConnected?(await p(u.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(u,d)=>{let h=u.needsNamespace?.selection==="single",g=u.needsDerivationPath,f=d[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&g)return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:f}}),{status:"derivation-path"};if(!ac(n))throw new Error("Something went wrong on handling namespace. Please retry.");let m=n.namespace.targetWallet.type,S=d.map(k=>({namespace:k}));return await a(m,S)},"handleNamespace"),c=i(async u=>{if(!u)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!ic(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=n.derivationPath.providerType,g=[{namespace:n.derivationPath.namespace,derivationPath:u}];return await a(d,g)},"handleDerivationPath"),p=i(async u=>{let d=t(u);return d.connected||d.connecting?(await e(u),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:p,handleNamespace:l,handleDerivationPath:c,getState:()=>n,resetState:u=>{r(u==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Vt,"useStatefulConnect");import{WalletState as Ca}from"@rango-dev/ui";import{useWallets as aS}from"@rango-dev/wallets-react";import{detectMobileScreens as sS,KEPLR_COMPATIBLE_WALLETS as lS,WalletTypes as hn}from"@rango-dev/wallets-shared";import{useCallback as cS,useEffect as pS}from"react";import tS,{createContext as oS,useContext as nS,useEffect as rS,useRef as iS}from"react";import{create as Ry}from"zustand";import{persist as eS}from"zustand/middleware";import{allProviders as Zh}from"@rango-dev/provider-all";var ea=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 ea;import{defineVersions as cc,pickVersion as pc,Provider as ta}from"@rango-dev/wallets-core";function uc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=dc(a);return s instanceof ta?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof ta?o.push(cc().version("1.0.0",n).build()):o.push(cc().version("0.0.0",n).build())}),o}return t}i(uc,"matchAndGenerateProviders");function dc(t){try{return pc(t,"1.0.0")[1]}catch{return pc(t,"0.0.0")[1]}}i(dc,"pickProviderVersionWithFallbackToLegacy");function mc(t){return t.map(o=>dc(o)).map(o=>o instanceof ta?o.id:o.config.type)}i(mc,"configWalletsToWalletName");function lr(t,e){return e.find(o=>o.name===t)?.displayName}i(lr,"getBlockchainDisplayNameFor");function ct(t,e){return e.find(o=>o.name===t)?.shortName}i(ct,"getBlockchainShortNameFor");function fc(t,e){return e.find(o=>o.name===t)?.logo}i(fc,"getBlockchainImage");function an(t,e){return e.find(o=>o.id===t)?.title}i(an,"getSwapperDisplayName");function sn(t,e){return e.find(o=>o.name===t)??null}i(sn,"findBlockchain");function oa(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(oa,"isTokenNative");function pt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(pt,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");function ln(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=pt(c));let p=o.tokensMapByTokenHash.get(c);p&&(n[c]=p)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(c=>{l.has(c)||a(o.tokensMapByBlockchainName[c])})}return s.forEach(l=>{let c=r[l];if(!c&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}c&&(c.isExcluded?(a(o.tokensMapByBlockchainName[l]),c.tokens.forEach(p=>{let u=pt(p);delete n[u]})):a(c.tokens))}),Object.values(n)}i(ln,"matchTokensFromConfigWithMeta");function cr(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(cr,"getSupportedBlockchainsFromConfig");function hc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(hc,"makeProvidersOptionsFromConfig");var pr={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"}},Jh={clientUrl:void 0},Rh={liquiditySources:void 0};function gc(t){let e=hc(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return Zh(o).map(a=>a())}i(gc,"generateProviders");var yc=i((t,e,o)=>{let n=gc({...pr,...t});return{config:{...pr,...t},iframe:Jh,campaignMode:Rh,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l}=o(),c=ln({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),p=ln({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});Ao.set("supportedSourceTokens",c),Ao.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=gc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=hc(a);return uc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Sc}from"rango-types";var Cc=[Sc.EVM,Sc.SOLANA];import{RangoClient as fy}from"rango-sdk";import{UI_ID as ey}from"@rango-dev/ui";var ur="c6381a79-2817-4602-83bf-6a641a409e32",kc="https://api.rango.exchange",Tc="https://explorer.rango.exchange",Fe={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...ey};import{BlockchainCategories as sy,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as ly}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as cy,getCosmosExperimentalChainInfo as py,isEvmAddress as uy,KEPLR_COMPATIBLE_WALLETS as fA,Networks as _c}from"@rango-dev/wallets-shared";import Bo from"bignumber.js";import{isCosmosBlockchain as dy}from"rango-types";import ty from"bignumber.js";var ce=new ty(0);import{WalletTypes as oy}from"@rango-dev/wallets-shared";var io="~",vc=[oy.LEAP];import{BlockchainCategories as ra,WalletState as ay}from"@rango-dev/ui";import{TransactionType as dr}from"rango-sdk";var wc="Roboto",na=[{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 Nc(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Nc,"debounce");function et(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(et,"containsText");function Ec(t,e){return t.toLowerCase()===e.toLowerCase()}i(Ec,"exactText");function Ic(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(Ic,"startWithText");var I=i(()=>document.getElementById(Fe.SWAP_BOX_ID),"getContainer"),ao=i(()=>document.getElementById(Fe.EXPANDED_BOX_ID),"getExpanded");function Ac(t,e,o){let n=!!e&&Ec(e,t),r=!!o&&Ec(o,t);return n!==r?n?-1:1:0}i(Ac,"compareExactMatchText");function ia(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(ia,"compareContainsText");function aa(t,e,o){let n=!!e&&Ic(e,t),r=!!o&&Ic(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(aa,"compareStartWithText");function Wc(t,e,o){if(!o)return 0;let n=Ac(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Ac(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=aa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ia(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=aa(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=ia(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=aa(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=ia(o,t.address,e.address);if(r!==0)return r}return 0}i(Wc,"compareWithSearchFor");var mr=i((t,e)=>{switch(e){case ra.ALL:return!0;case ra.UTXO:return t===dr.TRANSFER;case ra.OTHER:return t!==dr.TRANSFER&&t!==dr.COSMOS&&t!==dr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Bc=i(t=>na.find(o=>o.value===t)?.url,"getFontUrlByName");function Lc(t,e){let o=!!t.find(n=>n.state===ay.CONNECTED);return e===!1&&o}i(Lc,"isSingleWalletActive");function Mc(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(Mc,"memoizedResult");import{BigNumber as Pc}from"bignumber.js";var cn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),B=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Pc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Pc(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var fr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),pn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function un(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(un,"mapStatusToWalletState");function Dc(t,e,o,n){return o.filter(r=>!vc.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:c}=t(r);return s&&(!l||!!n&&c!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:c,needsNamespace:p,supportedChains:u,needsDerivationPath:d,properties:h,isHub:g}=e(r),f=Wo(u.map(S=>S.type)),m=un(t(r));return{title:a,image:s,link:cy(l),state:m,type:r,showOnMobile:c,needsNamespace:p,blockchainTypes:f,needsDerivationPath:d,properties:h,isHub:g}})}i(Dc,"mapWalletTypesToWalletInfo");function dn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(dn,"walletAndSupportedChainsNames");function la(t,e,o,n,r){let a=[];function s(c,p,u){if(!!!a.find(h=>h.chain===c)){let h={address:p,chain:c,walletType:t,isContractWallet:u??!1};a.push(h)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:p,network:u}=ly(c),d=l.length>0,h=l.includes(u),g=u===_c.Unknown;if(d&&!h&&!g)return;let m=u===_c.Unknown&&uy(p);if(g&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase(),r):l.filter(C=>o.includes(C)).forEach(C=>{s(C,p.toLowerCase())}):s(u,p)}),a}i(la,"prepareAccountsForWalletStore");function so(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:c}=r;c.forEach((p,u)=>{let d=p.from.blockchain,h=p.to.blockchain,g=a===o.swaps.length-1,f=u===c.length-1;(!g&&!f||g&&l!==d||e==="all")&&n.add(d),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(so,"getQuoteWallets");function mn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(mn,"isAccountAndWalletMatched");var $c=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?sa(n.usdValue,n.decimals):ce.toFixed();return o.plus(r)},new Bo(ce));return my(e.toString())},"calculateWalletUsdValue");function my(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(my,"numberWithThousandSeparator");var yr=i((t,e)=>{let o=py(Object.entries(t).map(([,n])=>n).filter(dy));return o&&o[e]?.experimental},"isExperimentalChain");function sa(t,e){return new Bo(t).shiftedBy(-e).toFixed()}i(sa,"representAmountInNumber");function Sr(t){if(!t)return null;let e=sa(t.amount,t.decimals),o=t.usdValue?sa(t.usdValue,t.decimals):null,n=B(e,8,8),r=o?B(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(Sr,"formatBalance");function Fc(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new Bo(t.usdValue).shiftedBy(-t.decimals):ce,n=e&&e.usdValue?new Bo(e.usdValue).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new Bo(t.amount).shiftedBy(-t.decimals):ce,n=e&&e.amount?new Bo(e.amount).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Fc,"compareTokenBalance");function Lt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Lt,"areTokensEqual");function Oc(t){return t.sort((e,o)=>+(o.state===bt.CONNECTED)-+(e.state===bt.CONNECTED)||+(o.state===bt.DISCONNECTED||o.state===bt.CONNECTING)-+(e.state===bt.DISCONNECTED||e.state===bt.CONNECTING))}i(Oc,"sortWalletsBasedOnConnectionState");function Cr(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(Cr,"getConciseAddress");function Uc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Uc,"getAddress");var zc=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Qc(t){return t.map(e=>e.state).join("-")}i(Qc,"hashWalletsState");function Hc(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Hc,"filterBlockchainsByWalletTypes");function qc(t,e){return e===sy.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(mr(n,e))return!0;return!1})}i(qc,"filterWalletsByCategory");var ca={API_KEY:ur};function Mt(t){return ca[t]||""}i(Mt,"getConfig");function Gc(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ca=e,ca}i(Gc,"initConfig");var Vc=20,Kc=25,pa="theme-widget",ua=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Lt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Lt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),da=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),jc=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var kr,xt=i(()=>kr||(kr=new fy(Mt("API_KEY"),Mt("BASE_URL")),kr),"httpService");function Tr(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(c=>c===s.swapperGroup)),l&&s.types.map(c=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:c,selected:!e.includes(s.swapperGroup)})})}}),n}i(Tr,"getUniqueSwappersGroups");function Xc(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Xc,"sortLiquiditySourcesByGroupTitle");function Xe(t,e){return e?.[t]==="hidden"}i(Xe,"isFeatureHidden");function Lo(t,e){return e?.[t]==="enabled"}i(Lo,"isRoutingEnabled");var Yc=i((t,e,o)=>Xe("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Zc=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let c=cr({config:a}),p=r;return c.length>0&&(p=p.filter(u=>c.includes(u.name))),p.filter(u=>Cc.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(c=>!(s.length>0&&!s.includes(c.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),c=e()._blockchainsMapByName;if(!o||!o.type)return l;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=Ao.get(u);d?.length||(d=ln({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Ao.set(u,d)),d=Yc(d,s,a.features);let h=e().blockchains({type:o.type});return d.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!h.some(m=>m.name===f.blockchain)?!1:o.searchFor?!!(et(f.symbol,o.searchFor)||et(f.address||"",o.searchFor)||et(f.name||"",o.searchFor)):!0).sort((f,m)=>{let S=e().isTokenPinned(f,o.type),k=e().isTokenPinned(m,o.type);if(S!==k)return S?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(f),_=o.getBalanceFor(m),w=Fc(A,_);if(w!==0)return w}let C=c.get(f.blockchain),T=c.get(m.blockchain),v=oa(f,C),b=oa(m,T);if(v!==b)return v?-1:1;if(f.isPopular!==m.isPopular)return f.isPopular?-1:1;if(o.searchFor){let A=Wc(f,m,o.searchFor);if(A)return A}return f.isSecondaryCoin!==m.isSecondaryCoin?f.isSecondaryCoin?1:-1:C&&T?C.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=pt(o),s=n.get(a);return s||(s=r.find(l=>pt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Lt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort(Xc)},fetch:async()=>{try{let{routing:o}=e().config,n=Lo("enableCentralizedSwappers",o),r=await xt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],p=r.popularTokens,u=r.swappers.filter(g=>g.enabled),d=new Set;r.tokens.forEach(g=>{d.add(g.blockchain),c.push(g)}),r.blockchains.sort((g,f)=>g.sort-f.sort).forEach(g=>{g.enabled&&d.has(g.name)&&a.set(g.name,g)}),c.forEach(g=>{let f=pt(g);l[g.blockchain]||(l[g.blockchain]=[]),s.set(f,g),l[g.blockchain].push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as gy,Catalonia as hy,Chinese as Jc,Denmark as yy,English as Sy,Finland as Cy,French as ky,German as Ty,Greece as vy,Hungary as wy,India as by,Indonesian as xy,Italian as Ey,Japanese as Iy,Korea as Ay,Lithuania as Ny,Malay as Wy,Netherlands as By,Pakistan as Ly,Philippines as My,Poland as Py,Portuguese as _y,Russian as Dy,SaudiArabia as $y,Serbia as Fy,Slovakia as Oy,SouthAfrica as Uy,Spanish as zy,Swahili as Qy,Swedish as Hy,Thai as qy,Turkish as Gy,Ukrainian as Vy,Vietnamese as Ky}from"@rango-dev/ui";var Rc=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:Uy},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:$y},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:gy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:hy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Jc},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Jc},{title:"Danish",label:"Dansk",local:"da",SVGFlag:yy},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:By},{title:"English",label:"English",local:"en",SVGFlag:Sy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:My},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:Cy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ky},{title:"German",label:"Deutsch",local:"de",SVGFlag:Ty},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:vy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:by},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:wy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:xy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:Ey},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Iy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:Ay},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:Ny},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Wy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Py},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:_y},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Dy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Fy},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Oy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:zy},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Qy},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Hy},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:qy},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Gy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Vy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:Ly},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Ky}],Mo="en";var ep=[.5,1,3],tp=1,op=5,np=100,rp=0;var ip=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:tp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let c=s===o,p=l<=9;return c&&p}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=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=Xe("theme",n),s=Xe("language",n),l=Xe("liquiditySource",n),c=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...c&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Mo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{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=cr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import Sa from"bignumber.js";import jy from"mitt";var he=jy(),Xy={on:he.on,off:he.off};import{WidgetEvents as ap}from"@rango-dev/queue-manager-rango-preset";var fa=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(fa||{}),ga=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ga||{}),ha=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ha||{}),Po=(a=>(a[a.RouteEvent=ap.RouteEvent]="RouteEvent",a[a.StepEvent=ap.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Po||{});var sp=i(t=>(e,o,n)=>t(i((...a)=>{e(s=>({...s,lastUpdatedAt:+new Date})),e(...a)},"modifedSet"),o,n),"keepLastUpdated");import Yy from"bignumber.js";function fn(t){return`${t.blockchain}${io}${t.address}${io}${t.symbol}`}i(fn,"createAssetKey");function ya(t,e){return`${fn(e)}${io}${t}`}i(ya,"createBalanceKey");function gn(t){let[e,o,n]=t.split(io);return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(gn,"extractAssetFromBalanceKey");function lp(t,e){let o={};return t.balances?.forEach(n=>{let r=ya(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,c=l?new Yy(l??ce).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:c};o[r]=p}),o}i(lp,"createBalanceStateForNewAccount");function cp(t,e){for(let o in e){let n=gn(o),r=fn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(cp,"updateAggregatedBalanceStateForNewAccount");function pp(t,e){let o=gn(e),n=fn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(pp,"removeBalanceFromAggregatedBalance");function Zy(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(Zy,"matchWalletDetailsWithConnectedWallet");var Jy=Mc(),up=sp((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>mn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>mn(s,a))?{...a,loading:!1,error:!1,explorerUrl:Zy(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>mn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>mn(s,l)));if(a.length>0){let s=a.map(l=>{let c=!r.some(p=>p.chain===l.chain&&p.selected&&p.walletType!==l.walletType);return{address:l.address,chain:l.chain,isContractWallet:l.isContractWallet,explorerUrl:null,walletType:l.walletType,selected:c,namespace:n,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(p=>!s.some(u=>u.walletType===p.walletType&&u.chain===p.chain)),...s]}))}},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n)=>{he.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o,n),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(p=>p.walletType===o);e().connectedWallets.forEach(p=>{p.walletType!==o&&(r=r.filter(u=>!(u.chain===p.chain&&u.address===p.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(p=>n.chains?.includes(p.chain))),n?.namespaces&&n.namespaces.length>0&&(r=r.filter(p=>p.namespace?n.namespaces?.includes(p.namespace):!1));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(p=>{let u=gn(p);!!r.find(h=>ya(h.address,{address:u.address,blockchain:h.chain,symbol:u.symbol})===p)?s=pp(s,p):a[p]=l[p]}),t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(he.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(l=>a.includes(l.chain)?(a=a.filter(c=>c!==l.chain),{...l,selected:!0}):l);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(c=>({address:c.address,blockchain:c.chain})),s;try{s=await xt().getWalletsDetails(a)}catch(c){throw e().setConnectedWalletHasError(o),new Error("Request for fetching balances failed.",{cause:c})}let l=s.wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let d=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));d.length>0&&e().fetchBalances(d,{retryOnFailedBalances:!1})}let p={},u=e()._aggregatedBalances;l.forEach(d=>{if(d.failed||(e().removeBalancesForWallet(r,{chains:[d.blockChain]}),!e().connectedWallets.find(g=>g.walletType===r&&g.address===d.address&&g.chain===d.blockChain)))return;let h=lp(d,e);u=cp(u,h),p={...p,...h}}),t(d=>({_balances:{...d._balances,...p},_aggregatedBalances:u})),e().setConnectedWalletRetrievedData(o,l)}else throw e().setConnectedWalletHasError(o),new Error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=fn(o),a=e()._aggregatedBalances[r]||[];if(a.length===0)return null;if(a.length===1){let c=a[0];return n[c]}let l=n[a[0]];return a.forEach(c=>{let p=n[c],u=new Sa(p.amount),d=new Sa(l.amount);u.isGreaterThan(d)&&(l=p)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,p]=l.split(io);return p===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>Jy(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,l)=>{let c=r[l],p=gn(l);if(p.blockchain===n.chain){let u=e().findToken(p),d=c.amount?new Sa(c.amount).shiftedBy(-c.decimals):ce;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:c.amount,decimal:c.decimals,amount:d.toString(),logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function dp(t){return Ry()(eS((...e)=>({...up(...e),...Zc(...e),...ip(...e),...yc(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(dp,"createAppStore");var mp=oS(null);function y(){let t=nS(mp);if(rS(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function fp(t){let e=iS();return e.current||(e.current=dp(t.config)),tS.createElement(mp.Provider,{value:e.current},t.children)}i(fp,"AppStoreProvider");function gt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=aS(),s=y().blockchains(),{handleDisconnect:l}=Vt(),c=mc(n()),p=Dc(r,a,c,e);p=sS()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Oc(p),d=i(m=>!o.find(S=>S.walletType===m&&S.chain===e),"isExperimentalChainNotAdded"),h=cS(()=>{let m=p?.filter(S=>S.state===Ca.CONNECTING)||[];for(let S of m)l(S.type)},[Qc(p)]);pS(()=>()=>{h()},[]);let g=i(m=>{let S=m.find(C=>C.type===hn.DEFAULT);return!S||S.state===Ca.NOT_INSTALLED?!1:m.filter(C=>C.state!=Ca.NOT_INSTALLED&&![hn.DEFAULT,hn.WALLET_CONNECT_2,hn.LEDGER].includes(C.type)&&a(C.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((m,S,k)=>yr(k,S)&&d(m)&&!lS.includes(m)||m==hn.DEFAULT&&!g(p),"shouldExcludeWallet");return{list:u.filter(m=>!f(m.type,e??"",s)),terminateConnectingWallets:h}}i(gt,"useWalletList");import{Modal as fS}from"@rango-dev/ui";import gS from"react";import{create as mS}from"zustand";var gp="rango-widget";var yn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(gp),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var dS=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),_o=dS;var re=_o(mS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})},setShowProfileBanner:o=>{t({showProfileBanner:o})}}))),lo=new yn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function J(t){let{watermark:e}=re();return gS.createElement(fS,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as ka}from"@lingui/core";import{Button as TS,Checkbox as vS,Divider as wS,Image as xp,ListItemButton as bS,MessageBox as xS,Radio as ES,RadioRoot as IS}from"@rango-dev/ui";import ve,{useState as AS}from"react";import{css as hS,darkTheme as yp,IconButton as yS,styled as co}from"@rango-dev/ui";var Et=co(yS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${yp} &`]:{backgroundColor:"$neutral"}}}),Sp=co("div",{position:"absolute",background:"$secondary500",[`.${yp} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Kt=co("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Cp=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"}}}}),kp=co("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Tp=co("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),vp=hS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),vr=co("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as SS,styled as wr}from"@rango-dev/ui";var wN=wr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Do=wr("div",{position:"relative"}),CS=SS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),$o=wr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${CS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),br=wr("div",{"& img":{borderRadius:"50%"}});function wp(t,e){return t.find(o=>o.name===e)?.logo}i(wp,"getBlockchainLogo");import{styled as kS}from"@rango-dev/ui";var bp=kS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function Sn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=AS([]),s=y().blockchains(),l=i(p=>{a(o?[p]:u=>u.includes(p)?u.filter(d=>d!==p):u.concat(p))},"onSelect"),c=i(p=>o?ve.createElement(IS,{value:r?.[0]},p):ve.createElement(ve.Fragment,null,p),"wrapRadioRoot");return ve.createElement(ve.Fragment,null,ve.createElement(wS,{size:20}),ve.createElement(xS,{type:"info",title:ka.t("Select chain types"),description:ka.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:ve.createElement(Do,null,ve.createElement(vr,null,ve.createElement(xp,{src:n,size:45})),ve.createElement($o,null))}),ve.createElement(bp,null,c(ve.createElement(ve.Fragment,null,e.needsNamespace?.data.map(p=>ve.createElement(bS,{key:p.id,id:p.id,title:p.label,hasDivider:!0,style:{height:60},onClick:()=>l(p.value),start:ve.createElement(xp,{src:wp(s,p.id),size:22}),end:o?ve.createElement(ES,{value:p.value}):ve.createElement(vS,{checked:r.includes(p.value)})}))))),ve.createElement(TS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},ka.t("Confirm")))}i(Sn,"Namespaces");import{i18n as Fo}from"@lingui/core";import{Button as BS,Divider as Ap,Image as LS,MessageBox as MS,Select as PS,TextField as _S}from"@rango-dev/ui";import Ue,{useEffect as DS,useState as Np}from"react";import{namespaces as NS}from"@rango-dev/wallets-shared";var xr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ta(t){let e=t?NS[t].derivationPaths:null;return e?[...e,xr]:[]}i(Ta,"getDerivationPaths");import{styled as Ep,Typography as WS}from"@rango-dev/ui";var Ip=Ep("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),va=Ep(WS,{paddingLeft:"$10"}),wa={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Wp="0";function Cn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Np(null),[l,c]=Np(Wp),p=a===xr.id,u=Ta(o),d=i(({value:g})=>{let f=u?.find(m=>m.id===g);f&&(a===xr.id&&Number.isNaN(Number(l))&&c(Wp),s(f.id))},"handleDerivationPathItemClick"),h=i(()=>{let g=u.find(f=>f.id===a);if(g)e(g.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return DS(()=>{s(Ta(o)[0]?.id||null)},[o]),Ue.createElement(Ue.Fragment,null,Ue.createElement(Ap,{size:20}),Ue.createElement(MS,{type:"info",title:Fo.t("Select Derivation Path"),description:Fo.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Ue.createElement(Do,null,Ue.createElement(br,null,Ue.createElement(LS,{src:n,size:45})),Ue.createElement($o,null))}),Ue.createElement(Ip,null,Ue.createElement(va,{variant:"body",size:"xsmall",color:"$neutral600"},Fo.t("Choose Derivation Path Template")),Ue.createElement(PS,{value:a||"",options:u.map(g=>({value:g.id,label:g.label})),variant:"filled",handleItemClick:d,styles:{trigger:wa}}),Ue.createElement(Ap,{size:20}),Ue.createElement(va,{variant:"body",size:"xsmall",color:"$neutral600"},p?Fo.t("Enter Path"):Fo.t("Enter Index")),Ue.createElement(_S,{type:p?"text":"number",variant:"contained",value:l,onChange:g=>c(g.target.value),style:wa})),Ue.createElement(BS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!u||!a||!l},Fo.t("Confirm")))}i(Cn,"DerivationPath");import{i18n as Oo}from"@lingui/core";import{Image as $S,MessageBox as ba,WalletState as FS}from"@rango-dev/ui";import{useWallets as OS}from"@rango-dev/wallets-react";import po from"react";function xa(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=OS();return un(a(n))===FS.CONNECTED?po.createElement(ba,{type:"success",title:Oo.t("Wallet Connected"),description:Oo.t("Your wallet is connected, you can use it to swap.")}):o?po.createElement(ba,{type:"error",title:Oo.t("Failed to Connect"),description:o||Oo.t("Your wallet is not connected. Please try again.")}):po.createElement(ba,{type:"loading",title:Oo.t("Connecting to your wallet"),description:Oo.t("Click connect in your wallet popup."),icon:po.createElement(Do,null,po.createElement(br,null,po.createElement($S,{src:r,size:45})),po.createElement($o,null))})}i(xa,"ConnectStatus");import{i18n as Ea}from"@lingui/core";import{Button as US,Divider as Bp,MessageBox as zS}from"@rango-dev/ui";import Er from"react";function Ia(t){let{displayName:e,onConfirm:o}=t;return Er.createElement(zS,{title:Ea.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Ea.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Er.createElement(Bp,{size:18}),Er.createElement(Bp,{size:32}),Er.createElement(US,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Ea.t("Confirm")))}i(Ia,"ExperimentalChain");function Lp(t,e){return t().status==="init"&&!!e}i(Lp,"isOnStatus");function kn(t){return t().status==="namespace"}i(kn,"isOnNamespace");function Tn(t){return t().status==="derivationPath"}i(Tn,"isOnDerivationPath");var GS=3e3,VS=300;function mo(t){let e=qS(),[o,n]=Mp(!1),[r,a]=Mp(),s=i(C=>{a(C.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=gt(),{handleConnect:c,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:h}=Vt(),g=i(C=>{u(t.wallet,C).then(k).catch(s)},"handleConfirmNamespaces"),f=i(C=>{if(!C)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(C).then(k).catch(s)},"handleDerivationPathConfirm"),m=i(()=>{n(!1)},"handleClosingModal"),S=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),k=i((C,T)=>{let v=C.status==="connected",b=["disconnected","disconnected-unhandled"].includes(C.status);v?(t.onConnect?.(),T||(e.current=setTimeout(m,GS))):b&&m()},"afterConnected");return HS(()=>{if(t.wallet){S();let C=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,C||n(!0)},VS)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(b=>{["namespace","derivation-path"].includes(b.status)||(C=!0),k(b,T)}).catch(s)}},[t.wallet]),uo.createElement(J,{open:o,onClose:m,onExit:()=>{S(),l(),t.onClose&&t.onClose()},container:I()},Lp(d,t.wallet)&&uo.createElement(uo.Fragment,null,uo.createElement(xa,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),uo.createElement(QS,{direction:"vertical",size:32})),kn(d)&&uo.createElement(Sn,{onConfirm:g,value:d().namespace}),Tn(d)&&uo.createElement(Cn,{onConfirm:f,value:d().derivationPath}))}i(mo,"StatefulConnectModal");import{Provider as ZS}from"@rango-dev/wallets-react";import Ir,{createContext as JS,useEffect as Fp,useMemo as RS,useRef as Op}from"react";import{useEffect as KS}from"react";function Pp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Pp,"hashProviders");function Aa(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return KS(()=>{o(),r()},[Pp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Aa,"useWalletProviders");import{legacyFormatAddressWithNetwork as jS,legacyReadAccountAddress as _p}from"@rango-dev/wallets-core/legacy";import{Events as fo}from"@rango-dev/wallets-react";import{isEvmBlockchain as XS}from"rango-sdk";function Dp(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=y(),{onConnectWalletHandler:l,onDisconnectWalletHandler:c}=t,p=s().filter(XS).map(m=>m.name),u=i((m,S)=>{let[k,,C,,T]=m,v=la(k,C,p,S.supportedChainNames,T.isContractWallet);v.length&&e(v,T.namespace)},"onAccountsEvent"),d=i((m,S,k,C,T)=>{if(S===fo.ACCOUNTS){let v=dn(T.supportedBlockchains);k&&u([m,S,k,C,T],{supportedChainNames:v})}if(S===fo.CONNECTED){let v=`${m}-${C.network}-${k}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}S===fo.PROVIDER_DISCONNECTED&&(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),S===fo.NAMESPACE_DISCONNECTED&&n(m,k)},"handleUpdatesForHub"),h=i((m,S,k,C,T)=>{if(S===fo.ACCOUNTS){let v=dn(T.supportedBlockchains),b=[],A=[];if(k?.forEach(w=>{let{network:x}=_p(w);p.includes(x)?b.push(w):A.push(w)}),r.filter(w=>w.walletType===m).map(w=>jS(w.address,w.chain)).length>0){if(b.length>0){let w=la(m,b,p,v,T.isContractWallet);a(m,{chains:w.map(x=>x.chain)})}A.length>0&&a(m,{chains:A.map(w=>{let{network:x}=_p(w);return x})})}k?u([m,S,k,C,T],{supportedChainNames:v}):(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}if(S===fo.ACCOUNTS&&C.connected){let v=`${m}-${C.network}-${k}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForLegacy"),g=i((m,S,k,C,T)=>{if(S===fo.NETWORK&&C.network){let v=`${m}-${C.network}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,S,k,C,T)=>{T.isHub?d(m,S,k,C,T):h(m,S,k,C,T),g(m,S,k,C,T)},"handler")}}i(Dp,"useUpdates");import{LegacyEvents as YS}from"@rango-dev/wallets-core/legacy";function $p(t,e){let[o,n,r,a,s]=e;n!==YS.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i($p,"propagateEvents");var Ar=JS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function eC(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),s=y().config,l={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:c}=Aa(s.wallets,l),p=Op(),u=Op(),{handler:d}=Dp({onConnectWalletHandler:p,onDisconnectWalletHandler:u});Fp(()=>{n().catch(console.log)},[]),Fp(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let h=re.use.isActiveTab(),g=RS(()=>({onConnectWallet:f=>{p.current=f},onDisconnectWallet:f=>{u.current=f}}),[]);return Ir.createElement(Ar.Provider,{value:g},Ir.createElement(ZS,{allBlockChains:a,providers:c,onUpdateState:(f,m,S,k,C)=>{let T=[f,m,S,k,C];d(...T),t.onUpdateState&&$p(t.onUpdateState,T)},autoConnect:!!h,configs:{wallets:s.wallets}},t.children))}i(eC,"Main");function Nr(t){let{config:e,...o}=t;return Ir.createElement(fp,{config:e},Ir.createElement(eC,{...o,config:e}))}i(Nr,"WidgetWallets");import Ri from"react";import tC,{Fragment as oC}from"react";import{MemoryRouter as nC,useInRouterContext as rC}from"react-router";function Up({children:t}){let o=rC()?oC:nC;return tC.createElement(o,null,t)}i(Up,"AppRouter");import{I18nManager as zE}from"@rango-dev/ui";import oc from"react";import _e from"react";import{useRoutes as IE}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as zo,useRef as Fr}from"react";import Ye from"bignumber.js";import{create as sC}from"zustand";import{subscribeWithSelector as lC}from"zustand/middleware";import{i18n as ht}from"@lingui/core";import{RouteEventType as FB}from"@rango-dev/queue-manager-rango-preset";import ze from"bignumber.js";import{PendingSwapNetworkStatus as Dr}from"rango-types";import{i18n as Oe}from"@lingui/core";var ee=i(()=>({genericServerError:Oe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Oe.t("Please reset your liquidity sources."),description:Oe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Oe.t("No Routes Found."),description:Oe.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:Oe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Oe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Oe.t("High Price Impact"),title:Oe.t("Price impact is too high!"),description:Oe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Oe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Oe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Oe.t("USD Price Unknown"),title:Oe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Oe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Oe.t("Confirm USD Price Unknown")}}),"errorMessages");function zp(t){switch(t.type){case 0:return t.diagnosisMessage??ee().noResultError.title;case 1:return ee().genericServerError;default:return""}}i(zp,"getQuoteErrorMessage");import{i18n as Wr}from"@lingui/core";var go=i(()=>({connectWallet:Wr.t("Connect Wallet"),swap:Wr.t("Swap"),swapAnyway:Wr.t("Swap anyway"),ethWarning:Wr.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");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"],Qp=100,Hp=30,qp=15,Gp=60;var Vp=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Kp=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as aC}from"@rango-dev/queue-manager-rango-preset";import bB from"bignumber.js";function Xp(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(Xp,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Lr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=aC(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=sn(a?a.toBlockchain:n.fromBlockchain,e),c=sn(r.toBlockchain,e),p=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:p,toBlockchain:c,toToken:u,inputAmount:d}}i(Lr,"createRetryQuote");function Uo(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=vn(o),s=ut(o);if(o&&a&&s){let p=Pt(a.toString(),s.toString());if(!!p&&eu(a,p)){let d=Pr(o?.swaps,n),h=_t(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:h}}}if(e&&nu(e,o))return{type:4,usdValueChange:B(ut(o)?.minus(ut(e)??0).toString()??"0",null,2),percentageChange:B(Pt(ut(e)??"1",ut(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=_r(o.swaps),c=r>op;if(ou(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:tu(o,r),minRequiredSlippage:l};return null}i(Uo,"generateQuoteWarnings");function Yp(t){return![4].includes(t.type)}i(Yp,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Ba(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Zp=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Mr=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),c=n.requestId.toLowerCase();return l.localeCompare(c)}),"sortQuotesBy"),Jp=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,validationStatus:null,...e[0]};let n=new Set(t.swaps.map(a=>a.swapperId)),r=e.find(a=>{let s=new Set(a.swaps.map(l=>l.swapperId));return Array.from(n).every(l=>s.has(l))});return{requestAmount:o,validationStatus:null,...r||e[0]}},"getDefaultQuote"),Rp=i(t=>{let e=i((o,n)=>{let r=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");function eu(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Vp.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new ze(r)))}i(eu,"hasHighValueLoss");function ru(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new ze(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new ze(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(ru,"hasLimitError");function iu(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new ze(l.fromAmountMinValue):null,p=l.fromAmountMaxValue?new ze(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?c?.gte(l.fromAmount)||p?.lte(l.fromAmount):c?.gt(l.fromAmount)||p?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new ze(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new ze(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=ee().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=ee().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=ee().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=ee().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(iu,"getLimitErrorMessage");function au(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=t;return e!=="success"?{title: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}:c?{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(au,"getSwapButtonState");function La(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ce))&&e&&e!=="0"&&n!==0)}i(La,"canComputePriceImpact");function Ma(t,e){let o=ce;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new ze(r.amount).multipliedBy(a||0))}return o}i(Ma,"getUsdFeeOfStep");function Pr(t,e){return t.reduce((o,n)=>o.plus(Ma(n,e)),ce)}i(Pr,"getTotalFeeInUsd");function Pa(t){let e=ce;return e=e.plus(new ze(t.amount).multipliedBy(t.price||0)),e}i(Pa,"getUsdFee");function su(t){return t.reduce((e,o)=>e.plus(Pa(o)),ce)}i(su,"getTotalFeesInUsd");function lu(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(lu,"getFeesGroup");function cu(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?e:null}i(cu,"checkSlippageErrors");function tu(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?o:null}i(tu,"checkSlippageWarnings");function _r(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(_r,"getMinRequiredSlippage");function ou(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(ou,"hasProperSlippage");function pu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:h,destination:g,contractCall:f}=t,m=a?.reduce((C,T)=>(C[T.chain]=T.address,C),{}),S=[];return r?.forEach(C=>{S.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:d??void 0,affiliateWallets:h??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:S,selectedWallets:m??{},slippage:p.toString(),contractCall:f,...g&&{destination:g},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1}}}i(pu,"createQuoteRequestBody");function uu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(uu,"getWalletsForNewSwap");function vn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new ze(e).multipliedBy(o)}i(vn,"getUsdInputFrom");function ut(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new ze(e).multipliedBy(o)}i(ut,"getUsdOutputFrom");function Ba(t,e){return new ze(e).div(new ze(t)).minus(1).multipliedBy(Qp).toNumber()}i(Ba,"getPercentageChange");function nu(t,e){let o=vn(t),n=ut(t),r=ut(e);if(!o||!n||!r)return!1;let a=Ba(n.toString(),r.toString());return Kp.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(nu,"isOutputAmountChangedExcessively");function du(t,e,o){let n=t.validationStatus,r=so({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>Xp(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=B(new ze(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=B(new ze(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=ht.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=ht.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=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:p,symbol:l,reason:u,currentAmount:c,blockchain:ct(s.asset.blockchain,o)}})})}i(du,"generateBalanceWarnings");function wn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Dr.NetworkChanged}i(wn,"isNetworkStatusInWarningState");function mu(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),wn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Dr.WaitingForConnectingWallet:n=n||ht.t("Waiting for connecting wallet");break;case Dr.WaitingForQueue:n=n||ht.t("Waiting for other running tasks to be finished");break;case Dr.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(mu,"getSwapMessages");function fu(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(fu,"getLastConvertedTokenInFailedSwap");function gu(t){return t.status==="failed"}i(gu,"shouldRetrySwap");function hu(t,e,o,n,r,a){if(!n||t)return!0;let s=so({filter:"all",quote:n}),l=so({filter:"required",quote:n}),c=s.every(d=>r.some(h=>h.chain===d)),p=l.every(d=>r.some(h=>h.chain===d)),u=o&&a?No(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!u||!p)}i(hu,"isConfirmSwapDisabled");function yu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(yu,"isTokensIdentical");var $r=i((t,e)=>t?.usdPrice?new Ye(e||ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=_o(sC()(lC(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ye(0),outputUsdValue:new Ye(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=ce,a=o.inputUsdValue;return pn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ye(e?.outputAmount):null,a=vn(e)??ce,r=ut(e)??ce),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ye(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ye(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ye(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:$r(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Ye(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 Ye(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:$r(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:$r(n??null,s),outputUsdValue:new Ye(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?$r(e.toToken,e.outputAmount?.toString()||""):new Ye(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ye(0),inputUsdValue:new Ye(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ye(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),Su=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&he.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&he.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function Cu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:c,toBlockchain:p}=O(),u=y().config,d=y().fetchStatus,h=y().blockchains(),g=y().tokens(),{findToken:f}=y(),{setAffiliateRef:m,setAffiliatePercent:S,setAffiliateWallets:k}=y(),C=u?.from?.tokens,T=u?.from?.blockchains,v=u?.to?.tokens,b=u?.to?.blockchains,A=Fr(void 0),_=Fr(void 0),w=Fr(void 0),x=Fr(void 0);zo(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),zo(()=>{if(d==="success"){r();let E=h.find(L=>L.name===u?.from?.blockchain),N=u?.from?.token,D=N&&f(N);(E||!E&&w.current)&&n(E??null),D?a({token:D,meta:{blockchains:h,tokens:g}}):!D&&A.current&&a({token:null}),w.current=u?.from?.blockchain,A.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,d]),zo(()=>{ua(s,C)&&a({token:null}),da(c,T)&&n(null)},[C,T]),zo(()=>{ua(l,v)&&a({token:null}),da(p,b)&&o(null)},[v,b]),zo(()=>{if(d==="success"){r();let E=h.find(L=>L.name===u?.to?.blockchain),N=u?.to?.token,D=N&&f(N);(E||!E&&x.current)&&o(E??null),D?e({token:D,meta:{blockchains:h,tokens:g}}):!D&&_.current&&e({token:null}),x.current=u?.to?.blockchain,_.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),zo(()=>{m(u?.affiliate?.ref??null),S(u?.affiliate?.percent??null),k(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(Cu,"useSyncStoresWithConfig");import{useEffect as $a,useRef as cC}from"react";import{useInRouterContext as pC,useLocation as uC,useSearchParams as dC}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 Da(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Da,"tokenToSearchParam");function Oa(){let t=uC(),[e,o]=dC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:h}=O(),g=y().fetchStatus,f=y().blockchains(),m=y().tokens(),S=pC(),{updateIframe:k,updateCampaignMode:C}=y(),T=y().isInCampaignMode(),v=cC(),{findToken:b}=y(),A=i(()=>{let w={};for(let[K,ne]of e.entries())K.startsWith("utm_")&&(w[K]=ne);let x=e.get("fromAmount"),E=e.get("fromBlockchain"),N=e.get("fromToken"),D=e.get("toBlockchain"),L=e.get("toToken"),j=e.get("autoConnect"),R=e.get("clientUrl"),Y=e.get("liquiditySources"),W=e.get("blockchain");return{fromAmount:x,fromBlockchain:E,fromToken:N,toBlockchain:D,toToken:L,autoConnect:j,clientUrl:R,liquiditySources:Y,utmQueryParams:w,blockchain:W}},"getUrlSearchParams"),_=i(w=>{for(let x in w)w[x]||delete w[x];o(w,{replace:!0})},"updateUrlSearchParams");$a(()=>{let{autoConnect:w,clientUrl:x,utmQueryParams:E,blockchain:N}=A();S&&g==="success"&&_({fromBlockchain:n?.name,fromToken:Da(a),toBlockchain:r?.name,toToken:Da(s),fromAmount:l,autoConnect:w??void 0,clientUrl:x??void 0,blockchain:N??void 0,liquiditySources:T?v.current:void 0,...E})},[t.pathname,l,n,a,r,s,T]),$a(()=>{if(!S)return;let w=A();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&h(w.fromAmount),g==="success"){let x=f.find(L=>L.name===w.fromBlockchain),E=w.fromToken&&x?b(_a(w.fromToken,x)):void 0,N=f.find(L=>L.name===w.toBlockchain),D=w.toToken&&N?b(_a(w.toToken,N)):void 0;x&&(c(x),E&&u({token:E,meta:{blockchains:f,tokens:m}})),N&&(p(N),D&&d({token:D,meta:{blockchains:f,tokens:m}}))}},[g]),$a(()=>{let{clientUrl:w,liquiditySources:x}=A();k("clientUrl",w||void 0),C("liquiditySources",x?.split(",")??void 0)},[])}i(Oa,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as Ik,Button as ed,darkTheme as Ak,Divider as En,DoneIcon as Nk,MessageBox as Wk,styled as Bk,TextField as Lk,Typography as Mk}from"@rango-dev/ui";import ye,{useEffect as Pk,useState as Vr}from"react";import{useNavigate as _k,useSearchParams as Dk}from"react-router-dom";import{ChevronRightIcon as mC,Divider as bu,Image as fC,Typography as xu}from"@rango-dev/ui";import yt from"react";import{darkTheme as ku,styled as Ua}from"@rango-dev/ui";var Tu=Ua("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${ku} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${ku} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),vu=Ua("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),wu=Ua("div",{display:"flex"});function za(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return yt.createElement(vu,null,yt.createElement(xu,{size:"large",variant:"label"},n),yt.createElement(bu,{size:10}),yt.createElement(Tu,{onClick:s?void 0:e,disabled:s},yt.createElement(wu,null,r&&yt.createElement(yt.Fragment,null,yt.createElement(fC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),yt.createElement(bu,{size:4,direction:"horizontal"})),yt.createElement(xu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),yt.createElement(mC,{size:12,color:"black"})))}i(za,"BlockchainSelectorButton");import{i18n as Ha}from"@lingui/core";import{Button as gC,Divider as bn,ExternalLinkIcon as hC,Image as yC,Typography as Ho}from"@rango-dev/ui";import We from"react";function Eu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Eu,"generateExplorerLink");import{darkTheme as Qo,styled as Iu}from"@rango-dev/ui";var Qa=Iu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Qo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Qo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Qo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Qo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Au=Iu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Qo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Qo} &`]:{color:"$colors$neutral900"}}});function qa(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=Eu(n.address,a);return We.createElement(J,{open:e,dismissible:!0,onClose:o,container:I()},We.createElement(Au,null,We.createElement(yC,{src:n.image,size:45,type:"circular"}),We.createElement(Ho,{variant:"title",size:"medium"},n.name),We.createElement(Ho,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),We.createElement(bn,{size:4}),We.createElement(Ho,{variant:"body",size:"medium"},s?We.createElement(Qa,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,We.createElement(hC,{size:12,color:"gray"})):We.createElement(Qa,null,n.address)),We.createElement(bn,{size:4}),n.coinSource&&We.createElement(Ho,{className:"_coin-source",variant:"body",size:"xsmall"},Ha.t("via")," ",We.createElement(Ho,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),We.createElement(bn,{size:"32"}),We.createElement(Ho,{size:"medium",variant:"body",className:"_custom-token-description"},Ha.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(bn,{size:40}),We.createElement(bn,{size:10}),We.createElement(gC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ha.t("Import")))}i(qa,"CustomTokenModal");import{useManager as kk}from"@rango-dev/queue-manager-react";import{BottomLogo as Tk,Divider as Xu,Header as vk}from"@rango-dev/ui";import be,{useEffect as us,useMemo as wk,useRef as Yu,useState as bk}from"react";import{useRef as SC}from"react";function Or(){return window.self!==window.top}i(Or,"isAppLoadedIntoIframe");function Ga(){let t=SC(null),{iframe:e}=y(),o=Or()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let c of l)n({type:"widget_height",data:{height:c.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ga,"useIframe");import{useNavigate as CC}from"react-router-dom";function Ze(){let t=CC();return()=>t(-1)}i(Ze,"useNavigateBack");import{createTheme as Ja,darkTheme as MC,lightTheme as PC}from"@rango-dev/ui";import{useEffect as _C,useState as DC}from"react";import{theme as BC,darkColors as LC}from"@rango-dev/ui";import Ya from"react";function kC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(kC,"expandShortHexColor");function TC(t){return/[0-9]+$/.test(t)}i(TC,"isOverridingColor");function vC(t,e){return t.padStart(e,"0")}i(vC,"pad");function Va(t){let e=Math.min(Math.max(Math.round(t),0),255);return vC(e.toString(16),2)}i(Va,"intToHex");function wC(t){return`#${Va(t.red)}${Va(t.green)}${Va(t.blue)}`}i(wC,"rgbToHex");function bC(t){let e=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return{red:e,green:o,blue:n}}i(bC,"hexToRGB");function xC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(xC,"generateShade");function EC(t,e){let o=.11*e;return{red:t.red+(255-t.red)*o,green:t.green+(255-t.green)*o,blue:t.blue+(255-t.blue)*o}}i(EC,"generateTint");function IC(t){return Nu(t,xC)}i(IC,"calculateShades");function AC(t){return Nu(t,EC)}i(AC,"calculateTints");function Nu(t,e){let o=bC(t),n=[];for(let r=1;r<9;r++)n.push(wC(e(o,r)));return n}i(Nu,"calculateColors");function Ka(t,e,o){let a=AC(t).reverse().concat(t),s=IC(t),l=a.concat(s),c={},p=l.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50;c[`${e}${d}`]=l[u]}return c}i(Ka,"createTintsAndShades");function ja(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!TC(r)){let c=kC(a);Object.assign(n,Ka(c,r,s))}}return{...n,...e}}i(ja,"expandToGenerateThemeColors");var Wu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),NC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Wu(o%52)+e;return Wu(o%52)+e},"toAlphabeticName"),WC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Xa=i(t=>NC(WC(5381,JSON.stringify(t))>>>0),"toHash");function Za(t){let e=BC.colors,o={...e,...LC},n,r;if(t?.light){let s={colors:ja(e,t.light)};n={id:`${pa}-light-${Xa(s)}`,tokens:s}}if(t?.dark){let s={colors:ja(o,t.dark,{reverseNeutralRange:!0})};r={id:`${pa}-dark-${Xa(s)}`,tokens:s}}return{light:n,dark:r}}i(Za,"customizedThemeTokens");function Bu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Ya.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Ya.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Ya.cloneElement(e,{key:l}))}}),o}i(Bu,"joinList");function Lu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Lu,"doesWindowPreferDarkColorScheme");function qo(t){let{colors:e,fontFamily:o=wc,borderRadius:n=Vc,secondaryBorderRadius:r=Kc}=t,[a,s]=DC(Lu()?"dark":"light"),{theme:l}=y(),{dark:c,light:p}=Za(e),u=Ja({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,PC.className],h=[u.className,MC.className];if(p){let f=Ja(p.id,p.tokens);d.push(f.className)}if(c){let f=Ja(c.id,c.tokens);h.push(f.className)}return _C(()=>{let f=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Lu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=d.join(" "),m=h.join(" ");return l==="auto"?a==="dark"?m:f:l==="dark"?m:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(qo,"useTheme");var dt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Mu}from"@lingui/core";import{Alert as $C,Button as FC}from"@rango-dev/ui";import Pu from"react";function Ra(t){return Pu.createElement($C,{action:Pu.createElement(FC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Mu.t("Activate this tab")),type:"warning",variant:"alarm",title:Mu.t("Another tab is open and handles transactions.")})}i(Ra,"ActivateTabAlert");import{i18n as es}from"@lingui/core";import{Button as OC,Divider as UC,MessageBox as zC}from"@rango-dev/ui";import Ur from"react";function ts(t){let{open:e,onClose:o,onConfirm:n}=t;return Ur.createElement(J,{open:e,dismissible:!0,onClose:o,container:I()},Ur.createElement(zC,{title:es.t("Activate current tab"),type:"warning",description:es.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.")},Ur.createElement(UC,{size:20}),Ur.createElement(OC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},es.t("Confirm"))))}i(ts,"ActivateTabModal");import{ChevronLeftIcon as QC}from"@rango-dev/ui";import _u from"react";function os(t){return _u.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},_u.createElement(QC,{color:"black",size:16}))}i(os,"BackButton");import{i18n as HC}from"@lingui/core";import{Button as qC,Typography as GC}from"@rango-dev/ui";import ns from"react";function rs(t){return ns.createElement(Kt,null,ns.createElement(qC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},ns.createElement(GC,{variant:"label",size:"medium",color:"error500"},HC.t("Cancel"))))}i(rs,"CancelButton");import{i18n as VC}from"@lingui/core";import{Image as KC,Tooltip as jC,WalletIcon as XC}from"@rango-dev/ui";import ho from"react";function is(t){let{list:e}=gt(),o=e.filter(r=>r.state==="connected"),n=o.length?ho.createElement("div",{className:vp()},o.map(r=>ho.createElement(vr,{key:r.title},ho.createElement(KC,{src:r.image,size:14})))):VC.t("Connect Wallet");return ho.createElement(jC,{container:t.container,side:"bottom",content:n},ho.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&ho.createElement(Sp,null),ho.createElement(XC,{size:18,color:"black"})))}i(is,"WalletButton");import{i18n as Qr}from"@lingui/core";import{NotificationsIcon as uk,Popover as dk,SettingsIcon as mk,Tooltip as Hr,TransactionIcon as fk}from"@rango-dev/ui";import Be from"react";import{Notifications as RC}from"@rango-dev/ui";import ek from"react";import{useNavigate as tk}from"react-router-dom";import{create as YC}from"zustand";import{persist as ZC,subscribeWithSelector as JC}from"zustand/middleware";var we=_o(YC()(ZC(JC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(c=>c.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(c=>c.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function as(){let t=tk(),{getNotifications:e,clearNotifications:o}=we(),n=e(),r=y().blockchains(),{findToken:a}=y();return ek.createElement(RC,{list:n,getBlockchainImage:l=>fc(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(as,"NotificationContent");import{useManager as ok}from"@rango-dev/queue-manager-react";import{InProgressIcon as nk}from"@rango-dev/ui";import Du from"react";var rk=i(()=>{let{manager:t}=ok();return dt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Du.createElement(Tp,null,Du.createElement(nk,{color:"info",size:6})):null},"InProgressTransactionBadge"),$u=rk;import{EventSeverity as ik}from"@rango-dev/queue-manager-rango-preset";import{Typography as ak}from"@rango-dev/ui";import Fu from"react";function Ou(){let{getNotifications:t}=we(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===ik.WARNING);return o?Fu.createElement(Cp,{isSever:n},Fu.createElement(ak,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Ou,"NotificationsBadge");import{RefreshProgressButton as sk}from"@rango-dev/ui";import ss,{useEffect as lk,useState as Uu}from"react";var ck=1e3,zu=60,pk=100;function zr({onClick:t}){let[e,o]=Uu(0),[n,r]=Uu(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");lk(()=>{let c;return t?c=window.setInterval(()=>{o(p=>p+1),e===zu&&l()},ck):s(c),document.addEventListener("visibilitychange",()=>a(c)),()=>{document.removeEventListener("visibilitychange",()=>a(c)),c&&clearInterval(c)}},[e,t]);let s=i(c=>{c&&clearInterval(c),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return ss.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},ss.createElement(kp,{onTransitionEnd:()=>r(!1),isRefetched:n},ss.createElement(sk,{size:22,color:t?"black":"gray",progress:e/zu*pk})))}i(zr,"RefreshButton");function yo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Xe("notification",s)||r.includes("notifications");return Be.createElement(Be.Fragment,null,!r.includes("refresh")&&Be.createElement(Hr,{container:a||I(),side:"top",content:Qr.t("Refresh")},Be.createElement(zr,{onClick:e})),!l&&Be.createElement(dk,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:I(),content:Be.createElement(as,null)},Be.createElement("div",null,Be.createElement(Hr,{container:I(),side:"top",content:Qr.t("Notifications")},Be.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Be.createElement(uk,{size:18,color:"black"}),Be.createElement(Ou,null))))),!r.includes("settings")&&Be.createElement(Hr,{container:I(),side:"top",content:Qr.t("Settings")},Be.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Be.createElement(mk,{size:18,color:"black"}))),!r.includes("history")&&Be.createElement(Hr,{container:I(),side:"top",content:Qr.t("History")},Be.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Be.createElement(fk,{size:18,color:"black"}),Be.createElement($u,null))))}i(yo,"HeaderButtons");import{i18n as ls}from"@lingui/core";import{Divider as Hu,MessageBox as yk,RefreshIcon as Sk}from"@rango-dev/ui";import Go from"react";import{Button as gk,styled as hk}from"@rango-dev/ui";var Qu=hk(gk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function cs(t){let{open:e,onClose:o}=t;return Go.createElement(J,{open:e,dismissible:!0,onClose:o,container:I()},Go.createElement(yk,{title:ls.t("Something went wrong"),type:"error",description:ls.t("Something went wrong. Please refresh the app.")},Go.createElement(Hu,{size:30}),Go.createElement(Qu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Go.createElement(Sk,{size:20,color:"primary"}),Go.createElement(Hu,{size:4,direction:"horizontal"}),ls.t("Refresh"))))}i(cs,"RefreshModal");function ps(t){let e=t.target;if(e){let o=e.scrollTop,n=I();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(ps,"onScrollContentAttachStatusToContainer");import{css as Ck,styled as qr}from"@rango-dev/ui";var qu="700px",Gr=Ck({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Gu=qr("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:qu},fixed:{height:qu}},showBanner:{true:{overflow:"visible"}}}}),Vu=qr("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Ku=qr("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}}),ju=qr("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)"});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Ga(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c,config:{__UNSTABLE_OR_INTERNAL__:p}}=y(),[u,d]=bk(!1),{config:{features:h,theme:g}}=y(),{watermark:f}=re(),m=f==="FULL",{activeTheme:S}=qo(g||{}),k=Xe("connectWalletButton",h),{isActiveTab:C,tabManagerInitiated:T,showActivateTabModal:v,setShowActivateTabModal:b,activateCurrentTab:A}=re(),_=Ze(),{manager:w}=kk(),E=dt(w).map(({swap:W})=>W).some(W=>W.status==="running"),N=i(()=>A(lo.forceClaim,E),"onActivateTab"),D=i(()=>{r.onWallet?.()},"onConnectWallet"),L=typeof r.hasBackButton>"u"||r.hasBackButton,j=Yu(null),R=Yu(null),Y=wk(()=>{let W=(p?.swapBoxBanner?.routes?.length??0)===0,K=!!p?.swapBoxBanner?.routes?.some(ne=>location.pathname.endsWith(ne));return p?.swapBoxBanner&&(W||K)},[p?.swapBoxBanner?.routes?.length,location.pathname]);return us(()=>(Or()&&R.current&&e(R.current),()=>{o()}),[]),us(()=>(j.current?.addEventListener("scroll",ps),()=>{j.current?.removeEventListener("scroll",ps)}),[]),us(()=>{d(l==="failed")},[l]),be.createElement(Gu,{height:s,id:Fe.SWAP_BOX_ID,className:`${S()} ${Gr()}`,ref:R,showBanner:Y},be.createElement(vk,{prefix:L?be.createElement(os,{onClick:()=>{_(),r.onBack?.()}}):null,title:r.title,suffix:be.createElement(be.Fragment,null,r.suffix,r.onWallet&&!k&&be.createElement(is,{container:I(),onClick:D,isConnected:!!c?.length}),r.onCancel&&be.createElement(rs,{onClick:r.onCancel}))}),be.createElement(Vu,{ref:j},n),be.createElement(ts,{open:v,onClose:()=>b(!1),onConfirm:N}),be.createElement(Ku,null,be.createElement("div",{className:"footer__content"},T&&!C&&be.createElement("div",{className:"footer__alert"},be.createElement(Ra,{onActivateTab:N}),be.createElement(Xu,{size:10})),a),be.createElement(Xu,{size:12}),be.createElement("div",{className:`footer__logo ${m?"logo__show":"logo__hidden"}`},be.createElement(Tk,null))),Y&&be.createElement(ju,null,p?.swapBoxBanner?.element),be.createElement(cs,{open:u,onClose:()=>d(!1)}))}i(oe,"Layout");import{styled as xk}from"@rango-dev/ui";var Zu="$20 $20 $10 $20",xn=xk("div",{padding:Zu,overflowY:"auto",flexGrow:1});import{styled as Ek}from"@rango-dev/ui";var ie=Ek("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as Vo}from"@lingui/core";import{useState as Ju}from"react";function Ru(){let[t,e]=Ju(!1),[o,n]=Ju(void 0),{findToken:r}=y(),a=y().customTokens();function s(c,p){switch(c){case"duplicated":return{title:Vo.t("Duplicate Token"),message:Vo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Vo.t("Token Already Exists"),message:Vo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Vo.t("Token Not Found"),message:Vo.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:p}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:c,tokenAddress:p})=>{e(!0);try{if(a.some(f=>f.address?.toLowerCase()===p.toLowerCase())){let f=s("duplicated");n(f);return}let d=await xt().getCustomToken({blockchain:c,address:p});if(!d||!d.token||d.error){let f=s("not-found",c);n(f);return}let h=d.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let f=s("token-exist");n(f);return}return h}catch(u){if(u?.code==="ERR_BAD_REQUEST"){let d=s("not-found",c);n(d);return}throw n(void 0),new Error(u.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Ru,"useFetchCustomToken");var $k=Bk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${Ak} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),Fk=1e3;function td(){let t=_k(),[e]=Dk(),o=Ze(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=sn(a,r),[l,c]=Vr(""),[p,u]=Vr(!1),[d,h]=Vr(),{fetchCustomToken:g,loading:f,error:m}=Ru(),[S,k]=Vr(""),C=!!s&&No(s,l),T=!s||!l||!C,v=i(async()=>{if(s)try{let _=await g({blockchain:a,tokenAddress:l});k(""),_&&h(_)}catch(_){_.message==="Failed to fetch"&&(k(It.t("Network Error")),u(!0))}},"getCustomToken"),b=i(()=>{m&&c(""),u(!1)},"closeErrorModal"),A=i(async()=>{S&&setTimeout(async()=>{await v()},Fk),b()},"handleErrorModalButtonClick");return Pk(()=>{m&&u(!0)},[m]),ye.createElement(oe,{header:{title:It.t("Add Custom Token")}},ye.createElement(ie,null,ye.createElement($k,null,ye.createElement("div",null,ye.createElement(za,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),ye.createElement(En,{size:"24"}),ye.createElement(Mk,{size:"large",variant:"label"},It.t("Enter Address")),ye.createElement(En,{size:10}),ye.createElement(Lk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&C&&ye.createElement(Nk,{color:"success",size:12}),onChange:_=>c(_.target.value)}),!C&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(En,{size:4}),ye.createElement(Ik,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(ed,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},It.t("Import"))),ye.createElement(J,{open:p,dismissible:!0,onClose:b,container:I()},ye.createElement(Wk,{title:m?.title||S,type:"error",description:m?.message||It.t("Failed Network, Please retry.")},ye.createElement(En,{size:40}),ye.createElement(En,{size:10}),ye.createElement(ed,{id:`widget-add-custom-token-${S?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},S?It.t("Retry"):It.t("Add another custom token")))),s&&d&&ye.createElement(qa,{blockchain:s,token:d,onSubmitClick:()=>{d&&(n(d),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!d})))}i(td,"AddCustomTokenPage");import{i18n as zs}from"@lingui/core";import{useManager as Tv}from"@rango-dev/queue-manager-react";import{Alert as vv,Button as wv,css as Hs,Divider as Qs,IconButton as Xm,styled as bv,Typography as xv,WalletIcon as Ev}from"@rango-dev/ui";import Me,{useEffect as ki,useLayoutEffect as Iv,useRef as Av,useState as On}from"react";import{useNavigate as Nv}from"react-router-dom";import{i18n as So}from"@lingui/core";import{Alert as cT,BalanceErrors as pT,Button as Nd,ChevronLeftIcon as uT,Divider as Cs,MessageBox as dT,Typography as ks}from"@rango-dev/ui";import te,{useCallback as mT,useEffect as Wd,useMemo as fT,useState as Xo}from"react";import{useNavigate as gT}from"react-router-dom";import{i18n as gs}from"@lingui/core";import{Alert as Hk,ChevronDownIcon as qk,CloseIcon as Gk,Divider as ld,IconButton as cd,PasteIcon as Vk,Typography as Kk,WalletIcon as jk}from"@rango-dev/ui";import Le,{useEffect as Xk,useRef as Yk}from"react";import Yr,{useRef as zk}from"react";import*as Ko from"@radix-ui/react-collapsible";import{keyframes as od,styled as Kr}from"@rango-dev/ui";var ds=300,Ok=od({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Uk=od({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),nd=Kr(Ko.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ms=Kr(Ko.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),jr=Kr(Ko.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Ok} ${ds}ms ease-out`},false:{animation:`${Uk} ${ds}ms ease-out`}}}}),Xr=Kr("div",{transition:`all ${ds}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Zr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=zk(null);return Yr.createElement(nd,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Yr.createElement(ms,{className:"collapsible_trigger",onClick:a},s),Yr.createElement(jr,{className:"collapsible_content",open:e},r),l==="bottom"&&Yr.createElement(ms,{className:"collapsible_trigger",onClick:a},s))}i(Zr,"CustomCollapsible");import{darkTheme as rd,styled as fs,TextField as Qk}from"@rango-dev/ui";var id=fs("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),ad=fs(Qk,{backgroundColor:"$neutral100",padding:"$15"}),sd=fs("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${rd} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${rd} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function pd(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=lr(e.name,l),p=Yk(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),g=n&&!!r&&e&&!No(e,r),f=i(()=>{a("")},"handleClear"),m=i(async k=>{if(k.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),p?.current?.focus()}},"handlePaste"),S=i(()=>r?Le.createElement(cd,{id:"widget-custom-destination-close-icon-btn",onClick:f,variant:"ghost"},Le.createElement(Gk,{size:12,color:"gray"})):d?null:Le.createElement(cd,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Le.createElement(Vk,{size:16})),"renderSuffix");return Xk(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Le.createElement(id,null,Le.createElement(Zr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Le.createElement(sd,null,Le.createElement("div",{className:"button__content"},Le.createElement(jk,{size:18,color:"info"}),Le.createElement(ld,{size:4,direction:"horizontal"}),Le.createElement(Kk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},gs.t("Send to a different address"))),Le.createElement(Xr,{orientation:n?"up":"down"},Le.createElement(qk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Le.createElement(ad,{ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:gs.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:S(),onChange:k=>{let C=k.target.value;a(C)}})),g&&Le.createElement(Le.Fragment,null,Le.createElement(ld,{size:4}),Le.createElement(Hk,{variant:"alarm",type:"error",title:gs.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(pd,"CustomDestination");import{css as Zk,darkTheme as hs,IconButton as Jk,styled as Dt}from"@rango-dev/ui";var ud=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),dd=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Rk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${hs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${hs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${hs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),md=Dt(Rk,{alignSelf:"stretch",minHeight:"93px"}),fd=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),gd=Dt(Jk,{position:"absolute",left:"$20"}),hd=Dt("div",{paddingTop:"$20"}),yd=Zk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Sd=Dt("div",{display:"flex"}),Cd=Dt("div",{overflow:"visible",width:"100%"});import{i18n as xd}from"@lingui/core";import{warn as rT}from"@rango-dev/logging-core";import{Divider as iT,SelectableWallet as aT,Typography as Ed,WalletState as Id}from"@rango-dev/ui";import Je,{useEffect as Ad,useState as An}from"react";import{Image as oT,MessageBox as nT}from"@rango-dev/ui";import In from"react";import{keyframes as eT,styled as ys}from"@rango-dev/ui";var kd=ys("div",{position:"relative"}),tT=eT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Td=ys("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${tT} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vd=ys("div",{"& img":{borderRadius:"50%"}});import{i18n as jo}from"@lingui/core";function wd(t,e){switch(t){case"in-progress":return{type:"loading",title:jo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:jo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:jo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:jo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:jo.t("Request Rejected"),description:jo.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(wd,"generateMessageByStatus");function bd(t){let{status:e,displayName:o,image:n}=t,r=wd(e,o),a=e=="in-progress";return In.createElement(nT,{type:r.type,title:r.title,description:r.description,icon:a?In.createElement(kd,null,In.createElement(vd,null,In.createElement(oT,{src:n,size:45})),In.createElement(Td,null)):void 0})}i(bd,"ExperimentalChainStatus");var sT=7,lT=3e3;function Ss(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[p,u]=An(),[d,h]=An(null),[g,f]=An(!1),[m,S]=An(null),{suggestAndConnect:k}=Jr(),{handleDisconnect:C}=Vt(),{list:T}=gt({chain:e}),[v,b]=An(T),A=T.length,_=r&&A-r>0,w=i(async E=>{f(!1),S("in-progress");try{await k(E.walletType,E.chain),S("completed")}catch{S("rejected")}},"addExperimentalChain");Ad(()=>{b(E=>{let N=T.findIndex(D=>o(D.type,e));return _&&N>1?[T[N]].concat(T.filter((D,L)=>L!==N)):E.map(D=>T.find(L=>L.type===D.type)??D)})},[JSON.stringify(T)]);let x=document.getElementById(Fe.SWAP_BOX_ID);return Ad(()=>{let E=null;return(m==="completed"||m==="rejected")&&(E=setTimeout(()=>S(null),lT)),()=>{E&&clearTimeout(E)}},[m]),Je.createElement(Je.Fragment,null,v.slice(0,r).map(E=>{let N=Uc({connectedWallets:c,walletType:E.type,chain:e}),D=N?Cr(N,sT):"",L=yr(l(),e),j=!c.find(ne=>ne.walletType===E.type&&ne.chain===e),R=L&&j&&E.state===Id.CONNECTED,Y=R?xd.t({id:"Add {chain} chain",values:{chain:e}}):D,W=i(async()=>{let ne=E.state===Id.DISCONNECTED,V=(E.isHub||!!E.needsNamespace)&&!D;ne?u(E):V?(await C(E.type),u(E)):R?(h({walletType:E.type,chain:e,address:N??""}),f(!0)):n({walletType:E.type,chain:e,address:N??""})},"onSelectableWalletClick"),K=d?.chain?lr(d.chain,l()):void 0;return Je.createElement(Je.Fragment,{key:`${E.title}_${K}`},!!d&&Je.createElement(J,{open:!!d&&g,container:x,onClose:()=>{h(null)}},Je.createElement(Ia,{displayName:K,onConfirm:()=>{w(d)}})),m&&Je.createElement(J,{open:!!m,onClose:S.bind(null,null),container:x},Je.createElement(bd,{status:m,displayName:K,image:E.image}),Je.createElement(iT,{direction:"vertical",size:32})),Je.createElement(aT,{key:E.type,description:Y,onClick:W,selected:o(E.type,e),disabled:!s,...E}))}),Je.createElement(mo,{wallet:p,onClose:()=>{u(void 0)},onConnect:()=>{t.onConnect&&(p?.type?t.onConnect(p.type):rT(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),_&&Je.createElement(md,{selected:!1,onClick:a},Je.createElement(Ed,{variant:"label",size:"medium"},xd.t("Show more wallets"),Je.createElement(Ed,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(Ss,"WalletList");var hT=2;function Bd(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=gT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:h,setCustomDestination:g}=O(),{config:f,connectedWallets:m,setWalletsAsSelected:S}=y(),[k,C]=Xo(""),[T,v]=Xo([]),[b,A]=Xo(""),[_,w]=Xo(!!h),x=fT(()=>so({filter:"all",quote:c}),[c]),E=so({filter:"required",quote:c}),N=l.find(M=>M.name===c?.swaps[c?.swaps.length-1].to.blockchain),D=i(M=>E.includes(M),"isWalletRequiredFor"),L=mT(()=>m.filter(M=>M.selected&&x.includes(M.chain)),[m,x]),[j,R]=Xo(L()),[Y,W]=Xo([]),K=i((M,H)=>W(G=>G.concat({blockchain:M,walletType:H})),"addNextSelectedWallets"),ne=T.length>0,V=i((M,H)=>!!j.find(G=>G.walletType===M&&G.chain===H&&G.selected&&(D(H)||!D(H)&&!h)),"isSelected"),fe=i((M,H,G)=>{let ge=!1;return M.map(le=>{if(le.chain===H){let De=le.selected;return!ge&&G?(ge=!0,De=!0):G||(De=!1),{...le,selected:De}}return le})},"updateSelectableWallets"),Ie=i(M=>{w(M),M?D(N?.name??"")||R(H=>fe(H,N?.name||"",!1)):(g(""),R(H=>fe(H,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ke=i(M=>{if(k&&C(""),V(M.walletType,M.chain))return;let G=m.find(ge=>ge.walletType===M.walletType&&ge.chain===M.chain);G&&(n(),M.chain===N?.name&&_&&!D(N.name)&&(w(!1),g(null)),R(ge=>ge.filter(le=>le.chain!==M.chain).concat({...G,selected:!0})))},"onChange"),se=i(()=>{let M=j.filter(H=>H.selected);S(M),p(M),d(!0),o()},"onConfirmBalance"),lt=i(async()=>{v([]),A("");let M=await r?.({selectedWallets:j.filter(G=>G.selected),customDestination:h}),H=M.warnings;H?.balance?.messages&&v(H.balance.messages),M.error&&A(zp(M.error)),!M.error&&!H?.balance?.messages.length?se():v(H?.balance?.messages??[])},"onConfirmWallets");Wd(()=>{R(M=>{let H=[];return M.forEach(G=>{!m.some(le=>le.chain===G.chain&&le.walletType===G.walletType&&le.address===G.address)||H.push(G)}),H=H.concat(m.filter(G=>!!!H.find(le=>le.chain===G.chain)&&G.selected&&x.includes(G.chain))),H})},[m,x]),Wd(()=>{let M=[];Y.length>0&&(Y.forEach(H=>{let G=m.find(ge=>ge.chain===H.blockchain&&ge.walletType===H.walletType);G?Ke(G):M.push(H)}),W(M))},[m,Y]);let q=document.getElementById(Fe.SWAP_BOX_ID);return te.createElement(J,{open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!k,container:q,...!k&&{styles:{container:{height:"100%"}},footer:te.createElement(Sd,null,te.createElement(Nd,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:hu(a,_,h,c,j,N),onClick:lt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},So.t("Confirm")))},...k&&{styles:{container:{height:"100%",padding:"$0"}},header:te.createElement(fd,null,te.createElement(gd,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},te.createElement(uT,{size:16})),te.createElement(ks,{variant:"headline",size:"small"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:ct(k,l)}})))},anchor:"center"},te.createElement(J,{open:ne,onClose:v.bind(null,[]),container:q},te.createElement(dT,{title:So.t("Insufficient account balance"),type:"error",description:te.createElement(pT,{messages:T??[]})},te.createElement(Nd,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:se},So.t("Proceed anyway")))),k&&te.createElement(hd,null,te.createElement("div",{className:yd()},te.createElement(Ss,{chain:k,isSelected:V,selectWallet:Ke,onShowMore:()=>C(k),onConnect:M=>{K(k,M)}}))),!k&&te.createElement(te.Fragment,null,b&&te.createElement(te.Fragment,null,te.createElement(cT,{variant:"alarm",type:"error",title:So.t(b)}),te.createElement(Cs,{size:12})),te.createElement(Cd,null,x.map((M,H)=>{let G=l.find(je=>je.name===M),ge=`wallet-${H}`,le=H===x.length-1,De=le&&N&&f?.customDestination!==!1;return te.createElement("div",{key:ge},te.createElement(ud,null,te.createElement(ks,{variant:"title",size:"xmedium"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:G?.shortName}})),te.createElement(ks,{variant:"label",color:"$neutral700",size:"medium"},So.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:G?.shortName}}))),te.createElement(Cs,{size:24}),te.createElement(dd,null,te.createElement(Ss,{chain:M,isSelected:V,selectWallet:Ke,limit:hT,onShowMore:()=>C(G?.name??""),onConnect:je=>{K(M,je)}})),!le&&te.createElement(Cs,{size:32}),De&&te.createElement(pd,{blockchain:N,open:_,handleOpenChange:Ie}))}))))}i(Bd,"ConfirmWalletsModal");import{i18n as _T}from"@lingui/core";import{Alert as DT,Button as $T,InfoIcon as FT}from"@rango-dev/ui";import ot from"react";import{Alert as CT,Button as kT,Divider as ws,NoRouteIcon as TT,RefreshIcon as vT,Typography as Fd}from"@rango-dev/ui";import tt from"react";import{i18n as Ld}from"@lingui/core";var yT=24,ST=60;function Md(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:ee().genericServerError,action:{onClick:n,title:Ld.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:ee().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Ld.t("Reset")}},description:ee().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:ee().noResultError.description}}i(Md,"makeInfo");var Ts=(o=>(o[o.small=yT]="small",o[o.large=ST]="large",o))(Ts||{}),vs=(o=>(o.small="small",o.large="medium",o))(vs||{});import{styled as Rr}from"@rango-dev/ui";var Pd=Rr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),_d=Rr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Dd=Rr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),$d=Rr("div",{padding:"$6 $0"});function Nn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Md(o,r,()=>a(s,!0),e);return tt.createElement(Pd,null,tt.createElement(TT,{size:Ts[n],color:"gray"}),tt.createElement(ws,{size:4}),tt.createElement(Fd,{variant:"title",size:vs[n]},ee().noResultError.title),n==="large"&&tt.createElement(ws,{size:4}),!!l.description&&tt.createElement(_d,{size:n},tt.createElement(Fd,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),tt.createElement(ws,{size:n==="large"?"24":"4"}),!!l.alert&&tt.createElement(Dd,{size:n},tt.createElement(CT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&tt.createElement(kT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:tt.createElement($d,null,tt.createElement(vT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(Nn,"NoResult");import{i18n as Wn}from"@lingui/core";import{Button as bT,Divider as xT,MessageBox as ET,Typography as IT,WarningIcon as AT}from"@rango-dev/ui";import $t from"react";import{Typography as Qd}from"@rango-dev/ui";import xs from"react";import{darkTheme as wT,styled as ei}from"@rango-dev/ui";var Od=ei("div",{width:"100%"}),bs=ei("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Ud=ei("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${wT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),zd=ei("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Hd(t){let{title:e,value:o,valueColor:n}=t;return xs.createElement(Ud,null,xs.createElement(Qd,{size:"medium",variant:"label",className:"_title"},e),xs.createElement(Qd,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Hd,"QuoteErrorsModalItem");function qd(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:Wn.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:Wn.t("Gas cost"),value:B(r.totalFee,2,2)},{title:Wn.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:Wn.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(J,{footer:$t.createElement(bT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(AT,null),fullWidth:!0,disabled:a,onClick:n},ee().highValueLossError.confirmMessage),open:e,onClose:o,container:I()},$t.createElement(ET,{type:s,title:ee().highValueLossError.impactTitle,description:ee().highValueLossError.description}),$t.createElement(bs,null,$t.createElement(xT,{size:"4"}),$t.createElement(IT,{size:"small",variant:"title"},Wn.t("Details")),$t.createElement(bs,null,l.map((c,p)=>$t.createElement(Hd,{key:p,...c})))))}i(qd,"HighValueLossWarningModal");import{i18n as ti}from"@lingui/core";function Gd(t,e){let o={alertType:"warning",title:"",action:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=ti.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o;if(t){switch(t.type){case 0:{_t(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=ee().highValueLossError.title;break}case 4:{o.title=ti.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=ee().unknownPriceError.title;break}case 2:{o.title=ti.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings";break}case 3:{o.title=ti.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Gd,"makeAlerts");import{i18n as Yo}from"@lingui/core";import{Button as Vd,Divider as Kd,MessageBox as NT,Typography as WT}from"@rango-dev/ui";import Co from"react";import{useNavigate as BT}from"react-router-dom";function jd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=BT(),p=e??o;return Co.createElement(J,{anchor:"bottom",open:n,prefix:Co.createElement(Vd,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+$.settings)},Co.createElement(WT,{variant:"label",size:"medium",color:"$neutral900"},Yo.t("Change settings"))),container:I(),onClose:r},Co.createElement(NT,{type:"warning",title:s.type===3?Yo.t("High slippage"):Yo.t("Low slippage"),description:s.type===3?Yo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:p}}):Yo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},Co.createElement(Kd,{size:18}),Co.createElement(Kd,{size:32}),Co.createElement(Vd,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Yo.t("Confirm anyway"))))}i(jd,"SlippageWarningModal");import{Button as LT,MessageBox as MT,WarningIcon as PT}from"@rango-dev/ui";import oi from"react";function Xd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return oi.createElement(J,{footer:oi.createElement(LT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:oi.createElement(PT,null),fullWidth:!0,disabled:r,onClick:n},ee().unknownPriceError.confirmMessage),open:e,onClose:o,container:I()},oi.createElement(MT,{type:"warning",title:ee().unknownPriceError.impactTitle,description:ee().unknownPriceError.description}))}i(Xd,"UnknownPriceWarningModal");function Bn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:p,onChangeSettings:u}=t,d={confirmationDisabled:a,open:r,onClose:c,onConfirm:p},h=o?.type===0||o?.type===1,g=Gd(e,o?.type===3||o?.type===4?o:null);return g&&!n&&(g.action=null),ot.createElement(ot.Fragment,null,h&&ot.createElement(Nn,{error:o,fetch:s}),!!g&&ot.createElement(Od,null,ot.createElement(DT,{title:g.title,type:g.alertType,variant:"alarm",...g.action==="show-info"&&{action:ot.createElement(zd,{onClick:l},ot.createElement(FT,{size:12,color:"gray"}))},...g.action==="change-settings"&&{action:ot.createElement($T,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:g.alertType,onClick:u},_T.t("Change"))}})),e&&ot.createElement(ot.Fragment,null,e.type===0&&ot.createElement(qd,{...d,warning:e}),(e.type===3||e.type===2)&&ot.createElement(jd,{...d,warning:e}),e.type===1&&ot.createElement(Xd,{...d,warning:e})))}i(Bn,"QuoteWarningsAndErrors");import gv from"bignumber.js";import hi from"react";import{i18n as ko}from"@lingui/core";import{Alert as ov,Divider as Jo,FullExpandedQuote as nv,InfoIcon as rv,NumericTooltip as Im,QuoteTag as iv,StepDetails as av,TokenAmount as sv,Typography as Ro}from"@rango-dev/ui";import Ps from"bignumber.js";import F,{useRef as lv,useState as cv}from"react";import{styled as Es}from"@rango-dev/ui";var Is=Es("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Yd=Es("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Zd=Es("div",{width:"100%",display:"flex"});import*as ni from"@radix-ui/react-collapsible";import{Button as OT,css as Ln,darkTheme as xe,Image as Jd,styled as Qe,Typography as UT}from"@rango-dev/ui";var zT=300,Rd=Qe(ni.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),em=Ln({padding:"$10 $15"}),tm=Qe(OT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${xe} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${xe} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${xe} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),om=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",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${xe} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}}}}]}),nm=Ln({width:"100%",padding:"$15 $15 $10 $15"}),rm=Ln({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Zo=Ln({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),im=Ln({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),am=Qe(ni.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${Jd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Jd}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),sm=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"}}}}),lm=Qe(jr,{width:"100%",background:"inherit"}),As=Qe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${zT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),l1=Qe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),cm=Qe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),pm=Qe("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Ns=Qe(UT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),um=Qe("div",{display:"flex",flexWrap:"wrap"}),Ws=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"}}}}),dm=Qe("div",{display:"flex"}),ri=Qe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as HT,CloseIcon as qT,Divider as si,IconButton as GT,NumericTooltip as VT,QuoteCost as KT,Typography as St}from"@rango-dev/ui";import Z,{useState as hm}from"react";import{css as QT,styled as ii}from"@rango-dev/ui";var ai=ii("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Bs=ii("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),mm=ii("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),fm=ii("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),gm=QT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var jT=i(t=>t.fee.isZero()?null:Z.createElement(ai,null,Z.createElement(St,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(St,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function Ls(t){let[e,o]=hm(!1),[n,r]=hm(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:h=!1}=t,g=s?.swaps??[],f=h?ao():I(),m=lu(g);return Z.createElement(Z.Fragment,null,Z.createElement(KT,{onClickFee:d?S=>{S.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:p,timeWarning:u,time:c,steps:a,tooltipGas:d?At.t("View more info"):void 0,tooltipContainer:f}),Z.createElement(J,{container:f,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Z.createElement(fm,{style:{textAlign:h?"left":"center"}},Z.createElement(St,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Z.createElement(GT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(qT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(mm,null,Z.createElement(St,{variant:"title",size:"small"},At.t("Details")),Z.createElement(si,{size:10}),Object.entries(m.payable).flatMap(([S,k])=>k.map((C,T)=>{let v=`payable-fee-${T}`,b=Pa(C);return Z.createElement(ai,{key:v},Z.createElement(St,{variant:"label",size:"medium",color:"neutral600"},Na(S,At.t)),Z.createElement(VT,{content:C.amount,container:f},Z.createElement(St,{variant:"label",size:"medium"},B(C.amount,2,2)," ",C.asset.symbol," ($",B(b,4,4),")")))})),Z.createElement(ai,{className:"total_payable_fee"},Z.createElement(St,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Z.createElement(St,{variant:"label",size:"medium"},"$",B(l,4,4))),Z.createElement(Bs,null),Object.keys(m.nonePayable).length&&Z.createElement(Zr,{triggerAnchor:"bottom",onClickTrigger:()=>r(S=>!S),trigger:Z.createElement("div",{className:gm()},Z.createElement(St,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Z.createElement(si,{size:4,direction:"horizontal"}),Z.createElement(Xr,{orientation:n?"up":"down"},Z.createElement(HT,{size:12,color:"gray"}))),open:n},Z.createElement(St,{size:"small",variant:"title"},At.t("Description")),Z.createElement(si,{size:4}),Z.createElement(St,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),Z.createElement(si,{size:10}),Object.entries(m.nonePayable).map(([S,k],C)=>{let T=su(k),v=Na(S,At.t),b=`non-payable-fee-${C}`;return Z.createElement(jT,{key:b,fee:T,label:v})}),Z.createElement(Bs,null)))))}i(Ls,"QuoteCostDetails");import{i18n as Cm}from"@lingui/core";import{TokenAmount as km}from"@rango-dev/ui";import li from"react";import{css as XT,styled as YT}from"@rango-dev/ui";var ym=YT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),Sm=XT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Mn(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return li.createElement(ym,null,li.createElement(km,{direction:"horizontal",label:Cm.t("Swap input"),type:"input",tooltipContainer:I(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),li.createElement("div",{className:Sm()}),li.createElement(km,{direction:"horizontal",tooltipContainer:I(),label:Cm.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(Mn,"QuoteSummary");import{i18n as xm}from"@lingui/core";import{ChevronDownIcon as RT,ChevronRightIcon as ev,Divider as Ms,Image as tv,Tooltip as mi,Typography as pi}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as ZT,useState as Pn}from"react";var Tm=480,vm=768,wm=1024,bm=1200,JT=i(()=>{let[t,e]=Pn(!1),[o,n]=Pn(!1),[r,a]=Pn(!1),[s,l]=Pn(!1),[c,p]=Pn(!1),u=i(()=>{e(window.innerWidth<=Tm),n(window.innerWidth>Tm&&window.innerWidth<=vm),a(window.innerWidth>vm&&window.innerWidth<=wm),l(window.innerWidth>wm&&window.innerWidth<=bm),p(window.innerWidth>bm)},"handleResize");return ZT(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),ci=JT;var ui=4,di=6,_n=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||I();return U.createElement(mi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(sm,{className:n,state:a},U.createElement(tv,{src:o,size:16})))},"ImageComponent");function Em(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||I(),p=r.length,u=Zp(r),{isTablet:d,isMobile:h}=ci();return U.createElement(am,{listItem:s==="list-item",ref:g=>e.current=g,selected:o,onClick:g=>{g.stopPropagation(),n(f=>!f)}},U.createElement("div",{className:Zo()},U.createElement(pi,{variant:"body",size:"xsmall"},xm.t("Via:")),U.createElement(Ms,{direction:"horizontal",size:4}),r.map((g,f)=>{let m=`item-${f}`,S=U.createElement(As,null,U.createElement(ev,{size:12,color:"black"}));return h||d?U.createElement(U.Fragment,{key:m},U.createElement(_n,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),f!==p-1&&U.createElement(U.Fragment,null,S)):U.createElement(U.Fragment,{key:m},p<=ui||p>ui&&f<ui-1?U.createElement(U.Fragment,null,U.createElement(_n,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),f!==p-1&&U.createElement(U.Fragment,null,S)):f===ui-1&&U.createElement(mi,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Zo()},S,r.map((k,C)=>{let T=`image-${C}`;return C>=f&&U.createElement(U.Fragment,{key:T},U.createElement(_n,{content:k.swapper.displayName,src:k.swapper.image,state:k.state,open:!1}),C!==p-1&&U.createElement(U.Fragment,null,S))}))},U.createElement(Ws,{state:r.find((k,C)=>C>=f&&(k.state==="error"||k.state==="warning"))?.state},U.createElement(pi,{size:"xsmall",variant:"body"},"+",p-f))))})),U.createElement("div",{className:Zo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Zo()},U.createElement(pi,{variant:"body",size:"xsmall"},xm.t("Chains:")),U.createElement(Ms,{direction:"horizontal",size:4}),u.map((g,f)=>U.createElement(U.Fragment,{key:g.displayName},u.length<=di||u.length>di&&f<di-1?U.createElement(mi,{container:c,side:"bottom",content:g.displayName,sideOffset:4},U.createElement(_n,{content:"",src:g.image,open:!1,className:f!==0?"blockchainImage":""})):f===di-1&&U.createElement(mi,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Zo()},u.map((m,S)=>S>=f&&U.createElement(_n,{key:m.displayName,content:"",src:m.image,open:!1,className:S>f?"blockchainImage":"",container:l})))},U.createElement(Ws,{className:"blockchainImage"},U.createElement(pi,{size:"xsmall",variant:"body"},"+",u.length-f))))),U.createElement(Ms,{direction:"horizontal",size:32}))),U.createElement(As,{orientation:a?"up":"down"},U.createElement(RT,{size:12,color:"black"}))))}i(Em,"QuoteTrigger");function _s(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:c=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:d=!1,container:h}=t,g=y().blockchains(),{findToken:f}=y(),m=y().swappers(),{customSlippage:S,slippage:k}=y(),C=S||k,[T,v]=cv(t.expanded),b=lv(null),A=B(o.value,6,6),_=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",x=Pt(o.usdValue,n.usdValue??null),E=B(x,2,2),N=_t(x??0),D=i((se,lt)=>se.map((q,M)=>{let H,G=r?.type===3&&r.swap.swapperId===q.swapperId,ge=r?.type===4&&r.recommendedSlippages?.has(M),le=a?.type===2&&a.recommendedSlippages?.has(M),De=G||ge,je=le;De?H="error":je&&(H="warning");let ke=De?ko.t("Slippage Error"):ko.t("Slippage Warning");return G&&(ke=ko.t("Bridge Limit Error")),{swapper:{displayName:an(q.swapperId,m)??"",image:q.swapperLogo},from:{token:{displayName:q.from.symbol,image:q.from.logo},chain:{displayName:ct(q.from.blockchain,g)??"",image:q.from.blockchainLogo},price:{value:M===0&&!lt?B(o.value,6,6):B(q.fromAmount,6,6),usdValue:B((q.from.usdPrice??0)*parseFloat(q.fromAmount),4,4),realValue:M===0?o.value:q.fromAmount,realUsdValue:new Ps(q.from.usdPrice??0).multipliedBy(q.fromAmount).toString()}},to:{token:{displayName:q.to.symbol,image:q.to.logo},chain:{displayName:ct(q.to.blockchain,g)||"",image:q.to.blockchainLogo},price:{value:B(q.toAmount,6,6),usdValue:B((q.to.usdPrice??0)*parseFloat(q.toAmount),4,4),realValue:q.toAmount,realUsdValue:new Ps(q.to.usdPrice??0).multipliedBy(q.toAmount).toString()}},state:H,alerts:De||je?F.createElement(Yd,{dense:d},F.createElement(ov,{variant:"alarm",type:De?"error":"warning",title:ke,footer:F.createElement(Zd,null,G&&F.createElement("div",null,F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Jo,{direction:"vertical",size:2}),F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},ko.t({id:"Yours: {amount} {symbol}",values:{amount:B(q.fromAmount,6,6),symbol:q?.from.symbol}}))),(ge||le)&&!G&&F.createElement("div",null,F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},ko.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(M)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(M)}}})),F.createElement(Jo,{direction:"vertical",size:2}),F.createElement(Ro,{size:"xsmall",variant:"body",color:"neutral900"},ko.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:cn(q.estimatedTimeInSeconds),fee:B(Ma(q,f),2,2),internalSwaps:q.internalSwaps?D(q.internalSwaps):void 0}}),"getQuoteSteps"),L=D(e?.swaps??[]),j=L.length,R=h||I(),Y=Rp(t.quote.tags||[]),W=!!u,K=fr(e?.swaps),ne=cn(K),V=Pr(e?.swaps??[],f),fe=B(V,2,2),Ie=V.gte(new Ps(Hp)),Ke=K/Gp>=qp;return d?F.createElement(nv,{selected:l,fee:fe,time:ne,tooltipContainer:ao(),steps:L,tags:Y,quoteCost:F.createElement(Ls,{quote:e,fullExpandedMode:!0,time:ne,fee:fe,feeWarning:Ie,timeWarning:Ke,showModalFee:p,steps:j}),percentageChange:E,warningLevel:N,outputPrice:{value:_,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(om,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:nm()},!c&&Y.length?F.createElement(F.Fragment,null,F.createElement(dm,null,Y.map((se,lt)=>{let q=`${se.value}_${lt}`;return F.createElement(F.Fragment,{key:q},F.createElement(iv,{label:se.label,value:se.value}),F.createElement(Jo,{size:4,direction:"horizontal"}))})),F.createElement(ri,null),!W&&F.createElement(Jo,{size:4})):null,F.createElement("div",{id:"portal-root",className:rm()},F.createElement(Ls,{quote:e,time:ne,fee:fe,feeWarning:Ie,timeWarning:Ke,showModalFee:p,steps:j}),W&&F.createElement(tm,{onClick:se=>{se.stopPropagation(),u()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Ro,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},ko.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:im()},F.createElement(pm,null,F.createElement(rv,{size:12,color:"gray"})),F.createElement(um,null,F.createElement(Ns,{size:"small",variant:"body"},`${A} ${L[0].from.token.displayName} = `),F.createElement(Im,{content:n.value,container:R,open:n.value?void 0:!1},F.createElement(Ns,{size:"small",variant:"body"},"\xA0",`${_} ${L[L.length-1].to.token.displayName}`))),F.createElement(Im,{content:n.usdValue,container:R},F.createElement(Jo,{size:2,direction:"horizontal"}),F.createElement(Ro,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(sv,{tooltipContainer:R,type:"output",direction:"vertical",price:{value:_,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:L[j-1].to.token.displayName,image:L[j-1].to.token.image},chain:{image:L[j-1].to.chain.image},percentageChange:E,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Mn,{from:L[0].from,to:L[j-1].to,percentageChange:E,warningLevel:N}),F.createElement(Jo,{size:4}))),F.createElement(Rd,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(Em,{type:s,quoteRef:b,selected:l,setExpanded:v,container:R,expanded:T,steps:L}),F.createElement(lm,{open:T},F.createElement(cm,null),F.createElement("div",{className:em()},L.map((se,lt)=>{let q=`item-${lt}`;return F.createElement(av,{type:"quote-details",key:q,tooltipContainer:R,step:se,hasSeparator:lt!==L.length-1,state:se.state})})))))}i(_s,"Quote");import{Divider as mv,Skeleton as fv}from"@rango-dev/ui";import Ot from"react";import{darkTheme as pv,styled as fi}from"@rango-dev/ui";var Am=fi("div",{$$color:"$colors$neutral100",[`.${pv} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Nm=fi("div",{paddingTop:"$2"}),Wm=fi("div",{paddingLeft:"$8"}),Bm=fi("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as zm,Divider as Ct,Skeleton as nt}from"@rango-dev/ui";import z from"react";import{css as uv,styled as Ft}from"@rango-dev/ui";var Ds=Ft("div",{display:"flex"}),Lm=Ft("div",{padding:"$10 $0 $20"}),Mm=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Pm=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),_m=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Dm=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),$m=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Fm=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Om=Ft("div",{padding:"$15 $0 $15 $0"}),Um=uv({display:"flex",justifyContent:"space-between",alignItems:"center"});function Dn(t){let{type:e,tagHidden:o=!0}=t,n=z.createElement(_m,null,z.createElement($m,null,z.createElement(zm,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),z.createElement(Ct,{size:8,direction:"horizontal"}),z.createElement(Fm,null,z.createElement(nt,{height:10,width:60,variant:"rounded"}),z.createElement(Ct,{size:4}),z.createElement(nt,{height:15,variant:"rounded"}))),z.createElement(nt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return z.createElement("div",null,!o&&z.createElement(z.Fragment,null,z.createElement(Ds,null,z.createElement(nt,{width:65,height:20,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(nt,{width:65,height:20,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(nt,{width:65,height:20,variant:"rounded"})),z.createElement(ri,null),!r&&z.createElement(Ct,{size:4})),z.createElement("div",{className:Um()},z.createElement(Ds,null,z.createElement(nt,{width:60,height:10,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(nt,{width:60,height:10,variant:"rounded"}),z.createElement(Ct,{size:4,direction:"horizontal"}),z.createElement(nt,{width:60,height:10,variant:"rounded"})),r&&z.createElement(nt,{width:85,height:24,variant:"rounded"})),e==="basic"&&z.createElement(Lm,null,z.createElement(nt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&z.createElement(Mm,null,z.createElement(Pm,null,z.createElement(zm,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),z.createElement(Ct,{direction:"horizontal",size:4}),z.createElement(nt,{height:15,width:150,variant:"rounded"})),z.createElement(Ct,{size:10}),z.createElement(nt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&z.createElement(z.Fragment,null,z.createElement(Ct,{size:4}),z.createElement(Om,null,n,z.createElement(Dm,null),n),z.createElement(Ct,{size:12})))}i(Dn,"QuoteSummarySkeleton");import{ChainToken as Vm,Divider as Fs,NextIcon as dv,Skeleton as gi}from"@rango-dev/ui";import Ee from"react";import{styled as $n}from"@rango-dev/ui";var Qm=$n("div",{display:"flex",alignItems:"start"}),Hm=$n("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),$s=$n("div",{display:"flex",alignItems:"center",flexGrow:1}),qm=$n("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Gm=$n("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Gm,null,Ee.createElement(gi,{height:22,width:22,variant:"circular"}),Ee.createElement(Fs,{direction:"horizontal",size:8}),Ee.createElement(gi,{height:15,width:148,variant:"rounded"})),Ee.createElement(Qm,null,Ee.createElement(Bm,{hideSeparator:!e}),Ee.createElement(Hm,{extraSpace:e},Ee.createElement($s,null,Ee.createElement(Vm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Fs,{direction:"horizontal",size:8}),Ee.createElement(gi,{height:12,variant:"rounded"})),Ee.createElement(qm,null,Ee.createElement(dv,{color:"gray",size:16})),Ee.createElement($s,null,Ee.createElement(Vm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Fs,{direction:"horizontal",size:8}),Ee.createElement(gi,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function Fn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Am,{expanded:o,rounded:e!=="basic"},Ot.createElement(Dn,{type:e,tagHidden:n}),Ot.createElement(Nm,null,Ot.createElement(fv,{height:15,variant:"rounded"})),o&&Ot.createElement(Wm,null,Ot.createElement(mv,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i(Fn,"QuoteSkeleton");function To(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:p,selected:u,onClickAllRoutes:d,fullExpandedMode:h=!1,container:g}=t,{inputAmount:f,inputUsdValue:m}=O(),S=e?.outputAmount?new gv(e?.outputAmount):null,k=e?ut(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?hi.createElement(Is,null,hi.createElement(Fn,{tagHidden:l,type:o,expanded:s})):T?hi.createElement(Is,{onClick:()=>c?.(e)},hi.createElement(_s,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:l,selected:u,type:o,expanded:s,onClickAllRoutes:d,fullExpandedMode:h,input:{value:f,usdValue:m?.toString()??""},output:{value:S?.toString()??"",usdValue:k?.toString()??""}})):null}i(To,"QuoteInfo");import{calculatePendingSwap as Cv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as kv}from"react";import{useRef as hv,useState as yv}from"react";var Sv=2e3;function yi({request:t}){let[e,o]=yv(!1),n=hv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,Sv)),await s(l,!1)),"retryFetch"),s=i(async(l,c=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(l,{signal:n.current.signal});return n.current=null,p}catch(p){if(c)return await a(l);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(yi,"useFetch");function Km(){let{fetch:t,loading:e,cancelFetch:o}=yi({request:async(n,r)=>await xt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Km,"useFetchConfirmQuote");function Si(t){if(!t.swaps)throw new Error(ee().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Os(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(Si,"throwErrorIfResponseIsNotValid");function Os(t){if(ru(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=iu(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=cu(t);if(o){let n=_r(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Os,"getQuoteError");function jm(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Uo({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let p=du(e,r,n.blockchains);return p.length===0||(l.balance={messages:p}),l}i(jm,"generateWarnings");function Ci(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(Ci,"handleQuoteErrors");function Us(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:c,customSlippage:p}=y(),u=y().getDisabledLiquiditySources(),d=y().blockchains(),h=y().tokens(),{findToken:g}=y(),f=p||c,{fetch:m,cancelFetch:S,loading:k}=Km();return kv(()=>S,[]),{loading:k,fetch:i(async T=>{let v=T.selectedWallets,b=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((w,x)=>(w[x.chain]=x.address,w),{}),_={requestId:a?.requestId||"",selectedWallets:A,destination:b||void 0};try{return await m(_,!0).then(w=>{let{result:x}=w;if(!x)throw new Error("Error fetching updated route");Si({diagnosisMessages:x.diagnosisMessages,requestId:x.requestId,swaps:x.result?.swaps});let E={outputAmount:x.result?.outputAmount,requestId:x.requestId,resultType:x.result?.resultType,swaps:x.result?.swaps||[],validationStatus:x.validationStatus,requestAmount:x.requestAmount};r(E);let N={slippage:f.toString(),disabledSwappersGroups:u},D=jm({previousQuote:a??void 0,currentQuote:E,meta:{blockchains:d},selectedWallets:v,userSlippage:f,inputUsdValue:n,findToken:g});l();let L=!!D.balance,j=Cv(o.toString(),x,uu(v),N,!L,{blockchains:d,tokens:h});return{quote:E,swap:j,error:null,warnings:D}})}catch(w){return Ci(w)}},"fetch"),cancelFetch:S}}i(Us,"useConfirmSwap");var Wv=bv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Xm}`]:{width:"$48",height:"$48"}}),Bv=Hs({flexGrow:1,paddingRight:"$10"}),Lv=Hs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Mv=Hs({display:"flex",justifyContent:"space-between",alignItems:"center"});function Ym(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=Nv(),[l,c]=On(""),p=!n,[u,d]=On(!1),[h,g]=On(!1),{isActiveTab:f}=re(),m=y().getDisabledLiquiditySources(),S=Av(m),{manager:k}=Tv(),{fetch:C,loading:T,cancelFetch:v}=Us(),[b,A]=On({swap:null,error:null,warnings:null}),[_,w]=On(!1),x=i(async({selectedWallets:W,customDestination:K})=>{let ne=await C?.({selectedWallets:W,customDestination:K});return A(ne),ne},"onConfirmSwap"),E=i(async()=>{if(b.swap&&n)try{await k?.create("swap",{swapDetails:b.swap},{id:b.swap.requestId});let W=`../${$.swaps}/${b.swap.requestId}`;s(W,{replace:!0}),setTimeout(()=>{e("")},0)}catch(W){c("Error: "+W?.message)}},"addNewSwap"),N=i(async()=>{g(!0),await E(),g(!1)},"onConfirm"),D=i(async()=>{b.warnings?.quote&&Yp(b.warnings.quote)&&!a?w(!0):await N()},"onStartConfirmSwap"),L=i(async()=>{A({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(W=>{A(W)}).catch(W=>console.error(W))},"onRefresh");ki(()=>{!!S.current.length&&!m.length&&L(),S.current=m},[m.length]),ki(()=>{p&&v()},[p]),ki(()=>{p&&d(p)},[p]),ki(()=>{p||C({selectedWallets:o,customDestination:r}).then(W=>A(W)).catch(W=>console.error(W))},[]),Iv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let j=b.warnings?.quote??null,R=b.error,Y=[];if(l&&Y.push(Me.createElement(vv,{type:"error",variant:"alarm",title:l})),j||R){let W=`../${$.settings}`;Y.push(Me.createElement(Bn,{warning:j,error:R,couldChangeSettings:!1,refetchQuote:L,showWarningModal:_,confirmationDisabled:!f,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await E()},onChangeSettings:()=>s(W)}))}return Me.createElement(oe,{header:{title:zs.t("Confirm Swap"),onWallet:()=>{let W=`../${$.wallets}`;s(W)}},footer:Me.createElement(Wv,null,Me.createElement("div",{className:Bv()},Me.createElement(wv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!b.error||!f,onClick:D},zs.t("Start Swap"))),Me.createElement(Xm,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!f,onClick:d.bind(null,!0)},Me.createElement(Ev,{size:24})))},u&&Me.createElement(Bd,{open:u,onClose:()=>d(!1),onCancel:v,loading:T,onCheckBalance:x}),Me.createElement(ie,null,Me.createElement("div",{className:Mv()},Me.createElement(xv,{variant:"title",size:"small"},zs.t("You get")),Me.createElement("div",{className:Lv()},Me.createElement(zr,{onClick:!T&&!u&&!_?L:void 0}))),Me.createElement(Qs,{size:"12"}),Bu(Y.map((W,K)=>({element:W,key:`alert-${K}`})),Me.createElement(Qs,{size:10})),Y.length>0?Me.createElement(Qs,{size:10}):null,Me.createElement(To,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:b.error,loading:T,warning:b.warnings?.quote??null})))}i(Ym,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as el,CustomTokensZeroStateDarkIcon as Xv,CustomTokensZeroStateIcon as Yv,DeleteIcon as Zv,Divider as Hn,IconButton as Jv,MessageBox as Rv,NotFound as ew,styled as ol}from"@rango-dev/ui";import de,{useState as tl}from"react";import{useNavigate as tw}from"react-router-dom";import{CloseIcon as _v,IconButton as Dv,SearchIcon as $v,TextField as Fv}from"@rango-dev/ui";import Un from"react";import{styled as Pv}from"@rango-dev/ui";var Zm=Pv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function kt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:c,...p}=t;return Un.createElement(Fv,{prefix:Un.createElement(Zm,null,Un.createElement($v,{color:"black"})),suffix:!!s.length&&Un.createElement(Dv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},Un.createElement(_v,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...p})}i(kt,"SearchInput");import{i18n as Rs}from"@lingui/core";import{darkTheme as cf,Divider as tn,ExternalLinkIcon as zv,Image as Qv,ListItemButton as Hv,NotFound as qv,PinIcon as Gv,Skeleton as pf,Typography as wi,VirtualizedList as Vv}from"@rango-dev/ui";import Q from"react";import{Divider as sf,ListItem as Uv,Skeleton as zn}from"@rango-dev/ui";import Tt from"react";import{css as en,darkTheme as Jm,ImageContainer as Ov,styled as mt,Typography as Rm}from"@rango-dev/ui";var qs=en({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),Gs=en({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Vs=en({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Ks=en({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Jm} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),js=en({}),Xs=en(),ef=mt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Ys=mt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ti=mt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${Gs}`]:{[`& .${Ks}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${js}`]:{bottom:"-15px"},[`& .${qs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Vs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Zs=mt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Js=mt(Rm,{}),tf=mt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Xs}`]:{$$color:"$colors$neutral600",[`.${Jm} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),vi=mt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),oz=mt("div",{display:"flex",alignItems:"center"}),of=mt("div",{position:"relative",[`& ${Ov}`]:{borderRadius:"$xm",overflow:"hidden"}}),nf=mt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),rf=mt(Rm,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),af=mt("a",{"& svg:hover":{color:"$colors$info"}});function lf(t){return Tt.createElement(Ti,null,Array.from(Array(t.size),e=>Tt.createElement(Uv,{key:e,hasDivider:!0,start:Tt.createElement(zn,{variant:"circular",width:35,height:35}),end:Tt.createElement(vi,null,Tt.createElement(zn,{variant:"text",size:"large",width:70}),Tt.createElement(sf,{size:4}),Tt.createElement(zn,{variant:"text",size:"medium",width:50})),title:Tt.createElement("div",null,Tt.createElement(zn,{variant:"text",size:"large",width:90}),Tt.createElement(sf,{size:4}),Tt.createElement(zn,{variant:"text",size:"medium",width:90}))})))}i(lf,"LoadingTokenList");var Kv=20,jv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return Q.createElement("div",{className:Gs()},o?Q.createElement("div",{className:qs()},o):Q.createElement(Ys,{className:Vs()},Q.createElement(wi,{variant:"title",size:"xmedium"},r.symbol),Q.createElement(tn,{direction:"horizontal",size:4}),Q.createElement(Zs,{css:a},Q.createElement(Js,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&Q.createElement("div",{className:`${Ks()} ${!o&&js()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",Q.createElement(tn,{size:4,direction:"horizontal"}),Q.createElement(af,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},Q.createElement(zv,{size:12}))))},"renderDesc");function Qn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,c=y().blockchains(),{getBalanceFor:p,fetchingWallets:u}=y(),{isTokenPinned:d}=y(),h=i(f=>{let m=Sr(p(f));return s?s(f):u?Q.createElement(vi,null,Q.createElement(pf,{variant:"text",size:"large",width:70}),Q.createElement(tn,{size:4}),Q.createElement(pf,{variant:"text",size:"medium",width:50})):m&&Q.createElement(tf,null,Q.createElement(rf,{variant:"title",size:"small"},m.amount),Q.createElement("div",null),m.usdValue&&Q.createElement(wi,{variant:"body",className:Xs(),size:"xsmall"},`$${m.usdValue}`))},"endRenderer"),g=i(()=>Q.createElement(Vv,{itemContent:f=>{let m=e[f],S=m.address||"",k=c.find(b=>b.name===m.blockchain),C=Ka(k.color,"main"),T={$$color:C.main150,[`.${cf} &`]:{$$color:C.main750},backgroundColor:"$$color"},v={$$color:C.main750,[`.${cf} &`]:{$$color:C.main150},color:"$$color"};return Q.createElement("div",{style:{paddingRight:5}},Q.createElement(Hv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":f,key:`${m.symbol}${m.address}`,id:`${m.symbol}${m.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[f]),start:Q.createElement(of,null,Q.createElement(Qv,{src:m.image,size:30}),t.type!=="custom-token"&&d(m,t.type)&&Q.createElement(nf,null,Q.createElement(Gv,{size:12,color:"gray"}))),title:k?.type==="COSMOS"||m.name||!m.name&&!S?Q.createElement(Ys,null,Q.createElement(wi,{variant:"title",size:"xmedium"},m.symbol),Q.createElement(tn,{direction:"horizontal",size:4}),Q.createElement(Zs,{css:T},Q.createElement(Js,{variant:"body",size:"xsmall",css:v},m.blockchain))):void 0,description:k?.info&&S&&k.type!=="COSMOS"?jv({address:S,token:e[f],customCssForTag:T,customCssForTagTitle:v,name:m.name,url:k.info.addressUrl.split("{wallet}").join(S)}):m.name||void 0,end:h(m)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return Q.createElement(Q.Fragment,null,a&&Q.createElement(Q.Fragment,null,Q.createElement(wi,{variant:"label",size:"large"},Rs.t("Select Token")),Q.createElement(tn,{size:4})),Q.createElement(ef,null,Q.createElement(tn,{size:4}),l==="loading"&&Q.createElement(lf,{size:Kv}),l==="success"&&(e.length?Q.createElement(Ti,{as:"ul"},g()):!!o&&Q.createElement(qv,{title:Rs.t("No results found"),description:Rs.t("Try using different keywords")}))))}i(Qn,"TokenList");var ow=ol("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),nw=ol("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),rw=ol(Jv,{"&:hover":{"& svg":{color:"$secondary550"}}});function uf(){let[t,e]=tl(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=qo({}),p=tw(),[u,d]=tl(!1),[h,g]=tl(),f=i(C=>{let T=C.target.value;e(T)},"handleSearch"),m=c==="dark",S=n.filter(C=>et(C.symbol,t)||et(C.address||"",t)||et(C.name||"",t)),k=i(()=>{if(h){let C=a?pt(a):null,T=r?pt(r):null,v=pt(h);C===v?l({token:null}):T===v&&s({token:null}),o(h)}d(!1)},"handleDeleteCustomToken");return de.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},de.createElement(ie,null,de.createElement(ow,null,n.length?de.createElement(de.Fragment,null,de.createElement(kt,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:f}),de.createElement(Hn,{size:16}),de.createElement(Qn,{list:S,type:"custom-token",searchedFor:t,showTitle:!1,action:C=>de.createElement(rw,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),g(C)}},de.createElement(Zv,{size:12,color:"gray"}))})):de.createElement(nw,null,de.createElement(ew,{icon:m?de.createElement(Xv,{size:200}):de.createElement(Yv,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),de.createElement(Hn,{size:20}),de.createElement(el,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},Ut.t("Add Custom Token"))),de.createElement(J,{open:u,dismissible:!0,onClose:()=>d(!1),container:I()},de.createElement(Rv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},de.createElement(Hn,{size:40}),de.createElement(Hn,{size:10}),de.createElement(el,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:k},Ut.t("Yes, Delete it")),de.createElement(Hn,{size:12}),de.createElement(el,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},Ut.t("No, Continue"))))))}i(uf,"CustomTokensPage");import{i18n as qe}from"@lingui/core";import{useManager as ww}from"@rango-dev/queue-manager-react";import{Button as cl,darkTheme as bw,Divider as wo,MessageBox as xw,NotFound as Ew,styled as pl,Typography as Ei}from"@rango-dev/ui";import{TransactionStatus as Vn}from"rango-types";import ae,{useMemo as Wf,useState as Ii}from"react";import{useNavigate as Iw}from"react-router-dom";import{FilterIcon as uw,Popover as dw}from"@rango-dev/ui";import vo from"react";import{css as iw,darkTheme as bi,IconButton as aw,styled as qn}from"@rango-dev/ui";var nl=qn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${bi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),df=qn(aw,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${bi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${bi} &`]:{backgroundColor:"$neutral"},[`& ${nl}::before`]:{backgroundColor:"$secondary100",[`.${bi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),mf=qn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),ff=qn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),gf=iw({display:"flex",justifyContent:"space-between",alignItems:"center"}),hf=qn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as yf}from"@lingui/core";import{Button as sw,Divider as Sf,ListItemButton as lw,Radio as cw,RadioRoot as pw,Typography as Cf}from"@rango-dev/ui";import rt from"react";function kf(t){let{filterBy:e,onClickItem:o}=t;return rt.createElement(ff,null,rt.createElement("div",{className:gf()},rt.createElement(Cf,{size:"small",variant:"body"},yf.t("Status")),rt.createElement(sw,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},yf.t("Reset"))),rt.createElement(Sf,{size:10}),rt.createElement(pw,{value:e},rt.createElement(hf,null,t.list.map((n,r)=>rt.createElement(lw,{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(Cf,{size:"medium",variant:"body"},n.title)),start:rt.createElement(cw,{value:n.id}),onClick:o})))))}i(kf,"FilterSelectorContent");function rl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return vo.createElement("div",null,vo.createElement(dw,{open:a,align:"end",onOpenChange:o,container:I(),content:vo.createElement(kf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},vo.createElement(df,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},vo.createElement(nl,{isSelect:!!n},vo.createElement(uw,{size:16,color:"black"}),!!n&&vo.createElement(mf,null)))))}i(rl,"FilterSelector");import{i18n as gw}from"@lingui/core";import{Divider as xf,GroupedVirtualizedList as hw,Skeleton as yw,SwapListItem as Ef,Typography as Sw}from"@rango-dev/ui";import He,{useCallback as If,useEffect as Cw,useRef as kw,useState as Tw}from"react";function Tf(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(Tf,"calculateGroupsSoFar");import{css as mw,darkTheme as fw,styled as Gn}from"@rango-dev/ui";var il=mw(),vf=Gn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),al=Gn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${il}`]:{$$color:"$colors$neutral600",[`.${fw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),sl=Gn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),wf=Gn("div",{gap:"$10",display:"flex",flexDirection:"column"}),bf=Gn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var vw=10;function ll(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Tw([]),l=kw(0),{swaps:c,groupCounts:p,groups:u}=n(e),d=If(Tf,[]),h=If(()=>{let g=e.length-l.current;g&&(l.current+=Math.min(g,vw),s(d(p,l.current)))},[e.length]);if(Cw(()=>{r||h()},[r,h]),r){let g=[1,2];return He.createElement(He.Fragment,null,[g,g].map((m,S)=>He.createElement(al,{key:S},He.createElement(sl,null,He.createElement(yw,{variant:"text",width:60,size:"small"}),He.createElement(xf,{size:16})),He.createElement(xf,{size:4}),He.createElement(wf,null,m.map((C,T)=>He.createElement(Ef,{isLoading:!0,key:T}))))))}return He.createElement(hw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:g=>He.createElement(al,null,He.createElement(sl,null,He.createElement(Sw,{variant:"label",size:"medium",className:il()},u[g]))),itemContent:(g,f)=>{let m=c[g];if(!m)return null;let S=m.steps[0],k=m.steps[m.steps.length-1];return He.createElement(vf,{key:m.requestId},He.createElement(Ef,{requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,tooltipContainer:I(),onlyShowTime:u[f]===gw.t("Today"),swapTokenData:{from:{token:{image:S.fromLogo,displayName:S.fromSymbol},blockchain:{image:S.fromBlockchainLogo||""},amount:B(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:k.toLogo,displayName:k.toSymbol},blockchain:{image:k.toBlockchainLogo||""},amount:B(k.outputAmount||k.expectedOutputAmountHumanReadable||"",6,6),realAmount:k.outputAmount||k.expectedOutputAmountHumanReadable||""}}}))}})}i(ll,"HistoryGroupedList");import{i18n as xi}from"@lingui/core";import Af from"dayjs";var Nf=i(t=>{let e=new Map([["today",{title:xi.t("Today"),swaps:[]}],["week",{title:xi.t("This week"),swaps:[]}],["month",{title:xi.t("This month"),swaps:[]}],["year",{title:xi.t("This year"),swaps:[]}]]);function o(c,p){e.has(c)||e.set(c,{title:c,swaps:[]}),e.get(c)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Af();t.forEach(c=>{let p=Number(c.creationTime),u=Af(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(c);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(c);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(c);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(c);else{let d=new Date(p).getFullYear().toString();o(d,c)}});let r=Array.from(e.values()).filter(c=>c.swaps.length>0),a=r.flatMap(c=>c.swaps),s=r.map(c=>c.swaps.length),l=r.map(c=>c.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Aw=pl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),Nw=pl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Ww=pl("div",{"._typography":{color:"$neutral700",[`.${bw}&`]:{color:"$neutral900"}}}),Bw=[{id:Vn.SUCCESS,title:qe.t("Complete")},{id:Vn.RUNNING,title:qe.t("Running")},{id:Vn.FAILED,title:qe.t("Failed")}],Lw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Bf(){let t=Iw(),{manager:e,state:o}=ww(),n=dt(e).map(({swap:T})=>T),[r,a]=Ii(""),[s,l]=Ii(!1),c=!o.loadedFromPersistor,[p,u]=Ii(""),[d,h]=Ii(!1),g=i(T=>{let v=T.target.value;a(v)},"handleSearch"),f=Wf(()=>!r&&!p?n:n.filter(T=>{let{inputAmount:v,status:b,steps:A,requestId:_}=T;return(!r||wt(v,r)||wt(b,r)||Lw(A,r)||wt(_,r))&&(!p||p===b)}),[n,r,p]),m=!f?.length&&!c,S=i(()=>h(!1),"onCloseModal"),k=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),C=Wf(()=>!n.some(T=>T.status===Vn.SUCCESS||T.status===Vn.FAILED),[n]);return ae.createElement(oe,{header:{title:qe.t("History"),suffix:ae.createElement(Kt,null,ae.createElement(cl,{id:"widget-history-clear-btn",disabled:C,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(Ei,{size:"medium",variant:"label",color:"error"},qe.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(Nw,null,ae.createElement(kt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:qe.t("Search Transaction"),autoFocus:!0,onChange:g,style:{height:36},value:r}),ae.createElement(wo,{size:10,direction:"horizontal"}),ae.createElement(rl,{filterBy:p,open:s,onOpenChange:T=>l(T),onClickItem:T=>u(T),list:Bw})),ae.createElement(wo,{size:"16"}),ae.createElement(Aw,null,m&&ae.createElement(bf,null,ae.createElement(wo,{size:32}),ae.createElement(Ew,{title:r?qe.t("No results found"):qe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?qe.t("Try using different keywords"):qe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!m&&ae.createElement(ll,{list:f,onSwapClick:t,groupBy:Nf,isLoading:c}))),ae.createElement(J,{open:d,onClose:S,container:I()},ae.createElement(wo,{size:20}),ae.createElement(xw,{type:"warning",title:qe.t("Clear Transaction History"),description:ae.createElement(Ww,null,ae.createElement(Ei,{variant:"body",size:"medium"},qe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(wo,{size:"24"}),ae.createElement(Ei,{variant:"body",size:"small"},qe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(wo,{size:30}),ae.createElement(cl,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:k},qe.t("Yes, Clear the history")),ae.createElement(wo,{size:10}),ae.createElement(cl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:S},ae.createElement(Ei,{variant:"title",size:"medium",color:"primary"},qe.t("No, Cancel")))))}i(Bf,"HistoryPage");import{i18n as ob}from"@lingui/core";import{Button as nb,Divider as Jf,styled as rb,WarningIcon as ib}from"@rango-dev/ui";import ab from"bignumber.js";import Ge,{useEffect as Rf,useState as eg}from"react";import{useNavigate as sb}from"react-router-dom";import{i18n as Mf}from"@lingui/core";import{Alert as Pw,Divider as ul,NoRouteIcon as _w,Typography as Dw}from"@rango-dev/ui";import bo from"react";import{styled as Mw}from"@rango-dev/ui";var Lf=Mw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function dl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Lt(t,e)?bo.createElement(Lf,null,bo.createElement(ul,{size:10}),bo.createElement(_w,{size:24,color:"gray"}),bo.createElement(ul,{size:4}),bo.createElement(Dw,{variant:"title",size:"small"},Mf.t("No Routes Found")),bo.createElement(ul,{size:4}),bo.createElement(Pw,{title:Mf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(dl,"SameTokensWarning");import{i18n as Qw}from"@lingui/core";import{Header as Hw}from"@rango-dev/ui";import Rt,{useEffect as qw,useState as Gw}from"react";import{i18n as Fw}from"@lingui/core";import{Divider as fl,FullExpandedQuote as Ow,Typography as Uw}from"@rango-dev/ui";import Se from"react";import{styled as ml}from"@rango-dev/ui";var Pf=ml("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),_f=ml("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Df=ml("div",{width:"146px"});import{i18n as Kn}from"@lingui/core";import{Select as $w}from"@rango-dev/ui";import $f from"react";function Ai(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:Kn.t("Smart Routing")},{value:"FEE",label:Kn.t("Lowest Fee")},{value:"SPEED",label:Kn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Kn.t("Maximum Return")},{value:"PRICE",label:Kn.t("Maximum Output")}];return $f.createElement(Df,null,$f.createElement($w,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ai,"SelectStrategy");var Ff=3;function jn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:c,quotes:p,updateQuotePartialState:u,fromToken:d,toToken:h,sortStrategy:g,error:f}=O(),{slippage:m,customSlippage:S}=y(),{findToken:k}=y(),C=l||I(),T=!!p&&p.results.length,v=S??m,b=i(w=>{if(!d||!h||!p)return null;let x={requestAmount:p.requestAmount,validationStatus:null,...w};return Uo({currentQuote:x,userSlippage:v,findToken:k})},"getQuoteWarning"),A=f?.type===0||f?.type===1,_=p?.results?Mr(g,p?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(_f,null,Se.createElement(Uw,{size:"xmedium",variant:"title"},Fw.t("Sort by")),Se.createElement(Ai,{container:C})),Se.createElement(fl,{size:"10"})),e&&Array.from({length:Ff},(w,x)=>Se.createElement(Se.Fragment,{key:x},s?Se.createElement(Ow,{loading:!0}):Se.createElement(Fn,{tagHidden:!1,type:"list-item",expanded:!1}),x!==Ff-1&&Se.createElement(fl,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?_.map((w,x)=>{let E=b(w),N=Os(w.swaps),D=_.length-1===x;return Se.createElement(Se.Fragment,{key:w.requestId},Se.createElement(To,{showModalFee:r,container:C,selected:c?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:N?.options||null,warning:E,fullExpandedMode:s,onClick:L=>{N||u("warning",E),u("error",N?.options||null),o(L)},type:"list-item"}),!D&&Se.createElement(fl,{size:16}))}):A&&Se.createElement(Pf,null,Se.createElement(Nn,{size:s?"large":"small",error:f,fetch:n}))))}i(jn,"Quotes");import{darkTheme as zw,styled as Of}from"@rango-dev/ui";var Uf=Of("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${zw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),zf=Of("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Vw=100;function gl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Gw(!1),c=s?"":"is-hidden",{config:p}=y(),u=p?.variant==="full-expanded",d=ao();return qw(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Vw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Rt.createElement(Uf,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${c} ${Gr()}`,id:Fe.EXPANDED_BOX_ID},Rt.createElement(Hw,{title:Qw.t("Routes"),suffix:Rt.createElement(Rt.Fragment,null,Rt.createElement(Ai,{container:d}),Rt.createElement(yo,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Rt.createElement(zf,null,Rt.createElement(jn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:ao(),onClickOnQuote:n,fullExpandedMode:u})))}i(gl,"ExpandedQuotes");import{i18n as jf}from"@lingui/core";import{SwapInput as Xf}from"@rango-dev/ui";import Yw from"bignumber.js";import Xn from"react";import{ReverseIcon as Xw}from"@rango-dev/ui";import yl from"react";import{keyframes as Kw,styled as Qf}from"@rango-dev/ui";var hl=450,jw=Kw({"0%":{transform:"rotateX(0deg) rotateY(0deg) rotateZ(0deg)"},"33%":{transform:"rotateX(0deg) rotateZ(78deg) rotateY(66deg)"},"66%":{transform:"rotateX(0deg) rotateZ(163deg) rotateY(66deg)"},"100%":{transform:"rotateX(0deg) rotateZ(180deg) rotateY(0deg)"}}),Hf=Qf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),qf=Qf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${jw} ${hl}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 Sl(){let t=O.use.switchFromAndTo();return yl.createElement(Hf,null,yl.createElement(qf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},hl),t()}},yl.createElement(Xw,{size:12})))}i(Sl,"SwitchFromAndToButton");import{styled as Gf}from"@rango-dev/ui";var Vf=Gf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Kf=Gf("div",{position:"relative"});function Cl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:p,inputAmount:u,inputUsdValue:d,outputAmount:h,outputUsdValue:g,selectedQuote:f}=O(),{connectedWallets:m,getBalanceFor:S}=y(),k=a?S(a):null,C=Sr(k)?.amount??"0",T=k?new Yw(k.amount).shiftedBy(-k.decimals):ce,v=!!s&&zc(m,s.name),b=!La(f,u,d),A=!La(f,u,g),_=!d||!g||!g.gt(0)?null:Pt(d.toString(),g.toString());return Xn.createElement(Vf,null,Xn.createElement(Kf,null,Xn.createElement(Xf,{label:jf.t("From"),mode:"From",onInputChange:p,balance:C,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:u,usdValue:b?void 0:B(d,4,4),realUsdValue:b?void 0:d?.toString(),error:b?ee().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:I(),onSelectMaxBalance:()=>{let w=B(T,k?.decimals),x=k?.amount?w.split(",").join(""):"";p(x)},anyWalletConnected:m.length>0}),Xn.createElement(Sl,null)),Xn.createElement(Xf,{sharpBottomStyle:!r&&(!!f||e),label:jf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(Pt(d,g),2,2),warningLevel:_t(_??0),price:{value:B(h,6,6),usdValue:A?void 0:B(g,4,4),realValue:h?.toString(),realUsdValue:A?void 0:g?.toString(),error:A?ee().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:I()}))}i(Cl,"Inputs");import{useCallback as Zw,useEffect as Jw,useRef as Rw,useState as eb}from"react";function Yf(){let{fetch:t,loading:e,cancelFetch:o}=yi({request:async(n,r)=>await xt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Yf,"useFetchAllQuotes");var tb=600;function Ni({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Yf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),l=a.some(Ie=>Ie.isContractWallet),{fromToken:c,toToken:p,inputAmount:u,inputUsdValue:d,selectedQuote:h,sortStrategy:g,resetQuote:f,error:m,warning:S,setSelectedQuote:k,updateQuotePartialState:C}=O(),{slippage:T,customSlippage:v,affiliatePercent:b,affiliateRef:A,affiliateWallets:_,fetchStatus:w}=y(),x=y().getLiquiditySources(),E=y().getDisabledLiquiditySources(),N=y().excludeLiquiditySources(),{findToken:D}=y(),[L,j]=eb(!0),R=Rw(u),Y=v??T,K=!c||!p||Lt(c,p)||!pn(u),ne=i(Ie=>{j(Ie)},"resetState"),V=i(Ie=>{let{fromToken:Ke,toToken:se,inputAmount:lt,liquiditySources:q,excludeLiquiditySources:M,disabledLiquiditySources:H,slippage:G,affiliateRef:ge,affiliatePercent:le,affiliateWallets:De}=Ie;if(L||ne(!0),!K&&Ke&&se){f();let je=pu({fromToken:Ke,toToken:se,inputAmount:lt,liquiditySources:q,excludeLiquiditySources:M,disabledLiquiditySources:H,wallets:a,slippage:G,affiliateRef:ge,affiliatePercent:le,affiliateWallets:De,contractCall:l});Lo("experimental",r)&&(je.experimental=!0),Lo("avoidNativeFee",r)&&(je.avoidNativeFee=!0),Lo("enableCentralizedSwappers",r)&&(je.enableCentralizedSwappers=!0),r?.maxLength&&(je.maxLength=r.maxLength),e(je).then(ke=>{let $e=Mr(g,ke.results),Gt=Jp(h,$e,ke.requestAmount);j(!1),C("quotes",ke),k(Gt),Si({diagnosisMessages:ke.diagnosisMessages,requestId:Gt?.requestId||"",swaps:Gt?.swaps});let ro=Gt&&Uo({currentQuote:Gt,userSlippage:Y,findToken:D});C("warning",ro)}).catch(ke=>{let{error:$e}=Ci(ke);($e?.type===0||$e?.type===1)&&f(),$e?.type!==2&&(C("error",$e),j(!1))})}},"fetch"),fe=Zw(Nc(Ie=>{V(Ie)},tb),[K]);return Jw(()=>{if(!t){j(!1);return}if(w!=="success")return;if(K){j(!1),(h||m||S)&&f();return}if(!pn(u)||d?.eq(0)){ne(!1),o();return}f(),ne(!0);let Ie=V;return R.current&&R.current!=u&&(Ie=fe),R.current=u,Ie({inputAmount:u,fromToken:c,toToken:p,liquiditySources:x,excludeLiquiditySources:N,disabledLiquiditySources:E,slippage:Y,affiliateRef:A,affiliatePercent:b,affiliateWallets:_,contractCall:l}),o},[w,u,c?.symbol,c?.address,c?.blockchain,p?.symbol,p?.address,p?.blockchain,K,x?.length,n,E.length,Y,A,b,l,JSON.stringify(_)]),{fetch:()=>V({inputAmount:u,fromToken:c,toToken:p,liquiditySources:x,excludeLiquiditySources:N,disabledLiquiditySources:E,slippage:Y,affiliateRef:A,affiliatePercent:b,affiliateWallets:_,contractCall:l}),loading:L}}i(Ni,"useSwapInput");function Zf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};he.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Zf,"emitPreventableEvent");var lb=rb("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),cb=300;function tg(){let t=sb(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:h}=O(),[g,f]=eg(!1),{isLargeScreen:m,isExtraLargeScreen:S}=ci(),{fetch:k,loading:C}=Ni({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:b}=y(),{isActiveTab:A}=re(),[_,w]=eg(!1),E=au({fetchMetaStatus:v,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:b.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),N=jc(m,S,T?.variant),D=!!n&&!!e&&!!o&&new ab(n).gt(0)&&!yu(e,o),L=D&&v==="success"&&C,Y=(!N||N&&c?.results.length)&&(l||s);Rf(()=>{u(),h("refetchQuote",!0)},[]),Rf(()=>{f(D)},[D]);let W=(r||s)&&!_?k:void 0,K=i(V=>{N&&g?(f(!1),setTimeout(()=>{t(V)},cb)):t(V)},"onHandleNavigation"),ne=i(V=>{r?.requestId!==V.requestId&&(w(!1),p(V))},"onClickOnQuote");return Ge.createElement(lb,null,Ge.createElement(oe,{height:"auto",footer:Ge.createElement(nb,{id:`widget-swap-${E.action}-btn`,type:"primary",size:"large",disabled:E.disabled||!A,prefix:E.action==="confirm-warning"&&Ge.createElement(ib,null),fullWidth:!0,onClick:()=>{E.action==="connect-wallet"?Zf({type:"clickConnectWallet"},()=>K($.wallets)):E.action==="confirm-warning"?w(!0):K($.confirmSwap)}},E.title),header:{onWallet:()=>{K($.wallets)},hasBackButton:!1,title:T.title||ob.t("Swap"),suffix:Ge.createElement(yo,{hidden:N?["refresh"]:void 0,onClickRefresh:W,onClickHistory:()=>K($.swaps),onClickSettings:()=>{K($.settings)}})}},Ge.createElement(ie,null,Ge.createElement(Cl,{fetchingQuote:L,fetchMetaStatus:v,isExpandable:N,onClickToken:V=>{K(V==="from"?$.fromSwap:$.toSwap)}}),Ge.createElement(Jf,{size:"2"}),N?null:Ge.createElement(To,{quote:r,loading:L,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),K($.routes)}:void 0}),Y?Ge.createElement(Ge.Fragment,null,Ge.createElement(Jf,{size:"10"}),Ge.createElement(Bn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:k,showWarningModal:_,confirmationDisabled:!A,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),d(!0),K($.confirmSwap)},onChangeSettings:()=>K($.settings)})):null,Ge.createElement(dl,null))),N?Ge.createElement(gl,{loading:L,onClickOnQuote:ne,fetch:k,onClickRefresh:W,isVisible:g}):null)}i(tg,"Home");import{i18n as og}from"@lingui/core";import{Alert as pb,Divider as ub,List as db,ListItemButton as mb,Radio as fb,RadioRoot as gb,Typography as hb}from"@rango-dev/ui";import Wt from"react";function eo(){let{setLanguage:t,language:e,config:o}=y(),n=Rc,r=o?.language||Mo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Mo),resetLanguage:()=>t(null)}}i(eo,"useLanguage");function ng(){let{activeLanguage:t,changeLanguage:e,languages:o}=eo(),n=Ze(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(hb,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(fb,{value:s}),start:Wt.createElement(c,null)}});return Wt.createElement(oe,{header:{title:og.t("Language")}},Wt.createElement(ie,null,Wt.createElement(pb,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(ub,{size:"8"}),Wt.createElement(gb,{value:t},Wt.createElement(db,{type:Wt.createElement(mb,{title:og.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(ng,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as Tb,Checkbox as vb,Image as wb,ListItemButton as bb,NotFound as xb,Typography as Eb}from"@rango-dev/ui";import Ve,{useState as Ib}from"react";import{Checkbox as Cb,Skeleton as ig}from"@rango-dev/ui";import Zn from"react";import{styled as kl}from"@rango-dev/ui";var Yn=kl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Tl=kl("div",{width:80,display:"flex",justifyContent:"flex-end"}),vl=kl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as yb,styled as Sb}from"@rango-dev/ui";var rg=Sb(yb,{height:61});var kb=30;function wl(){return Zn.createElement(Yn,null,Array.from(Array(kb),(t,e)=>Zn.createElement(rg,{hasDivider:!0,key:e,start:Zn.createElement(ig,{variant:"circular",width:35,height:35}),title:Zn.createElement(ig,{variant:"text",size:"large",width:90}),end:Zn.createElement(Cb,{checked:!1})})))}i(wl,"LoadingLiquiditySourceList");function bl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=Ib(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=Tr(o,n),p={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=c.filter(k=>u.includes(k.type)),h=d.length===d.filter(k=>k.selected).length,g=i(()=>{d.forEach(k=>{h?s(k.groupTitle):k.selected||s(k.groupTitle)})},"toggleAllSources"),f=d.map(k=>{let{selected:C,groupTitle:T,logo:v,id:b,...A}=k;return{id:`widget-setting-liquidity-source-${b.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ve.createElement(wb,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ve.createElement(vb,{checked:C,disabled:l}),title:Ve.createElement(Eb,{variant:"title",size:"xmedium"},zt.t(T)),selected:C,groupTitle:T,logo:v,...A}}),m=i(k=>{let C=k.target.value;a(C)},"handleSearch"),S=f;return r&&(S=f.filter(k=>wt(k.groupTitle,r))),Ve.createElement(oe,{header:{title:zt.t(t),suffix:Ve.createElement(Tl,null,Ve.createElement(Tb,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:g},h?zt.t("Deselect all"):zt.t("Select all")))}},Ve.createElement(ie,{view:!0},Ve.createElement(kt,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ve.createElement(wl,null),!S.length&&r?Ve.createElement(vl,null,Ve.createElement(xb,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ve.createElement(Yn,{disabled:l},S.map(k=>{let{groupTitle:C,...T}=k;return Ve.createElement(Ve.Fragment,{key:k.id},Ve.createElement(bb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(bl,"LiquiditySourcePage");import{i18n as Ab}from"@lingui/core";import Wi from"react";import{useNavigate as Nb}from"react-router-dom";function ag(){let t=Nb(),e=Ze(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=Ni({refetchQuote:n}),p=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Wi.createElement(oe,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Ab.t("Routes"),suffix:Wi.createElement(yo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Wi.createElement(ie,null,Wi.createElement(jn,{fetch:l,loading:c,onClickOnQuote:p})))}i(ag,"RoutesPage");import{i18n as mg}from"@lingui/core";import{Divider as fg,getCategoriesCount as Ob,SelectableCategoryList as Ub}from"@rango-dev/ui";import Qt,{useState as gg}from"react";import{useNavigate as zb}from"react-router-dom";import{i18n as xl}from"@lingui/core";import{Divider as Mb,Image as Pb,ListItemButton as _b,NotFound as Db,Typography as dg}from"@rango-dev/ui";import it,{useEffect as $b,useState as Fb}from"react";var sg=i((t,e,o)=>t.filter(n=>mr(n.type,o)).filter(n=>et(n.name,e)||et(n.displayName,e)),"filterBlockchains");import{ImageContainer as Wb,styled as lg}from"@rango-dev/ui";var cg=lg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Bi=lg(xn,{padding:0,margin:0,listStyle:"none",[`& ${Wb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Bb,Skeleton as pg}from"@rango-dev/ui";import Li from"react";var Lb=20;function ug(){return Li.createElement(Bi,null,Array.from(Array(Lb),t=>Li.createElement(Bb,{key:t,hasDivider:!0,start:Li.createElement(pg,{variant:"circular",width:35,height:35}),title:Li.createElement(pg,{variant:"text",size:"large",width:90})})))}i(ug,"LoadingBlockchainList");function El(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Fb(e),{fetchStatus:c}=y();$b(()=>{l([...sg(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?it.createElement(Db,{title:xl.t("No results found"),description:xl.t("Try using different keywords")}):it.createElement(Bi,{as:"ul",key:`${r}-${o}`},s.map(u=>it.createElement(_b,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:it.createElement(Pb,{src:u.logo,size:30}),title:it.createElement(dg,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return it.createElement(it.Fragment,null,a&&it.createElement(it.Fragment,null,it.createElement(dg,{variant:"label",size:"large"},xl.t("Select Chain")),it.createElement(Mb,{size:4})),it.createElement(cg,null,c==="loading"&&it.createElement(ug,null),c==="success"&&p()))}i(El,"BlockchainList");function Mi(t){let{type:e}=t,o=Ze(),[n,r]=gg(""),[a,s]=gg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:p}=y(),u=zb(),d=y().blockchains({type:e}),h=Ob(d),g=!t.hideCategory&&h!==1;return Qt.createElement(oe,{header:{title:mg.t("Select Chain")}},Qt.createElement(ie,{view:!0},g&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Ub,{setCategory:s,category:a,blockchains:d,isLoading:p==="loading"}),Qt.createElement(fg,{size:24})),Qt.createElement(kt,{value:n,autoFocus:!0,placeholder:mg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Qt.createElement(fg,{size:16}),Qt.createElement(El,{list:d,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?u(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?c(f):l(f),o())}})))}i(Mi,"SelectBlockchainPage");import{i18n as _i}from"@lingui/core";import{Divider as Tg}from"@rango-dev/ui";import xo,{useState as Xb}from"react";import{useNavigate as Yb}from"react-router-dom";import{i18n as Nl}from"@lingui/core";import{BlockchainsChip as Pi,Divider as Cg,Image as kg,Skeleton as Vb,Tooltip as Kb,Typography as Wl}from"@rango-dev/ui";import Pe from"react";import{useEffect as qb}from"react";var hg=["ETH","COSMOS","OSMOSIS"];function Il(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Qb),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let c=0;c<=l;c++){let p=n[c];s=s.filter(u=>p.name!==u)}}n.sort(Hb(s)),r=n.splice(a)}return{list:n,more:r}}i(Il,"prepare");function Qb(t,e){let o=hg,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(Qb,"sortByMostUsedBlockchains");function Hb(t){return i(function(o,n){let r=t.findIndex(c=>c===o.name),a=t.findIndex(c=>c===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(Hb,"generateSortByPreferredBlockchainsFor");function yg(t,e){return!!e.list.find(o=>o.name===t)}i(yg,"isInVisibleList");function Al(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();qb(()=>{if(e?.selected){let a=Il(t,o,e);yg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Il(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Al,"usePrepareBlockchainList");import{styled as Gb}from"@rango-dev/ui";var Sg=Gb("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var jb=12;function Bl(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Al(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),p=O.use.resetFromBlockchain(),u=s.more.length>0,d=s.more.length===1,h=!d&&u;return Pe.createElement(Pe.Fragment,null,Pe.createElement(Cg,{size:12}),Pe.createElement(Wl,{variant:"label",size:"large"},Nl.t("Select Chain")),Pe.createElement(Cg,{size:12}),Pe.createElement(Sg,null,l==="loading"&&Array.from(Array(jb),g=>Pe.createElement(Vb,{key:g,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Pi,{selected:!n,onClick:()=>{o==="from"?p():c()}},Pe.createElement(Wl,{variant:"body",size:"xsmall",color:"secondary500"},Nl.t("All"))),s.list.map(g=>Pe.createElement(Kb,{key:g.name,content:g.shortName,side:"bottom",sideOffset:2,container:I()},Pe.createElement(Pi,{key:g.name,selected:!!n&&n.name===g.name,onClick:()=>r(g)},Pe.createElement(kg,{src:g.logo,size:30})))),d?Pe.createElement(Pi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(kg,{src:s.more[0].logo,size:30})):null,h?Pe.createElement(Pi,{onClick:a,key:"more-blockchains"},Pe.createElement(Wl,{variant:"body",size:"xsmall",color:"secondary500"},Nl._("More +{count}",{count:s.more.length}))):null)))}i(Bl,"BlockchainsSection");function Ll(t){let{type:e}=t,o=Yb(),n=Ze(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:p}=O(),{getBalanceFor:u}=y(),[d,h]=Xb(""),f=(e==="source"?r:a)?.name??"",m=y().blockchains({type:e}),S=y().tokens({type:e,blockchain:f,searchFor:d,getBalanceFor:u}),k=i(v=>{e==="source"?c(v):p(v)},"updateBlockchain"),C=i(v=>{e==="source"?s({token:v,meta:{blockchains:m,tokens:S}}):l({token:v,meta:{blockchains:m,tokens:S}})},"updateToken"),T={source:_i.t("Source"),destination:_i.t("Destination")};return xo.createElement(oe,{header:{title:_i.t("Swap {type}",{type:T[e]})}},xo.createElement(ie,null,xo.createElement(Bl,{blockchains:m,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{k(v)}}),xo.createElement(Tg,{size:24}),xo.createElement(kt,{value:d,autoFocus:!0,placeholder:_i.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),xo.createElement(Tg,{size:16}),xo.createElement(Qn,{list:S,selectedBlockchain:f,searchedFor:d,type:e,onChange:v=>{C(v);let b=m.find(A=>v.blockchain===A.name);b&&k(b),n()}})))}i(Ll,"SelectSwapItemsPage");import{i18n as _l}from"@lingui/core";import{Alert as vx,Button as wx,styled as bx}from"@rango-dev/ui";import Eo from"react";import{useInRouterContext as xx,useSearchParams as Ex}from"react-router-dom";import{i18n as Ig}from"@lingui/core";import{Divider as Ag,InfoIcon as ex,SlippageIcon as tx,TextField as ox,Tooltip as nx,Typography as Ng}from"@rango-dev/ui";import at from"react";import{Chip as Zb,styled as Jn,TextField as Jb}from"@rango-dev/ui";var vg=Jn("div",{paddingTop:"$5",padding:"$10 $5"}),wg=Jn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Jb}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),bg=Jn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Di=Jn("div",{maxWidth:"280px",padding:"$10"}),xg=Jn(Zb,{width:"61px",flexShrink:0});import{i18n as Ml}from"@lingui/core";import{Typography as Rb}from"@rango-dev/ui";import Rn from"react";function Eg(){return Rn.createElement(Di,null,Rn.createElement(Rb,{variant:"label",size:"medium",color:"neutral700"},Ml.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Rn.createElement("br",null),Rn.createElement("br",null),Rn.createElement("b",null,Ml.t("Warning")),":\xA0",Ml.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(Eg,"SlippageTooltipContent");function Pl(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return at.createElement(vg,null,at.createElement(bg,null,at.createElement(tx,{size:16,color:"gray"}),at.createElement(Ag,{direction:"horizontal",size:4}),at.createElement(Ng,{variant:"title",size:"xmedium"},Ig.t("Slippage tolerance per swap")),at.createElement(Ag,{direction:"horizontal",size:4}),at.createElement(nx,{container:I(),side:"top",sideOffset:4,content:at.createElement(Eg,null)},at.createElement(ex,{color:"gray"}))),at.createElement(wg,null,ep.map((r,a)=>{let s=`slippage-${a}`;return at.createElement(xg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),at.createElement(ox,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=rp&&s<=np?n(s):n(null)},suffix:o&&at.createElement(Ng,{variant:"body",size:"small"},"%"),placeholder:Ig.t("Custom")})))}i(Pl,"Slippage");import{i18n as ft}from"@lingui/core";import{AutoThemeIcon as Wg,BridgesIcon as rx,ChevronRightIcon as $i,DarkModeIcon as Bg,Divider as er,ExchangeIcon as ix,InfinityIcon as ax,InfoIcon as sx,LanguageIcon as lx,LightModeIcon as Lg,List as cx,ListItem as px,ListItemButton as ux,Skeleton as dx,styled as mx,Switch as fx,Tabs as gx,TargetIcon as hx,Tooltip as yx,Typography as Re}from"@rango-dev/ui";import P from"react";import{useNavigate as Sx}from"react-router-dom";var Cx=mx("div",{width:"202px",height:"$40"}),kx=[{id:"light",icon:P.createElement(Lg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},ft.t("Light"))},{id:"dark",icon:P.createElement(Bg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},ft.t("Dark"))},{id:"auto",icon:P.createElement(Wg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},ft.t("Auto"))}],Tx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return P.createElement(Wg,{...e});case"dark":return P.createElement(Bg,{...e});default:return P.createElement(Lg,{...e})}},"getThemeIcon");function Mg(){let t=Sx(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=eo(),s=a.find(W=>W.local===r)?.label,l=y().fetchStatus,c=y().swappers(),p=y().getDisabledLiquiditySources(),{config:{features:u}}=y(),d=y().customTokens(),h=Xe("theme",u),g=Xe("liquiditySource",u),f=Xe("language",u),m=Xe("customTokens",u),S=y().infiniteApprove,k=y().toggleInfiniteApprove,C=Tr(c,p),T=C.filter(W=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(W.type)),v=T.length,b=T.filter(W=>W.selected).length,A=C.filter(W=>W.type==="DEX"),_=A.length,w=A.filter(W=>W.selected).length,x=i((W,K)=>{switch(l){case"loading":return P.createElement(dx,{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"},`${W} / ${K}`)}},"handleSwapperEndItem"),E={id:"widget-setting-bridge-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Bridges")),end:P.createElement(P.Fragment,null,x(b,v),P.createElement(er,{direction:"horizontal",size:8}),P.createElement($i,{color:"black"})),onClick:()=>t($.bridges),start:P.createElement(rx,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Exchanges")),end:P.createElement(P.Fragment,null,x(w,_),P.createElement(er,{direction:"horizontal",size:8}),P.createElement($i,{color:"black"})),start:P.createElement(ix,{color:"gray",size:16}),onClick:()=>t($.exchanges)},D={id:"widget-setting-custom-tokens-item-btn",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"},`${d.length}`),P.createElement(er,{direction:"horizontal",size:8}),P.createElement($i,{color:"black"})),start:P.createElement(hx,{color:"gray",size:16}),onClick:()=>t($.customTokens)},L={id:"widget-setting-language-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Language")),start:P.createElement(lx,{color:"gray",size:16}),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},s),P.createElement(er,{direction:"horizontal",size:8}),P.createElement($i,{color:"black"})),onClick:()=>t($.languages)},j={id:"widget-setting-infinite-approval-item-btn",title:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Infinite approval")),P.createElement(er,{direction:"horizontal",size:4}),P.createElement(yx,{side:"top",sideOffset:4,container:I(),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(sx,{color:"gray"}))),start:P.createElement(ax,{color:"gray",size:16}),end:P.createElement(fx,{checked:S}),onClick:k},R={id:"widget-setting-theme-item-btn",type:P.createElement(px,null),title:P.createElement(Re,{variant:"title",size:"xmedium"},ft.t("Theme")),end:P.createElement(Cx,null,P.createElement(gx,{container:I(),items:kx,value:n,onChange:W=>o(W.id),type:"primary",borderRadius:"small"})),start:Tx(n)},Y=g?[]:[E,N];return m||Y.push(D),f||Y.push(L),Y.push(j),!e?.singleTheme&&!h&&Y.push(R),P.createElement(cx,{type:P.createElement(ux,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Y})}i(Mg,"SettingsLists");var Ix=bx("div",{paddingLeft:"$8"});function Pg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Ex(),r=xx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Eo.createElement(oe,{header:{title:_l.t("Settings")}},Eo.createElement(ie,null,o&&Eo.createElement(vx,{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(Ix,null,Eo.createElement(wx,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},_l.t("Reset")))}),Eo.createElement(Pl,null),Eo.createElement(Mg,null)))}i(Pg,"SettingsPage");import{i18n as gE}from"@lingui/core";import{cancelSwap as hE}from"@rango-dev/queue-manager-rango-preset";import{useManager as yE}from"@rango-dev/queue-manager-react";import{Alert as SE}from"@rango-dev/ui";import Jl from"react";import{useParams as CE}from"react-router-dom";import{i18n as st}from"@lingui/core";import{getCurrentNamespaceOfOrNull as Yx,getCurrentStep as Zx,getRelatedWalletOrNull as Jx}from"@rango-dev/queue-manager-rango-preset";import{Button as fh,CopyIcon as Rx,Divider as eE,DoneIcon as tE,IconButton as oE,QuoteCost as nE,RangoExplorerIcon as rE,StepDetails as iE,Tooltip as gh,Typography as Io,useCopyToClipboard as aE}from"@rango-dev/ui";import{useWallets as sE}from"@rango-dev/wallets-react";import hh from"bignumber.js";import{PendingSwapNetworkStatus as Gi}from"rango-types";import X,{useEffect as yh,useRef as lE,useState as Sh}from"react";import{useNavigate as cE}from"react-router-dom";import{i18n as to}from"@lingui/core";var Ax=[to.t("Sunday"),to.t("Monday"),to.t("Tuesday"),to.t("Wednesday"),to.t("Thursday"),to.t("Friday"),to.t("Saturday")];function _g(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?to.t("Today"):`${Ax[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(_g,"timeSince");function Dg(t){return t.finishTime?_g(parseInt(t.finishTime)):_g(parseInt(t.creationTime))}i(Dg,"getSwapDate");import{PendingSwapNetworkStatus as Ui}from"rango-types";import zi from"react";import{i18n as Fi}from"@lingui/core";import{Button as $g,Divider as Dl,MessageBox as Nx}from"@rango-dev/ui";import oo from"react";var Fg=i(({onCancel:t,onClose:e})=>oo.createElement(oo.Fragment,null,oo.createElement(Dl,{size:20}),oo.createElement(Nx,{type:"error",title:Fi.t("Cancel Swap"),description:Fi.t("Are you sure you want to cancel this swap?")}),oo.createElement(Dl,{size:32}),oo.createElement($g,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Fi.t("Yes, Cancel it")),oo.createElement(Dl,{size:12}),oo.createElement($g,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Fi.t("No, Continue"))),"CancelContent");import{i18n as Oi}from"@lingui/core";import{Button as Og,Divider as $l,MessageBox as Wx,Typography as Bx}from"@rango-dev/ui";import Ht from"react";var Ug=i(({onDelete:t,onClose:e})=>Ht.createElement(Ht.Fragment,null,Ht.createElement($l,{size:20}),Ht.createElement(Wx,{type:"error",title:Oi.t("Delete Transaction"),description:Oi.t("Are you sure you want to delete this swap?")}),Ht.createElement($l,{size:32}),Ht.createElement(Og,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Oi.t("Yes, Delete it")),Ht.createElement($l,{size:12}),Ht.createElement(Og,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Ht.createElement(Bx,{variant:"title",size:"medium",color:"primary"},Oi.t("No, Cancel")))),"DeleteContent");import{i18n as Fl}from"@lingui/core";import{PendingSwapNetworkStatus as Ol}from"rango-types";var Ul={[Ol.WaitingForNetworkChange]:{type:"loading",title:Fl.t("Change Network")},[Ol.WaitingForConnectingWallet]:{type:"warning",title:Fl.t("Connect Wallet")},[Ol.NetworkChanged]:{type:"success",title:Fl.t("Network Changed")}};import{warn as Lx}from"@rango-dev/logging-core";import{MessageBox as Mx,Wallet as Px}from"@rango-dev/ui";import{useWallets as _x}from"@rango-dev/wallets-react";import on,{useState as Dx}from"react";import{styled as zl}from"@rango-dev/ui";var zg=zl("div",{display:"flex",justifyContent:"center"}),D5=zl("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}}),Qg=zl("img",{width:"100%"});var Hg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=Dx(),{getWalletInfo:p,state:u}=_x(),d=n?.walletType,h=d?un(u(d)):null,g=d?p(d):null,f=a&&!!d&&!!h&&!!g,{list:m}=gt(),S=i(()=>{if(d){let k=m.find(C=>C.type===d);k?c(k):Lx(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${k}`))}},"handleWalletItemClick");return on.createElement(on.Fragment,null,on.createElement(Mx,{type:e,title:o,description:r}),f&&on.createElement(zg,null,on.createElement(Px,{container:I(),title:g.name,image:g.img,type:d,state:h,link:g.installLink,disabled:s,onClick:S})),on.createElement(mo,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function Ql(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===Ui.WaitingForNetworkChange||e===Ui.WaitingForConnectingWallet||e===Ui.NetworkChanged;return zi.createElement(J,{open:!!e,onClose:o,container:document.getElementById(Fe.SWAP_BOX_ID)||document.body},c&&zi.createElement(Hg,{type:Ul[e].type,title:Ul[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Ui.WaitingForNetworkChange}),e==="delete"&&zi.createElement(Ug,{onClose:o,onDelete:n}),e==="cancel"&&zi.createElement(Fg,{onClose:o,onCancel:r}))}i(Ql,"SwapDetailsModal");import{i18n as tr}from"@lingui/core";import{Button as Hl,Divider as or,MessageBox as Vg,TokenAmount as $x,Typography as Kg}from"@rango-dev/ui";import me from"react";import{Link as Fx,useNavigate as Ox}from"react-router-dom";var qg="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",Gg="/profile";function ql(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:p,percentageChange:u,description:d,diagnosisUrl:h}=t,g=Ox(),{showProfileBanner:f}=re();return me.createElement(J,{open:e,onClose:o,container:document.getElementById(Fe.SWAP_BOX_ID)||document.body},n==="success"?me.createElement(Vg,{type:"success",title:tr.t("Swap Successful")},me.createElement($x,{direction:"vertical",tooltipContainer:I(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:p,percentageChange:u}),me.createElement(or,{size:12}),me.createElement(Kg,{variant:"body",size:"medium",color:"neutral700",align:"center"},d)):me.createElement(Vg,{type:"error",title:tr.t("Transaction Failed"),description:d}),me.createElement(or,{size:30}),n==="success"&&me.createElement(me.Fragment,null,f&&me.createElement(me.Fragment,null,me.createElement(Fx,{to:Gg},me.createElement(Qg,{src:qg,alt:"Profile Banner"})),me.createElement(or,{size:30})),me.createElement(Hl,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{g("../../")}},tr.t("Done"))),me.createElement(or,{size:12}),h&&me.createElement(me.Fragment,null,me.createElement(Hl,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},tr.t("Diagnosis")),me.createElement(or,{size:12})),me.createElement(Hl,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},me.createElement(Kg,{variant:"title",size:"medium",color:"primary"},tr.t("See Details"))))}i(ql,"SwapDetailsCompleteModal");import Xx from"react";import{i18n as Gx}from"@lingui/core";import{Alert as ph,IconButton as Vx,LinkIcon as Kx}from"@rango-dev/ui";import no,{Fragment as jx}from"react";import{Alert as zx,ChevronDownIcon as Qx,IconButton as Hx}from"@rango-dev/ui";import rn,{useState as qx}from"react";import{css as nr,darkTheme as jg,styled as qt,Typography as Ux}from"@rango-dev/ui";var Xg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Qi=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${jg} &`]:{color:"$secondary500"}}}}}),Yg=qt(xn,{padding:"$0 $20 $20 $20"}),wK=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Zg=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),bK=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),nn=nr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${jg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Jg=nr({padding:"$5 0"}),Hi=nr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Rg=nr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),eh=nr({width:"100%",padding:"0 $20 $10"}),th=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),oh=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),qi=qt(Ux,{wordBreak:"break-word"});import{styled as Gl}from"@rango-dev/ui";var nh=Gl("div",{display:"flex",flexDirection:"column",gap:"$10"}),rh=Gl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),ih=Gl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function ah(t){let{message:e}=t,[o,n]=qx(!1);return rn.createElement(zx,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&rn.createElement(Hx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},rn.createElement(rh,{rotated:o},rn.createElement(Qx,{size:12,color:"gray"}))),footer:rn.createElement(ih,{open:o},rn.createElement(qi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(ah,"FailedAlert");import{i18n as sh}from"@lingui/core";import{Alert as Vl,Button as lh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Kl}from"rango-types";import rr from"react";function ch(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?rr.createElement(Vl,{type:"warning",title:n.shortMessage,action:rr.createElement(lh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Kl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},sh.t("Change"))}):r===Kl.WaitingForConnectingWallet?rr.createElement(Vl,{type:"warning",title:n.shortMessage,action:rr.createElement(lh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Kl.WaitingForConnectingWallet)}},sh.t("Connect"))}):rr.createElement(Vl,{type:"warning",title:n.shortMessage})}i(ch,"WarningAlert");function jl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=wn(a),c=a.status==="waitingForApproval"&&!l,p=a.status==="running"&&!l,u=p&&!s||c&&!a.explorerUrl?.length;return no.createElement(nh,null,a.explorerUrl?.map((d,h,g)=>{let f=h+d.url,m=h===g.length-1,S=(m&&p||c)&&!u,k=m&&a.status==="failed";return no.createElement(jx,{key:f},no.createElement(ph,{type:m&&(S&&"loading"||k&&"error")||"success",title:d.description?`${d.description} Tx`:Gx.t("View transaction"),action:d.url&&no.createElement(Vx,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(d.url,"_blank")},no.createElement(Kx,{size:12}))}))}),u&&no.createElement(ph,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&no.createElement(ch,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&no.createElement(ah,{message:r}))}i(jl,"SwapDetailsAlerts");var uh=2e3;var dh=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:ct(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:ct(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:an(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:ct(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:ct(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:an(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:Xx.createElement(jl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function mh(t){if(wn(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(mh,"getStepState");function Xl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=sE(),c=y().blockchains(),p=y().swappers(),{findToken:u}=y(),d=O.use.retry(),h=re.use.isActiveTab(),g=cE(),[f,m]=aE(uh),S=lE(null),[k,C]=Sh(null),[T,v]=Sh(null),b=i(()=>{r(),C(null)},"onCancel"),A=we.use.getNotifications(),_=we.use.removeNotification(),w=A(),x=Zx(e),E=x?.networkStatus;yh(()=>{w.find($e=>$e.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),_(e.requestId)):T&&v(null))},[e.status,e.requestId]),yh(()=>{W?C(Gi.WaitingForNetworkChange):E===Gi.WaitingForConnectingWallet||E===Gi.NetworkChanged?C(E):C(null)},[E]);let N=fu(e),D=x?Yx(e,x):null,L=x?Jx(e,x):null,j=Dg(e),R=gu(e),Y=i(ke=>!!l(ke)?.mobileWallet,"isMobileWallet"),W=E===Gi.WaitingForNetworkChange&&!!D&&!!L?.walletType&&(Y(L.walletType)||a(L.walletType,D.network)),K=W?s.bind(null,L.walletType,[{namespace:D.namespace,network:D.network}]):void 0,ne=mu(e,x),V=dh({swap:e,switchNetwork:K,showNetworkModal:E,setNetworkModal:C,message:ne,blockchains:c,swappers:p}),fe=V.length,[Ie,Ke]=[e.steps[0],e.steps[fe-1]],se=Ke.outputAmount||Ke.expectedOutputAmountHumanReadable,lt=e.steps.reduce((ke,$e)=>ke+parseFloat($e.feeInUsd||""),0),q=e.steps.find(ke=>ke.diagnosisUrl)?.diagnosisUrl,M=B(parseFloat(se||"0")*(Ke.toUsdPrice||0),4,4),H=B(parseFloat(e.inputAmount)*(Ie.fromUsdPrice||0),4,4),G=se?new hh(se).multipliedBy(Ke.toUsdPrice||0).toString():"",ge=new hh(e.inputAmount).multipliedBy(Ie.fromUsdPrice||0).toString(),le=Pt(H,M),De=ne.detailedMessage.content||ne.shortMessage,je=e.status==="success"?st.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:B(se,6,6),token:V[fe-1].to.token.displayName,conciseAddress:Cr(e.wallets[V[fe-1].to.chain.displayName]?.address||""),chain:V[fe-1].to.chain.displayName}}):X.createElement(oh,null,X.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},De?"":st.t("Transaction was not sent."),N?`${st.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:N.outputAmount,symbol:N.symbol,blockchain:N.blockchain}})}`:""),De&&X.createElement(qi,{align:"center",variant:"body",size:"medium",color:"neutral700"},X.createElement("b",null,"Reason:")," ",De));return X.createElement(oe,{header:{title:st.t("Swap Details"),onCancel:e.status==="running"?()=>C("cancel"):void 0,suffix:e.status!=="running"&&X.createElement(Kt,null,X.createElement(fh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>C("delete")},X.createElement(Io,{size:"medium",variant:"label",color:"error"},st.t("Delete"))))},footer:R&&!T&&X.createElement(fh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ke=Lr(e,c,u);d(ke),setTimeout(()=>{g("../../")},0)}},st.t("Try again"))},X.createElement(ie,{compact:!0,view:!0},X.createElement(Qi,null,X.createElement("div",{className:nn()},X.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${st.t("Request ID")}`),X.createElement("div",{className:Hi()},X.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),X.createElement(gh,{container:I(),content:f?st.t("Copied To Clipboard"):st.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},X.createElement(oE,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:m.bind(null,o||"")},f?X.createElement(tE,{size:16,color:"secondary"}):X.createElement(Rx,{size:16,color:"gray"}))),X.createElement(th,{target:"_blank",href:`${Tc}/swap/${o}`},X.createElement(gh,{container:I(),content:st.t("View on Rango Explorer"),side:"bottom"},X.createElement(rE,{size:20}))))),X.createElement("div",{className:nn()},X.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?st.t("Finished at"):st.t("Created at")),X.createElement(Io,{variant:"label",size:"small",color:"neutral700"},j))),X.createElement("div",{className:Rg()},X.createElement(nE,{fee:B(String(lt),2,2),time:cn(fr(e.steps)),steps:fe}),X.createElement(Mn,{from:{price:{value:B(e.inputAmount,6,6),usdValue:H,realUsdValue:ge,realValue:e.inputAmount},token:{displayName:V[0].from.token.displayName,image:V[0].from.token.image},chain:{image:V[0].from.chain.image,displayName:V[0].from.chain.displayName}},to:{price:{value:B(se,6,6),usdValue:M,realUsdValue:G,realValue:se||""},token:{displayName:V[fe-1].to.token.displayName,image:V[fe-1].to.token.image},chain:{image:V[fe-1].to.chain.image,displayName:V[fe-1].to.chain.displayName}},percentageChange:B(le,2,2),warningLevel:_t(le??0)})),X.createElement("div",{className:eh()},X.createElement(Io,{variant:"title",size:"small"},st.t("Swaps steps"))),X.createElement(eE,{size:8}),X.createElement(Yg,{ref:S},V.map((ke,$e)=>{let Gt=$e,ro=mh(e.steps[$e]),Vh=ro==="error"||ro==="in-progress"||ro==="warning"||ro==="completed"&&$e===V.length-1;return X.createElement(iE,{key:Gt,step:ke,type:"swap-progress",ref:S,state:ro,hasSeparator:$e!==0,tabIndex:Gt,isFocused:Vh,tooltipContainer:I()})}))),X.createElement(Ql,{state:k,onClose:()=>C(null),onCancel:b,onDelete:n,message:ne.detailedMessage.content,currentStepWallet:L,walletButtonDisabled:!h}),X.createElement(ql,{open:!!T,diagnosisUrl:q,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(se,6,6),usdValue:M,realUsdValue:G,realValue:se||"",percentageChange:B(le,2,2),token:{displayName:V[fe-1].to.token.displayName,image:V[fe-1].to.token.image},chain:{image:V[fe-1].to.chain.image},description:je}))}i(Xl,"SwapDetails");import{i18n as Ki}from"@lingui/core";import{Divider as Th,NotFound as fE,Skeleton as ar,Typography as ji}from"@rango-dev/ui";import Ce from"react";import{i18n as pE}from"@lingui/core";import{Divider as uE,Skeleton as dE,Typography as mE}from"@rango-dev/ui";import Te from"react";import{css as vt,styled as Yl}from"@rango-dev/ui";var Ch=Yl("div",{width:"100%",height:"100%",padding:"$10 $20"}),ir=Yl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Vi=Yl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),D4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),$4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),F4=vt({paddingTop:"$15",display:"flex"}),O4=vt({padding:"$15 $0"}),U4=vt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),z4=vt({paddingBottom:"$10"}),Q4=vt({display:"flex",justifyContent:"start",alignItems:"center"}),H4=vt({paddingTop:"$5",display:"flex",alignItems:"center"}),q4=vt({display:"flex",alignItems:"center"}),G4=vt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),kh=vt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Zl(){return Te.createElement(Ch,null,Te.createElement(Dn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(mE,{variant:"title",size:"small"},pE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(ir,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:kh()},Te.createElement(uE,{direction:"horizontal",size:20}),Te.createElement(dE,{height:22,variant:"rectangular"}))),Te.createElement(Vi,null),Te.createElement(ir,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Vi,null),Te.createElement(ir,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Vi,null),Te.createElement(ir,null,Te.createElement(Nt,{separator:!1}))))}i(Zl,"LoadingSwapDetails");function vh(t){let{requestId:e,showSkeleton:o}=t;return Ce.createElement(oe,{header:{title:Ki.t("Swap Details"),suffix:Ce.createElement(Kt,null)}},o&&Ce.createElement(Xg,null,Ce.createElement(Qi,null,Ce.createElement("div",{className:nn()},Ce.createElement(ji,{variant:"label",size:"large",color:"neutral700"},`${Ki.t("Request ID")}`),Ce.createElement("div",{className:Hi()},Ce.createElement(ji,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(ar,{width:60,height:10,variant:"rounded"})),Ce.createElement(Th,{direction:"horizontal",size:4}),Ce.createElement(ar,{width:16,height:16,variant:"rectangular"}),Ce.createElement(Th,{direction:"horizontal",size:4}),Ce.createElement(ar,{width:16,height:16,variant:"rectangular"}))),Ce.createElement("div",{className:nn()},Ce.createElement(ji,{className:Jg(),variant:"label",size:"large",color:"neutral700"},Ce.createElement(ar,{width:60,height:10,variant:"rounded"})),Ce.createElement(ji,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(ar,{width:60,height:10,variant:"rounded"})))),Ce.createElement(Zl,null)),!o&&Ce.createElement(Zg,null,Ce.createElement(fE,{title:Ki.t("Not found"),description:Ki.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(vh,"SwapDetailsPlaceholder");function wh(){let{manager:t,state:e}=yE(),o=!e.loadedFromPersistor,n=dt(t),{requestId:r}=CE(),a=Ze(),{fetchStatus:s}=y();if(!r)return Jl.createElement(SE,{containerStyles:{margin:"20px"},type:"error",title:gE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",c=r?n.find(({swap:h})=>h.requestId===r):void 0,p=i(()=>{if(c?.id){let h=t?.get(c.id);h&&hE(h)}},"onCancel"),u=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),d=c?.swap;return!d||l?Jl.createElement(vh,{requestId:r,showSkeleton:l}):Jl.createElement(Xl,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(wh,"SwapDetailsPage");import{i18n as bh}from"@lingui/core";import{Divider as kE,getCategoriesCount as TE,SelectableCategoryList as vE,styled as Eh,Typography as wE,Wallet as bE}from"@rango-dev/ui";import Bt,{useState as xh}from"react";var xE=Eh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),EE=Eh(ie,{textAlign:"center"});function Ih(){let{fetchStatus:t}=y(),[e,o]=xh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=xh(),l=re.use.isActiveTab(),{list:c}=gt(),p=Hc(c,n),d=TE(p)!==1,h=qc(c,e),g=i(f=>{Lc(c,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:bh.t("Connect Wallets")}},Bt.createElement(EE,null,d&&Bt.createElement(Bt.Fragment,null,Bt.createElement(vE,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Bt.createElement(kE,{size:24})),Bt.createElement(wE,{variant:"title",size:"xmedium",align:"center"},bh.t("Choose a wallet to connect.")),Bt.createElement(xE,null,h.map((f,m)=>{let S=`wallet-${m}-${f.type}`;return Bt.createElement(bE,{key:S,...f,container:I(),onClick:()=>g(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(mo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Ih,"WalletsPage");function Ah(){return Cu(),Oa(),IE([{path:$.home,element:_e.createElement(tg,null)},{path:$.routes,element:_e.createElement(ag,null)},{path:$.fromSwap,children:[{index:!0,element:_e.createElement(Ll,{type:"source"})},{path:$.blockchains,element:_e.createElement(Mi,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:_e.createElement(Ll,{type:"destination"})},{path:$.blockchains,element:_e.createElement(Mi,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:_e.createElement(Pg,null)},{path:$.languages,element:_e.createElement(ng,null)},{path:$.exchanges,element:_e.createElement(bl,{sourceType:"Exchanges"})},{path:$.bridges,element:_e.createElement(bl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:_e.createElement(uf,null)},{path:$.addCustomTokens,children:[{index:!0,element:_e.createElement(td,null)},{path:$.blockchains,element:_e.createElement(Mi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:_e.createElement(Bf,null)},{path:$.swapDetails,element:_e.createElement(wh,null)}]},{path:$.wallets,element:_e.createElement(Ih,null)},{path:$.confirmSwap,element:_e.createElement(Ym,null)}])}i(Ah,"AppRoutes");import{useQueueManager as DE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as $E}from"@rango-dev/wallets-shared";import{isEvmBlockchain as FE}from"rango-sdk";import{useContext as OE,useEffect as _h,useState as Dh}from"react";import{globalCss as AE}from"@rango-dev/ui";var Nh=i(()=>AE({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");function Wh(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Mt("BASE_URL")}/meta/dapp/config?apiKey=${Mt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(Wh,"useFetchApiConfig");import{useWallets as NE}from"@rango-dev/wallets-react";import{useEffect as WE,useRef as BE}from"react";function Bh(){let{connect:t,state:e}=NE(),o=BE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);WE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Bh,"useForceAutoConnect");import{isApprovalTX as LE,RouteEventType as Lh,StepEventType as Mh,StepExecutionEventStatus as ME,WidgetEvents as Xi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ph}from"react";function Rl(){let t=we.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Ph(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===Mh.TX_EXECUTION&&a.status===ME.TX_SENT&&!LE(s)||a.type===Mh.SUCCEEDED){let p=l.wallets[s?.fromBlockchain],u=e.find(d=>d.address?.toLocaleLowerCase()===p.address?.toLocaleLowerCase()&&d.walletType===p.walletType&&d.chain===s?.fromBlockchain);if(u&&o([u]),s?.fromBlockchain!==s?.toBlockchain){let d=l.wallets[s?.toBlockchain],h=e.find(g=>g.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&g.walletType===d.walletType&&g.chain===s?.toBlockchain);h&&o([h])}}t(a,l)},"handleStepEvent");return he.on(Xi.StepEvent,n),()=>he.off(Xi.StepEvent,n)},[he,e]),Ph(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===Lh.FAILED||a.type===Lh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return he.on(Xi.RouteEvent,n),()=>he.off(Xi.RouteEvent,n)},[he])}i(Rl,"useSubscribeToWidgetEvents");import{useManager as PE}from"@rango-dev/queue-manager-react";import{useEffect as _E}from"react";function ec(){let{isSynced:t,syncNotifications:e}=we(),{manager:o,state:n}=PE();_E(()=>{we.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(dt(o))},[we.persist.hasHydrated(),n.loadedFromPersistor,t])}i(ec,"useSyncNotifications");function tc(){Bh(),Nh(),Rl(),ec();let t=y().blockchains(),{canSwitchNetworkTo:e}=Jr(),[o,n]=Dh(""),[r,a]=Dh(),s=OE(Ar),l=t.filter(FE),{fetchApiConfig:c}=Wh();_h(()=>()=>Su(),[]),DE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),_h(()=>(lo.init(),we.persist.hasHydrated()||we.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(p=>{a(p),p===$E(o)?.[0]&&n("")}),c().catch(console.log),lo.destroy),[])}i(tc,"useBootstrap");import{styled as UE}from"@rango-dev/ui";var $h=UE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Yi(){tc();let{config:t}=y(),{activeTheme:e}=qo(t?.theme||{}),{activeLanguage:o}=eo();return oc.createElement(zE,{language:o},oc.createElement($h,{id:"swap-container",className:e()},oc.createElement(Ah,null)))}i(Yi,"Main");import{setSolanaSignerConfig as sI}from"@rango-dev/signer-solana";import rc,{useEffect as Hh,useMemo as lI}from"react";import{useState as QE}from"react";var HE=i(()=>{let[t,e]=QE(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=Bc(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Fh=HE;import{checkWaitingForNetworkChange as qE,makeQueueDefinition as GE}from"@rango-dev/queue-manager-rango-preset";import{Provider as VE}from"@rango-dev/queue-manager-react";import{useWallets as KE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as jE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as XE}from"rango-types";import YE,{useMemo as ZE}from"react";function JE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=KE(),l=ZE(()=>GE({API_KEY:t.apiKey||Mt("API_KEY"),BASE_URL:Mt("BASE_URL"),emitter:{emit:he.emit}}),[t.apiKey]),{blockchains:c,connectedWallets:p}=y(),u=c(),d={blockchains:p.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,b)=>a(v,b.network)?await r(v,[b]):void 0,"switchNetwork"),g=i(v=>!!s(v).mobileWallet,"isMobileWallet"),f=u.filter(v=>v.enabled).reduce((v,b)=>(v[b.name]=b,v),{}),m=u.filter(XE),S=i(v=>{let{supportedChains:b}=s(v);return dn(b)},"getSupportedChainNames"),k=e(),C={meta:{blockchains:f,evmBasedChains:m,evmNetworkChainInfo:jE(m),getSupportedChainNames:S},getSigners:o,wallets:d,providers:k,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g},T=re.use.isActiveTab();return YE.createElement(VE,{queuesDefs:[l],context:C,onPersistedDataLoaded:v=>{qE(v)},isPaused:!T},t.children)}i(JE,"QueueManager");var Oh=JE;import{useManager as nI}from"@rango-dev/queue-manager-react";import rI,{createContext as iI,useContext as aI}from"react";function Uh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:h,toToken:g,requestAmount:f}=p,m={blockchains:e,tokens:o};if(u!==void 0){let S=e.find(k=>k.name===u)??null;n(S)}if(d!==void 0){let S=d?t(d)??null:null;r({meta:m,token:S})}if(h!==void 0){let S=e.find(k=>k.name===h)??null;a(S)}if(g!==void 0){let S=g?t(g)??null:null;s({meta:m,token:S})}f!==void 0&&l(f)},"updateQuoteInputs")}i(Uh,"useUpdateQuoteInputs");import{cancelSwap as RE,getCurrentNamespaceOfOrNull as eI,getCurrentStep as tI,getRelatedWalletOrNull as oI}from"@rango-dev/queue-manager-rango-preset";var Zi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return dt(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&&RE(o)}getCurrentStepInfo(e){let o=tI(e);return{step:o,wallet:o?oI(e,o):null,network:o?eI(e,o)?.network:null}}};var zh=iI(void 0);function nc(t){let{manager:e}=nI(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new Zi(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=y(),u=$c(a()),d=y().blockchains(),h=y().tokens(),g=y().swappers(),f=y().fetchStatus,m=eo().resetLanguage,S=we().getNotifications(),k=we().clearNotifications,C=Uh(),{fromBlockchain:T,toBlockchain:v,fromToken:b,toToken:A,inputAmount:_}=O(),w={isActiveTab:o,setCurrentTabAsActive:lo.forceClaim,history:c,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async x=>l(x)},meta:{blockchains:d,tokens:h,swappers:g,loadingStatus:f,findToken:r},resetLanguage:m,notifications:{list:S,clearAll:k},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:b?{symbol:b.symbol,blockchain:b.blockchain,address:b.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:_},updateQuoteInputs:C}};return rI.createElement(zh.Provider,{value:w},t.children)}i(nc,"WidgetInfo");function Qh(){let t=aI(zh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Qh,"useWidget");function Ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Fh();return Hh(()=>{n&&r(n)},[n]),lI(()=>{Gc({API_KEY:o?.apiKey||ur,BASE_URL:o?.apiUrl||kc})},[o.apiKey,o.apiUrl]),Hh(()=>{t.config?.signers?.customSolanaRPC&&sI("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),rc.createElement(Nr,{config:o,onUpdateState:e},rc.createElement(Oh,{apiKey:o.apiKey},rc.createElement(nc,null,t.children)))}i(Ji,"WidgetProvider");function qh(t){let e=t.config?.externalWallets;return Ri.createElement(Up,null,e?Ri.createElement(Yi,null):Ri.createElement(Ji,{config:t.config??pr},Ri.createElement(Yi,null)))}i(qh,"Widget");function Gh(){let{on:t,off:e}=he;return{on:t,off:e}}i(Gh,"useWidgetEvents");var J3={DerivationPath:Cn,Namespaces:Sn,isOnDerivationPath:Tn,isOnNamespace:kn};export{b3 as EventSeverity,Po as MainEvents,P3 as Networks,$3 as PendingSwapNetworkStatus,fa as QuoteEventTypes,x3 as RouteEventType,na as SUPPORTED_FONTS,J3 as StatefulConnect,E3 as StepEventType,I3 as StepExecutionBlockedEventStatus,A3 as StepExecutionEventStatus,Fe as UI_ID,ha as UiEventTypes,ga as WalletEventTypes,L3 as WalletEvents,_3 as WalletTypes,qh as Widget,Po as WidgetEvents,Ji as WidgetProvider,Nr as WidgetWallets,Za as customizedThemeTokens,W3 as readAccountAddress,Vt as useStatefulConnect,gt as useWalletList,Jr as useWallets,Qh as useWidget,Gh as useWidgetEvents,Xy as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map