@rango-dev/widget-embedded 0.0.0-experimental-01e2a135-20260613 → 0.0.0-experimental-e5c14f42-20260614

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 UC=Object.defineProperty;var i=(t,e)=>UC(t,"name",{value:e,configurable:!0});import{EventSeverity as Ite,RouteEventType as Ate,StepEventType as Nte,StepExecutionBlockedEventStatus as Wte,StepExecutionEventStatus as Pte}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Lte}from"@rango-dev/wallets-core/legacy";import{useWallets as ra,Events as Mte}from"@rango-dev/wallets-react";import{Networks as $te,WalletTypes as Fte}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Ute}from"rango-types";import{Divider as av}from"@rango-dev/ui";import mo,{useEffect as sv,useRef as lv,useState as Dd}from"react";import{WalletState as zC}from"@rango-dev/ui";import{useWallets as HC}from"@rango-dev/wallets-react";import{useReducer as QC}from"react";function Kp(t){return!!t.derivationPath}i(Kp,"isStateOnDerivationPathStep");function jp(t){return!!t.namespace}i(jp,"isStateOnNamespace");var ri={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function Xp(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"detached":return{...t,status:"detached",namespace:{targetWallet:e.payload.targetWallet},selectedNamespaces:e.payload.selectedNamespaces};case"reset":return ri;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ri;default:throw new Error("Action hasn't been defined.")}}i(Xp,"reducer");function an(){let{state:t,disconnect:e,connect:o}=HC(),[n,r]=QC(Xp,ri),a=i(async(m,f,h)=>{r({type:"reset"});try{let g=f?.map(d=>({...d,network:void 0}));return await o(m.type,g),{status:"connected"}}catch(g){let d=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";if(h?.disconnectOnError)try{await u(m)}catch{console.warn("An error happened during disconnecting wallet after error on connecting.")}throw new Error(d,{cause:g})}},"runConnect"),s=i(async(m,f)=>{let h=m.state===zC.DISCONNECTED,g=f?.forceConnectToNamespaces;if(h){let d=!!m.isHub,y=d?m.properties?.find(C=>C.name==="namespaces")?.value:m.needsNamespace,S=d?m.properties?.find(C=>C.name==="derivationPath")?.value:m.needsDerivationPath;if(g){let C=g.find(k=>!y?.data?.map(E=>E.value).includes(k));if(C)throw new Error(`One of the forced namespaces is not available in the wallet. Forced namespace: ${C}`);if(g.length>1&&S)throw new Error("Derivation path is not supported when multiple namespaces are selected.");return g.length===1&&g[0]&&S?(r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:g[0]}}),{status:"derivation-path"}):await a(m,g.map(k=>({namespace:k})),{...f,disconnectOnError:!0})}if(!y?.data?.length)return await a(m,void 0,f);if(y?.data.length&&y.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:m,defaultSelectedChains:f?.defaultSelectedChains}}),{status:"namespace"};if(y?.data.length===1&&y.data[0]){if(S){let C=y.data[0];return r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:C.value}}),{status:"derivation-path"}}return await a(m,y?.data?.map(C=>({namespace:C.value})),f)}}if(m.isHub&&!f?.forceConnectToNamespaces){let d=m.properties?.find(y=>y.name==="namespaces")?.value;if(d?.data.length&&d.data.length>1)return r({type:"detached",payload:{targetWallet:m,selectedNamespaces:null}}),{status:"Detached"}}return f?.disconnectIfConnected?(await u(m),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),c=i(async(m,f)=>{let h=!!m.isHub,g=h?m.properties?.find(k=>k.name==="namespaces")?.value:m.needsNamespace,d=h?m.properties?.find(k=>k.name==="derivationPath")?.value:m.needsDerivationPath,y=g?.selection==="single",S=f[0];if(!S)throw new Error("To confirm a namespace, you should select at least one namespace.");if(y&&d)return r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:S}}),{status:"derivation-path"};if(!jp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let C=f.map(k=>({namespace:k}));return r({type:"detached",payload:{targetWallet:m,selectedNamespaces:C??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(m,f,h)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!Kp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=[{namespace:n.derivationPath.namespace,derivationPath:f}],S=!!m.isHub?m.properties?.find(E=>E.name==="namespaces")?.value:m.needsNamespace,C=!!S?.data&&S.data.length>1,k=!!h?.forceConnectToNamespaces;return C&&!k?(r({type:"detached",payload:{targetWallet:m,selectedNamespaces:d??null,derivationPath:f}}),{status:"Detached"}):await a(m,d)},"handleDerivationPath"),p=i(()=>n,"getState"),u=i(async m=>{let f=t(m.type);return f.connected||f.connecting?(await e(m.type),Wo(p)?(r({type:"needsNamespace",payload:{targetWallet:m}}),{status:"namespace"}):{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:c,handleDerivationPath:l,getState:p,resetState:m=>{r(m==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(an,"useStatefulConnect");import{WalletState as rr}from"@rango-dev/ui";import{useWallets as ek}from"@rango-dev/wallets-react";import{detectMobileScreens as tk,KEPLR_COMPATIBLE_WALLETS as ok,WalletTypes as ir}from"@rango-dev/wallets-shared";import{useCallback as nk,useEffect as _s}from"react";import XT,{createContext as YT,useContext as ZT,useEffect as JT,useRef as RT}from"react";import{create as KT}from"zustand";import{persist as jT}from"zustand/middleware";import{allProviders as qC}from"@rango-dev/provider-all";var ds=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()}},sn=new ds;import{defineVersions as Zp,pickVersion as Jp,Provider as ms}from"@rango-dev/wallets-core";function Rp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=fs(a);return s instanceof ms?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 ms?o.push(Zp().version("1.0.0",n).build()):o.push(Zp().version("0.0.0",n).build())}),o}return t}i(Rp,"matchAndGenerateProviders");function fs(t){try{return Jp(t,"1.0.0")[1]}catch{return Jp(t,"0.0.0")[1]}}i(fs,"pickProviderVersionWithFallbackToLegacy");function eu(t){return t.map(o=>fs(o)).map(o=>o instanceof ms?o.id:o.config.type)}i(eu,"configWalletsToWalletName");function ii(t,e){return e.find(o=>o.name===t)?.displayName}i(ii,"getBlockchainDisplayNameFor");function vt(t,e){return e.find(o=>o.name===t)?.shortName}i(vt,"getBlockchainShortNameFor");function tu(t,e){return e.find(o=>o.name===t)?.logo}i(tu,"getBlockchainImage");function jn(t,e){return e.find(o=>o.id===t)?.title}i(jn,"getSwapperDisplayName");function Po(t,e){return e.find(o=>o.name===t)??null}i(Po,"findBlockchain");function gs(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(gs,"isTokenNative");function wt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(wt,"createTokenHash");function Bo(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Bo,"isValidTokenAddress");function Xn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(c=>{c.forEach(l=>{typeof l!="string"&&(l=wt(l));let p=o.tokensMapByTokenHash.get(l);p&&(n[l]=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 c=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(l=>{let p=o.tokensMapByBlockchainName[l];!c.has(l)&&p&&a(p)})}return s.forEach(c=>{let l=r[c];if(!l&&o.tokensMapByBlockchainName?.[c]){a(o.tokensMapByBlockchainName[c]);return}l&&(l.isExcluded&&o.tokensMapByBlockchainName[c]?(a(o.tokensMapByBlockchainName[c]),l.tokens.forEach(p=>{let u=wt(p);delete n[u]})):a(l.tokens))}),Object.values(n)}i(Xn,"matchTokensFromConfigWithMeta");function ai(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(ai,"getSupportedBlockchainsFromConfig");function nu(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(nu,"makeProvidersOptionsFromConfig");var ln={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/assets/refs/heads/main/manifests/tonconnect/manifest.json"}},GC={clientUrl:void 0},VC={liquiditySources:void 0};function ou(t){let e=nu(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 qC(o).map(a=>a())}i(ou,"generateProviders");var ru=i((t,e,o)=>{let n=ou({...ln,...t});return{config:{...ln,...t},iframe:GC,campaignMode:VC,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:c}=o(),l=Xn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}}),p=Xn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}});sn.set("supportedSourceTokens",l),sn.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=ou(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=nu(a);return Rp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as iu}from"rango-types";var au=[iu.EVM,iu.SOLANA],si="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as lT}from"rango-sdk";function su(){return process.env.REACT_APP_RANGO_API_KEY}i(su,"getApiKeyFromEnv");function lu(){let t=su();if(t)return t;throw new Error("Ensure you have set REACT_APP_RANGO_API_KEY in your env variables.")}i(lu,"getApiKeyFromEnvOrThrow");function cu(){return su()||"NOT_SET"}i(cu,"getApiKeyFromEnvOrNotSet");import{BlockchainCategories as eT,WalletState as ft}from"@rango-dev/ui";import{legacyReadAccountAddress as tT}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as oT,getCosmosExperimentalChainInfo as nT,isEvmAddress as rT,KEPLR_COMPATIBLE_WALLETS as ZP,Networks as _u}from"@rango-dev/wallets-shared";import pn from"bignumber.js";import{isCosmosBlockchain as iT}from"rango-types";import KC from"bignumber.js";var ue=new KC(0);import{WalletTypes as jC}from"@rango-dev/wallets-shared";var Lo="~",pu=[jC.LEAP];import{BlockchainCategories as ys,WalletState as RC}from"@rango-dev/ui";import{TransactionType as li}from"rango-sdk";import{UI_ID as XC}from"@rango-dev/ui";var uu="https://api.rango.exchange",du="https://explorer.rango.exchange",rt={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...XC};var mu="Roboto",hs=[{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 cn(t){return Array.from(new Set(t))}i(cn,"removeDuplicateFrom");function ci(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ci,"debounce");function mt(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(mt,"containsText");function hu(t,e){return t.toLowerCase()===e.toLowerCase()}i(hu,"exactText");function yu(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(yu,"startWithText");var W=i(()=>document.getElementById(rt.SWAP_BOX_ID),"getContainer"),_o=i(()=>document.getElementById(rt.EXPANDED_BOX_ID),"getExpanded");function Su(t,e,o){let n=!!e&&hu(e,t),r=!!o&&hu(o,t);return n!==r?n?-1:1:0}i(Su,"compareExactMatchText");function Ss(t,e,o){let n=!!e&&mt(e,t),r=!!o&&mt(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(Ss,"compareContainsText");function Cs(t,e,o){let n=!!e&&yu(e,t),r=!!o&&yu(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(Cs,"compareStartWithText");function Cu(t,e,o){if(!o)return 0;let n=Su(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Su(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=Cs(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=Ss(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=Cs(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=Ss(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=Cs(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=Ss(o,t.address,e.address);if(r!==0)return r}return 0}i(Cu,"compareWithSearchFor");var pi=i((t,e)=>{switch(e){case ys.ALL:return!0;case ys.UTXO:return t===li.TRANSFER;case ys.OTHER:return t!==li.TRANSFER&&t!==li.COSMOS&&t!==li.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Tu=i(t=>hs.find(o=>o.value===t)?.url,"getFontUrlByName");function ku(t,e){let o=!!t.find(n=>n.state===RC.CONNECTED);return e===!1&&o}i(ku,"isSingleWalletActive");function vu(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(vu,"memoizedResult");function wu(t,e){let o=new Set;return e.forEach(n=>{o.add(n.blockchain)}),t.filter(n=>o.has(n.name))}i(wu,"filterBlockchainsWithAtLeastOneToken");import{BigNumber as Bu}from"bignumber.js";function Eu(t){return t.replace(/^0+(?=\d)/g,"")}i(Eu,"removeLeadingZeros");function bu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(bu,"ensureLeadingZeroForDecimal");function xu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(xu,"formatThousandsWithCommas");function Iu(t){return t.replace(/\s+/g,"-")}i(Iu,"replaceSpacesWithDash");function Au(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(Au,"stripTrailingZeros");function Nu(t){return t=t.replace(/[^\d.]/g,"").replace(/\./g,(e,o,n)=>n.indexOf(".")===o?".":""),t}i(Nu,"parseNumericValue");function ui(t){return/^0+(?:\.0+)?$/.test(t)}i(ui,"isZeroValue");function Wu(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(Wu,"isValidCurrencyFormat");function Pu(t){return/\d+$/.test(t)}i(Pu,"isColorKeyOverridden");var Yn=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"),D=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Bu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Bu(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 di=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var Dt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),Zn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function Lu(t){return ui(t)?"0":t.endsWith(".")?t.slice(0,-1):Au(t)}i(Lu,"sanitizeInputAmount");function Jn(t,e){return sT(t,e)?ft.PARTIALLY_CONNECTED:e.connected?ft.CONNECTED:e.connecting?ft.CONNECTING:e.installed?ft.DISCONNECTED:ft.NOT_INSTALLED}i(Jn,"getWalletConnectionStatus");function Mu(t,e,o,n){return o.filter(r=>!pu.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:c,network:l}=t(r);return s&&(!c||!!n&&l!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:c,showOnMobile:l,needsNamespace:p,supportedChains:u,needsDerivationPath:m,properties:f,isHub:h}=e(r),g=cn(u.map(y=>y.type)),d=Jn(e(r),t(r));return{title:a,image:s,link:oT(c),state:d,type:r,showOnMobile:l,needsNamespace:p,blockchainTypes:g,needsDerivationPath:m,properties:f,isHub:h}})}i(Mu,"mapWalletTypesToWalletInfo");function Rn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(Rn,"walletAndSupportedChainsNames");function ks(t,e,o,n,r){let a=[];function s(l,p,u){if(!!!a.find(f=>f.chain===l)){let f={address:p,chain:l,walletType:t,isContractWallet:u??!1};a.push(f)}}i(s,"addAccount");let c=n||[];return e.forEach(l=>{let{address:p,network:u}=tT(l),m=c.length>0,f=c.includes(u),h=u===_u.Unknown;if(m&&!f&&!h)return;let d=u===_u.Unknown&&rT(p);if(h&&!d)return;o.includes(u)||d?r?s(u,p.toLowerCase(),r):c.filter(C=>o.includes(C)).forEach(C=>{s(C,p.toLowerCase())}):s(u,p)}),a}i(ks,"prepareAccountsForWalletStore");function Mo(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,c=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:l}=r;l.forEach((p,u)=>{let m=p.from.blockchain,f=p.to.blockchain,h=a===o.swaps.length-1,g=u===l.length-1;(!h&&!g||h&&c!==m||e==="all")&&n.add(m),e==="all"&&n.add(f)})}e==="all"&&n.add(c)}),Array.from(n)}i(Mo,"getQuoteChains");function er(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(er,"isAccountAndWalletMatched");var Du=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?Ts(n.usdValue,n.decimals):ue.toFixed();return o.plus(r)},new pn(ue));return aT(e.toString())},"calculateWalletUsdValue");function aT(t){let e=t.toString().split(".");return e[0]&&(e[0]=xu(e[0])),e.join(".")}i(aT,"numberWithThousandSeparator");var gi=i((t,e)=>{let o=nT(Object.entries(t).map(([,n])=>n).filter(iT));return o&&!!o[e]?.experimental},"isExperimentalChain");function Ts(t,e){return new pn(t).shiftedBy(-e).toFixed()}i(Ts,"representAmountInNumber");function hi(t){if(!t)return null;let e=Ts(t.amount,t.decimals),o=t.usdValue?Ts(t.usdValue,t.decimals):null,n=D(e,8,8),r=o?D(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(hi,"formatBalance");function $u(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new pn(t.usdValue).shiftedBy(-t.decimals):ue,n=e&&e.usdValue?new pn(e.usdValue).shiftedBy(-e.decimals):ue;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new pn(t.amount).shiftedBy(-t.decimals):ue,n=e&&e.amount?new pn(e.amount).shiftedBy(-e.decimals):ue;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i($u,"compareTokenBalance");function Vt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Vt,"areTokensEqual");function Fu(t){return t.sort((e,o)=>+(o.state===ft.CONNECTED)-+(e.state===ft.CONNECTED)||+(o.state===ft.PARTIALLY_CONNECTED)-+(e.state===ft.PARTIALLY_CONNECTED)||+(o.state===ft.DISCONNECTED||o.state===ft.CONNECTING)-+(e.state===ft.DISCONNECTED||e.state===ft.CONNECTING))}i(Fu,"sortWalletsBasedOnConnectionState");function po(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(po,"getConciseAddress");function Ou({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Ou,"getAddress");var Uu=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function yi(t){return t.map(e=>e.state).join("-")}i(yi,"hashWalletsState");function zu(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(zu,"filterBlockchainsByWalletTypes");function Hu(t,e){return e===eT.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(pi(n,e))return!0;return!1})}i(Hu,"filterWalletsByCategory");function sT(t,e){if(!t.isHub||!t.needsNamespace||!e.connected)return!1;let n=t.needsNamespace.data.filter(r=>!r.unsupported);return t.needsNamespace.selection==="multiple"&&n.some(r=>!e.namespaces?.get(r.value)?.connected)}i(sT,"checkIsWalletPartiallyConnected");var vs={API_KEY:cu()};function Kt(t){return vs[t]||""}i(Kt,"getConfig");function Qu(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),vs=e,vs}i(Qu,"initConfig");var qu=20,Gu=25,ws="theme-widget",Es=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Vt(n,t));else if(!Array.isArray(e)){let n=e[t.blockchain];if(n){o=!!n.tokens.some(a=>Vt(a,t));let r=n.isExcluded;return!r&&!o||r&&o}}}return o},"isTokenExcludedInConfig"),bs=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Vu=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Si,gt=i(()=>Si||(Si=new lT(Kt("API_KEY"),Kt("BASE_URL")),Si),"httpService");import{i18n as ju}from"@lingui/core";var Ci=[.5,1,3],Ti=1,un=5,tr=30,ki=0;var Je=(a=>(a[a.NO_RESULT=0]="NO_RESULT",a[a.REQUEST_FAILED=1]="REQUEST_FAILED",a[a.REQUEST_CANCELED=2]="REQUEST_CANCELED",a[a.BRIDGE_LIMIT=3]="BRIDGE_LIMIT",a[a.INSUFFICIENT_SLIPPAGE=4]="INSUFFICIENT_SLIPPAGE",a))(Je||{});import{WidgetEvents as Ku}from"@rango-dev/queue-manager-rango-preset";var or=(s=>(s.QUOTE_INPUT_UPDATE="quoteInputUpdate",s.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",s.ROUTE_REQUESTED="routeRequested",s.ROUTE_NOT_FOUND="routeNotFound",s.ROUTE_FETCH_FAILED="routeFetchFailed",s.ROUTE_CHANGED="routeChanged",s))(or||{}),vi=(r=>(r.CONNECT="connect",r.DISCONNECT="disconnect",r.CONNECT_INITIATED="connectInitiated",r.DETECTED="detected",r))(vi||{}),Re=(d=>(d.CLICK_CONNECT_WALLET="clickConnectWallet",d.TOKEN_SELECTED="tokenSelected",d.CHAIN_FILTER_APPLIED="chainFilterApplied",d.SETTINGS_CHANGED="settingsChanged",d.ROUTE_FEE_VIEWED="routeFeeViewed",d.DESTINATION_ADDRESS_SET="destinationAddressSet",d.GAS_WARNING_SHOWN="gasWarningShown",d.GAS_WARNING_BYPASSED="gasWarningBypassed",d.SWAP_INITIATED="swapInitiated",d.SWAP_WALLETS_MODAL_SHOWN="swapWalletsModalShown",d.SWAP_WALLETS_CONFIRMED="swapWalletsConfirmed",d.SWAP_STARTED="swapStarted",d.SWAP_RESUMED="swapResumed",d.SWAP_RETRIED="swapRetried",d.SWAP_CANCELLED="swapCancelled",d))(Re||{}),dn=(a=>(a[a.RouteEvent=Ku.RouteEvent]="RouteEvent",a[a.StepEvent=Ku.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(dn||{});function wi(t,e){let o=t.map(a=>a.swapperGroup),n=[];return cn(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(c=>c.swapperGroup===a);if(s){let c=!0;o&&(c=o.some(l=>l===s.swapperGroup)),c&&s.types.map(l=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:l,selected:!e.includes(s.swapperGroup)})})}}),n}i(wi,"getUniqueSwappersGroups");function Xu(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Xu,"sortLiquiditySourcesByGroupTitle");function it(t,e){return e?.[t]==="hidden"}i(it,"isFeatureHidden");function mn(t,e){return e?.[t]==="enabled"}i(mn,"isRoutingEnabled");var Yu=i((t,e,o)=>it("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function fn(t){return t==ki?{type:"error",message:ju.t("Slippage must be greater than or equal to 0.01")}:t>un&&t<=tr?{type:"warning",message:ju.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(fn,"getSlippageValidation");var Zu=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 l=ai({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>au.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(l=>!(s.length>0&&!s.includes(l.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),c=Array.from(n.values()),l=e()._blockchainsMapByName;if(!o||!o.type)return c;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=sn.get(u);m?.length||(m=Xn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),sn.set(u,m)),m=Yu(m,s,a.features);let f=e().blockchains({type:o.type});return m.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!f.some(d=>d.name===g.blockchain)?!1:o.searchFor?!!(mt(g.symbol,o.searchFor)||mt(g.address||"",o.searchFor)||mt(g.name||"",o.searchFor)):!0).sort((g,d)=>{let y=e().isTokenPinned(g,o.type),S=e().isTokenPinned(d,o.type);if(y!==S)return y?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(g),A=o.getBalanceFor(d),x=$u(I,A);if(x!==0)return x}let C=l.get(g.blockchain),k=l.get(d.blockchain),E=gs(g,C),w=gs(d,k);if(E!==w)return E?-1:1;if(g.isPopular!==d.isPopular)return g.isPopular?-1:1;if(o.searchFor){let I=Cu(g,d,o.searchFor);if(I)return I}return g.isSecondaryCoin!==d.isSecondaryCoin?g.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=wt(o),s=n.get(a);return s||(s=r.find(c=>wt(c)===a)),s},findNativeToken:o=>{let n=o.feeAssets[0];return e().findToken({blockchain:o.name,address:n.address,symbol:n.symbol})},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Vt(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(Xu)},fetch:async()=>{try{let{routing:o}=e().config,n=mn("enableCentralizedSwappers",o),r=await gt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=r.popularTokens,p=r.swappers.filter(m=>m.enabled);r.blockchains.sort((m,f)=>m.sort-f.sort).forEach(m=>{m.enabled&&a.set(m.name,m)}),r.tokens.forEach(m=>{let f=wt(m);c[m.blockchain]||(c[m.blockchain]=[]),s.set(f,m),c[m.blockchain]?.push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c,_popularTokens:l,_swappers:p})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as cT,Catalonia as pT,Chinese as Ju,Denmark as uT,English as dT,Finland as mT,French as fT,German as gT,Greece as hT,Hungary as yT,India as ST,Indonesian as CT,Italian as TT,Japanese as kT,Korea as vT,Lithuania as wT,Malay as ET,Netherlands as bT,Pakistan as xT,Philippines as IT,Poland as AT,Portuguese as NT,Russian as WT,SaudiArabia as PT,Serbia as BT,Slovakia as LT,SouthAfrica as _T,Spanish as MT,Swahili as DT,Swedish as $T,Thai as FT,Turkish as OT,Ukrainian as UT,Vietnamese as zT}from"@rango-dev/ui";var Ru=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:_T},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:PT},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:cT},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:pT},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Ju},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Ju},{title:"Danish",label:"Dansk",local:"da",SVGFlag:uT},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:bT},{title:"English",label:"English",local:"en",SVGFlag:dT},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:IT},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:mT},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:fT},{title:"German",label:"Deutsch",local:"de",SVGFlag:gT},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:hT},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:ST},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:yT},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:CT},{title:"Italian",label:"Italiana",local:"it",SVGFlag:TT},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:kT},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:vT},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:wT},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:ET},{title:"Polish",label:"Polski",local:"pl",SVGFlag:AT},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:NT},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:WT},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:BT},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:LT},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:MT},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:DT},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:$T},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:FT},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:OT},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:UT},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:xT},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:zT}],gn="en";var ed=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Ti,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],quoteTokensRate:"default",changeQuoteTokensRate:()=>t(o=>({quoteTokensRate:o.quoteTokensRate==="default"?"reversed":"default"})),addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,c)=>{let l=s===o,p=c<=9;return l&&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=cn(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=it("theme",n),s=it("language",n),c=it("liquiditySource",n),l=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...l&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||gn},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||gn}})},setCustomToken:o=>{e().fetchCustomTokensBalances({tokens:[o],connectedWallets:e().connectedWallets}),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=ai({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import Ps from"bignumber.js";import HT from"mitt";var de=HT(),QT={on:de.on,off:de.off};var td=null;function od(t){td=t}i(od,"setWalletConnectionSource");function nd(){return td}i(nd,"getWalletConnectionSource");var rd=i(t=>(e,o,n)=>t(i((...a)=>{let[s,...c]=a;e(l=>({...typeof s=="function"?s(l):s,lastUpdatedAt:+new Date}),...c)},"modifedSet"),o,n),"keepLastUpdated");import id from"bignumber.js";function jt(t){return`${t.blockchain}${Lo}${t.address}${Lo}${t.symbol}`}i(jt,"createAssetKey");function ad(t,e){return`${jt(e)}${Lo}${t}`}i(ad,"createBalanceKey");function nr(t){let[e,o,n]=t.split(Lo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(nr,"extractAssetFromBalanceKey");function Is(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[jt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new id(r??ue).multipliedBy(o[s].amount).toString():""})})}),o}i(Is,"computeNextBalancesWithNewPrices");function As(t,e){let o={};return t.balances?.forEach(n=>{let r=ad(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new id(c??ue).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(As,"createBalanceStateForNewAccount");function Ns(t,e){for(let o in e){let n=nr(o);if(n){let r=jt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}}return t}i(Ns,"updateAggregatedBalanceStateForNewAccount");function qT(t,e){let o=nr(e);if(!o)return t;let n=jt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(qT,"removeBalanceFromAggregatedBalance");function Ws(t,e,o){let n=t.connectedWallets.filter(l=>e.includes(l.walletType));t.connectedWallets.forEach(l=>{e.includes(l.walletType)||(n=n.filter(p=>!(p.chain===l.chain&&p.address===l.address)))}),o?.chains&&o.chains.length>0&&(n=n.filter(l=>o.chains?.includes(l.chain))),o?.namespaces&&o.namespaces.length>0&&(n=n.filter(l=>l.namespace?o.namespaces?.includes(l.namespace):!1));let r={},a=t._aggregatedBalances,s=t._balances;return Object.keys(s).forEach(l=>{let p=nr(l);if(!p)return;!!n.find(m=>ad(m.address,{address:p.address,blockchain:m.chain,symbol:p.symbol})===l)?a=qT(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(Ws,"computeNextStateAfterWalletBalanceRemoval");function GT(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(GT,"matchWalletDetailsWithConnectedWallet");var VT=vu(),sd=rd((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>er(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>er(s,a))?{...a,loading:!1,error:!1,explorerUrl:GT(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>er(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n,r)=>{let a=e().connectedWallets,s=o.filter(c=>!a.some(l=>er(c,l)));if(s.length>0){let c=s.map(l=>{let p=!a.some(u=>u.chain===l.chain&&u.selected&&u.walletType!==l.walletType);return{address:l.address,chain:l.chain,isContractWallet:l.isContractWallet,explorerUrl:null,walletType:l.walletType,selected:p,namespace:n,derivationPath:r,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(u=>!c.some(m=>m.walletType===u.walletType&&m.chain===u.chain)),...c]}))}},fetchCustomTokensBalances:async o=>{let{tokens:n,connectedWallets:r}=o,a=n.reduce((l,p)=>((l[p.blockchain]||=[]).push(p),l),{}),s=new Set,c=r.reduce((l,p)=>{let u=`${p.address}-${p.chain}`;return s.has(u)||(s.add(u),a[p.chain]&&(l[p.address]||(l[p.address]=[]),l[p.address]?.push(...a[p.chain]||[]))),l},{});Object.entries(c).forEach(async([l,p])=>{try{let{balances:u}=await gt().getMultipleTokenBalance({assets:p.map(({symbol:m,address:f,blockchain:h})=>({symbol:m,address:f,blockchain:h})),walletAddress:l});if(u){let m=e()._balances,f=e()._aggregatedBalances;u.forEach(h=>{if(parseFloat(h.amount.amount)===0)return;let g={blockChain:h.asset.blockchain,balances:[h],address:l},d={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};Is(d,g,m);let y=As(g,e);f=Ns(f,y),m={...m,...y}}),t(h=>({_balances:{...h._balances,...m},_aggregatedBalances:f}))}}catch(u){console.error(u)}})},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(c=>c.chain===r.chain&&c.walletType!==r.walletType&&r.selected),s=!!o.find(c=>c.chain===r.chain&&c.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n,r,a)=>{let s=o[0];s&&(de.emit("walletEvent",{type:"connect",payload:{walletType:s.walletType,accounts:o,chain:s.chain??null,walletName:a?.walletName??s.walletType,source:nd()}}),e().addConnectedWallet(o,n,r),e().fetchBalances(o))},removeBalancesForWallet:(o,n)=>{let r={_balances:e()._balances,_aggregatedBalances:e()._aggregatedBalances,connectedWallets:e().connectedWallets},{_balances:a,_aggregatedBalances:s}=Ws(r,[o],n);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(de.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(c=>a.includes(c.chain)?(a=a.filter(l=>l!==c.chain),{...c,selected:!0}):c);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let{shouldFetchCustomTokens:r=!0,selectedCustomTokens:a}=n||{};await e().fetchMainTokensBalances(o),r&&e().fetchCustomTokensBalances({tokens:a??e().customTokens(),connectedWallets:o})},fetchMainTokensBalances:async(o,n)=>{if(o.length===0||!o[0])return;let r=[...new Set(o.map(l=>l.walletType))];e().setConnectedWalletAsRefetching(o);let a=o.map(l=>({address:l.address,blockchain:l.chain})),s;try{s=await gt().getWalletsDetails(a)}catch(l){e().setConnectedWalletHasError(o),console.error(`Request for fetching balances failed. cause: ${l}`);return}let c=s.wallets;if(c){let l=e()._balances,p=e()._aggregatedBalances;c.forEach(m=>{if(m.failed)return;let f={_balances:l,_aggregatedBalances:p,connectedWallets:e().connectedWallets,findToken:e().findToken};Is(f,m,l);let{_balances:h,_aggregatedBalances:g}=Ws(f,r,{chains:[m.blockChain]});if(p=g,l=h,!e().connectedWallets.find(y=>r.includes(y.walletType)&&y.address===m.address&&y.chain===m.blockChain))return;let d=As(m,e);p=Ns(p,d),l={...l,...d}}),t(m=>({_balances:{...m._balances,...l},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(o,c);let{retryOnFailedBalances:u=!0}=n||{};if(u){let m=c.filter(f=>f.failed).map(f=>{let h=e().connectedWallets.find(g=>g.chain===f.blockChain&&g.address)?.walletType;return h?{chain:f.blockChain,walletType:h,address:f.address}:null}).filter(f=>!!f);m.length>0&&await e().fetchMainTokensBalances(m,{retryOnFailedBalances:!1})}}else e().setConnectedWalletHasError(o),console.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=jt(o),a=e()._aggregatedBalances[r]||[];if(a.length===0||!a[0])return null;let s=a[0];if(a.length===1&&n[s])return n[s];let c=n[a[0]];if(!c)return null;let l=c;return a.forEach(p=>{let u=n[p];if(!u)return;let m=new Ps(u.amount),f=new Ps(l.amount);m.isGreaterThan(f)&&(l=u)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,c)=>{let l=n[c],[,,,p]=c.split(Lo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>VT(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,c)=>{let l=r[c],p=nr(c);if(p&&p.blockchain===n.chain&&l){let u=e().findToken(p),m=l?.amount?new Ps(l.amount).shiftedBy(-l.decimals):ue;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:l.amount,decimal:l.decimals,amount:m.toString(),isSupported:!!u,logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function ld(t){return KT()(jT((...e)=>({...sd(...e),...Zu(...e),...ed(...e),...ru(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,quoteTokensRate:e.quoteTokensRate}),version:1,migrate:(e,o)=>{let n=e;return o===0&&(n._customTokens=n._customTokens.map(r=>({...r,warning:!0}))),n}}))}i(ld,"createAppStore");var cd=YT(null);function T(){let t=ZT(cd);if(JT(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(T,"useAppStore");function pd(t){let e=RT();return e.current||(e.current=ld(t.config)),XT.createElement(cd.Provider,{value:e.current},t.children)}i(pd,"AppStoreProvider");function ud(t,e){let o=!1,n={...t.payload,preventDefault(){o=!0}};de.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(ud,"emitPreventableEvent");function ee(t){de.emit("uiEvent",t)}i(ee,"emitUiEvent");function Bs(t){od(t),de.emit("walletEvent",{type:"connectInitiated",payload:{source:t}})}i(Bs,"emitWalletConnectInitiated");function $o(t){de.emit("quoteEvent",t)}i($o,"emitQuoteEvent");function Ls(t){de.emit("walletEvent",{type:"detected",payload:t})}i(Ls,"emitWalletDetected");var Ei=new Set;function It(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=T(),{state:r,getWalletInfo:a}=ek(),s=T().blockchains(),{handleDisconnect:c}=an(),l=eu(n()),p=Mu(r,a,l,e);p=tk()?p.filter(d=>d.showOnMobile!==!1&&r(d.type).installed):p;let u=Fu(p);_s(()=>{p.forEach(d=>{d.state!==rr.NOT_INSTALLED&&!Ei.has(d.type)&&(Ei.add(d.type),Ls({walletType:d.type,walletName:d.title}))})},[yi(p)]),_s(()=>{p.forEach(d=>{d.state!==rr.NOT_INSTALLED&&!Ei.has(d.type)&&(Ei.add(d.type),Ls({walletType:d.type,walletName:d.title}))})},[yi(p)]);let m=i(d=>!o.find(y=>y.walletType===d&&y.chain===e),"isExperimentalChainNotAdded"),f=nk(()=>{let d=p?.filter(y=>y.state===rr.CONNECTING)||[];for(let y of d)c(y)},[yi(p)]);_s(()=>()=>{f()},[]);let h=i(d=>{let y=d.find(C=>C.type===ir.DEFAULT);return!y||y.state===rr.NOT_INSTALLED?!1:d.filter(C=>C.state!=rr.NOT_INSTALLED&&![ir.DEFAULT,ir.WALLET_CONNECT_2,ir.LEDGER].includes(C.type)&&a(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((d,y,S)=>gi(S,y)&&m(d)&&!ok.includes(d)||d==ir.DEFAULT&&!h(p),"shouldExcludeWallet");return{list:u.filter(d=>!g(d.type,e??"",s)),terminateConnectingWallets:f}}i(It,"useWalletList");import{Modal as sk}from"@rango-dev/ui";import lk from"react";import{create as ak}from"zustand";var dd="rango-widget";var ar=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(dd),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 ik=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"),uo=ik;var oe=uo(ak()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!1,showCompactTokenSelector:!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})},setShowCompactTokenSelector:o=>{t({showCompactTokenSelector:o})}}))),Fo=new ar({onInit:()=>oe.setState({tabManagerInitiated:!0}),onClaim:()=>oe.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>oe.setState({isActiveTab:!1})});function R(t){let{watermark:e}=oe();return lk.createElement(sk,{hasWatermark:e==="FULL",...t},t.children)}i(R,"WatermarkedModal");import{i18n as Sn}from"@lingui/core";import{Alert as vk,Button as wk,Divider as Cn,Image as Ek,MessageBox as bk,RadioRoot as xk,WalletImageContainer as Ik}from"@rango-dev/ui";import le,{useEffect as Ak,useMemo as Nk,useState as Wk}from"react";import{i18n as dk}from"@lingui/core";import{Typography as Td}from"@rango-dev/ui";import hn from"react";function bi(t,e){return t.find(o=>o.name===e)?.logo}i(bi,"getBlockchainLogo");import{darkTheme as ck,Image as pk,styled as Xt,Typography as uk}from"@rango-dev/ui";var xi=Xt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${ck} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Ii=Xt("div",{display:"flex",gap:"$8",alignItems:"center"}),fd=Xt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),gd=Xt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),hd=Xt("div",{display:"flex",gap:"$6",alignItems:"center"}),yd=Xt("div",{paddingLeft:"48px"}),Sd=Xt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),Cd=Xt(uk,{maxWidth:"100px"}),Ai=Xt(pk,{variants:{disabled:{true:{opacity:"0.5"}}}});function Ni(t){let{namespace:e}=t,o=T().blockchains();return hn.createElement(xi,{unsupported:!0},hn.createElement(Ii,null,hn.createElement(Ai,{src:bi(o,e.id),size:40,disabled:!0}),hn.createElement(gd,null,hn.createElement(Td,{variant:"label",size:"large"},e.label),hn.createElement(Td,{variant:"body",size:"xsmall"},dk.t("(Currently not supported)")))))}i(Ni,"NamespaceUnsupportedItem");import{Checkbox as Ck,Radio as Tk}from"@rango-dev/ui";import Fs from"react";import{i18n as $s}from"@lingui/core";import{ChevronDownIcon as fk,ChevronUpIcon as gk,Divider as hk,Typography as sr}from"@rango-dev/ui";import Ne,{useEffect as yk,useState as Sk}from"react";import{Image as vd,Tooltip as wd,Typography as mk}from"@rango-dev/ui";import $t from"react";import{styled as kd}from"@rango-dev/ui";var Ms=kd("div",{display:"flex",alignItems:"center",padding:0,margin:0}),Wi=kd("div",{marginLeft:"-5px",listStyleType:"none",backgroundColor:"$background",borderRadius:"$lg",minWidth:"15px",height:"15px",variants:{firstItem:{true:{marginLeft:0}}},display:"flex",alignItems:"center",justifyContent:"center"});var Ds=3;function Ed(t){let{chains:e}=t;return $t.createElement(Ms,{id:"widget-supported-chains-container"},e.slice(0,Ds).map((o,n)=>$t.createElement(wd,{key:o.name,container:W(),side:"bottom",align:"start",content:o.name,sideOffset:4},$t.createElement(Wi,{firstItem:n===0},$t.createElement(vd,{src:o.logo,size:15})))),e.length>Ds&&$t.createElement(wd,{container:W(),side:"bottom",align:"start",sideOffset:4,content:$t.createElement(Ms,null,e.map((o,n)=>$t.createElement(Wi,{key:o.name,firstItem:n===0},$t.createElement(vd,{src:o.logo,size:15}))))},$t.createElement(Wi,null,$t.createElement(mk,{variant:"body",size:"xsmall"},"+",e.length-Ds))))}i(Ed,"SupportedChainsList");function Oo(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=Sk(!1),p=T().blockchains();yk(()=>l(!1),[o]);let u=e.getSupportedChains(p),m=!o&&!r&&u.length>1;return Ne.createElement(xi,{hasError:!!o,clickable:!!s,onClick:s},Ne.createElement(Ii,null,Ne.createElement(Ai,{src:bi(p,e.id),size:40}),Ne.createElement(fd,{showSupportedChains:m||r||!!o},Ne.createElement(hd,null,Ne.createElement(sr,{variant:"label",size:"large"},e.label),r&&Ne.createElement(sr,{variant:"body",size:"small",color:"success500"},$s.t("Connected")),!!o&&Ne.createElement(sr,{variant:"body",size:"small",color:"error500"},$s.t("Connection failed"))),m&&Ne.createElement(Ed,{chains:u}),r&&Ne.createElement(Cd,{variant:"body",size:"small",color:"neutral700"},a),o&&Ne.createElement(Sd,{onClick:()=>l(f=>!f)},Ne.createElement(sr,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},$s.t("See why")),c?Ne.createElement(gk,{size:12,color:"gray"}):Ne.createElement(fk,{size:12,color:"gray"}))),n),!!o&&c&&Ne.createElement(Ne.Fragment,null,Ne.createElement(hk,{size:4}),Ne.createElement(yd,null,Ne.createElement(sr,{variant:"body",size:"small",color:"neutral700"},o))))}i(Oo,"NamespaceItem");function bd(t){let{onClick:e,type:o,namespace:n}=t;return Fs.createElement(Oo,{namespace:n,onClick:e,suffix:o==="radio"?Fs.createElement(Tk,{value:n.value}):Fs.createElement(Ck,{checked:t.value})})}i(bd,"NamespaceListItem");import{Button as kk,styled as xd}from"@rango-dev/ui";var Pi=xd("ul",{padding:0,paddingBottom:"$20",margin:0}),yn=xd(kk,{minHeight:"$40"});function lr(t){let{targetWallet:e}=t.value,o=e.properties?.find(d=>d.name==="namespaces"),n=e.isHub,r=e.isHub?o?.value.selection==="single":e.needsNamespace?.selection==="single",a=n?o?.value:e.needsNamespace,s=e.image,c=T().blockchains(),[l,p]=Wk([]),u=Nk(()=>a?.data.filter(d=>!d.unsupported),[e?.type]),m=i(d=>{p(r?[d]:y=>y.includes(d)?y.filter(S=>S!==d):y.concat(d))},"onSelect"),f=u?.length===l.length,h=i(()=>{if(r)throw new Error("onSelectAll should not be called on single selection mode.");f?p([]):u&&p(u.map(d=>d.value))},"onSelectAll"),g=i(d=>r?le.createElement(xk,{value:l?.[0]},d):le.createElement(le.Fragment,null,d),"wrapRadioRoot");return Ak(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let d=u.filter(y=>y.getSupportedChains(c).some(S=>t.value.defaultSelectedChains?.includes(S.name)));p(d.map(y=>y.value))}else p(u.map(d=>d.value))},[]),le.createElement(le.Fragment,null,le.createElement(bk,{type:"info",title:Sn.t("Connect {wallet}",{wallet:e.title}),description:Sn.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect."),icon:le.createElement(Ik,null,le.createElement(Ek,{src:s,size:45}))}),r?le.createElement(le.Fragment,null,le.createElement(Cn,{size:20,className:"_initial_namespace_list_header_alert_top_divider"}),le.createElement(vk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:Sn.t("This wallet can only connect to one chain at a time. ")}),le.createElement(Cn,{size:30,className:"_initial_namespace_list_header_alert_bottom_divider"})):le.createElement(le.Fragment,null,le.createElement(Cn,{size:30,className:"_initial_namespace_list_header_button_top_divider"}),le.createElement(wk,{style:{marginLeft:"auto"},id:"widget-name-space-select-all-btn",size:"xsmall",variant:"ghost",type:"primary",onClick:h},f?Sn.t("Deselect all"):Sn.t("Select all")),le.createElement(Cn,{size:10,className:"_initial_namespace_list_header_button_bottom_divider"})),le.createElement(Pi,null,g(le.createElement(le.Fragment,null,a?.data.map((d,y,S)=>le.createElement(le.Fragment,{key:d.id},d.unsupported?le.createElement(Ni,{namespace:d}):le.createElement(bd,{value:l.includes(d.value),namespace:d,type:r?"radio":"checkbox",onClick:()=>m(d.value)}),y!==S.length-1&&le.createElement(Cn,{size:10})))))),le.createElement(Cn,{size:20}),le.createElement(yn,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!l.length,onClick:()=>t.onConfirm(l)},Sn.t("Connect")))}i(lr,"Namespaces");import{i18n as cr}from"@lingui/core";import{Alert as $k,Button as Fk,Divider as Tn,Image as Ok,MessageBox as Uk,WalletImageContainer as zk}from"@rango-dev/ui";import{useWallets as Hk}from"@rango-dev/wallets-react";import fe from"react";import{styled as Pk}from"@rango-dev/ui";var Id=Pk("div",{display:"flex",justifyContent:"end"});import{i18n as Os}from"@lingui/core";import{Button as Bk,Spinner as Lk}from"@rango-dev/ui";import Us,{useLayoutEffect as _k,useRef as Mk,useState as Dk}from"react";function Ad(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=Dk(null),p=Mk(!1);_k(()=>{o&&!p.current&&u()},[]);let u=i(async g=>{try{p.current=!0,await a(g)}catch(d){l(d)}finally{p.current=!1}},"handleConnectNamespace"),m=i(async()=>{l(null),r.connected?await s():u({shouldAskForDerivationPath:!0})},"handleButtonClick"),f=i(()=>{let g=r.accounts?.[0]?.split(":"),d=g?.[g.length-1];return!r.connected||!d?null:po(d)},"getConnectedAddress"),h=i(()=>r.connected?Os.t("Disconnect"):c?Os.t("Try again"):Os.t("Connect"),"getButtonText");return Us.createElement(Oo,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?Us.createElement(Lk,{color:"info"}):Us.createElement(Bk,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>m(),disabled:n},h())})}i(Ad,"NamespaceDetachedItem");function pr(t){let{value:e,selectedNamespaces:o,onConfirm:n,confirmText:r=cr.t("Done"),onDisconnectWallet:a,navigateToDerivationPath:s}=t,{targetWallet:c}=e,{connect:l,disconnect:p,state:u}=Hk(),m=c.type,f=u(m),h=c.properties?.find(E=>E.name==="namespaces"),g=c.properties?.find(E=>E.name==="derivationPath"),d=h?.value.selection==="single",y=i(async(E,w)=>{d&&await p(m),g&&w?.shouldAskForDerivationPath?s(E):await l(m,[{namespace:E,network:"",derivationPath:w?.derivationPath??void 0}])},"handleConnectNamespace"),S=i(async E=>{await p(m,[E])},"handleDisconnectNamespace"),C=i(()=>d?fe.createElement(fe.Fragment,null,fe.createElement(Tn,{size:20,className:"_detached_namespace_list_header_alert_top_divider"}),fe.createElement($k,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:cr.t("This wallet can only connect to one chain at a time.")}),fe.createElement(Tn,{size:30,className:"_detached_namespace_list_header_alert_bottom_divider"})):fe.createElement(fe.Fragment,null,fe.createElement(Tn,{size:30,className:"_detached_namespace_list_header_button_top_divider"}),fe.createElement(Id,null,fe.createElement(Fk,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:f.connecting||!f.connected,onClick:a},cr.t("Disconnect wallet"))),fe.createElement(Tn,{size:16,className:"_detached_namespace_list_header_button_bottom_divider"})),"renderNamespaceListHeader"),k=i(E=>{if(E.unsupported)return fe.createElement(Ni,{namespace:E});let w=o?.find(x=>x.namespace===E.value),I=f.namespaces?.get(E.value);if(!I)throw new Error(`State for ${E.value} was not found!`);let A=d&&f.connecting;return fe.createElement(Ad,{namespace:E,initialConnect:!!w,disabled:A,state:I,handleConnect:async x=>y(E.value,{derivationPath:w?.derivationPath,shouldAskForDerivationPath:x?.shouldAskForDerivationPath}),handleDisconnect:async()=>S(E.value)})},"renderNamespaceItem");return fe.createElement(fe.Fragment,null,fe.createElement(Uk,{type:"info",title:cr.t("Connect {wallet}",{wallet:c.type}),description:cr.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:fe.createElement(zk,null,fe.createElement(Ok,{src:c.image,size:45}))}),C(),fe.createElement(Pi,{id:"widget-detached-namespace-list"},c.needsNamespace?.data.map((E,w,I)=>fe.createElement(fe.Fragment,{key:E.id},k(E),w!==I.length-1&&fe.createElement(Tn,{size:10})))),fe.createElement(Tn,{size:20}),fe.createElement(yn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},r))}i(pr,"Detached");import{i18n as kn}from"@lingui/core";import{Divider as Vk,Image as Kk,MessageBox as jk,Select as Xk,TextField as Yk}from"@rango-dev/ui";import At,{useEffect as Zk,useState as Wd}from"react";import{namespaces as Qk}from"@rango-dev/wallets-shared";var Bi={id:"custom",label:"Custom",generateDerivationPath:t=>t};function zs(t){let e=t?Qk[t]?.derivationPaths:null;return e?[...e,Bi]:[]}i(zs,"getDerivationPaths");import{Button as qk,styled as Hs,Typography as Gk}from"@rango-dev/ui";var Nd=Hs("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Qs=Hs(Gk,{paddingLeft:"$10"}),qs={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},BM=Hs(qk,{minHeight:"$40"});var Pd="0";function ur(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Wd(null),[c,l]=Wd(Pd),p=a===Bi.id,u=zs(o),m=i(({value:h})=>{let g=u?.find(d=>d.id===h);g&&(a===Bi.id&&Number.isNaN(Number(c))&&l(Pd),s(g.id))},"handleDerivationPathItemClick"),f=i(()=>{let h=u.find(g=>g.id===a);if(h)e(h.generateDerivationPath(c));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return Zk(()=>{s(zs(o)[0]?.id||null)},[o]),At.createElement(At.Fragment,null,At.createElement(jk,{type:"info",title:kn.t("Select Derivation Path"),description:kn.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:At.createElement(Kk,{src:n,size:45})}),At.createElement(Nd,{className:"_derivation_path_inputs_container"},At.createElement(Qs,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},kn.t("Choose Derivation Path Template")),At.createElement(Xk,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:m,styles:{trigger:qs}}),At.createElement(Vk,{size:20}),At.createElement(Qs,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?kn.t("Enter Path"):kn.t("Enter Index")),At.createElement(Yk,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:qs})),At.createElement(yn,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!u||!a||!c},kn.t("Confirm")))}i(ur,"DerivationPath");import{i18n as vn}from"@lingui/core";import{Image as ev,MessageBox as Vs,WalletImageContainer as tv,WalletState as ov}from"@rango-dev/ui";import{useWallets as nv}from"@rango-dev/wallets-react";import Uo from"react";import{keyframes as Jk,styled as Gs}from"@rango-dev/ui";var QM=Gs("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Bd=Gs("div",{position:"relative"}),Rk=Jk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Ld=Gs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Rk} 1s linear infinite`,top:0,bottom:0,right:0,left:0});function Ks(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a,getWalletInfo:s}=nv();return Jn(s(n),a(n))===ov.CONNECTED?Uo.createElement(Vs,{type:"success",title:vn.t("Wallet Connected"),description:vn.t("Your wallet is connected, you can use it to swap.")}):o?Uo.createElement(Vs,{type:"error",title:vn.t("Failed to Connect"),description:o||vn.t("Your wallet is not connected. Please try again.")}):Uo.createElement(Vs,{type:"loading",title:vn.t("Connecting to your wallet"),description:vn.t("Click connect in your wallet popup."),icon:Uo.createElement(Bd,null,Uo.createElement(tv,null,Uo.createElement(ev,{src:r,size:45})),Uo.createElement(Ld,null))})}i(Ks,"ConnectStatus");import{i18n as js}from"@lingui/core";import{Button as rv,Divider as _d,MessageBox as iv}from"@rango-dev/ui";import Li from"react";function Xs(t){let{displayName:e,onConfirm:o,id:n}=t;return Li.createElement(iv,{id:n,title:js.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:js.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Li.createElement(_d,{size:18}),Li.createElement(_d,{size:32}),Li.createElement(rv,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},js.t("Confirm")))}i(Xs,"ExperimentalChain");function Md(t,e){return t().status==="init"&&!!e}i(Md,"isOnStatus");function dr(t){return t().status==="namespace"}i(dr,"isOnNamespace");function mr(t){return t().status==="derivationPath"}i(mr,"isOnDerivationPath");function Wo(t){return t().status==="detached"}i(Wo,"isOnDetached");var cv=3e3,pv=300;function fr(t){let e=lv(),[o,n]=Dd(!1),[r,a]=Dd(),s=i(w=>{a(w.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=It(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:m,resetState:f,handleDisconnect:h}=an(),g=i(w=>{u(t.wallet,w).then(k).catch(s)},"handleConfirmNamespaces"),d=i(()=>{S()},"handleDetachedConfirm"),y=i(w=>{if(!w)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(t.wallet,w).then(k).catch(s)},"handleDerivationPathConfirm"),S=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),k=i((w,I)=>{let A=w.status==="connected",x=["disconnected","disconnected-unhandled"].includes(w.status);A?(t.onConnect?.(),I||(e.current=setTimeout(S,cv))):x&&S()},"afterConnected"),E=i(w=>{t.wallet?.needsDerivationPath&&u(t.wallet,[w])},"handleNavigateToDerivationPath");return sv(()=>{if(t.wallet){C();let w=!1,I=!0;i(()=>{setTimeout(()=>{I=!1,w||n(!0)},pv)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(x=>{["namespace","Detached","derivation-path"].includes(x.status)||(w=!0),k(x,I)}).catch(s)}},[t.wallet]),mo.createElement(R,{id:t.id,open:o,onClose:S,onExit:()=>{C(),c(),t.onClose&&t.onClose()},container:W()},Md(m,t.wallet)&&mo.createElement(mo.Fragment,null,mo.createElement(Ks,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),mo.createElement(av,{direction:"vertical",size:32})),dr(m)&&mo.createElement(lr,{onConfirm:g,value:m().namespace}),mr(m)&&mo.createElement(ur,{onConfirm:y,value:m().derivationPath}),Wo(m)&&mo.createElement(pr,{onConfirm:d,onDisconnectWallet:()=>void h(m().namespace.targetWallet),value:m().namespace,selectedNamespaces:m().selectedNamespaces,navigateToDerivationPath:E}))}i(fr,"StatefulConnectModal");import cs from"react";import uv,{Fragment as dv}from"react";import{MemoryRouter as mv,useInRouterContext as fv}from"react-router";function _i({children:t}){let o=fv()?dv:mv;return uv.createElement(o,null,t)}i(_i,"AppRouter");import{I18nManager as gW}from"@rango-dev/ui";import Hp from"react";import He from"react";import{useRoutes as V0}from"react-router-dom";var O={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 En,useRef as zi}from"react";import lt from"bignumber.js";import{create as gm}from"zustand";import{subscribeWithSelector as hm}from"zustand/middleware";import{createContext as gv,useContext as hv}from"react";var $d=gv({swapMode:"swap",isMultiMode:!1});function at(){let{swapMode:t,isMultiMode:e}=hv($d);return{swapMode:t,isMultiMode:e}}i(at,"useSwapMode");import{i18n as Et}from"@lingui/core";import{getRelatedWalletOrNull as Cv,RouteEventType as a$}from"@rango-dev/queue-manager-rango-preset";import Ve from"bignumber.js";import{PendingSwapNetworkStatus as gr}from"rango-types";import{i18n as Ge}from"@lingui/core";var ne=i(()=>({genericServerError:Ge.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Ge.t("Please reset your liquidity sources."),description:Ge.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Ge.t("No Routes Found."),description:Ge.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:Ge.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Ge.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Ge.t("High Price Impact"),title:Ge.t("Price impact is too high!"),description:Ge.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Ge.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Ge.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Ge.t("USD Price Unknown"),title:Ge.t("USD Price Unknown, Cannot calculate Price Impact."),description:Ge.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Ge.t("Confirm USD Price Unknown")}}),"errorMessages");function Fd(t){return t.type===0?t.diagnosisMessage??ne().noResultError.title:t.type===1?t.diagnosisMessage??ne().genericServerError:""}i(Fd,"getQuoteErrorMessage");import{i18n as Mi}from"@lingui/core";var zo=i(()=>({connectWallet:Mi.t("Connect Wallet"),swap:Mi.t("Swap"),swapAnyway:Mi.t("Swap anyway"),ethWarning:Mi.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Ys(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(Ys,"getFeeLabel");var Zs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Od=100,Ud=30,zd=15,Hd=60;var Qd=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],qd=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as Sv}from"@rango-dev/queue-manager-rango-preset";import VD from"bignumber.js";function Vd(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(Vd,"getRequiredBalanceOfWallet");function Zt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Zt,"getPriceImpactLevel");function Di(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=Sv(t.steps);if(!r||!n)return{fromBlockchain:null,fromToken:void 0,toBlockchain:null,toToken:void 0,inputAmount:""};let s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},c=Po(a?a.toBlockchain:n.fromBlockchain,e),l=Po(r.toBlockchain,e),p=o(a?{blockchain:c?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:c?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:c,fromToken:p,toBlockchain:l,toToken:u,inputAmount:m}}i(Di,"createRetryQuote");function wn(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=Ho(o),s=st(o);if(o&&a&&s){let p=Yt(a.toString(),s.toString());if(!!p&&Zd(a,p)){let m=Fi(o?.swaps,n),f=Zt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:m,warningLevel:f}}}if(e&&em(e,o))return{type:4,usdValueChange:D(st(o)?.minus(st(e)??0).toString()??"0",null,2),percentageChange:D(Yt(st(e)??"1",st(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Oi(o.swaps),l=r>un;if(Rd(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Jd(o,r),minRequiredSlippage:c};return null}i(wn,"generateQuoteWarnings");function Kd(t){return![4].includes(t.type)}i(Kd,"isQuoteWarningConfirmationRequired");function Yt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Js(t.toString(),e.toString());return n&&n<0?n:null}i(Yt,"getPriceImpact");var jd=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"),$i=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 c=o.requestId.toLowerCase(),l=n.requestId.toLowerCase();return c.localeCompare(l)}),"sortQuotesBy"),Xd=i((t,e,o)=>{let n=e[0];if(!e.length||!n)return null;if(!t)return{requestAmount:o,validationStatus:null,...n};let r=new Set(t.swaps.map(s=>s.swapperId)),a=e.find(s=>{let c=new Set(s.swaps.map(l=>l.swapperId));return Array.from(r).every(l=>c.has(l))});return{requestAmount:o,validationStatus:null,...a||n}},"getDefaultQuote"),Yd=i(t=>{let e=i((o,n)=>{let r=Zs.indexOf(o.value),a=Zs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Zd(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Qd.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ve(r)))}i(Zd,"hasHighValueLoss");function tm(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ve(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ve(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(tm,"hasLimitError");function om(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new Ve(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new Ve(c.fromAmountMaxValue):null;return c.fromAmountRestrictionType==="EXCLUSIVE"?l?.gte(c.fromAmount)||p?.lte(c.fromAmount):l?.gt(c.fromAmount)||p?.lt(c.fromAmount)})[0];if(!e)return{swap:void 0,fromAmountRangeError:"",recommendation:""};let o=e.fromAmountMinValue?new Ve(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ve(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=Et.t({id:"Required: >= {min} {symbol}",values:{min:D(o,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=Et.t({id:"Required: > {min} {symbol}",values:{min:D(o,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=Et.t({id:"Required: <= {max} {symbol}",values:{max:D(n,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=Et.t({id:"Required: < {max} {symbol}",values:{max:D(n,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(om,"getLimitErrorMessage");function nm(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:c,needsToWarnEthOnPath:l}=t;return e!=="success"?{title:zo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||c||!r||r==="0"?{title:zo().swap,action:"confirm-swap",disabled:!0}:s?{title:zo().swapAnyway,action:"confirm-warning",disabled:!1}:l?{title:zo().ethWarning,action:"confirm-warning",disabled:!1}:{title:zo().swap,action:"confirm-swap",disabled:!1}:{title:zo().connectWallet,action:"connect-wallet",disabled:!1}}i(nm,"getSwapButtonState");function Rs(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ue))&&e&&e!=="0"&&n!==0)}i(Rs,"canComputePriceImpact");function el(t,e){let o=ue;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(!r||r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Ve(r.amount).multipliedBy(a||0))}return o}i(el,"getUsdFeeOfStep");function Fi(t,e){return t.reduce((o,n)=>o.plus(el(n,e)),ue)}i(Fi,"getTotalFeeInUsd");function tl(t){let e=ue,o=new Ve(t.price||0);return e=e.plus(new Ve(t.amount).multipliedBy(o)),e}i(tl,"getUsdFee");function rm(t){return t.reduce((e,o)=>e.plus(tl(o)),ue)}i(rm,"getTotalFeesInUsd");function im(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(im,"getFeesGroup");function am(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?Object.fromEntries(e):null}i(am,"checkSlippageErrors");function Jd(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?Object.fromEntries(o):null}i(Jd,"checkSlippageWarnings");function Oi(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(Oi,"getMinRequiredSlippage");function Rd(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Rd,"hasProperSlippage");function sm(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:c,excludeLiquiditySources:l,slippage:p,affiliateRef:u,affiliatePercent:m,affiliateWallets:f,destination:h,contractCall:g}=t,d=a?.reduce((C,k)=>(C[k.chain]=k.address,C),{}),y=[];return r?.forEach(C=>{y.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:m??void 0,affiliateWallets:f??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:y,selectedWallets:d??{},slippage:p.toString(),contractCall:g,...h&&{destination:h},...l&&{swapperGroups:s.concat(c??[]),swappersGroupsExclude:!0},...!l&&{swapperGroups:c?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1}}}i(sm,"createQuoteRequestBody");function lm(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(lm,"getWalletsForNewSwap");function Ho(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new Ve(e).multipliedBy(o)}i(Ho,"getUsdInputFrom");function st(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1]?.to.usdPrice;if(!(!e||!o))return new Ve(e).multipliedBy(o)}i(st,"getUsdOutputFrom");function Js(t,e){return new Ve(e).div(new Ve(t)).minus(1).multipliedBy(Od).toNumber()}i(Js,"getPercentageChange");function em(t,e){let o=Ho(t),n=st(t),r=st(e);if(!o||!n||!r)return!1;let a=Js(n.toString(),r.toString());return qd.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(em,"isOutputAmountChangedExcessively");function cm(t,e,o){let n=t.validationStatus,r=Mo({filter:"required",quote:t});return e.sort((s,c)=>r.indexOf(s.chain)-r.indexOf(c.chain)).flatMap(s=>Vd(s,n)||[]).filter(s=>!s.ok).map(s=>{let c=s.asset.symbol,l=D(new Ve(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=D(new Ve(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=Et.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=Et.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=Et.t(" for input and network fee")),Et.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:p,symbol:c,reason:u,currentAmount:l,blockchain:vt(s.asset.blockchain,o)}})})}i(cm,"generateBalanceWarnings");function hr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==gr.NetworkChanged}i(hr,"isNetworkStatusInWarningState");function pm(t,e,o){let n="bellow button or",r=t.extraMessage,a=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(n)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(n,"")),hr(e)){r=t.networkStatusExtraMessage||"",a=t.networkStatusExtraMessageDetail||"";let p=(e?Cv(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case gr.WaitingForConnectingWallet:r=u?Et.t("Connect {wallet}",{wallet:u}):r;break;case gr.WaitingForQueue:r=r||Et.t("Waiting for other running tasks to be finished");break;case gr.WaitingForNetworkChange:r=r||Et.t("Waiting for changing wallet network");break;case gr.NetworkChangeFailed:r=r||Et.t("The network switch could not be completed. Please try again, or switch the network manually in your wallet.");break;default:r=r||"";break}}a=a||"",r=r||"";let c=r?.indexOf("code")!==-1&&r?.indexOf("reason")!==-1;return{shortMessage:r,detailedMessage:{content:a,long:c}}}i(pm,"getSwapMessages");function um(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(um,"getLastConvertedTokenInFailedSwap");function dm(t){return t.status==="failed"}i(dm,"shouldRetrySwap");function mm(t,e,o,n,r,a){if(!n||t)return!0;let s=Mo({filter:"all",quote:n}),c=Mo({filter:"required",quote:n}),l=s.every(m=>r.some(f=>f.chain===m)),p=c.every(m=>r.some(f=>f.chain===m)),u=o&&a?Bo(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(mm,"isConfirmSwapDisabled");function fm(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(fm,"isTokensIdentical");var Ui=i((t,e)=>t?.usdPrice?new lt(e||ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),ym=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new lt(0),outputUsdValue:new lt(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=ue,a=o.inputUsdValue;return Zn(o.inputAmount)?(e&&(n=e?.outputAmount?new lt(e?.outputAmount):null,a=Ho(e)??ue,r=st(e)??ue),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new lt(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new lt(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new lt(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:Ui(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 lt(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),sanitizeInputAmount:e=>{let o=Lu(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=Nu(e);ui(e)||(o=Eu(o),o=bu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new lt(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:Ui(n.fromToken,o)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Ui(n??null,s),outputUsdValue:new lt(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?Ui(e.toToken,e.outputAmount?.toString()||""):new lt(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new lt(0),inputUsdValue:new lt(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new lt(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})}),"initializer"),Sm=gm()(hm(ym)),Cm=gm()(hm(ym)),Tv=uo(Sm),kv=uo(Cm);function G(){let{swapMode:t}=at();return uo(t==="refuel"?Cm:Sm)}i(G,"useQuoteStore");var Tm=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&de.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&&de.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})},"subscribeCallback"),km=Tv.subscribe(Tm),vm=kv.subscribe(Tm);function wm(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=G()(),u=T().config,m=T().fetchStatus,f=T().blockchains(),{findToken:h}=T(),{setAffiliateRef:g,setAffiliatePercent:d,setAffiliateWallets:y}=T(),S=u?.from?.tokens,C=u?.from?.blockchains,k=u?.to?.tokens,E=u?.to?.blockchains,w=zi(void 0),I=zi(void 0),A=zi(void 0),x=zi(void 0);En(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),En(()=>{if(m==="success"){r();let b=f.find(B=>B.name===u?.from?.blockchain),v=u?.from?.token,N=v&&h(v);(b||!b&&A.current)&&n(b??null),N?a({token:N,meta:{blockchains:f}}):!N&&w.current&&a({token:null}),A.current=u?.from?.blockchain,w.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,m]),En(()=>{Es(s,S)&&a({token:null}),bs(l,C)&&n(null)},[S,C]),En(()=>{Es(c,k)&&a({token:null}),bs(p,E)&&o(null)},[k,E]),En(()=>{if(m==="success"){r();let b=f.find(B=>B.name===u?.to?.blockchain),v=u?.to?.token,N=v&&h(v);(b||!b&&x.current)&&o(b??null),N?e({token:N,meta:{blockchains:f}}):!N&&I.current&&e({token:null}),x.current=u?.to?.blockchain,I.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,m]),En(()=>{g(u?.affiliate?.ref??null),d(u?.affiliate?.percent??null),y(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(wm,"useSyncStoresWithConfig");import{useEffect as rl,useRef as vv}from"react";import{useInRouterContext as wv,useLocation as Ev,useSearchParams as bv}from"react-router-dom";function ol(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(ol,"convertTokenSearchParamToAsset");function nl(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(nl,"tokenToSearchParam");function al(){let t=Ev(),[e,o]=bv(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:m,setInputAmount:f}=G()(),h=T().fetchStatus,g=T().blockchains(),d=wv(),{updateIframe:y,updateCampaignMode:S}=T(),C=T().isInCampaignMode(),k=vv(),{findToken:E}=T(),w=i(()=>{let A={};for(let[P,Z]of e.entries())(P.startsWith("utm_")||P.startsWith("privy_"))&&(A[P]=Z);let x=e.get("fromAmount"),b=e.get("fromBlockchain"),v=e.get("fromToken"),N=e.get("toBlockchain"),B=e.get("toToken"),_=e.get("autoConnect"),Q=e.get("clientUrl"),V=e.get("liquiditySources"),Y=e.get("blockchain");return{fromAmount:x,fromBlockchain:b,fromToken:v,toBlockchain:N,toToken:B,autoConnect:_,clientUrl:Q,liquiditySources:V,extraQueryParams:A,blockchain:Y}},"getUrlSearchParams"),I=i(A=>{for(let x in A)A[x]||delete A[x];o(A,{replace:!0})},"updateUrlSearchParams");rl(()=>{let{autoConnect:A,clientUrl:x,extraQueryParams:b,blockchain:v}=w();d&&h==="success"&&I({fromBlockchain:n?.name,fromToken:nl(a),toBlockchain:r?.name,toToken:nl(s),fromAmount:c,autoConnect:A??void 0,clientUrl:x??void 0,blockchain:v??void 0,liquiditySources:C?k.current:void 0,...b})},[t.pathname,c,n,a,r,s,C,h]),rl(()=>{if(!d)return;let A=w();if(!k.current&&A.liquiditySources&&(k.current=A.liquiditySources),A.fromAmount&&f(A.fromAmount),h==="success"){let x=g.find(Q=>Q.name===A.fromBlockchain),b=A.fromToken&&x&&ol(A.fromToken,x),v=b?E(b):void 0,N=g.find(Q=>Q.name===A.toBlockchain),B=A.toToken&&N&&ol(A.toToken,N),_=B?E(B):void 0;x&&(l(x),v&&u({token:v,meta:{blockchains:g}})),N&&(p(N),_&&m({token:_,meta:{blockchains:g}}))}},[h]),rl(()=>{let{clientUrl:A,liquiditySources:x}=w();y("clientUrl",A||void 0),S("liquiditySources",x?.split(",")??void 0)},[])}i(al,"useSyncUrlAndStore");import{i18n as In}from"@lingui/core";import{Alert as Vw,Button as Kw,darkTheme as jw,Divider as Dl,DoneIcon as Xw,styled as Yw,TextField as Zw,Typography as Jw}from"@rango-dev/ui";import je,{useState as Rw}from"react";import{useNavigate as eE,useSearchParams as tE}from"react-router-dom";import{ChevronRightIcon as xv,Divider as Am,Image as Iv,Typography as Nm}from"@rango-dev/ui";import Nt from"react";import{darkTheme as Em,styled as sl}from"@rango-dev/ui";var bm=sl("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${Em} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Em} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),xm=sl("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),Im=sl("div",{display:"flex"});function ll(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return Nt.createElement(xm,null,Nt.createElement(Nm,{size:"large",variant:"label"},n),Nt.createElement(Am,{size:10}),Nt.createElement(bm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},Nt.createElement(Im,null,r&&Nt.createElement(Nt.Fragment,null,Nt.createElement(Iv,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),Nt.createElement(Am,{size:4,direction:"horizontal"})),Nt.createElement(Nm,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),Nt.createElement(xv,{size:12,color:"black"})))}i(ll,"BlockchainSelectorButton");import{i18n as dl}from"@lingui/core";import{Button as Mv,Divider as Mm,MessageBox as Dv}from"@rango-dev/ui";import fo,{useEffect as Dm,useState as ml}from"react";import{i18n as Hi}from"@lingui/core";import{Divider as Qo,ExternalLinkIcon as Wv,Image as Pv,InfoIcon as Bv,Tooltip as Lv,Typography as Sr}from"@rango-dev/ui";import ge from"react";var Wm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function Pm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Pm,"generateExplorerLink");import{Button as Av,darkTheme as bn,styled as yr,Typography as Nv}from"@rango-dev/ui";var cl=yr("a",{textDecoration:"none",color:"$colors$neutral700",[`.${bn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${bn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${bn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${bn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Bm=yr("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${bn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${bn} &`]:{color:"$colors$neutral900"}}}),pl=yr(Av,{minHeight:"$40"}),Lm=yr(Nv,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),_m=yr("div",{display:"flex",justifyContent:"center",alignItems:"center"});var _v=9;function ul(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=Pm(n.address,s),l=i(()=>window.open(Wm,"_blank"),"onClickLearnMore");return ge.createElement(R,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:W()},ge.createElement(Bm,null,ge.createElement(Pv,{src:n.image===""?si:n.image,size:45,type:"circular"}),ge.createElement(Qo,{size:4}),ge.createElement(_m,null,ge.createElement(Lm,{variant:"title",size:"medium"},n.symbol),n.symbol.length>_v&&ge.createElement(Lv,{content:n.symbol,container:W()},ge.createElement(Bv,{size:12,color:"gray"}))),ge.createElement(Sr,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),ge.createElement(Qo,{size:4}),ge.createElement(Sr,{variant:"body",size:"medium"},c?ge.createElement(cl,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,ge.createElement(Wv,{size:12,color:"gray"})):ge.createElement(cl,null,n.address)),ge.createElement(Qo,{size:4}),n.coinSource&&ge.createElement(Sr,{className:"_coin-source",variant:"body",size:"xsmall"},Hi.t("via")," ",ge.createElement(Sr,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),ge.createElement(Qo,{size:"32"}),ge.createElement(Sr,{size:"medium",variant:"body",className:"_custom-token-description"},Hi.t("This token is not part of our verified token list. please verify its source and make sure to understand all associated risks before proceeding."))),ge.createElement(Qo,{size:40}),ge.createElement(Qo,{size:10}),ge.createElement(pl,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Hi.t("Import Anyway")),ge.createElement(Qo,{size:10}),ge.createElement(pl,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},Hi.t("Learn More")))}i(ul,"CustomTokenModal");function Cr(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:c,onExitErrorModal:l,onExitImportModal:p}=t,{setCustomToken:u}=T(),[m,f]=ml(!1),[h,g]=ml(!1),[d,y]=ml(!1),S=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),C=i(()=>{n?.type!=="network-error"&&s?.(),f(!1)},"closeErrorModal"),k=i(()=>{y(!0),C()},"handleErrorModalButtonClick"),E=i(()=>{d&&n?.type==="network-error"&&(y(!1),S()),l()},"handleExit"),w=i(()=>{e&&(u(e),c())},"handleSubmit");return Dm(()=>{n&&f(!0)},[n]),Dm(()=>{o&&e&&g(!0)},[o,e]),fo.createElement(fo.Fragment,null,fo.createElement(R,{open:m,dismissible:!0,id:"widget-add-custom-token-modal",onClose:C,onExit:E,container:W()},fo.createElement(Dv,{title:n?.title??"",type:"error",description:n?.message||dl.t("Failed Network, Please retry.")},fo.createElement(Mm,{size:40}),fo.createElement(Mm,{size:10}),fo.createElement(Mv,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:k},n?.type==="network-error"?dl.t("Retry"):dl.t("Add another custom token")))),o&&e&&fo.createElement(ul,{blockchain:o,token:e,onSubmitClick:w,onClose:()=>g(!1),open:h,onExit:p}))}i(Cr,"ImportCustomToken");import{useManager as Uw}from"@rango-dev/queue-manager-react";import{BottomLogo as zw,Divider as yf,Header as Hw}from"@rango-dev/ui";import Pe,{useEffect as Ji,useLayoutEffect as Qw,useRef as Sf,useState as Cf}from"react";import{useRef as $v}from"react";function Qi(){return window.self!==window.top}i(Qi,"isAppLoadedIntoIframe");function fl(){let t=$v(null),{iframe:e}=T(),o=Qi()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(c=>{for(let l of c)n({type:"widget_height",data:{height:l.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(fl,"useIframe");import{useNavigate as Fv}from"react-router-dom";function Ke(){let t=Fv();return()=>t(-1)}i(Ke,"useNavigateBack");import{createTheme as kl,darkTheme as Zv,lightTheme as Jv}from"@rango-dev/ui";import{useEffect as Rv,useState as ew}from"react";import{theme as Xv,darkColors as Yv}from"@rango-dev/ui";import Cl from"react";var qi=16,Gi=255,$m=.11;function Ov(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(Ov,"expandShortHexColor");function Uv(t,e){return t.padStart(e,"0")}i(Uv,"pad");function gl(t){let e=Math.min(Math.max(Math.round(t),0),Gi);return Uv(e.toString(qi),2)}i(gl,"intToHex");function zv(t){return`#${gl(t.red)}${gl(t.green)}${gl(t.blue)}`}i(zv,"rgbToHex");function Hv(t){let e=parseInt(t.slice(1,3),qi),o=parseInt(t.slice(3,5),qi),n=parseInt(t.slice(5,7),qi);return{red:e,green:o,blue:n}}i(Hv,"hexToRGB");function Qv(t,e){let o=1-$m*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(Qv,"generateShade");function qv(t,e){let o=$m*e;return{red:t.red+(Gi-t.red)*o,green:t.green+(Gi-t.green)*o,blue:t.blue+(Gi-t.blue)*o}}i(qv,"generateTint");function Gv(t){return Fm(t,Qv)}i(Gv,"calculateShades");function Vv(t){return Fm(t,qv)}i(Vv,"calculateTints");function Fm(t,e){let o=Hv(t),n=[];for(let r=1;r<9;r++)n.push(zv(e(o,r)));return n}i(Fm,"calculateColors");function hl(t,e,o){let a=Vv(t).reverse().concat(t),s=Gv(t),c=a.concat(s),l={},p=c.length;for(let u=0;u<p;u++){let m=100+(o?p-1-u:u)*50,f=c[u];f&&(l[`${e}${m}`]=f)}return l}i(hl,"createTintsAndShades");function yl(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)&&!Pu(r)){let l=Ov(a);Object.assign(n,hl(l,r,s))}}return{...n,...e}}i(yl,"expandToGenerateThemeColors");var Om=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),Kv=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Om(o%52)+e;return Om(o%52)+e},"toAlphabeticName"),jv=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Sl=i(t=>Kv(jv(5381,JSON.stringify(t))>>>0),"toHash");function Tl(t){let e=Xv.colors,o={...e,...Yv},n,r;if(t?.light){let s={colors:yl(e,t.light)};n={id:`${ws}-light-${Sl(s)}`,tokens:s}}if(t?.dark){let s={colors:yl(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ws}-dark-${Sl(s)}`,tokens:s}}return{light:n,dark:r}}i(Tl,"customizedThemeTokens");function Um(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Cl.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Cl.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(Cl.cloneElement(e,{key:c}))}}),o}i(Um,"joinList");function zm(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(zm,"doesWindowPreferDarkColorScheme");function go(t){let{colors:e,fontFamily:o=mu,borderRadius:n=qu,secondaryBorderRadius:r=Gu}=t,[a,s]=ew(zm()?"dark":"light"),{theme:c}=T(),{dark:l,light:p}=Tl(e),u=kl({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[u.className,Jv.className],f=[u.className,Zv.className];if(p){let g=kl(p.id,p.tokens);m.push(g.className)}if(l){let g=kl(l.id,l.tokens);f.push(g.className)}return Rv(()=>{let g=i(d=>{d.matches?s("dark"):s("light")},"switchThemeListener");return zm()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=m.join(" "),d=f.join(" ");return c==="auto"?a==="dark"?d:g:c==="dark"?d:g},"getActiveTheme"),mode:c==="auto"?a:c}}i(go,"useTheme");var bt=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 Hm}from"@lingui/core";import{Alert as tw,Button as ow}from"@rango-dev/ui";import Qm from"react";function vl(t){return Qm.createElement(tw,{action:Qm.createElement(ow,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Hm.t("Activate this tab")),type:"warning",variant:"alarm",title:Hm.t("Another tab is open and handles transactions.")})}i(vl,"ActivateTabAlert");import{i18n as wl}from"@lingui/core";import{Button as nw,Divider as rw,MessageBox as iw}from"@rango-dev/ui";import Vi from"react";function El(t){let{open:e,onClose:o,onConfirm:n}=t;return Vi.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:W()},Vi.createElement(iw,{title:wl.t("Activate current tab"),type:"warning",description:wl.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.")},Vi.createElement(rw,{size:20}),Vi.createElement(nw,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},wl.t("Confirm"))))}i(El,"ActivateTabModal");import{ChevronLeftIcon as lw}from"@rango-dev/ui";import Zm from"react";import{css as aw,darkTheme as qm,IconButton as sw,styled as qo}from"@rango-dev/ui";var Ft=qo(sw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${qm} &`]:{backgroundColor:"$neutral"}}}),Gm=qo("div",{position:"absolute",background:"$secondary500",[`.${qm} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),ho=qo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Vm=qo("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"}}}}),Km=qo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),jm=qo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Xm=aw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Ym=qo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function bl(t){return Zm.createElement(Ft,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Zm.createElement(lw,{color:"black",size:16}))}i(bl,"BackButton");import{i18n as cw}from"@lingui/core";import{Button as pw,Typography as uw}from"@rango-dev/ui";import xl from"react";function Il(t){return xl.createElement(ho,null,xl.createElement(pw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},xl.createElement(uw,{variant:"label",size:"medium",color:"error500"},cw.t("Cancel"))))}i(Il,"CancelButton");import{i18n as dw}from"@lingui/core";import{Image as mw,Tooltip as fw,WalletIcon as gw,WalletState as Jm}from"@rango-dev/ui";import Go from"react";function Al(t){let{list:e}=It(),o=e.filter(r=>r.state===Jm.CONNECTED||r.state===Jm.PARTIALLY_CONNECTED),n=o.length?Go.createElement("div",{className:Xm()},o.map(r=>Go.createElement(Ym,{key:r.title},Go.createElement(mw,{src:r.image,size:14})))):dw.t("Connect Wallet");return Go.createElement(fw,{container:t.container,side:"bottom",content:n},Go.createElement(Ft,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&Go.createElement(Gm,null),Go.createElement(gw,{size:18,color:"black"})))}i(Al,"WalletButton");import{i18n as ji}from"@lingui/core";import{NotificationsIcon as Pw,Popover as Bw,SettingsIcon as Lw,Tooltip as Xi,TransactionIcon as _w}from"@rango-dev/ui";import _e from"react";import{Notifications as Cw}from"@rango-dev/ui";import Tw from"react";import{useNavigate as kw}from"react-router-dom";import{create as hw}from"zustand";import{persist as yw,subscribeWithSelector as Sw}from"zustand/middleware";var We=uo(hw()(yw(Sw((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1];if(!r||!a)return;let 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}}},c=e().notifications.filter(l=>l.requestId!==n.requestId);t(()=>({notifications:[...c,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(l=>l.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 Nl(){let t=kw(),{getNotifications:e,clearNotifications:o}=We(),n=e(),r=T().blockchains(),{findToken:a}=T();return Tw.createElement(Cw,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>tu(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${O.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(Nl,"NotificationContent");import{useManager as vw}from"@rango-dev/queue-manager-react";import{InProgressIcon as ww}from"@rango-dev/ui";import Rm from"react";var Ew=i(()=>{let{manager:t}=vw();return bt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Rm.createElement(jm,{id:"widget-header-history-badge-container"},Rm.createElement(ww,{color:"info",size:6})):null},"InProgressTransactionBadge"),ef=Ew;import{EventSeverity as bw}from"@rango-dev/queue-manager-rango-preset";import{Typography as xw}from"@rango-dev/ui";import tf from"react";function of(){let{getNotifications:t}=We(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===bw.WARNING);return o?tf.createElement(Vm,{isSever:n},tf.createElement(xw,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(of,"NotificationsBadge");import{RefreshProgressButton as Iw}from"@rango-dev/ui";import Wl,{useEffect as Aw,useState as nf}from"react";var Nw=1e3,rf=60,Ww=100;function Ki({onClick:t}){let[e,o]=nf(0),[n,r]=nf(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");Aw(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===rf&&c()},Nw):s(l),document.addEventListener("visibilitychange",()=>a(l)),()=>{document.removeEventListener("visibilitychange",()=>a(l)),l&&clearInterval(l)}},[e,t]);let s=i(l=>{l&&clearInterval(l),o(0)},"clearTimeout"),c=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return Wl.createElement(Ft,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},Wl.createElement(Km,{onTransitionEnd:()=>r(!1),isRefetched:n},Wl.createElement(Iw,{size:22,color:t?"black":"gray",progress:e/rf*Ww})))}i(Ki,"RefreshButton");function Vo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=T(),c=it("notification",s)||r.includes("notifications");return _e.createElement(_e.Fragment,null,!r.includes("refresh")&&_e.createElement(Xi,{container:a||W(),side:"top",content:ji.t("Refresh")},_e.createElement(Ki,{onClick:e})),!c&&_e.createElement(Bw,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:W(),content:_e.createElement(Nl,null)},_e.createElement("div",null,_e.createElement(Xi,{container:W(),side:"top",content:ji.t("Notifications")},_e.createElement(Ft,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},_e.createElement(Pw,{size:18,color:"black"}),_e.createElement(of,null))))),!r.includes("settings")&&_e.createElement(Xi,{container:W(),side:"top",content:ji.t("Settings")},_e.createElement(Ft,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},_e.createElement(Lw,{size:18,color:"black"}))),!r.includes("history")&&_e.createElement(Xi,{container:W(),side:"top",content:ji.t("History")},_e.createElement(Ft,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},_e.createElement(_w,{size:18,color:"black"}),_e.createElement(ef,null))))}i(Vo,"HeaderButtons");import{i18n as Pl}from"@lingui/core";import{Divider as sf,MessageBox as $w,RefreshIcon as Fw}from"@rango-dev/ui";import xn from"react";import{Button as Mw,styled as Dw}from"@rango-dev/ui";var af=Dw(Mw,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function Bl(t){let{open:e,onClose:o}=t;return xn.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:W()},xn.createElement($w,{title:Pl.t("Something went wrong"),type:"error",description:Pl.t("Something went wrong. Please refresh the app.")},xn.createElement(sf,{size:30}),xn.createElement(af,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},xn.createElement(Fw,{size:20,color:"primary"}),xn.createElement(sf,{size:4,direction:"horizontal"}),Pl.t("Refresh"))))}i(Bl,"RefreshModal");var lf="700px",cf="425px",pf="550px",uf="640px",df="800px";function Ll(t){let e=t.target;if(e){let o=e.scrollTop,n=W();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(Ll,"onScrollContentAttachStatusToContainer");import{css as Ow,styled as Yi}from"@rango-dev/ui";var Zi=Ow({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),mf=Yi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",maxHeight:lf,variants:{height:{auto:{height:"auto"},fixed:{height:"100%",minHeight:cf,[`@media screen and (min-height: ${df})`]:{minHeight:pf}}},showBanner:{true:{overflow:"visible"}}}}),ff=Yi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),gf=Yi("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"}}}),hf=Yi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function se(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=fl(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=T(),[u,m]=Cf(!1),{config:{features:f,theme:h}}=T(),{watermark:g}=oe(),d=g==="FULL",{activeTheme:y}=go(h||{}),[S,C]=Cf(!1),k=it("connectWalletButton",f),{isActiveTab:E,tabManagerInitiated:w,showActivateTabModal:I,setShowActivateTabModal:A,activateCurrentTab:x,setShowCompactTokenSelector:b}=oe(),v=Ke(),{manager:N}=Uw(),_=bt(N).map(({swap:X})=>X).some(X=>X.status==="running"),Q=i(()=>x(Fo.forceClaim,_),"onActivateTab"),V=i(()=>{r.onWallet?.()},"onConnectWallet"),Y=typeof r.hasBackButton>"u"||r.hasBackButton,P=Sf(null),Z=Sf(null);return Ji(()=>{let X=(p?.swapBoxBanner?.routes?.length??0)===0,ie=!!p?.swapBoxBanner?.routes?.some(Te=>location.pathname.endsWith(Te));C(!!p?.swapBoxBanner&&(X||ie))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Ji(()=>(Qi()&&Z.current&&e(Z.current),()=>{o()}),[]),Ji(()=>(P.current?.addEventListener("scroll",Ll),()=>{P.current?.removeEventListener("scroll",Ll)}),[]),Ji(()=>{m(c==="failed")},[c]),Qw(()=>{if(!Z.current)return;let X=new ResizeObserver(ie=>{for(let Te of ie)Te.contentRect&&b(Te.contentRect.height<parseInt(uf))});return X.observe(Z.current),()=>X.disconnect()},[]),Pe.createElement(mf,{height:s,id:rt.SWAP_BOX_ID,className:`${y()} ${Zi()}`,ref:Z,showBanner:S},Pe.createElement(Hw,{prefix:Y?Pe.createElement(bl,{onClick:()=>{v(),r.onBack?.()}}):null,title:r.title,suffix:Pe.createElement(Pe.Fragment,null,r.suffix,r.onWallet&&!k&&Pe.createElement(Al,{container:W(),onClick:V,isConnected:!!l?.length}),r.onCancel&&Pe.createElement(Il,{onClick:r.onCancel}))}),Pe.createElement(ff,{ref:P},n),Pe.createElement(El,{open:I,onClose:()=>A(!1),onConfirm:Q}),Pe.createElement(gf,null,Pe.createElement("div",{className:"footer__content"},w&&!E&&Pe.createElement("div",{className:"footer__alert"},Pe.createElement(vl,{onActivateTab:Q}),Pe.createElement(yf,{size:10})),a),Pe.createElement(yf,{size:12}),Pe.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},Pe.createElement(zw,null))),S&&Pe.createElement(hf,null,p?.swapBoxBanner?.element),Pe.createElement(Bl,{open:u,onClose:()=>m(!1)}))}i(se,"Layout");import{styled as qw}from"@rango-dev/ui";var Tf="$20 $20 $10 $20",_l=qw("div",{padding:Tf,overflowY:"auto",flexGrow:1});import{styled as Gw}from"@rango-dev/ui";var pe=Gw("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 yo}from"@lingui/core";import{useState as Ml}from"react";function kf(){let[t,e]=Ml(!1),[o,n]=Ml(null),[r,a]=Ml(null),{findToken:s}=T(),c=T().customTokens(),l=i(()=>{a(null),e(!1),n(null)},"resetState");function p(m,f){switch(m){case"duplicated":return{type:m,title:yo.t("Duplicate Token"),message:yo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:m,title:yo.t("Token Already Exists"),message:yo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{type:m,title:yo.t("Token Not Found"),message:yo.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:f}})};case"network-error":return{type:m,title:yo.t("Network error"),message:yo.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:m,tokenAddress:f})=>{e(!0);try{if(c.some(S=>S.address?.toLowerCase()===f.toLowerCase())){let S=p("duplicated");n(S);return}let g=await gt().getCustomToken({blockchain:m,address:f});if(!g||!g.token||g.error){let S=p("not-found",m);n(S);return}let d=g.token;if(s({blockchain:d.blockchain,address:d.address,symbol:d.symbol})){let S=p("token-exist");n(S);return}return a({...d,warning:!0})}catch(h){if(h.code==="ERR_BAD_REQUEST"){let g=p("not-found",m);n(g);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:l}}i(kf,"useFetchCustomToken");var oE=Yw("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $12",backgroundColor:"$neutral300","& input":{padding:"0"},[`.${jw} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function vf(){let t=eE(),[e]=tE(),o=Ke(),n=T().blockchains(),r=e.get("blockchain")||"",a=Po(r,n),[s,c]=Rw(""),{fetchCustomToken:l,token:p,loading:u,error:m,resetState:f}=kf(),h=!!a&&Bo(a,s),g=!a||!s||!h,d=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return je.createElement(se,{header:{title:In.t("Add Custom Token")}},je.createElement(pe,null,je.createElement(oE,null,je.createElement("div",null,je.createElement(ll,{onClick:()=>t(O.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:In.t("Select chain"),placeholder:In.t("Select chain")}),je.createElement(Dl,{size:"24"}),je.createElement(Jw,{size:"large",variant:"label"},In.t("Enter Address")),je.createElement(Dl,{size:10}),je.createElement(Zw,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:In.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&je.createElement(Xw,{color:"success",size:12}),onChange:y=>c(y.target.value)}),!h&&!!s&&je.createElement(je.Fragment,null,je.createElement(Dl,{size:4}),je.createElement(Vw,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),je.createElement(Kw,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:d},In.t("Import"))),je.createElement(Cr,{token:p,blockchain:a??void 0,address:s,error:m??void 0,fetchCustomToken:l,onCloseErrorModal:()=>{m?.type!=="network-error"&&c("")},onImport:o,onExitErrorModal:f,onExitImportModal:f})))}i(vf,"AddCustomTokenPage");import{i18n as yc}from"@lingui/core";import{useManager as Gb}from"@rango-dev/queue-manager-react";import{Alert as Vb,Button as Kb,css as Cc,Divider as Sc,IconButton as hh,styled as jb,Typography as Xb,WalletIcon as Yb}from"@rango-dev/ui";import $e,{useEffect as Ia,useLayoutEffect as Zb,useRef as Jb,useState as Pr}from"react";import{useNavigate as Rb}from"react-router-dom";import{i18n as Ko}from"@lingui/core";import{Alert as xE,BalanceErrors as IE,Button as Yf,ChevronLeftIcon as AE,Divider as ql,MessageBox as NE,Typography as Gl}from"@rango-dev/ui";import re,{useCallback as WE,useEffect as ia,useMemo as PE,useRef as BE,useState as Pn}from"react";import{useNavigate as LE}from"react-router-dom";import{i18n as Ul}from"@lingui/core";import{Alert as sE,ChevronDownIcon as lE,CloseIcon as cE,Divider as Nf,IconButton as Wf,PasteIcon as pE,Typography as uE,WalletIcon as dE}from"@rango-dev/ui";import Me,{useEffect as Pf,useRef as Bf}from"react";import oa,{useRef as iE}from"react";import*as An from"@radix-ui/react-collapsible";import{keyframes as wf,styled as Ri}from"@rango-dev/ui";var $l=300,nE=wf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),rE=wf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Ef=Ri(An.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Fl=Ri(An.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),ea=Ri(An.Content,{overflow:"hidden",variants:{open:{true:{animation:`${nE} ${$l}ms ease-out`},false:{animation:`${rE} ${$l}ms ease-out`}}}}),ta=Ri("div",{transition:`all ${$l}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function na(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=iE(null);return oa.createElement(Ef,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&oa.createElement(Fl,{className:"collapsible_trigger",onClick:a},s),oa.createElement(ea,{className:"collapsible_content",open:e},r),c==="bottom"&&oa.createElement(Fl,{className:"collapsible_trigger",onClick:a},s))}i(na,"CustomCollapsible");import{darkTheme as bf,styled as Ol,TextField as aE}from"@rango-dev/ui";var xf=Ol("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"},"& input":{padding:"$15"}}),If=Ol(aE,{backgroundColor:"$neutral100"}),Af=Ol("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${bf} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${bf} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Lf(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=G()(),{config:s}=T(),c=T().blockchains(),l=ii(e.name,c),p=Bf(null),u=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!Bo(e,r),g=i(()=>{a("")},"handleClear"),d=i(async C=>{if(C.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),p?.current?.focus()}},"handlePaste"),y=i(()=>r?Me.createElement(Wf,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Me.createElement(cE,{size:12,color:"gray"})):m?null:Me.createElement(Wf,{id:"widget-custom-destination-paste-icon-btn",onClick:d,variant:"ghost"},Me.createElement(pE,{size:16})),"renderSuffix");Pf(()=>{!!u&&r===null&&(a(u),o(!0))},[u]);let S=Bf(null);return Pf(()=>{if(!r){S.current=null;return}n&&Bo(e,r)&&S.current!==r&&(S.current=r,ee({type:"destinationAddressSet",payload:{destinationChain:e.name}}))},[r,n,e]),Me.createElement(xf,null,Me.createElement(na,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(Af,{id:"widget-custom-destination-collapsible-btn"},Me.createElement("div",{className:"button__content"},Me.createElement(dE,{size:18,color:"info"}),Me.createElement(Nf,{size:4,direction:"horizontal"}),Me.createElement(uE,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ul.t("Send to a different address"))),Me.createElement(ta,{orientation:n?"up":"down"},Me.createElement(lE,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(If,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ul.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:y(),onChange:C=>{let k=C.target.value;a(k)}})),h&&Me.createElement(Me.Fragment,null,Me.createElement(Nf,{size:4}),Me.createElement(sE,{variant:"alarm",type:"error",title:Ul.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Lf,"CustomDestination");import{css as mE,IconButton as fE,SelectableWalletButton as gE,styled as So}from"@rango-dev/ui";var _f=So("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Mf=So("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Df=So(gE,{justifyContent:"center"}),$f=So("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),Ff=So(fE,{position:"absolute",left:"$20"}),Of=So("div",{paddingTop:"$20"}),Uf=mE({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),zf=So("div",{display:"flex"}),Hf=So("div",{overflow:"visible",width:"100%"});import{i18n as Hl}from"@lingui/core";import{warn as TE}from"@rango-dev/logging-core";import{Divider as kE,makeInfo as vE,SelectableWallet as wE,Typography as jf,WalletState as Wn}from"@rango-dev/ui";import ct,{useEffect as Xf,useState as kr}from"react";import{Image as SE,MessageBox as CE}from"@rango-dev/ui";import Tr from"react";import{keyframes as hE,styled as zl}from"@rango-dev/ui";var Qf=zl("div",{position:"relative"}),yE=hE({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),qf=zl("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${yE} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Gf=zl("div",{"& img":{borderRadius:"50%"}});import{i18n as Nn}from"@lingui/core";function Vf(t,e){switch(t){case"in-progress":return{type:"loading",title:Nn.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Nn.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Nn.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Nn.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Nn.t("Request Rejected"),description:Nn.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(Vf,"generateMessageByStatus");function Kf(t){let{status:e,displayName:o,image:n}=t,r=Vf(e,o),a=e=="in-progress";return Tr.createElement(CE,{type:r.type,title:r.title,description:r.description,icon:a?Tr.createElement(Qf,null,Tr.createElement(Gf,null,Tr.createElement(SE,{src:n,size:45})),Tr.createElement(qf,null)):void 0})}i(Kf,"ExperimentalChainStatus");var EE=7,bE=3e3;function Ql(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=oe.use.isActiveTab(),{blockchains:l,connectedWallets:p}=T(),[u,m]=kr(),[f,h]=kr(null),[g,d]=kr(!1),[y,S]=kr(null),{suggestAndConnect:C}=ra(),{list:k}=It({chain:e}),[E,w]=kr(k),I=k.length,A=a&&I-a>0,x=i(async v=>{d(!1),S("in-progress");try{let N=k.find(V=>V.type===V.type),B=N?.isHub?N.properties?.find(V=>V.name==="namespaces")?.value:N?.needsNamespace,_=l(),Q=B?.data.find(V=>V.getSupportedChains(_).some(Y=>Y.name===v.chain));if(!Q)throw new Error("Requested chain is not supported");await C(v.walletType,{namespace:Q.value,network:v.chain}),S("completed")}catch{S("rejected")}},"addExperimentalChain");Xf(()=>{w(v=>{let N=k.findIndex(B=>n(B.type,e));return A&&N>1?[k[N]].concat(k.filter((B,_)=>_!==N)):v.map(B=>k.find(_=>_.type===B.type)??B)})},[JSON.stringify(k)]);let b=document.getElementById(rt.SWAP_BOX_ID);return Xf(()=>{let v=null;return(y==="completed"||y==="rejected")&&(v=setTimeout(()=>S(null),bE)),()=>{v&&clearTimeout(v)}},[y]),ct.createElement(ct.Fragment,null,E.slice(0,a).map(v=>{let N=Ou({connectedWallets:p,walletType:v.type,chain:e}),B=v.state===Wn.CONNECTED||v.state===Wn.PARTIALLY_CONNECTED,_=N?po(N,EE):"",Q=B&&!!v.needsNamespace&&!_,V=gi(l(),e),Y=!p.find(me=>me.walletType===v.type&&me.chain===e),P=V&&Y&&v.state===Wn.CONNECTED,Z=i(async()=>{v.state===Wn.DISCONNECTED||Q&&!P?m(v):P?(h({walletType:v.type,chain:e,address:N??""}),d(!0)):r({walletType:v.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=vE(v.state),ie=i(()=>P?Hl.t({id:"Add {chain} chain",values:{chain:e}}):Q?Hl.t("Chain not connected"):_||X.description,"getWalletDescription"),Te=i(()=>v.state===Wn.CONNECTED||v.state===Wn.PARTIALLY_CONNECTED?Q?"neutral600":"neutral700":X.color,"getWalletDescriptionColor"),dt=f?.chain?ii(f.chain,l()):void 0;return ct.createElement(ct.Fragment,{key:`${v.title}_${dt}`},!!f&&ct.createElement(R,{id:"widget-wallets-list-watermarked-modal",open:!!f&&g,container:b,onClose:()=>{h(null)}},ct.createElement(Xs,{id:"widget-wallets-list-experimental-chain-container",displayName:dt,onConfirm:()=>{x(f)}})),y&&ct.createElement(R,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!y,onClose:S.bind(null,null),container:b},ct.createElement(Kf,{status:y,displayName:dt,image:v.image}),ct.createElement(kE,{direction:"vertical",size:32})),ct.createElement(wE,{key:v.type,id:"widget-wallets-list-selectable-wallet-btn",description:ie(),descriptionColor:Te(),onClick:Z,selected:n(v.type,e),disabled:!c,...v}))}),ct.createElement(fr,{id:"widget-wallets-list-stateful-connect-modal",wallet:u,options:{defaultSelectedChains:o||[e]},onClose:()=>{m(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):TE(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),A&&ct.createElement(Df,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},ct.createElement(jf,{variant:"label",size:"medium"},Hl.t("Show more wallets"),ct.createElement(jf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(a??0)))))}i(Ql,"WalletList");var _E=2;function Zf(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=LE(),c=T().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:m,customDestination:f,setCustomDestination:h}=G()(),{config:g,connectedWallets:d,setWalletsAsSelected:y}=T(),[S,C]=Pn(""),[k,E]=Pn([]),[w,I]=Pn(""),[A,x]=Pn(!!f),b=PE(()=>Mo({filter:"all",quote:l}),[l]),v=Mo({filter:"required",quote:l}),N=c.find(z=>z.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),B=i(z=>v.includes(z),"isWalletRequiredFor"),_=WE(()=>d.filter(z=>z.selected&&b.includes(z.chain)),[d,b]),[Q,V]=Pn(_()),[Y,P]=Pn([]),Z=i((z,q)=>P($=>$.concat({blockchain:z,walletType:q})),"addNextSelectedWallets"),X=k.length>0,ie=i((z,q)=>!!Q.find($=>$.walletType===z&&$.chain===q&&$.selected&&(B(q)||!B(q)&&!f)),"isSelected"),Te=i((z,q,$)=>{let M=!1;return z.map(ce=>{if(ce.chain===q){let H=ce.selected;return!M&&$?(M=!0,H=!0):$||(H=!1),{...ce,selected:H}}return ce})},"updateSelectableWallets"),dt=i(z=>{x(z),z?B(N?.name??"")||V(q=>Te(q,N?.name||"",!1)):(h(""),V(q=>Te(q,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),me=i(z=>{if(S&&C(""),ie(z.walletType,z.chain))return;let $=d.find(M=>M.walletType===z.walletType&&M.chain===z.chain);$&&(n(),z.chain===N?.name&&A&&!B(N.name)&&(x(!1),h(null)),V(M=>M.filter(ce=>ce.chain!==z.chain).concat({...$,selected:!0})))},"onChange"),Oe=i(()=>{let z=Q.filter(q=>q.selected);ee({type:"swapWalletsConfirmed",payload:{routeId:l?.requestId??""}}),y(z),p(z),m(!0),o()},"onConfirmBalance"),Qe=i(async()=>{E([]),I("");let z=await r?.({selectedWallets:Q.filter($=>$.selected),customDestination:f}),q=z.warnings;q?.balance?.messages&&E(q.balance.messages),z.error&&I(Fd(z.error)),!z.error&&!q?.balance?.messages.length?Oe():E(q?.balance?.messages??[])},"onConfirmWallets");ia(()=>{V(z=>{let q=[];return z.forEach($=>{!d.some(ce=>ce.chain===$.chain&&ce.walletType===$.walletType&&ce.address===$.address)||q.push($)}),q=q.concat(d.filter($=>!!!q.find(ce=>ce.chain===$.chain)&&$.selected&&b.includes($.chain))),q})},[d,b]),ia(()=>{let z=[];Y.length>0&&(Y.forEach(q=>{let $=d.find(M=>M.chain===q.blockchain&&M.walletType===q.walletType);$?me($):z.push(q)}),P(z))},[d,Y]);let kt=l?.requestId??"",ot=BE(!1);ia(()=>{if(e&&!ot.current){ot.current=!0;let z=v.filter(q=>!d.some($=>$.chain===q));ee({type:"swapWalletsModalShown",payload:{chainsRequired:v.length,chainsPending:z.length}})}else e||(ot.current=!1)},[e,v,d]),ia(()=>{X&&ee({type:"gasWarningShown",payload:{routeId:kt}})},[X,kt]);let Ee=document.getElementById(rt.SWAP_BOX_ID);return re.createElement(R,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:Ee,...!S&&{styles:{container:{height:"100%"}},footer:re.createElement(zf,null,re.createElement(Yf,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:mm(a,A,f,l,Q,N),onClick:Qe,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ko.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:re.createElement($f,null,re.createElement(Ff,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},re.createElement(AE,{size:16})),re.createElement(Gl,{variant:"headline",size:"small"},Ko.t({id:"Your {blockchainName} wallets",values:{blockchainName:vt(S,c)}})))},anchor:"center"},re.createElement(R,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:X,onClose:E.bind(null,[]),container:Ee},re.createElement(NE,{title:Ko.t("Insufficient account balance"),type:"error",description:re.createElement(IE,{messages:k??[]})},re.createElement(Yf,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>{ee({type:"gasWarningBypassed",payload:{routeId:kt}}),Oe()}},Ko.t("Proceed anyway")))),S&&re.createElement(Of,null,re.createElement("div",{className:Uf()},re.createElement(Ql,{chain:S,quoteChains:b,isSelected:ie,selectWallet:me,onShowMore:()=>C(S),onConnect:z=>{Z(S,z)}}))),!S&&re.createElement(re.Fragment,null,w&&re.createElement(re.Fragment,null,re.createElement(xE,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ko.t(w)}),re.createElement(ql,{size:12})),re.createElement(Hf,null,b.map((z,q)=>{let $=c.find(ae=>ae.name===z),M=`wallet-${q}`,ce=q===b.length-1,H=ce&&N&&g?.customDestination!==!1;return re.createElement("div",{key:M},re.createElement(_f,null,re.createElement(Gl,{variant:"title",size:"xmedium"},Ko.t({id:"Your {blockchainName} wallets",values:{blockchainName:$?.shortName}})),re.createElement(Gl,{variant:"label",color:"$neutral700",size:"medium"},Ko.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:$?.shortName}}))),re.createElement(ql,{size:24}),re.createElement(Mf,null,re.createElement(Ql,{chain:z,quoteChains:b,isSelected:ie,selectWallet:me,limit:_E,onShowMore:()=>C($?.name??""),onConnect:ae=>{Z(z,ae)}})),!ce&&re.createElement(ql,{size:32}),H&&re.createElement(Lf,{blockchain:N,open:A,handleOpenChange:dt}))}))))}i(Zf,"ConfirmWalletsModal");import{i18n as ab}from"@lingui/core";import{Alert as sb,Button as lb,Divider as yg,InfoIcon as cb}from"@rango-dev/ui";import Ue from"react";import{Alert as $E,Button as FE,Divider as jl,NoRouteIcon as OE,RefreshIcon as UE,Typography as rg}from"@rango-dev/ui";import ht from"react";import{i18n as Jf}from"@lingui/core";var ME=24,DE=60;function Rf(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:ne().genericServerError,action:{onClick:n,title:Jf.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:ne().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Jf.t("Reset")}},description:ne().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:ne().noResultError.description}}i(Rf,"makeInfo");var Vl=(o=>(o[o.small=ME]="small",o[o.large=DE]="large",o))(Vl||{}),Kl=(o=>(o.small="small",o.large="medium",o))(Kl||{});import{styled as aa}from"@rango-dev/ui";var eg=aa("div",{display:"flex",flexDirection:"column",alignItems:"center"}),tg=aa("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),og=aa("div",{variants:{size:{small:{width:"100%"},large:{}}}}),ng=aa("div",{padding:"$6 $0"});function vr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=T().getDisabledLiquiditySources(),s=T().toggleAllLiquiditySources,c=T().swappers(),l=Rf(o,a,()=>s(c,!0),e);return r&&(l.alert=null),ht.createElement(eg,{id:"widget-no-result-container"},ht.createElement(OE,{size:Vl[n],color:"gray"}),ht.createElement(jl,{size:4}),ht.createElement(rg,{variant:"title",size:Kl[n]},ne().noResultError.title),n==="large"&&ht.createElement(jl,{size:4}),!!l.description&&ht.createElement(tg,{size:n},ht.createElement(rg,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),ht.createElement(jl,{size:n==="large"?"24":"4"}),!!l.alert&&ht.createElement(og,{size:n},ht.createElement($E,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&ht.createElement(FE,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:ht.createElement(ng,null,ht.createElement(UE,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(vr,"NoResult");import{i18n as wr}from"@lingui/core";import{Button as jE,Divider as XE,MessageBox as YE,Typography as ZE,WarningIcon as JE}from"@rango-dev/ui";import Jt from"react";import{InfoIcon as qE,Tooltip as GE,Typography as VE}from"@rango-dev/ui";import Bn from"react";import{Button as zE,darkTheme as HE,styled as jo,Typography as QE}from"@rango-dev/ui";var ig=jo("div",{width:"100%"}),Xl=jo("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),ag=jo("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${HE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),sg=jo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),lg=jo(QE,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),cg=jo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),pg=jo(zE,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var KE=35;function ug(t){let{title:e,value:o,valueColor:n}=t,r=W();return Bn.createElement(ag,null,Bn.createElement(VE,{size:"medium",variant:"label",className:"_title"},e),Bn.createElement(sg,null,Bn.createElement(lg,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`),o.length>KE&&Bn.createElement(GE,{content:o,container:r},Bn.createElement(qE,{size:12,color:"gray"}))))}i(ug,"QuoteErrorsModalItem");function dg(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",c=[{title:wr.t("Swapping"),value:D(r.inputUsdValue)},{title:wr.t("Gas cost"),value:D(r.totalFee,2,2)},{title:wr.t("Receiving"),value:D(r.outputUsdValue)},{title:wr.t("Price impact"),value:D(r.priceImpact,2,2),valueColor:`${s}500`}];return Jt.createElement(R,{id:"widget-high-value-loss-warning-modal",footer:Jt.createElement(jE,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Jt.createElement(JE,null),fullWidth:!0,disabled:a,onClick:n},ne().highValueLossError.confirmMessage),open:e,onClose:o,container:W()},Jt.createElement(YE,{type:s,title:ne().highValueLossError.impactTitle,description:ne().highValueLossError.description}),Jt.createElement(Xl,null,Jt.createElement(XE,{size:"4"}),Jt.createElement(ZE,{size:"small",variant:"title"},wr.t("Details")),Jt.createElement(Xl,null,c.map((l,p)=>Jt.createElement(ug,{key:p,...l})))))}i(dg,"HighValueLossWarningModal");import{i18n as Ln}from"@lingui/core";function mg(t,e){let o={alertType:"warning",title:"",action:null,actionButtonTitle:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Ln.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Ln.t("Increase")),o;if(t){switch(t.type){case 0:{Zt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=ne().highValueLossError.title;break}case 4:{o.title=Ln.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=ne().unknownPriceError.title;break}case 2:{o.title=Ln.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Ln.t("Increase");break}case 3:{o.title=Ln.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(mg,"makeAlerts");function fg(t,e){return e?.type===4?Number(e.minRequiredSlippage):t?.type===2?Number(t.minRequiredSlippage):null}i(fg,"getRequiredSlippage");import{i18n as _n}from"@lingui/core";import{Button as RE,Divider as Yl,MessageBox as eb,WarningIcon as tb}from"@rango-dev/ui";import ko from"react";import{useNavigate as ob}from"react-router-dom";function gg(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=ob();return ko.createElement(R,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:W(),onClose:o},ko.createElement(eb,{type:"warning",title:r.type===3?_n.t("High slippage"):_n.t("Low slippage"),description:r.type===3?_n.t("Caution, your slippage is high. Your trade may be front run."):_n.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},ko.createElement(Yl,{size:18}),ko.createElement(Yl,{size:32}),ko.createElement(pg,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:a,onClick:n},ko.createElement(tb,{color:"white",size:16}),_n.t("Swap anyway")),ko.createElement(Yl,{size:10}),ko.createElement(RE,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+O.settings)},_n.t("Change Slippage"))))}i(gg,"SlippageWarningModal");import{Button as nb,MessageBox as rb,WarningIcon as ib}from"@rango-dev/ui";import sa from"react";function hg(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return sa.createElement(R,{id:"widget-unknown-price-warning-modal",footer:sa.createElement(nb,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:sa.createElement(ib,null),fullWidth:!0,disabled:r,onClick:n},ne().unknownPriceError.confirmMessage),open:e,onClose:o,container:W()},sa.createElement(rb,{type:"warning",title:ne().unknownPriceError.impactTitle,description:ne().unknownPriceError.description}))}i(hg,"UnknownPriceWarningModal");function Er(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,skipAlerts:s,refetchQuote:c,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:m,onChangeSlippage:f}=t,h={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,d=mg(e,o?.type===3||o?.type===4?o:null);d&&!n&&(d.action=null);let y=!!d&&!s,S=i(C=>{if(C==="change-slippage"){let k=o?.type===3||o?.type===4?o:null,E=fg(e,k);f?.(E)}else C==="change-settings"&&m()},"onclickActionButton");return Ue.createElement(Ue.Fragment,null,g&&Ue.createElement(Ue.Fragment,null,Ue.createElement(yg,{size:10}),Ue.createElement(vr,{skipAlerts:s,error:o,fetch:c})),y&&Ue.createElement(ig,null,Ue.createElement(yg,{size:10}),Ue.createElement(sb,{id:"widget-quote-warning-and-errors-alert",title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:Ue.createElement(cg,{onClick:l},Ue.createElement(cb,{size:12,color:"gray"}))},...(d.action==="change-settings"||d.action==="change-slippage")&&{action:Ue.createElement(lb,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:d.alertType,onClick:()=>S(d.action)},d.actionButtonTitle||ab.t("Change"))}})),e&&Ue.createElement(Ue.Fragment,null,e.type===0&&Ue.createElement(dg,{...h,warning:e}),(e.type===3||e.type===2)&&Ue.createElement(gg,{...h,warning:e}),e.type===1&&Ue.createElement(hg,{...h,warning:e})))}i(Er,"QuoteWarningsAndErrors");import Fb from"bignumber.js";import wa from"react";import{i18n as Xo}from"@lingui/core";import{Alert as xb,CampaignQuoteTag as Ib,Divider as Dn,FullExpandedQuote as Ab,InfoIcon as sc,NumericTooltip as lc,QuoteTag as Nb,StepDetails as Wb,TokenAmount as Pb,Typography as $n,useIsTruncated as cc}from"@rango-dev/ui";import pc from"bignumber.js";import U,{useRef as Ta,useState as Bb}from"react";import{styled as Zl}from"@rango-dev/ui";var Jl=Zl("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Sg=Zl("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),Cg=Zl("div",{width:"100%",display:"flex"});import*as la from"@radix-ui/react-collapsible";import{Button as pb,css as ca,darkTheme as De,Image as Tg,styled as Xe,Typography as Rl}from"@rango-dev/ui";var ub=300,kg=Xe(la.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),vg=ca({padding:"$10 $15"}),wg=Xe(pb,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${De} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${De} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${De} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),Eg=Xe("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",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${De} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}}}}]}),bg=ca({width:"100%",padding:"$15 $15 $10 $15"}),xg=ca({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Mn=ca({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Ig=Xe(la.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:{[`& ${Tg}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Tg}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),Ag=Xe("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"}}}}),Ng=Xe(ea,{width:"100%",background:"inherit"}),ec=Xe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${ub}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),tq=Xe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),Wg=Xe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${De} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Pg=Xe("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),tc=Xe(Rl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),oc=Xe(Rl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),nc=Xe("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"}}}}),Bg=Xe("div",{display:"flex"}),pa=Xe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${De} &`]:{borderTopColor:"$neutral800"}}),Lg=Xe(Rl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as Ot}from"@lingui/core";import{ChevronDownIcon as mb,CloseIcon as fb,Divider as ma,IconButton as gb,NumericTooltip as hb,QuoteCost as yb,Typography as Wt}from"@rango-dev/ui";import J,{useState as $g}from"react";import{css as db,styled as ua}from"@rango-dev/ui";var da=ua("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),rc=ua("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),_g=ua("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Mg=ua("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),Dg=db({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var Sb=i(t=>t.fee.isZero()?null:J.createElement(da,null,J.createElement(Wt,{variant:"label",size:"medium",color:"neutral600"},t.label),J.createElement(Wt,{variant:"label",size:"medium"},"$",D(t.fee,4,4))),"NonPayableFee");function ic(t){let[e,o]=$g(!1),[n,r]=$g(!1),{steps:a,quote:s,fee:c,time:l,feeWarning:p,timeWarning:u,showModalFee:m,fullExpandedMode:f=!1}=t,h=s?.swaps??[],g=f?_o():W(),d=im(h),y=D(c,2,2);return J.createElement(J.Fragment,null,J.createElement(yb,{onClickFee:m?S=>{S.stopPropagation(),!e&&s&&ee({type:"routeFeeViewed",payload:{routeId:s.requestId}}),o(!e)}:void 0,fee:y,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:m?Ot.t("View more info"):void 0,tooltipContainer:g}),J.createElement(R,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:J.createElement(Mg,{style:{textAlign:f?"left":"center"}},J.createElement(Wt,{variant:"title",size:"medium"},Ot.t("Gas & Fee Explanation")),J.createElement(gb,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},J.createElement(fb,{color:"gray",size:14}))),onClose:()=>{o(!1)}},J.createElement(_g,null,J.createElement(Wt,{variant:"title",size:"small"},Ot.t("Details")),J.createElement(ma,{size:10}),Object.entries(d.payable).flatMap(([S,C])=>C.map((k,E)=>{let w=`payable-fee-${E}`,I=tl(k);return J.createElement(da,{key:w},J.createElement(Wt,{variant:"label",size:"medium",color:"neutral600"},Ys(S,Ot.t)),J.createElement(hb,{content:k.amount,container:g},J.createElement(Wt,{variant:"label",size:"medium"},D(k.amount,2,2),k.asset.symbol," ($",D(I,4,4),")")))})),J.createElement(da,{className:"total_payable_fee"},J.createElement(Wt,{variant:"label",size:"medium"},Ot.t("Total Payable Fee")),J.createElement(Wt,{variant:"label",size:"medium"},"$",D(c,4,4))),J.createElement(rc,null),!!Object.keys(d.nonePayable).length&&J.createElement(na,{triggerAnchor:"bottom",onClickTrigger:()=>r(S=>!S),trigger:J.createElement("div",{className:Dg()},J.createElement(Wt,{size:"small",variant:"body",color:"neutral700"},n?Ot.t("Hide non-payable fees"):Ot.t("Show non-payable fees")),J.createElement(ma,{size:4,direction:"horizontal"}),J.createElement(ta,{orientation:n?"up":"down"},J.createElement(mb,{size:12,color:"gray"}))),open:n},J.createElement(Wt,{size:"small",variant:"title"},Ot.t("Description")),J.createElement(ma,{size:4}),J.createElement(Wt,{size:"small",variant:"body",color:"neutral700"},Ot.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),J.createElement(ma,{size:10}),Object.entries(d.nonePayable).map(([S,C],k)=>{let E=rm(C),w=Ys(S,Ot.t),I=`non-payable-fee-${k}`;return J.createElement(Sb,{key:I,fee:E,label:w})}),J.createElement(rc,null)))))}i(ic,"QuoteCostDetails");import{i18n as Ug}from"@lingui/core";import{TokenAmount as zg}from"@rango-dev/ui";import fa from"react";import{css as Cb,styled as Tb}from"@rango-dev/ui";var Fg=Tb("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),Og=Cb({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function br(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return fa.createElement(Fg,null,fa.createElement(zg,{direction:"horizontal",label:Ug.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:W(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),fa.createElement("div",{className:Og()}),fa.createElement(zg,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:W(),label:Ug.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(br,"QuoteSummary");import{i18n as Vg}from"@lingui/core";import{ChevronDownIcon as wb,ChevronRightIcon as Eb,Divider as ac,Image as bb,Tooltip as Ca,Typography as ha}from"@rango-dev/ui";import K from"react";import{useLayoutEffect as kb,useState as xr}from"react";var Hg=480,Qg=768,qg=1024,Gg=1200,vb=i(()=>{let[t,e]=xr(!1),[o,n]=xr(!1),[r,a]=xr(!1),[s,c]=xr(!1),[l,p]=xr(!1),u=i(()=>{e(window.innerWidth<=Hg),n(window.innerWidth>Hg&&window.innerWidth<=Qg),a(window.innerWidth>Qg&&window.innerWidth<=qg),c(window.innerWidth>qg&&window.innerWidth<=Gg),p(window.innerWidth>Gg)},"handleResize");return kb(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),ga=vb;var ya=4,Sa=6,Ir=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||W();return K.createElement(Ca,{container:c,side:"bottom",sideOffset:4,open:r,content:e},K.createElement(Ag,{className:n,state:a},K.createElement(bb,{src:o,size:16})))},"ImageComponent");function Kg(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||W(),p=r.length,u=jd(r),{isTablet:m,isMobile:f}=ga();return K.createElement(Ig,{className:"widget-quote-trigger-btn",listItem:s==="list-item",ref:h=>e.current=h,selected:o,onClick:h=>{h.stopPropagation(),n(g=>!g)}},K.createElement("div",{className:Mn()},K.createElement(ha,{variant:"body",size:"xsmall"},Vg.t("Via:")),K.createElement(ac,{direction:"horizontal",size:4}),r.map((h,g)=>{let d=`item-${g}`,y=K.createElement(ec,null,K.createElement(Eb,{size:12,color:"black"}));return f||m?K.createElement(K.Fragment,{key:d},K.createElement(Ir,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&K.createElement(K.Fragment,null,y)):K.createElement(K.Fragment,{key:d},p<=ya||p>ya&&g<ya-1?K.createElement(K.Fragment,null,K.createElement(Ir,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&K.createElement(K.Fragment,null,y)):g===ya-1&&K.createElement(Ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:K.createElement("div",{className:Mn()},y,r.map((S,C)=>{let k=`image-${C}`;return C>=g&&K.createElement(K.Fragment,{key:k},K.createElement(Ir,{content:S.swapper.displayName,src:S.swapper.image??"",state:S.state,open:!1}),C!==p-1&&K.createElement(K.Fragment,null,y))}))},K.createElement(nc,{state:r.find((S,C)=>C>=g&&(S.state==="error"||S.state==="warning"))?.state},K.createElement(ha,{size:"xsmall",variant:"body"},"+",p-g))))})),K.createElement("div",{className:Mn()},K.createElement("div",{className:"blockchains_section"},K.createElement("div",{className:Mn()},K.createElement(ha,{variant:"body",size:"xsmall"},Vg.t("Chains:")),K.createElement(ac,{direction:"horizontal",size:4}),u.map((h,g)=>K.createElement(K.Fragment,{key:h.displayName},u.length<=Sa||u.length>Sa&&g<Sa-1?K.createElement(Ca,{container:l,side:"bottom",content:h.displayName,sideOffset:4},K.createElement(Ir,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===Sa-1&&K.createElement(Ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:K.createElement("div",{className:Mn()},u.map((d,y)=>y>=g&&K.createElement(Ir,{key:d.displayName,content:"",src:d.image??"",open:!1,className:y>g?"blockchainImage":"",container:c})))},K.createElement(nc,{className:"blockchainImage"},K.createElement(ha,{size:"xsmall",variant:"body"},"+",u.length-g))))),K.createElement(ac,{direction:"horizontal",size:32}))),K.createElement(ec,{orientation:a?"up":"down"},K.createElement(wb,{size:12,color:"black"}))))}i(Kg,"QuoteTrigger");function uc(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:c=!1,tagHidden:l=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:m=!1,container:f}=t,h=T().blockchains(),{findToken:g}=T(),d=T().swappers(),{customSlippage:y,slippage:S}=T(),C=y||S,[k,E]=Bb(t.expanded),w=Ta(null),I=D(n.value,6,6),A=n.usdValue?D(n.usdValue,4,4):"",{config:{__UNSTABLE_OR_INTERNAL__:x}}=T(),b=Yt(o.usdValue,n.usdValue??null),v=D(b,2,2),N=Zt(b??0),B=i((M,ce)=>M.map((H,ae)=>{let qe,nt=r?.type===3&&r.swap.swapperId===H.swapperId,co=r?.type===4&&!!r.recommendedSlippages?.[ae],Vn=a?.type===2&&!!a.recommendedSlippages?.[ae],No=nt||co,ni=Vn;No?qe="error":ni&&(qe="warning");let rn=No?Xo.t("Slippage Error"):Xo.t("Slippage Warning");return nt&&(rn=Xo.t("Bridge Limit Error")),{swapper:{displayName:jn(H.swapperId,d)??"",image:H.swapperLogo},from:{token:{displayName:H.from.symbol,image:H.from.logo},chain:{displayName:vt(H.from.blockchain,h)??"",image:H.from.blockchainLogo},price:{value:ae===0&&!ce?D(o.value,6,6):D(H.fromAmount,6,6),usdValue:D((H.from.usdPrice??0)*parseFloat(H.fromAmount),4,4),realValue:ae===0?o.value:H.fromAmount,realUsdValue:new pc(H.from.usdPrice??0).multipliedBy(H.fromAmount).toString()}},to:{token:{displayName:H.to.symbol,image:H.to.logo},chain:{displayName:vt(H.to.blockchain,h)||"",image:H.to.blockchainLogo},price:{value:D(H.toAmount,6,6),usdValue:D((H.to.usdPrice??0)*parseFloat(H.toAmount),4,4),realValue:H.toAmount,realUsdValue:new pc(H.to.usdPrice??0).multipliedBy(H.toAmount).toString()}},state:qe,alerts:No||ni?U.createElement(Sg,{dense:m},U.createElement(xb,{variant:"alarm",type:No?"error":"warning",title:rn,id:"widget-quote-footer-step-alarm-alert",footer:U.createElement(Cg,null,nt&&U.createElement("div",null,U.createElement($n,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),U.createElement(Dn,{direction:"vertical",size:2}),U.createElement($n,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},Xo.t({id:"Yours: {amount} {symbol}",values:{amount:D(H.fromAmount,6,6),symbol:H?.from.symbol}}))),(co||Vn)&&!nt&&U.createElement("div",null,U.createElement($n,{size:"xsmall",variant:"body",color:"neutral900"},Xo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[ae]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[ae]}}})),U.createElement(Dn,{direction:"vertical",size:2}),U.createElement($n,{size:"xsmall",variant:"body",color:"neutral900"},Xo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:Yn(H.estimatedTimeInSeconds),fee:D(el(H,g),2,2),internalSwaps:H.internalSwaps?B(H.internalSwaps):void 0}}),"getQuoteSteps"),_=B(e?.swaps??[]),Q=_.length,V=f||W(),Y=Yd(t.quote.tags||[]),P=!!u,Z=di(e?.swaps),X=Yn(Z),ie=Fi(e?.swaps??[],g),Te=D(ie,2,2),dt=ie.gte(new pc(Ud)),me=Z/Hd>=zd,Oe=Ta(null),Qe=cc(o.value,Oe),kt=Ta(null),ot=cc(n.value,kt),Ee=Ta(null),z=cc(A,Ee),q=_[Q-1],$=_[0];return!$||!q?null:m?U.createElement(Ab,{selected:c,fee:Te,time:X,tooltipContainer:_o(),steps:_,tags:Y,campaignTag:x?.campaignTag,id:"widget-quote-full-expanded-quote-container",quoteCost:U.createElement(ic,{quote:e,fullExpandedMode:!0,time:X,fee:ie,feeWarning:dt,timeWarning:me,showModalFee:p,steps:Q}),percentageChange:v,warningLevel:N,outputPrice:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue}}):U.createElement(Eg,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},U.createElement("div",{className:bg()},!l&&Y.length?U.createElement(U.Fragment,null,U.createElement(Bg,null,Y.map((M,ce)=>{let H=`${M.value}_${ce}`;return U.createElement(U.Fragment,{key:H},M.value=="CAMPAIGN"&&x?.campaignTag?U.createElement(Ib,{routeTag:M,...x.campaignTag}):U.createElement(Nb,{label:M.label,value:M.value}),U.createElement(Dn,{size:4,direction:"horizontal"}))})),U.createElement(pa,null),!P&&U.createElement(Dn,{size:4})):null,U.createElement("div",{id:"portal-root",className:xg()},U.createElement(ic,{quote:e,time:X,fee:ie,feeWarning:dt,timeWarning:me,showModalFee:p,steps:Q}),P&&U.createElement(wg,{onClick:M=>{M.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},U.createElement($n,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},Xo.t("See All Routes")))),s==="basic"&&U.createElement(Pg,null,U.createElement(oc,{ref:Oe,size:"small",variant:"body"},o.value),Qe&&U.createElement(lc,{content:o.value,container:V,open:o.value?void 0:!1},U.createElement(sc,{size:12,color:"gray"})),U.createElement(tc,{size:"small",variant:"body"},_[0]?.from.token.displayName),U.createElement($n,{size:"small",variant:"body"},"="),U.createElement(oc,{ref:kt,size:"small",variant:"body"},n.value),ot&&U.createElement(lc,{content:n.value,container:V,open:n.value?void 0:!1},U.createElement(sc,{size:12,color:"gray"})),U.createElement(tc,{size:"small",variant:"body"},q?.to.token.displayName),U.createElement(Dn,{size:2,direction:"horizontal"}),U.createElement(Lg,{ref:Ee,color:"$neutral600",size:"xsmall",variant:"body"},`($${A})`),z&&U.createElement(lc,{content:n.usdValue,container:V},U.createElement(sc,{size:12,color:"gray"}))),s==="list-item"&&U.createElement(Pb,{id:"widget-quote-token-amount-container",tooltipContainer:V,type:"output",direction:"vertical",price:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:q.to.token.displayName,image:q.to.token.image},chain:{image:q.to.chain.image},percentageChange:v,warningLevel:N}),s==="swap-preview"&&U.createElement(U.Fragment,null,U.createElement(br,{from:$.from,to:q.to,percentageChange:v,warningLevel:N}),U.createElement(Dn,{size:4}))),U.createElement(kg,{selected:c,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:E},U.createElement(Kg,{type:s,quoteRef:w,selected:c,setExpanded:E,container:V,expanded:k,steps:_}),U.createElement(Ng,{open:k},U.createElement(Wg,null),U.createElement("div",{className:vg()},_.map((M,ce)=>{let H=`item-${ce}`;return U.createElement(Wb,{type:"quote-details",className:"widget-quote-step-details-container",key:H,tooltipContainer:V,step:M,hasSeparator:ce!==_.length-1,state:M.state})})))))}i(uc,"Quote");import{Divider as Db,Skeleton as $b}from"@rango-dev/ui";import oo from"react";import{darkTheme as Lb,styled as ka}from"@rango-dev/ui";var jg=ka("div",{$$color:"$colors$neutral100",[`.${Lb} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Xg=ka("div",{paddingTop:"$2"}),Yg=ka("div",{paddingLeft:"$8"}),Zg=ka("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as sh,Divider as Pt,Skeleton as yt}from"@rango-dev/ui";import j from"react";import{css as _b,styled as to}from"@rango-dev/ui";var dc=to("div",{display:"flex"}),Jg=to("div",{padding:"$10 $0 $20"}),Rg=to("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),eh=to("div",{display:"flex",justifyContent:"start",alignItems:"center"}),th=to("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),oh=to("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),nh=to("div",{width:"65%",display:"flex",justifyContent:"start"}),rh=to("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),ih=to("div",{padding:"$15 $0 $15 $0"}),ah=_b({display:"flex",justifyContent:"space-between",alignItems:"center"});function Ar(t){let{type:e,tagHidden:o=!0}=t,n=j.createElement(th,null,j.createElement(nh,null,j.createElement(sh,{loading:!0,size:"medium"}),j.createElement(Pt,{size:8,direction:"horizontal"}),j.createElement(rh,null,j.createElement(yt,{height:10,width:60,variant:"rounded"}),j.createElement(Pt,{size:4}),j.createElement(yt,{height:15,variant:"rounded"}))),j.createElement(yt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return j.createElement("div",null,!o&&j.createElement(j.Fragment,null,j.createElement(dc,null,j.createElement(yt,{width:65,height:20,variant:"rounded"}),j.createElement(Pt,{size:4,direction:"horizontal"}),j.createElement(yt,{width:65,height:20,variant:"rounded"}),j.createElement(Pt,{size:4,direction:"horizontal"}),j.createElement(yt,{width:65,height:20,variant:"rounded"})),j.createElement(pa,null),!r&&j.createElement(Pt,{size:4})),j.createElement("div",{className:ah()},j.createElement(dc,null,j.createElement(yt,{width:60,height:10,variant:"rounded"}),j.createElement(Pt,{size:4,direction:"horizontal"}),j.createElement(yt,{width:60,height:10,variant:"rounded"}),j.createElement(Pt,{size:4,direction:"horizontal"}),j.createElement(yt,{width:60,height:10,variant:"rounded"})),r&&j.createElement(yt,{width:85,height:24,variant:"rounded"})),e==="basic"&&j.createElement(Jg,null,j.createElement(yt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&j.createElement(Rg,null,j.createElement(eh,null,j.createElement(sh,{loading:!0,size:"medium"}),j.createElement(Pt,{direction:"horizontal",size:4}),j.createElement(yt,{height:15,width:150,variant:"rounded"})),j.createElement(Pt,{size:10}),j.createElement(yt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&j.createElement(j.Fragment,null,j.createElement(Pt,{size:4}),j.createElement(ih,null,n,j.createElement(oh,null),n),j.createElement(Pt,{size:12})))}i(Ar,"QuoteSummarySkeleton");import{ChainToken as dh,Divider as fc,NextIcon as Mb,Skeleton as va}from"@rango-dev/ui";import Be from"react";import{styled as Nr}from"@rango-dev/ui";var lh=Nr("div",{display:"flex",alignItems:"start"}),ch=Nr("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),mc=Nr("div",{display:"flex",alignItems:"center",flexGrow:1}),ph=Nr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),uh=Nr("div",{display:"flex",alignItems:"center"});function Ut(t){let{separator:e=!0}=t;return Be.createElement(Be.Fragment,null,Be.createElement(uh,null,Be.createElement(va,{height:22,width:22,variant:"circular"}),Be.createElement(fc,{direction:"horizontal",size:8}),Be.createElement(va,{height:15,width:148,variant:"rounded"})),Be.createElement(lh,null,Be.createElement(Zg,{hideSeparator:!e}),Be.createElement(ch,{extraSpace:e},Be.createElement(mc,null,Be.createElement(dh,{size:"small",loading:!0}),Be.createElement(fc,{direction:"horizontal",size:8}),Be.createElement(va,{height:12,variant:"rounded"})),Be.createElement(ph,null,Be.createElement(Mb,{color:"gray",size:16})),Be.createElement(mc,null,Be.createElement(dh,{size:"small",loading:!0}),Be.createElement(fc,{direction:"horizontal",size:8}),Be.createElement(va,{height:12,variant:"rounded"})))))}i(Ut,"StepSkeleton");function Wr(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return oo.createElement(jg,{expanded:o,rounded:e!=="basic"},oo.createElement(Ar,{type:e,tagHidden:n}),oo.createElement(Xg,null,oo.createElement($b,{height:15,variant:"rounded"})),o&&oo.createElement(Yg,null,oo.createElement(Db,{size:24}),oo.createElement(Ut,null),oo.createElement(Ut,null),oo.createElement(Ut,{separator:!1})))}i(Wr,"QuoteSkeleton");function Yo(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:c,onClick:l,showModalFee:p,selected:u,id:m,onClickAllRoutes:f,fullExpandedMode:h=!1,container:g}=t,{inputAmount:d,inputUsdValue:y}=G()(),S=e?.outputAmount?new Fb(e?.outputAmount):null,C=e?st(e):null,E=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?wa.createElement(Jl,null,wa.createElement(Wr,{tagHidden:c,type:o,expanded:s})):E?wa.createElement(Jl,{onClick:()=>l?.(e),id:m},wa.createElement(uc,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:c,selected:u,type:o,expanded:s,onClickAllRoutes:f,fullExpandedMode:h,input:{value:d,usdValue:y?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(Yo,"QuoteInfo");import{warn as Hb}from"@rango-dev/logging-core";import{calculatePendingSwap as Qb}from"@rango-dev/queue-manager-rango-preset";import{useEffect as qb}from"react";import{useRef as Ob,useState as Ub}from"react";var zb=2e3;function Ea({request:t}){let[e,o]=Ub(!1),n=Ob(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,zb)),await s(c,!1)),"retryFetch"),s=i(async(c,l=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(c,{signal:n.current.signal});return n.current=null,p}catch(p){if(l)return await a(c);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(Ea,"useFetch");function mh(){let{fetch:t,loading:e,cancelFetch:o}=Ea({request:async(n,r)=>await gt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(mh,"useFetchConfirmQuote");function ba(t){if(!t.swaps)throw new Error(ne().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=gc(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ba,"throwErrorIfResponseIsNotValid");function gc(t){if(tm(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=om(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=am(t);if(o){let n=Oi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(gc,"getQuoteError");function fh(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,c={quote:null,balance:null},l=wn({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});l&&(c.quote=l);let p=cm(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(fh,"generateWarnings");function xa(t){return t?.code==="ERR_CANCELED"?{type:2}:t.cause?t.cause:t?.code==="ERR_BAD_REQUEST"?{type:0,diagnosisMessage:t.response.data.error}:{type:1,diagnosisMessage:t.message}}i(xa,"handleQuoteErrors");function hc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=G()(),{slippage:l,customSlippage:p}=T(),u=T().getDisabledLiquiditySources(),m=T().blockchains(),f=T().tokens(),{findToken:h}=T(),{swapMode:g}=at(),d=p||l,{fetch:y,cancelFetch:S,loading:C}=mh();return qb(()=>S,[]),{loading:C,fetch:i(async E=>{let w=E.selectedWallets,I=E?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=w.reduce((b,v)=>(b[v.chain]=v.address,b),{}),x={requestId:a?.requestId||"",selectedWallets:A,destination:I||void 0};try{return await y(x,!0).then(b=>{let{result:v}=b;if(!v)throw new Error(b.error??"Error fetching updated quote");ba({diagnosisMessages:v.diagnosisMessages,requestId:v.requestId,swaps:v.result?.swaps});let N={outputAmount:v.result?.outputAmount,requestId:v.requestId,resultType:v.result?.resultType,swaps:v.result?.swaps||[],validationStatus:v.validationStatus,requestAmount:v.requestAmount};r(N);let B={slippage:d.toString(),disabledSwappersGroups:u},_=fh({previousQuote:a??void 0,currentQuote:N,meta:{blockchains:m},selectedWallets:w,userSlippage:d,inputUsdValue:n,findToken:h});c();let Q=!!_.balance,V=Qb({inputAmount:o.toString(),bestRoute:v,wallets:lm(w),settings:B,validateBalanceOrFee:!Q,meta:{blockchains:m,tokens:f},swapMode:g});return{quote:N,swap:V,error:null,warnings:_}})}catch(b){let v=xa(b);return v.type!==2&&Hb(new Error("confirm swap error"),{tags:{...v,type:Je[v.type],initialQuote:a,requestBody:x}}),{swap:null,error:v,warnings:null}}},"fetch"),cancelFetch:S}}i(hc,"useConfirmSwap");function gh(t){if(t==null||t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}i(gh,"toNumberOrNull");function Fn(t){let e=t.swaps[0],o=t.swaps[t.swaps.length-1],n=Ho(t),r=st(t);return{routeId:t.requestId,sourceChain:e?.from.blockchain??"",destinationChain:o?.to.blockchain??"",sourceToken:e?.from.symbol??"",destinationToken:o?.to.symbol??"",sourceTokenAmount:gh(t.requestAmount),destinationTokenAmount:gh(t.outputAmount),inputAmountUsd:n?n.toNumber():null,outputAmountUsd:r?r.toNumber():null}}i(Fn,"buildSwapEstimatePayload");var ex=jb("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${hh}`]:{width:"$48",height:"$48"}}),tx=Cc({flexGrow:1,paddingRight:"$10"}),ox=Cc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),nx=Cc({display:"flex",justifyContent:"space-between",alignItems:"center"});function yh(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=G()(),s=Rb(),[c,l]=Pr(""),p=!n,[u,m]=Pr(!1),[f,h]=Pr(!1),{isActiveTab:g}=oe(),d=T().getDisabledLiquiditySources(),y=Jb(d),{manager:S}=Gb(),{fetch:C,loading:k,cancelFetch:E}=hc(),[w,I]=Pr({swap:null,error:null,warnings:null}),[A,x]=Pr(!1),b=i(async({selectedWallets:P,customDestination:Z})=>{let X=await C?.({selectedWallets:P,customDestination:Z});return I(X),X},"onConfirmSwap"),v=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let P=`../${O.swaps}/${w.swap.requestId}`;s(P,{replace:!0}),setTimeout(()=>{e("")},0)}catch(P){l("Error: "+P?.message)}},"addNewSwap"),N=i(async()=>{h(!0),await v(),h(!1)},"onConfirm"),B=i(async()=>{w.warnings?.quote&&Kd(w.warnings.quote)&&!a?x(!0):(t&&ee({type:"swapStarted",payload:{...Fn(t),stepCount:t.swaps.length}}),await N())},"onStartConfirmSwap"),_=i(async()=>{I({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(P=>{I(P)}).catch(P=>console.error(P))},"onRefresh");Ia(()=>{!!y.current.length&&!d.length&&_(),y.current=d},[d.length]),Ia(()=>{p&&E()},[p]),Ia(()=>{p&&m(p)},[p]),Ia(()=>{p||C({selectedWallets:o,customDestination:r}).then(P=>I(P)).catch(P=>console.error(P))},[]),Zb(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let Q=w.warnings?.quote??null,V=w.error,Y=[];if(c&&Y.push($e.createElement(Vb,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),Q||V){let P=`../${O.settings}`;Y.push($e.createElement(Er,{warning:Q,error:V,couldChangeSettings:!1,refetchQuote:_,skipAlerts:V?.type===4||Q?.type===2,showWarningModal:A,confirmationDisabled:!g,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await v()},onChangeSettings:()=>s(P)}))}return $e.createElement(se,{header:{title:yc.t("Confirm Swap"),onWallet:()=>{let P=`../${O.wallets}`;s(P)}},footer:$e.createElement(ex,null,$e.createElement("div",{className:tx()},$e.createElement(Kb,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||f,disabled:!!w.error||!g,onClick:B},yc.t("Start Swap"))),$e.createElement(hh,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||f,disabled:!g,onClick:m.bind(null,!0)},$e.createElement(Yb,{size:24})))},u&&$e.createElement(Zf,{open:u,onClose:()=>m(!1),onCancel:E,loading:k,onCheckBalance:b}),$e.createElement(pe,null,$e.createElement("div",{className:nx()},$e.createElement(Xb,{variant:"title",size:"small"},yc.t("You get")),$e.createElement("div",{className:ox()},$e.createElement(Ki,{onClick:!k&&!u&&!A?_:void 0}))),$e.createElement(Sc,{size:"12"}),Um(Y.map((P,Z)=>({element:P,key:`alert-${Z}`})),$e.createElement(Sc,{size:10})),Y.length>0?$e.createElement(Sc,{size:10}):null,$e.createElement(Yo,{quote:t,type:"swap-preview",id:"widget-confirm-swap-quote-container",expanded:!0,tagHidden:!0,error:w.error,loading:k,warning:w.warnings?.quote??null})))}i(yh,"ConfirmSwapPage");import{i18n as ro}from"@lingui/core";import{Button as Pc,CustomTokensZeroStateDarkIcon as wx,CustomTokensZeroStateIcon as Ex,DeleteIcon as bx,Divider as Dr,IconButton as xx,MessageBox as Ix,NotFound as Ax,styled as Lc}from"@rango-dev/ui";import Se,{useState as Bc}from"react";import{useNavigate as Nx}from"react-router-dom";import{CloseIcon as rx,IconButton as ix,SearchIcon as ax,TextField as sx}from"@rango-dev/ui";import On from"react";import{styled as Sh}from"@rango-dev/ui";var Ch=Sh("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),Th=Sh("div",{width:"100%","& ._text-field":{paddingLeft:"$10","& input":{paddingLeft:"$2",paddingTop:"$12",paddingBottom:"$12"}}});function Bt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:c,setValue:l,suffix:p,id:u,...m}=t,f=s.length?On.createElement(ix,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},On.createElement(rx,{color:"gray",size:10})):null;return p&&(f=p),On.createElement(Th,null,On.createElement(sx,{prefix:On.createElement(Ch,null,On.createElement(ax,{color:"black"})),id:u,suffix:f,fullWidth:o,color:n,variant:e,style:{borderRadius:25,alignItems:"center",...c},size:r,value:s,onChange:a,...m}))}i(Bt,"SearchInput");import{i18n as Wc}from"@lingui/core";import{Button as ux,CustomTokenWarning as dx,darkTheme as Bh,Divider as no,ExternalLinkIcon as mx,Image as fx,ListItem as gx,NotFound as hx,PinIcon as yx,Skeleton as Zo,Typography as _r,VirtualizedList as Sx}from"@rango-dev/ui";import L,{useState as Cx}from"react";import{useTranslation as Tx}from"react-i18next";import{Divider as Wh,ListItem as px,Skeleton as Lr}from"@rango-dev/ui";import Lt from"react";import{css as Un,darkTheme as Tc,ImageContainer as lx,ListItemButton as cx,styled as pt,Typography as kh}from"@rango-dev/ui";var kc=Un({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),vc=Un({position:"relative",height:12,width:"30%",maxWidth:"150px"}),wc=Un({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Ec=Un({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Tc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),bc=Un({}),xc=Un(),vh=pt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Ic=pt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Aa=pt("ul",{flexGrow:1,height:"100%",padding:0,margin:0,display:"flex",flexDirection:"column",listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${vc}`]:{[`& .${Ec}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${bc}`]:{bottom:"-15px"},[`& .${kc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${wc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),wh=pt(cx,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),Ac=pt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Nc=pt(kh,{}),Eh=pt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${xc}`]:{$$color:"$colors$neutral600",[`.${Tc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Br=pt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),a2=pt("div",{display:"flex",alignItems:"center"}),bh=pt("div",{position:"relative",[`& ${lx}`]:{borderRadius:"$xm",overflow:"hidden"}}),xh=pt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Ih=pt(kh,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Ah=pt("a",{"& svg:hover":{color:"$colors$info"}}),Nh=pt("div",{paddingRight:"$5","& .widget-token-list-item-btn":{width:"100%",overflow:"hidden",height:"60px"},"& .widget-token-list-item-import-btn":{height:"$20",padding:"0 $10","& ._text":{display:"flex",justifyContent:"center",alignItems:"center"},"& ._typography":{[`.${Tc} &`]:{color:"$foreground"}}}});function Ph(t){return Lt.createElement(Aa,null,Array.from(Array(t.size),e=>Lt.createElement(px,{key:e,hasDivider:!0,start:Lt.createElement(Lr,{variant:"circular",width:35,height:35}),end:Lt.createElement(Br,null,Lt.createElement(Lr,{variant:"text",size:"large",width:70}),Lt.createElement(Wh,{size:4}),Lt.createElement(Lr,{variant:"text",size:"medium",width:50})),title:Lt.createElement("div",null,Lt.createElement(Lr,{variant:"text",size:"large",width:90}),Lt.createElement(Wh,{size:4}),Lt.createElement(Lr,{variant:"text",size:"medium",width:90}))})))}i(Ph,"LoadingTokenList");var kx=20,vx=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return L.createElement("div",{className:vc()},o?L.createElement("div",{className:kc()},o):L.createElement(Ic,{className:wc()},L.createElement(_r,{variant:"title",size:"xmedium"},r.symbol),L.createElement(no,{direction:"horizontal",size:4}),L.createElement(Ac,{css:a},L.createElement(Nc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&L.createElement("div",{className:`${Ec()} ${!o&&bc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",L.createElement(no,{size:4,direction:"horizontal"}),L.createElement(Ah,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},L.createElement(mx,{size:12}))))},"renderDesc");function Mr(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:c,showWarning:l=!0}=t,p=T().fetchStatus,u=T().blockchains(),{getBalanceFor:m,fetchingWallets:f}=T(),{isTokenPinned:h}=T(),{setFromToken:g,setToToken:d}=G()(),{t:y}=Tx(),S=Ke(),[C,k]=Cx(null),E=i(()=>{c==="source"?g({token:C,meta:{blockchains:u}}):d({token:C,meta:{blockchains:u}})},"updateToken"),w=i(()=>{E(),S()},"handleImportToken"),I=i(b=>{if(b.customToken){let{customToken:N,...B}=b;return L.createElement(ux,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(Q=>{Q.stopPropagation(),k({...B,warning:!0})},"handleClick")},L.createElement(_r,{variant:"body",size:"xsmall",color:"background"},y("import")))}let v=hi(m(b));return s?s(b):f?L.createElement(Br,null,L.createElement(Zo,{variant:"text",size:"large",width:70}),L.createElement(no,{size:4}),L.createElement(Zo,{variant:"text",size:"medium",width:50})):v&&L.createElement(Eh,null,L.createElement(Ih,{variant:"title",size:"small"},v.amount),L.createElement("div",null),v.usdValue&&L.createElement(_r,{variant:"body",className:xc(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),A=i(()=>L.createElement(Sx,{style:{flexGrow:1,minHeight:0},itemContent:b=>{let v=e[b];if(v==="skeleton")return L.createElement(gx,{hasDivider:!0,start:L.createElement(Zo,{variant:"circular",width:35,height:35}),end:L.createElement(Br,null,L.createElement(Zo,{variant:"text",size:"large",width:70}),L.createElement(no,{size:4}),L.createElement(Zo,{variant:"text",size:"medium",width:50})),title:L.createElement("div",null,L.createElement(Zo,{variant:"text",size:"large",width:90}),L.createElement(no,{size:4}),L.createElement(Zo,{variant:"text",size:"medium",width:90}))});let N=u.find(P=>P.name===v?.blockchain);if(!N||!v)return null;let B=v.address,_=hl(N.color,"main"),Q={$$color:_.main150,[`.${Bh} &`]:{$$color:_.main750},backgroundColor:"$$color"},V={$$color:_.main750,[`.${Bh} &`]:{$$color:_.main150},color:"$$color"},Y=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return L.createElement(Nh,null,L.createElement(wh,{"tab-index":b,key:`${v.symbol}${B}`,id:`${v.symbol}${B}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v?.customToken,onClick:Y,start:L.createElement(bh,null,L.createElement(fx,{src:v.image===""?si:v.image,size:30}),t.type!=="custom-token"&&v&&h(v,t.type)&&L.createElement(xh,null,L.createElement(yx,{size:12,color:"gray"}))),title:N.type==="COSMOS"||v.name||!v.name&&!B?L.createElement(Ic,null,L.createElement(_r,{variant:"title",size:"xmedium"},v.symbol),L.createElement(no,{direction:"horizontal",size:4}),L.createElement(Ac,{css:Q},L.createElement(Nc,{variant:"body",size:"xsmall",css:V},v.blockchain)),l&&v.warning&&L.createElement(L.Fragment,null,L.createElement(no,{direction:"horizontal",size:4}),L.createElement(dx,{container:W()}))):void 0,description:typeof v!="string"&&N.info&&B&&N.type!=="COSMOS"?vx({address:B,token:v,customCssForTag:Q,customCssForTagTitle:V,name:v.name,url:N.info.addressUrl.split("{wallet}").join(B)}):v.name||void 0,end:I(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),x=C?Po(C?.blockchain,u):null;return L.createElement(L.Fragment,null,a&&L.createElement(L.Fragment,null,L.createElement(_r,{variant:"label",size:"large"},Wc.t("Select Token")),L.createElement(no,{size:4})),L.createElement(vh,null,L.createElement(no,{size:4}),p==="loading"&&L.createElement(Ph,{size:kx}),p==="success"&&(e.length?L.createElement(L.Fragment,null,L.createElement(Cr,{token:C,address:C?.address??"",blockchain:x??void 0,onImport:w,onExitErrorModal:()=>k(null),onExitImportModal:()=>k(null)}),L.createElement(Aa,{as:"ul"},A())):!!o&&L.createElement(hx,{title:Wc.t("No results found"),description:Wc.t("Try using different keywords")}))))}i(Mr,"TokenList");var Wx=Lc("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Px=Lc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Bx=Lc(xx,{"&:hover":{"& svg":{color:"$secondary550"}}});function Lh(){let[t,e]=Bc(""),{deleteCustomToken:o}=T(),n=T().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=G()(),{mode:l}=go({}),p=Nx(),[u,m]=Bc(!1),[f,h]=Bc(),g=i(C=>{let k=C.target.value;e(k)},"handleSearch"),d=l==="dark",y=n.filter(C=>mt(C.symbol,t)||mt(C.address||"",t)||mt(C.name||"",t)),S=i(()=>{if(f){let C=a?wt(a):null,k=r?wt(r):null,E=wt(f);C===E?c({token:null}):k===E&&s({token:null}),o(f)}m(!1)},"handleDeleteCustomToken");return Se.createElement(se,{header:{title:ro.t("Custom Tokens")}},Se.createElement(pe,null,Se.createElement(Wx,null,n.length?Se.createElement(Se.Fragment,null,Se.createElement(Bt,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:ro.t("Search Token"),onChange:g}),Se.createElement(Dr,{size:16}),Se.createElement(Mr,{list:y,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:C=>Se.createElement(Bx,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),h(C)}},Se.createElement(bx,{size:12,color:"gray"}))})):Se.createElement(Px,null,Se.createElement(Ax,{icon:d?Se.createElement(wx,{size:200}):Se.createElement(Ex,{size:200}),title:ro.t("No custom tokens"),description:ro.t("press the button to add your custom token")})),Se.createElement(Dr,{size:20}),Se.createElement(Pc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p(O.addCustomTokens)},ro.t("Add Custom Token"))),Se.createElement(R,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>m(!1),container:W()},Se.createElement(Ix,{title:ro.t("Delete Custom Token"),type:"error",description:ro.t("Are you sure you want to Delete this Token?")},Se.createElement(Dr,{size:40}),Se.createElement(Dr,{size:10}),Se.createElement(Pc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},ro.t("Yes, Delete it")),Se.createElement(Dr,{size:12}),Se.createElement(Pc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},ro.t("No, Continue"))))))}i(Lh,"CustomTokensPage");import{i18n as Fe}from"@lingui/core";import{useManager as Jx}from"@rango-dev/queue-manager-react";import{Button as Uc,darkTheme as Rx,Divider as vo,MessageBox as eI,NotFound as tI,styled as zc,Tabs as oI,Typography as Pa}from"@rango-dev/ui";import{TransactionStatus as Or}from"rango-types";import te,{useMemo as Jh,useState as Ur}from"react";import{useNavigate as nI}from"react-router-dom";import{FilterIcon as Ox,Popover as Ux}from"@rango-dev/ui";import Jo from"react";import{css as Lx,darkTheme as Na,IconButton as _x,styled as $r}from"@rango-dev/ui";var _c=$r("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Na} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),_h=$r(_x,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Na} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Na} &`]:{backgroundColor:"$neutral"},[`& ${_c}::before`]:{backgroundColor:"$secondary100",[`.${Na} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),Mh=$r("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),Dh=$r("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),$h=Lx({display:"flex",justifyContent:"space-between",alignItems:"center"}),Fh=$r("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as Oh}from"@lingui/core";import{Button as Mx,Divider as Uh,ListItemButton as Dx,Radio as $x,RadioRoot as Fx,Typography as zh}from"@rango-dev/ui";import St from"react";function Hh(t){let{filterBy:e,onClickItem:o}=t;return St.createElement(Dh,null,St.createElement("div",{className:$h()},St.createElement(zh,{size:"small",variant:"body"},Oh.t("Status")),St.createElement(Mx,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},Oh.t("Reset"))),St.createElement(Uh,{size:10}),St.createElement(Fx,{value:e},St.createElement(Fh,null,t.list.map((n,r)=>St.createElement(Dx,{key:n.id,className:"widget-filter-selector-list-item-btn",style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:St.createElement(St.Fragment,null,St.createElement(Uh,{direction:"horizontal",size:4}),St.createElement(zh,{size:"medium",variant:"body"},n.title)),start:St.createElement($x,{value:n.id}),onClick:o})))))}i(Hh,"FilterSelectorContent");function Mc(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Jo.createElement("div",null,Jo.createElement(Ux,{open:a,align:"end",onOpenChange:o,container:W(),content:Jo.createElement(Hh,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Jo.createElement(_h,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Jo.createElement(_c,{isSelect:!!n},Jo.createElement(Ox,{size:16,color:"black"}),!!n&&Jo.createElement(Mh,null)))))}i(Mc,"FilterSelector");import{i18n as Qx}from"@lingui/core";import{getCurrentStep as qx}from"@rango-dev/queue-manager-rango-preset";import{Divider as Kh,GroupedVirtualizedList as Gx,Skeleton as Vx,SwapListItem as jh,Typography as Kx}from"@rango-dev/ui";import et,{useCallback as Xh,useEffect as jx,useRef as Xx,useState as Yx}from"react";function Qh(t,e){let o=[],n=0;do{let r=t[n];r&&(o.push(Math.min(r,e)),e-=r),n++}while(e>0&&n<=t.length);return o}i(Qh,"calculateGroupsSoFar");import{css as zx,darkTheme as Hx,styled as Fr}from"@rango-dev/ui";var Dc=zx(),qh=Fr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),$c=Fr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Dc}`]:{$$color:"$colors$neutral600",[`.${Hx} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Fc=Fr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Gh=Fr("div",{gap:"$10",display:"flex",flexDirection:"column"}),Vh=Fr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var Zx=10;function Oc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Yx([]),c=Xx(0),{swaps:l,groupCounts:p,groups:u}=n(e),m=Xh(Qh,[]),f=Xh(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,Zx),s(m(p,c.current)))},[e.length]);if(jx(()=>{r||f()},[r,f]),r){let h=[1,2];return et.createElement(et.Fragment,null,[h,h].map((d,y)=>et.createElement($c,{key:y},et.createElement(Fc,null,et.createElement(Vx,{variant:"text",width:60,size:"small"}),et.createElement(Kh,{size:16})),et.createElement(Kh,{size:4}),et.createElement(Gh,null,d.map((C,k)=>et.createElement(jh,{isLoading:!0,key:k}))))))}return et.createElement(Gx,{style:{flexGrow:1,minHeight:0},endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>et.createElement($c,null,et.createElement(Fc,null,et.createElement(Kx,{variant:"label",size:"medium",className:Dc()},u[h]))),itemContent:(h,g)=>{let d=l[h];if(!d)return null;let y=qx(d),S=d.steps[0],C=d.steps[d.steps.length-1];return!S||!C?null:et.createElement(qh,{key:d.requestId},et.createElement(jh,{className:"widget-history-group-list-swap-item-btn",requestId:d.requestId,creationTime:d.creationTime,status:d.status,onClick:o,currentStep:y,tooltipContainer:W(),onlyShowTime:u[g]===Qx.t("Today"),swapTokenData:{from:{token:{image:S.fromLogo,displayName:S.fromSymbol},blockchain:{image:S.fromBlockchainLogo||""},amount:D(d.inputAmount,6,6),realAmount:d.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:D(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(Oc,"HistoryGroupedList");import{i18n as Wa}from"@lingui/core";import Yh from"dayjs";var Zh=i(t=>{let e=new Map([["today",{title:Wa.t("Today"),swaps:[]}],["week",{title:Wa.t("This week"),swaps:[]}],["month",{title:Wa.t("This month"),swaps:[]}],["year",{title:Wa.t("This year"),swaps:[]}]]);function o(l,p){e.has(l)||e.set(l,{title:l,swaps:[]}),e.get(l)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Yh();t.forEach(l=>{let p=Number(l.creationTime),u=Yh(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(l);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(l);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(l);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(l);else{let m=new Date(p).getFullYear().toString();o(m,l)}});let r=Array.from(e.values()).filter(l=>l.swaps.length>0),a=r.flatMap(l=>l.swaps),s=r.map(l=>l.swaps.length),c=r.map(l=>l.title);return{swaps:a,groupCounts:s,groups:c}},"groupSwapsByDate");var rI=zc("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%",minHeight:0,flexGrow:1}),iI=zc("div",{display:"flex",justifyContent:"center",alignItems:"center"}),aI=zc("div",{"._typography":{color:"$neutral700",[`.${Rx}&`]:{color:"$neutral900"}}}),sI=i((t,e)=>t?.length?t.filter(o=>Dt(o.fromBlockchain,e)||Dt(o.toBlockchain,e)||Dt(o.toSymbol,e)||Dt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Rh(){let t=nI(),{manager:e,state:o}=Jx(),n=bt(e).map(({swap:x})=>x),[r,a]=Ur(""),[s,c]=Ur(!1),l=!o.loadedFromPersistor,[p,u]=Ur(""),[m,f]=Ur(!1),[h,g]=Ur("all"),d=i(x=>{let b=x.target.value;a(b)},"handleSearch"),{isMultiMode:y}=at(),S=[{id:Or.SUCCESS,title:Fe.t("Complete")},{id:Or.RUNNING,title:Fe.t("Running")},{id:Or.FAILED,title:Fe.t("Failed")}],C=[{id:"all",title:Fe.t("All")},{id:"swap",title:Fe.t("Swap")},{id:"refuel",title:Fe.t("Refuel")}],k=Jh(()=>!r&&!p&&h==="all"?n:n.filter(x=>{let{inputAmount:b,status:v,steps:N,requestId:B,mode:_}=x;return(!r||Dt(b,r)||Dt(v,r)||sI(N,r)||Dt(B,r))&&(!p||p===v)&&(h==="all"?!0:h==="swap"?!_||_==="swap":h==="refuel"?_==="refuel":!1)}),[n,r,p,h]),E=!k?.length&&!l,w=i(()=>f(!1),"onCloseModal"),I=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(x){console.log(x)}},"onClear"),A=Jh(()=>!n.some(x=>x.status===Or.SUCCESS||x.status===Or.FAILED),[n]);return te.createElement(se,{header:{title:Fe.t("History"),suffix:te.createElement(ho,null,te.createElement(Uc,{id:"widget-history-clear-btn",disabled:A,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},te.createElement(Pa,{size:"medium",variant:"label",color:"error"},Fe.t("Clear"))))}},te.createElement(pe,null,te.createElement(iI,null,te.createElement(Bt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Fe.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:d,style:{height:36},value:r}),te.createElement(vo,{size:10,direction:"horizontal"}),te.createElement(Mc,{filterBy:p,open:s,onOpenChange:x=>c(x),onClickItem:x=>u(x),list:S})),te.createElement(vo,{size:"16"}),y&&!l&&te.createElement(te.Fragment,null,te.createElement(oI,{items:C,onChange:x=>g(x.id),value:h,type:"secondary"}),te.createElement(vo,{size:"12"})),te.createElement(rI,null,E&&te.createElement(Vh,null,te.createElement(vo,{size:32}),te.createElement(tI,{title:r?Fe.t("No results found"):Fe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Fe.t("Try using different keywords"):Fe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!E&&te.createElement(Oc,{list:k,onSwapClick:t,groupBy:Zh,isLoading:l}))),te.createElement(R,{open:m,onClose:w,id:"widget-history-clear-modal",container:W()},te.createElement(vo,{size:20}),te.createElement(eI,{type:"warning",title:Fe.t("Clear Transaction History"),description:te.createElement(aI,null,te.createElement(Pa,{variant:"body",size:"medium"},Fe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),te.createElement(vo,{size:"24"}),te.createElement(Pa,{variant:"body",size:"small"},Fe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),te.createElement(vo,{size:30}),te.createElement(Uc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:I},Fe.t("Yes, Clear the history")),te.createElement(vo,{size:10}),te.createElement(Uc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:w},te.createElement(Pa,{variant:"title",size:"medium",color:"primary"},Fe.t("No, Cancel")))))}i(Rh,"HistoryPage");import{i18n as Ay}from"@lingui/core";import{Button as QI,Divider as tp,styled as qI,WarningIcon as GI}from"@rango-dev/ui";import VI from"bignumber.js";import ke,{useEffect as Ny,useState as Wy}from"react";import{useNavigate as KI}from"react-router-dom";import{i18n as ty}from"@lingui/core";import{Alert as cI,Divider as Hc,NoRouteIcon as pI,Typography as uI}from"@rango-dev/ui";import Ro from"react";import{styled as lI}from"@rango-dev/ui";var ey=lI("div",{display:"flex",flexDirection:"column",alignItems:"center"});function Qc(){let{fromToken:t,toToken:e}=G()();return!!t&&!!e&&Vt(t,e)?Ro.createElement(ey,null,Ro.createElement(Hc,{size:10}),Ro.createElement(pI,{size:24,color:"gray"}),Ro.createElement(Hc,{size:4}),Ro.createElement(uI,{variant:"title",size:"small"},ty.t("No Routes Found")),Ro.createElement(Hc,{size:4}),Ro.createElement(cI,{title:ty.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(Qc,"SameTokensWarning");import{Alert as dI,Button as mI}from"@rango-dev/ui";import ny from"react";import{i18n as Ba}from"@lingui/core";function oy(t){let e=null;return t===ki?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:Ba.t("Reset"),title:Ba.t("Slippage cannot be set lower than 0.01%.")},e):t>un?(e={alertType:"warning",action:"change-settings",actionButtonTitle:Ba.t("Change"),title:Ba.t("Caution, your slippage is high!")},e):null}i(oy,"makeAlerts");function ry(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=T(),{onChangeSettings:a}=t,c=oy(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(Ti),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?ny.createElement(dI,{title:c.title,type:c.alertType,variant:"alarm",action:ny.createElement(mI,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(ry,"SlippageWarningsAndErrors");import{i18n as SI}from"@lingui/core";import{IconButton as CI,ReverseIcon as TI,Skeleton as kI,Tooltip as vI,Typography as zr}from"@rango-dev/ui";import Ct from"react";import La from"bignumber.js";function ay(t){let{error:e,isDarkTheme:o,warning:n}=t,{quoteError:r,slippageError:a}=e,{quoteWarning:s,slippageWarning:c}=n,l=!!a||r?.type===4,p=!!c||s?.type===2;return l?"$error500":p?"$warning500":o?"$neutral600":"$neutral700"}i(ay,"getSlippageColor");function sy(t){let{toTokenUsdPrice:e,fromTokenUsdPrice:o}=t;if(!e||!o)return{rawValue:"0",displayValue:"0"};let n=new La(e),r=new La(o),a=n.dividedBy(r),s;return a.isLessThan(1)?s=a.toFixed(14).replace(/\.?0+$/,""):a.toFixed(0).length>10?s=a.toFixed(0).slice(0,10):s=a.toFixed(2),{displayValue:s,rawValue:a.toFixed()}}i(sy,"getUsdExchangeRate");function ly(t,e){let o=new La(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,La.ROUND_DOWN).toFormat(2)}`}i(ly,"formatTokenValueInUsd");import{darkTheme as hI,styled as Gc,Typography as yI}from"@rango-dev/ui";var cy=Gc("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),py=Gc("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${hI} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),Vc=Gc(yI,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function Kc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=T(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,m=o!==null?o:e,{mode:f}=go({}),h=fn(m),g=f==="dark",d=n==="default",y={quoteError:a,slippageError:h?.type==="error"?h.message:null},S={quoteWarning:s,slippageWarning:h?.type==="warning"?h.message:null},C=p?.swaps[0]?.from||c,k=p?.swaps[p?.swaps.length-1]?.to||l,E=d?C:k,w=d?k:C,I=Number(d?p?.outputAmount:p?.requestAmount),A=Number(d?p?.requestAmount:p?.outputAmount),x=I||E.usdPrice,b=A||w.usdPrice,{rawValue:v,displayValue:N}=sy({toTokenUsdPrice:b,fromTokenUsdPrice:x});return Ct.createElement(cy,null,Ct.createElement(zr,{variant:y||S?"label":"body",size:y||S?"medium":"small",color:ay({error:y,warning:S,isDarkTheme:g})},SI.t("Slippage:")," ",m,"%"),u?Ct.createElement(kI,{height:16,width:104,variant:"rounded"}):x&&b&&Ct.createElement(py,null,Ct.createElement(zr,{className:"rate-text",variant:"body",size:"small"},"1"),Ct.createElement(Vc,{className:"rate-text",variant:"body",size:"small"},w.symbol),Ct.createElement(CI,{id:"widget-home-page-change-rate-button",onClick:r},Ct.createElement(TI,{size:14,color:"secondary"})),Ct.createElement(vI,{container:W(),side:"top",sideOffset:4,content:Ct.createElement(zr,{className:"rate-text",variant:"body",size:"small"},v)},Ct.createElement(zr,{className:"rate-text",variant:"body",size:"small"},N)),Ct.createElement(Vc,{className:"rate-text",variant:"body",size:"small"},E.symbol),E.usdPrice&&Ct.createElement(zr,{color:"neutral600",variant:"body",size:"small"},"~",ly(Number(v),E.usdPrice))))}i(Kc,"SwapMetrics");import{i18n as AI}from"@lingui/core";import{Header as NI}from"@rango-dev/ui";import wo,{useEffect as WI,useState as PI}from"react";import{i18n as EI}from"@lingui/core";import{Divider as Xc,FullExpandedQuote as bI,Typography as xI}from"@rango-dev/ui";import be from"react";import{styled as jc}from"@rango-dev/ui";var uy=jc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),dy=jc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),my=jc("div",{width:"146px"});import{i18n as Hr}from"@lingui/core";import{Select as wI}from"@rango-dev/ui";import fy from"react";function _a(t){let{updateQuotePartialState:e,sortStrategy:o}=G()(),n=[{value:"SMART",label:Hr.t("Smart Routing")},{value:"FEE",label:Hr.t("Lowest Fee")},{value:"SPEED",label:Hr.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Hr.t("Maximum Return")},{value:"PRICE",label:Hr.t("Maximum Output")}];return fy.createElement(my,null,fy.createElement(wI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(_a,"SelectStrategy");var gy=3;function Qr(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:c}=t,{selectedQuote:l,quotes:p,updateQuotePartialState:u,fromToken:m,toToken:f,sortStrategy:h,error:g}=G()(),{slippage:d,customSlippage:y}=T(),{findToken:S}=T(),C=c||W(),k=!!p&&p.results.length,E=y??d,{config:{__UNSTABLE_OR_INTERNAL__:w}}=T(),I=i(b=>{if(!m||!f||!p)return null;let v={requestAmount:p.requestAmount,validationStatus:null,...b};return wn({currentQuote:v,userSlippage:E,findToken:S})},"getQuoteWarning"),A=g?.type===0||g?.type===1,x=p?.results?$i(h,p?.results):[];return be.createElement(be.Fragment,null,a&&be.createElement(be.Fragment,null,be.createElement(dy,null,be.createElement(xI,{size:"xmedium",variant:"title"},EI.t("Sort by")),be.createElement(_a,{container:C})),be.createElement(Xc,{size:"10"})),e&&Array.from({length:gy},(b,v)=>be.createElement(be.Fragment,{key:v},s?be.createElement(bI,{campaignTag:w?.campaignTag,loading:!0}):be.createElement(Wr,{tagHidden:!1,type:"list-item",expanded:!1}),v!==gy-1&&be.createElement(Xc,{size:16}))),!e&&be.createElement(be.Fragment,null,k?x.map((b,v)=>{let N=I(b),B=gc(b.swaps),_=x.length-1===v;return be.createElement(be.Fragment,{key:b.requestId},be.createElement(Yo,{id:"widget-quotes-quote-info-container",showModalFee:r,container:C,selected:l?.requestId===b.requestId,tagHidden:!1,quote:{...b,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:B?.options||null,warning:N,fullExpandedMode:s,onClick:Q=>{B||u("warning",N),u("error",B?.options||null),o(Q)},type:"list-item"}),!_&&be.createElement(Xc,{size:16}))}):A&&be.createElement(uy,null,be.createElement(vr,{size:s?"large":"small",error:g,fetch:n}))))}i(Qr,"Quotes");import{darkTheme as II,styled as hy}from"@rango-dev/ui";var yy=hy("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${II} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Sy=hy("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var BI=100;function Yc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=PI(!1),l=s?"":"is-hidden",{config:p}=T(),u=p?.variant==="full-expanded",m=_o();return WI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},BI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),wo.createElement(yy,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${Zi()} widget-expanded-quotes-container`,id:rt.EXPANDED_BOX_ID},wo.createElement(NI,{title:AI.t("Routes"),suffix:wo.createElement(wo.Fragment,null,wo.createElement(_a,{container:m}),wo.createElement(Vo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),wo.createElement(Sy,null,wo.createElement(Qr,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:_o(),onClickOnQuote:n,fullExpandedMode:u})))}i(Yc,"ExpandedQuotes");import{i18n as by}from"@lingui/core";import{SwapInput as xy}from"@rango-dev/ui";import DI from"bignumber.js";import qr from"react";import{ReverseIcon as MI}from"@rango-dev/ui";import Jc from"react";import{keyframes as LI,styled as Cy}from"@rango-dev/ui";var Zc=450,_I=LI({"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)"}}),Ty=Cy("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),ky=Cy("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${_I} ${Zc}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 Rc(){let t=G().use.switchFromAndTo();return Jc.createElement(Ty,null,Jc.createElement(ky,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Zc),t()}},Jc.createElement(MI,{size:12})))}i(Rc,"SwitchFromAndToButton");import{styled as vy}from"@rango-dev/ui";var wy=vy("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Ey=vy("div",{position:"relative"});function ep(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:c,toBlockchain:l,setInputAmount:p,sanitizeInputAmount:u,inputAmount:m,inputUsdValue:f,outputAmount:h,outputUsdValue:g,selectedQuote:d}=G()(),{swapMode:y}=at(),{connectedWallets:S,getBalanceFor:C}=T(),k=a?C(a):null,E=hi(k)?.amount??"0",w=k?new DI(k.amount).shiftedBy(-k.decimals):ue,I=!!s&&Uu(S,s.name),A=!Rs(d,m,f),x=!Rs(d,m,g),b=!f||!g||!g.gt(0)?null:Yt(f.toString(),g.toString());return qr.createElement(wy,null,qr.createElement(Ey,null,qr.createElement(xy,{label:by.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:E,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:m,usdValue:A?void 0:D(f,4,4),realUsdValue:A?void 0:f?.toString(),error:A?ne().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:I,tooltipContainer:W(),onSelectMaxBalance:()=>{let v=w.isGreaterThan(ue)?w.toFixed():"";p(v)},anyWalletConnected:S.length>0}),y==="swap"&&qr.createElement(Rc,null)),qr.createElement(xy,{selectionType:y==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!d||e),label:by.t("To"),mode:"To",id:"widget-swap-to-input",fetchingQuote:e,chain:{displayName:l?.displayName||"",image:l?.logo},token:{displayName:c?.symbol||"",image:c?.image,securityWarning:!!c?.warning},percentageChange:D(Yt(f,g),2,2),warningLevel:Zt(b??0),price:{value:D(h,6,6),usdValue:x?void 0:D(g,4,4),realValue:h?.toString(),realUsdValue:x?void 0:g?.toString(),error:x?ne().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:W()}))}i(ep,"Inputs");import{warn as $I}from"@rango-dev/logging-core";import{useCallback as FI,useEffect as OI,useRef as UI,useState as zI}from"react";function Iy(){let{fetch:t,loading:e,cancelFetch:o}=Ea({request:async(n,r)=>await gt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Iy,"useFetchAllQuotes");var HI=600;function Ma({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Iy(),{excludeLiquiditySources:n,routing:r}=T().config,{connectedWallets:a}=T(),c=a.some(me=>me.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:m,selectedQuote:f,sortStrategy:h,resetQuote:g,error:d,warning:y,setSelectedQuote:S,updateQuotePartialState:C}=G()(),{slippage:k,customSlippage:E,affiliatePercent:w,affiliateRef:I,affiliateWallets:A,fetchStatus:x}=T(),b=T().getLiquiditySources(),v=T().getDisabledLiquiditySources(),N=T().excludeLiquiditySources(),{findToken:B}=T(),{swapMode:_}=at(),[Q,V]=zI(!0),Y=UI(u),P=E??k,X=!l||!p||Vt(l,p)||!Zn(u),ie=i(me=>{V(me)},"resetState"),Te=i(me=>{let{fromToken:Oe,toToken:Qe,inputAmount:kt,liquiditySources:ot,excludeLiquiditySources:Ee,disabledLiquiditySources:z,slippage:q,affiliateRef:$,affiliatePercent:M,affiliateWallets:ce}=me;if(Q||ie(!0),!X&&Oe&&Qe){g();let H=sm({fromToken:Oe,toToken:Qe,inputAmount:kt,liquiditySources:ot,excludeLiquiditySources:Ee,disabledLiquiditySources:z,wallets:a,slippage:q,affiliateRef:$,affiliatePercent:M,affiliateWallets:ce,contractCall:c});mn("experimental",r)&&(H.experimental=!0),mn("avoidNativeFee",r)&&(H.avoidNativeFee=!0),mn("enableCentralizedSwappers",r)&&(H.enableCentralizedSwappers=!0),r?.maxLength&&(H.maxLength=r.maxLength),_==="refuel"&&(H.maxLength=1),e(H).then(ae=>{let qe=$i(h,ae.results),nt=Xd(f,qe,ae.requestAmount);V(!1),C("quotes",ae),S(nt),!ae.results?.length||!nt?$o({type:"routeNotFound",payload:{sourceChain:Oe.blockchain,destinationChain:Qe.blockchain,sourceToken:Oe.symbol,destinationToken:Qe.symbol,inputAmountUsd:m?m.toNumber():null}}):$o({type:"routeRequested",payload:{...Fn(nt),routeCount:ae.results.length}}),ba({diagnosisMessages:ae.diagnosisMessages,requestId:nt?.requestId||"",swaps:nt?.swaps});let co=nt&&wn({currentQuote:nt,userSlippage:P,findToken:B});C("warning",co)}).catch(ae=>{let qe=xa(ae);qe.type===0?$o({type:"routeNotFound",payload:{sourceChain:Oe.blockchain,destinationChain:Qe.blockchain,sourceToken:Oe.symbol,destinationToken:Qe.symbol,inputAmountUsd:m?m.toNumber():null}}):qe.type===1&&$o({type:"routeFetchFailed",payload:{sourceChain:Oe.blockchain,destinationChain:Qe.blockchain,errorCode:String(ae?.response?.status??"")}}),(qe.type===0||qe.type===1)&&g(),qe.type!==2&&(C("error",qe),V(!1),$I(new Error("quote error"),{tags:{...qe,type:Je[qe.type],requestBody:H}}))})}},"fetch"),dt=FI(ci(me=>{Te(me)},HI),[X]);return OI(()=>{if(!t){V(!1);return}if(x!=="success")return;if(X){V(!1),(f||d||y)&&g();return}if(!Zn(u)&&m?.eq(0)){ie(!1),o();return}g(),ie(!0);let me=Te;return Y.current&&Y.current!=u&&(me=dt),Y.current=u,me({inputAmount:u,fromToken:l,toToken:p,liquiditySources:b,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:P,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),o},[x,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,X,b?.length,n,v.length,P,I,w,c,JSON.stringify(A)]),{fetch:()=>Te({inputAmount:u,fromToken:l,toToken:p,liquiditySources:b,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:P,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),loading:Q}}i(Ma,"useSwapInput");var jI=qI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),XI=300;function Py(){let t=KI(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:c,quotes:l,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:m,updateQuotePartialState:f}=G()(),[h,g]=Wy(!1),{isLargeScreen:d,isExtraLargeScreen:y}=ga(),{fetch:S,loading:C}=Ma({refetchQuote:a}),{config:k,fetchStatus:E,connectedWallets:w,customSlippage:I,slippage:A,setSlippage:x,setCustomSlippage:b}=T(),{isActiveTab:v}=oe(),[N,B]=Wy(!1),_=I!==null?I:A,{swapMode:Q}=at(),V=fn(_),P=nm({fetchMetaStatus:E,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),Z=Vu(d,y,k?.variant),X=!!n&&!!e&&!!o&&new VI(n).gt(0)&&!fm(e,o),ie=X&&E==="success"&&C,Te=V?.quoteValidation||c,Oe=(!Z||Z&&l?.results.length)&&(Te||s),Qe=!!e&&!!o,kt=Qe&&!!V,ot=(r||s)&&!N?S:void 0,Ee=i(M=>{Z&&h?(g(!1),setTimeout(()=>{t(M)},XI)):t(M)},"onHandleNavigation"),z=i(M=>{r?.requestId!==M.requestId&&(r&&$o({type:"routeChanged",payload:{sourceChain:M.swaps[0]?.from.blockchain??"",destinationChain:M.swaps[M.swaps.length-1]?.to.blockchain??"",fromRouteId:r.requestId,toRouteId:M.requestId}}),B(!1),p(M))},"onClickOnQuote"),q=i(M=>{if(M){if(Ci.includes(M)){x(M),b(null);return}b(M)}},"onChangeSlippage"),$=i(M=>{Ee(M==="from"?O.fromSwap:Q==="swap"?O.toSwap:O.toSwap+"/"+O.blockchains)},"handleInputTokenClick");return Ny(()=>{u(),f("refetchQuote",!0)},[]),Ny(()=>{g(X)},[X]),ke.createElement(jI,null,ke.createElement(se,{height:"auto",footer:ke.createElement(QI,{id:`widget-swap-${P.action}-btn`,type:"primary",size:"large",disabled:P.disabled||!v,prefix:P.action==="confirm-warning"&&ke.createElement(GI,null),fullWidth:!0,onClick:()=>{P.action==="connect-wallet"?ud({type:"clickConnectWallet"},()=>{Bs("swap_button"),Ee(O.wallets)}):P.action==="confirm-warning"?B(!0):r&&(ee({type:"swapInitiated",payload:{...Fn(r),walletConnected:w.length>0}}),Ee(O.confirmSwap))}},P.title),header:{onWallet:()=>{Bs("nav"),Ee(O.wallets)},hasBackButton:!1,title:k.title||(Q==="swap"?Ay.t("Swap"):Ay.t("Refuel")),suffix:ke.createElement(Vo,{hidden:Z?["refresh"]:void 0,onClickRefresh:ot,onClickHistory:()=>Ee(O.swaps),onClickSettings:()=>{Ee(O.settings)}})}},ke.createElement(pe,null,ke.createElement(ep,{fetchingQuote:ie,fetchMetaStatus:E,isExpandable:Z,onClickToken:$}),ke.createElement(tp,{size:"2"}),Z?null:ke.createElement(Yo,{quote:r,loading:ie,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:Te,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),Ee(O.routes)}:void 0}),Qe&&ke.createElement(ke.Fragment,null,ke.createElement(tp,{size:8}),ke.createElement(Kc,{quoteError:s,quoteWarning:Te,fromToken:e,toToken:o,quote:r,loading:ie})),Oe?ke.createElement(ke.Fragment,null,ke.createElement(Er,{warning:Te,error:s,skipAlerts:!!V,couldChangeSettings:!0,refetchQuote:S,showWarningModal:N,confirmationDisabled:!v,onOpenWarningModal:()=>B(!0),onCloseWarningModal:()=>B(!1),onChangeSlippage:q,onConfirmWarningModal:()=>{B(!1),m(!0),Ee(O.confirmSwap)},onChangeSettings:()=>Ee(O.settings)})):null,kt&&ke.createElement(ke.Fragment,null,ke.createElement(tp,{size:"10"}),ke.createElement(ry,{onChangeSettings:()=>Ee(O.settings)})),ke.createElement(Qc,null))),Z?ke.createElement(Yc,{loading:ie,onClickOnQuote:z,fetch:S,onClickRefresh:ot,isVisible:h}):null)}i(Py,"Home");import{i18n as By}from"@lingui/core";import{Alert as YI,Divider as ZI,List as JI,ListItemButton as RI,Radio as eA,RadioRoot as tA,Typography as oA}from"@rango-dev/ui";import zt from"react";function Eo(){let{setLanguage:t,language:e,config:o}=T(),n=Ru,r=o?.language||gn;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||gn),resetLanguage:()=>t(null)}}i(Eo,"useLanguage");function Ly(){let{activeLanguage:t,changeLanguage:e,languages:o}=Eo(),n=Ke(),r=o.map(a=>{let{local:s,label:c,SVGFlag:l}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:zt.createElement(oA,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:zt.createElement(eA,{value:s}),start:zt.createElement(l,null)}});return zt.createElement(se,{header:{title:By.t("Language")}},zt.createElement(pe,null,zt.createElement(YI,{type:"warning",id:"widget-language-machine-translation-alarm-alert",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),zt.createElement(ZI,{size:"8"}),zt.createElement(tA,{value:t},zt.createElement(JI,{type:zt.createElement(RI,{title:By.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(Ly,"LanguagePage");import{i18n as io}from"@lingui/core";import{Button as sA,Checkbox as lA,Image as cA,ListItemButton as pA,NotFound as uA,Typography as dA}from"@rango-dev/ui";import tt,{useState as mA}from"react";import{Checkbox as iA,Skeleton as My}from"@rango-dev/ui";import Vr from"react";import{styled as op}from"@rango-dev/ui";var Gr=op("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),np=op("div",{width:80,display:"flex",justifyContent:"flex-end"}),rp=op("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as nA,styled as rA}from"@rango-dev/ui";var _y=rA(nA,{height:61});var aA=30;function ip(){return Vr.createElement(Gr,null,Array.from(Array(aA),(t,e)=>Vr.createElement(_y,{hasDivider:!0,key:e,start:Vr.createElement(My,{variant:"circular",width:35,height:35}),title:Vr.createElement(My,{variant:"text",size:"large",width:90}),end:Vr.createElement(iA,{checked:!1})})))}i(ip,"LoadingLiquiditySourceList");function ap({sourceType:t}){let e=T().fetchStatus,o=T().swappers(),n=T().getDisabledLiquiditySources(),[r,a]=mA(""),s=T().toggleLiquiditySource,c=T().isInCampaignMode(),l=wi(o,n),p={Exchanges:io.t("Exchanges"),Bridges:io.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=l.filter(S=>u.includes(S.type)),f=m.length===m.filter(S=>S.selected).length,h=i(()=>{ee({type:"settingsChanged",payload:{settingName:"bridge_exclusion",previousValue:`${t}:${f?"all_enabled":"some_disabled"}`,newValue:`${t}:${f?"all_disabled":"all_enabled"}`}}),m.forEach(S=>{f?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),g=m.map(S=>{let{selected:C,groupTitle:k,logo:E,id:w,...I}=S;return{id:`widget-setting-liquidity-source-${Iu(w.toLowerCase())}-item-btn`,start:tt.createElement(cA,{src:E,size:22,type:"circular"}),onClick:()=>{c||(ee({type:"settingsChanged",payload:{settingName:"bridge_exclusion",previousValue:`${k}:${C?"enabled":"disabled"}`,newValue:`${k}:${C?"disabled":"enabled"}`}}),s(k))},end:tt.createElement(lA,{checked:C,disabled:c}),title:tt.createElement(dA,{variant:"title",size:"xmedium"},io.t(k)),selected:C,groupTitle:k,logo:E,...I}}),d=i(S=>{let C=S.target.value;a(C)},"handleSearch"),y=g;return r&&(y=g.filter(S=>Dt(S.groupTitle,r))),tt.createElement(se,{header:{title:io.t(t),suffix:tt.createElement(np,null,tt.createElement(sA,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:h},f?io.t("Deselect all"):io.t("Select all")))}},tt.createElement(pe,{view:!0},tt.createElement(Bt,{value:r,setValue:a,id:"widget-liquidity-source-search-input",fullWidth:!0,color:"light",variant:"contained",placeholder:io.t("Search {sourceType}",{sourceType:p[t]}),onChange:d}),e==="loading"&&tt.createElement(ip,null),!y.length&&r?tt.createElement(rp,null,tt.createElement(uA,{title:io.t("No results found"),description:io.t("Try using different keywords")})):e==="success"&&tt.createElement(Gr,{disabled:c,className:"widget-liquidity-source-list"},y.map(S=>{let{groupTitle:C,...k}=S;return tt.createElement(tt.Fragment,{key:S.id},tt.createElement(pA,{style:{height:"61px"},...k,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(ap,"LiquiditySourcePage");import{i18n as fA}from"@lingui/core";import Da from"react";import{useNavigate as gA}from"react-router-dom";function Dy(){let t=gA(),e=Ke(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=G()(),{fetch:c,loading:l}=Ma({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${O.settings}`,m=`../${O.wallets}`;return Da.createElement(se,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:fA.t("Routes"),suffix:Da.createElement(Vo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Da.createElement(pe,null,Da.createElement(Qr,{fetch:c,loading:l,onClickOnQuote:p})))}i(Dy,"RoutesPage");import{i18n as Qy}from"@lingui/core";import{Divider as qy,getCategoriesCount as bA,SelectableCategoryList as xA}from"@rango-dev/ui";import ao,{useMemo as IA,useState as Gy}from"react";import{useNavigate as AA}from"react-router-dom";import{i18n as sp}from"@lingui/core";import{Divider as CA,Image as TA,ListItemButton as kA,NotFound as vA,Typography as Hy}from"@rango-dev/ui";import Tt,{useEffect as wA,useState as EA}from"react";var $y=i((t,e,o)=>t.filter(n=>pi(n.type,o)).filter(n=>mt(n.name,e)||mt(n.displayName,e)),"filterBlockchains");import{ImageContainer as hA,styled as Fy}from"@rango-dev/ui";var Oy=Fy("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),$a=Fy(_l,{padding:0,margin:0,listStyle:"none",[`& ${hA}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as yA,Skeleton as Uy}from"@rango-dev/ui";import Fa from"react";var SA=20;function zy(){return Fa.createElement($a,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(SA),t=>Fa.createElement(yA,{key:t,hasDivider:!0,start:Fa.createElement(Uy,{variant:"circular",width:35,height:35}),title:Fa.createElement(Uy,{variant:"text",size:"large",width:90})})))}i(zy,"LoadingBlockchainList");function lp(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=EA(e),{fetchStatus:l}=T();wA(()=>{c([...$y(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?Tt.createElement(vA,{title:sp.t("No results found"),description:sp.t("Try using different keywords")}):Tt.createElement($a,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>Tt.createElement(kA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:Tt.createElement(TA,{src:u.logo,size:30}),title:Tt.createElement(Hy,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return Tt.createElement(Tt.Fragment,null,a&&Tt.createElement(Tt.Fragment,null,Tt.createElement(Hy,{variant:"label",size:"large"},sp.t("Select Chain")),Tt.createElement(CA,{size:4})),Tt.createElement(Oy,null,l==="loading"&&Tt.createElement(zy,null),l==="success"&&p()))}i(lp,"BlockchainList");function Oa(t){let{type:e}=t,o=Ke(),[n,r]=Gy(""),[a,s]=Gy("ALL"),c=G().use.setToBlockchain(),l=G().use.setFromBlockchain(),p=G().use.setToToken(),{fetchStatus:u,findNativeToken:m}=T(),f=AA(),{swapMode:h}=at(),g=T().blockchains({type:e}),d=T().tokens(),y=IA(()=>wu(g,d),[g.length,d.length]),S=bA(y),C=!t.hideCategory&&S!==1,k=i(E=>{if(e==="custom-token")f(`..?blockchain=${E.name}`,{replace:!0});else{if(ee({type:"chainFilterApplied",payload:{side:e==="source"?"from":"to",chain:E.name,filterSource:"expanded"}}),e==="source")l(E);else if(h==="swap")c(E);else{let w=m(E);w&&p({token:w,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ao.createElement(se,{header:{title:Qy.t("Select Chain")}},ao.createElement(pe,{view:!0},C&&ao.createElement(ao.Fragment,null,ao.createElement(xA,{setCategory:s,category:a,blockchains:y,isLoading:u==="loading"}),ao.createElement(qy,{size:24})),ao.createElement(Bt,{value:n,autoFocus:!0,placeholder:Qy.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:E=>r(E.target.value)}),ao.createElement(qy,{size:16}),ao.createElement(lp,{list:y,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:k})))}i(Oa,"SelectBlockchainPage");import{i18n as Ha}from"@lingui/core";import{Divider as Jy,Spinner as QA}from"@rango-dev/ui";import bo,{useEffect as qA,useState as GA}from"react";import{useNavigate as VA}from"react-router-dom";import{i18n as up}from"@lingui/core";import{BlockchainsChip as Ua,Divider as Xy,Image as Yy,Skeleton as _A,Tooltip as MA,Typography as dp}from"@rango-dev/ui";import xe from"react";import{useEffect as PA}from"react";var Vy=["ETH","COSMOS","OSMOSIS"];function cp(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(NA),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let c=o.limit-e.length;for(let l=0;l<=c;l++){let p=n[l];s=s.filter(u=>p?.name!==u)}}n.sort(WA(s)),r=n.splice(a)}return{list:n,more:r}}i(cp,"prepare");function NA(t,e){let o=Vy,n=o.findIndex(c=>c===t.name),r=o.findIndex(c=>c===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(NA,"sortByMostUsedBlockchains");function WA(t){return i(function(o,n){let r=t.findIndex(l=>l===o.name),a=t.findIndex(l=>l===n.name),s=r>-1,c=a>-1;return s&&c?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(WA,"generateSortByPreferredBlockchainsFor");function Ky(t,e){return!!e.list.find(o=>o.name===t)}i(Ky,"isInVisibleList");function pp(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=T();PA(()=>{if(e?.selected){let a=cp(t,o,e);Ky(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=cp(t,o,e);return{list:r.list,more:r.more,history:[]}}i(pp,"usePrepareBlockchainList");import{styled as BA}from"@rango-dev/ui";var jy=BA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var DA=6,$A=12;function mp(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=oe(),c=pp(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=T(),p=G().use.resetToBlockchain(),u=G().use.resetFromBlockchain(),m=c.more.length>0,f=c.more[0],h=c.more.length===1&&f,g=!h&&m;return xe.createElement(xe.Fragment,null,!s&&xe.createElement(xe.Fragment,null,xe.createElement(Xy,{size:12}),xe.createElement(dp,{variant:"label",size:"large"},up.t("Select Chain"))),xe.createElement(Xy,{size:12}),xe.createElement(jy,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?DA:$A),(d,y)=>xe.createElement(_A,{key:y,variant:"rounded",height:50})),l==="success"&&xe.createElement(xe.Fragment,null,xe.createElement(Ua,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},xe.createElement(dp,{variant:"body",size:"xsmall",color:"secondary500"},up.t("All"))),c.list.map(d=>xe.createElement(MA,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:W()},xe.createElement(Ua,{className:"widget-blockchains-section-item-btn",key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},xe.createElement(Yy,{src:d.logo,size:30})))),h?xe.createElement(Ua,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},xe.createElement(Yy,{src:f.logo,size:30})):null,g?xe.createElement(Ua,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},xe.createElement(dp,{variant:"body",size:"xsmall",color:"secondary500"},up._("More +{count}",{count:c.more.length}))):null)))}i(mp,"BlockchainsSection");import{useCallback as OA,useRef as UA,useState as fp}from"react";function gp(){let t=T().blockchains(),e=UA(null),{customTokens:o}=T(),[n,r]=fp(!1),[a,s]=fp([]),[c,l]=fp(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await gt().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),d=new Set(o().map(C=>jt(C))),y=new Set(t.map(C=>C.name)),S=g.tokens.filter(C=>y.has(C.blockchain)&&!d.has(jt(C)));s(S),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=OA(ci((f,h)=>{e.current?.signal.aborted||p(f,h)},600),[t.length]);return{fetch:(f,h)=>{e.current=new AbortController,s([]),r(!0),u(f,h)},cancel:i(()=>{e.current?.abort()},"cancel"),loading:n,tokens:a,error:c}}i(gp,"useSearchCustomTokens");function za(t,e,o){return o&&t.length===1&&t[0]?.address===e?!1:t.length<20&&e.trim().length>=3}i(za,"shouldSearchForCustomTokens");function Zy(t,e,o,n,r){let a=[...t];return za(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(Zy,"prepareTokensList");function Qa(t){let{type:e}=t,o=VA(),n=Ke(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=G()(),{getBalanceFor:u}=T(),{fetch:m,loading:f,tokens:h,cancel:g}=gp(),[d,y]=GA(""),S=e==="source"?r:a,C=S?.name??"",k=T().blockchains({type:e}),E=T().tokens({type:e,blockchain:C,searchFor:d,getBalanceFor:u}),w=Zy(E,h,d,f,S?.name),I=i(b=>{e==="source"?l(b):p(b)},"updateBlockchain"),A=i(b=>{e==="source"?s({token:b,meta:{blockchains:k}}):c({token:b,meta:{blockchains:k}})},"updateToken"),x={source:Ha.t("Source"),destination:Ha.t("Destination")};return qA(()=>(za(E,d,S?.name)&&m(d,S?.name??void 0),()=>{g()}),[E.length,d,S?.name]),bo.createElement(se,{header:{title:Ha.t("Swap {type}",{type:x[e]})}},bo.createElement(pe,null,bo.createElement(mp,{blockchains:k,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(O.blockchains),onChange:b=>{ee({type:"chainFilterApplied",payload:{side:e==="source"?"from":"to",chain:b.name,filterSource:"featured"}}),I(b)}}),bo.createElement(Jy,{size:24}),bo.createElement(Bt,{value:d,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:Ha.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>y(""),onChange:b=>y(b.target.value),suffix:za(E,d,S?.name)&&f?bo.createElement(QA,{size:12,color:"secondary"}):void 0}),bo.createElement(Jy,{size:16}),bo.createElement(Mr,{list:w,selectedBlockchain:C,searchedFor:d,type:e,onChange:b=>{ee({type:"tokenSelected",payload:{side:e==="source"?"from":"to",tokenName:b.name,tokenSymbol:b.symbol,tokenAddress:b.address,chain:b.blockchain,selectionMethod:d.trim()?"search":b.isPopular?"popular":"recent",activeChainFilter:C||"all"}}),A(b);let v=k.find(N=>b.blockchain===N.name);v&&I(v),n()}})))}i(Qa,"SelectSwapItemsPage");import{i18n as Cp}from"@lingui/core";import{Alert as CN,Button as TN,styled as kN}from"@rango-dev/ui";import en from"react";import{useInRouterContext as vN,useSearchParams as wN}from"react-router-dom";import{i18n as rS}from"@lingui/core";import{Alert as YA,Divider as yp,InfoIcon as ZA,SlippageIcon as JA,TextField as RA,Tooltip as eN,Typography as iS}from"@rango-dev/ui";import ze from"react";import{Chip as KA,styled as Kr,TextField as jA}from"@rango-dev/ui";var Ry=Kr("div",{paddingTop:"$5",padding:"$10 $5"}),eS=Kr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${jA}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),tS=Kr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),qa=Kr("div",{maxWidth:"280px",padding:"$10"}),oS=Kr(KA,{width:"61px",flexShrink:0});import{i18n as hp}from"@lingui/core";import{Typography as XA}from"@rango-dev/ui";import jr from"react";function nS(){return jr.createElement(qa,null,jr.createElement(XA,{variant:"label",size:"medium",color:"neutral700"},hp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),jr.createElement("br",null),jr.createElement("br",null),jr.createElement("b",null,hp.t("Warning")),":\xA0",hp.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(nS,"SlippageTooltipContent");function Sp(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=T(),r=o!==null?fn(o):null,a=o??t,s=i((u,m)=>{u!==m&&ee({type:"settingsChanged",payload:{settingName:"slippage",previousValue:String(u),newValue:String(m)}})},"emitSlippageChanged"),c=i(u=>{let m=u.target.value,f=parseFloat(m);if(isNaN(f))return n(null);let h=f;f>tr&&(h=tr),s(a,h),n(h)},"onSlippageValueChange"),l=i(u=>{s(a,u),o!==null&&n(null),e(u)},"onClickSlippageChip"),p=i(u=>{let m=u.target,f=m.value;Wu(f)||(m.value=f.slice(0,-1))},"onInput");return ze.createElement(Ry,null,ze.createElement(tS,null,ze.createElement(JA,{size:16,color:"gray"}),ze.createElement(yp,{direction:"horizontal",size:4}),ze.createElement(iS,{variant:"title",size:"xmedium"},rS.t("Slippage tolerance per swap")),ze.createElement(yp,{direction:"horizontal",size:4}),ze.createElement(eN,{container:W(),side:"top",sideOffset:4,content:ze.createElement(nS,null)},ze.createElement(ZA,{color:"gray"}))),ze.createElement(eS,null,Ci.map((u,m)=>{let f=`slippage-${m}`;return ze.createElement(oS,{id:`widget-slippage-chip-${u.toString()}%-btn`,key:f,onClick:()=>l(u),selected:o===null&&u===t,label:`${u.toString()}%`})}),ze.createElement(RA,{type:"number",min:"0.01",max:"30",step:"0.01",status:r?.type||(o?"success":"default"),id:"widget-slippage-chip-text-input",onInput:p,fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:c,suffix:o&&ze.createElement(iS,{variant:"body",size:"small"},"%"),placeholder:rS.t("Custom")})),r&&ze.createElement(ze.Fragment,null,ze.createElement(yp,{size:10}),ze.createElement(YA,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(Sp,"Slippage");import{i18n as xt}from"@lingui/core";import{AutoThemeIcon as aS,BridgesIcon as tN,ChevronRightIcon as Ga,DarkModeIcon as sS,Divider as Xr,ExchangeIcon as oN,InfinityIcon as nN,InfoIcon as rN,LanguageIcon as iN,LightModeIcon as lS,List as aN,ListItem as sN,ListItemButton as lN,Skeleton as cN,styled as pN,Switch as uN,Tabs as dN,TargetIcon as mN,Tooltip as fN,Typography as ut}from"@rango-dev/ui";import F from"react";import{useNavigate as gN}from"react-router-dom";var hN=pN("div",{width:"202px",height:"$40"}),yN=[{id:"light",icon:F.createElement(lS,{color:"black",size:24}),tooltip:F.createElement(ut,{size:"xsmall",variant:"body"},xt.t("Light"))},{id:"dark",icon:F.createElement(sS,{color:"black",size:24}),tooltip:F.createElement(ut,{size:"xsmall",variant:"body"},xt.t("Dark"))},{id:"auto",icon:F.createElement(aS,{color:"black",size:24}),tooltip:F.createElement(ut,{size:"xsmall",variant:"body"},xt.t("Auto"))}],SN=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return F.createElement(aS,{...e});case"dark":return F.createElement(sS,{...e});default:return F.createElement(lS,{...e})}},"getThemeIcon");function cS(){let t=gN(),{theme:e}=T().config,{setTheme:o,theme:n}=T(),{activeLanguage:r,languages:a}=Eo(),s=a.find(P=>P.local===r)?.label,c=T().fetchStatus,l=T().swappers(),p=T().getDisabledLiquiditySources(),{config:{features:u}}=T(),m=T().customTokens(),f=it("theme",u),h=it("liquiditySource",u),g=it("language",u),d=it("customTokens",u),y=T().infiniteApprove,S=T().toggleInfiniteApprove,C=wi(l,p),k=C.filter(P=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(P.type)),E=k.length,w=k.filter(P=>P.selected).length,I=C.filter(P=>P.type==="DEX"),A=I.length,x=I.filter(P=>P.selected).length,b=i((P,Z)=>{switch(c){case"loading":return F.createElement(cN,{variant:"text",size:"medium",width:50});case"failed":return F.createElement(ut,{variant:"body",size:"medium",color:"$error500"},xt.t("Loading failed"));default:return F.createElement(ut,{variant:"body",size:"medium"},`${P} / ${Z}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Bridges")),end:F.createElement(F.Fragment,null,b(w,E),F.createElement(Xr,{direction:"horizontal",size:8}),F.createElement(Ga,{color:"black"})),onClick:()=>t(O.bridges),start:F.createElement(tN,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Exchanges")),end:F.createElement(F.Fragment,null,b(x,A),F.createElement(Xr,{direction:"horizontal",size:8}),F.createElement(Ga,{color:"black"})),start:F.createElement(oN,{color:"gray",size:16}),onClick:()=>t(O.exchanges)},B={id:"widget-setting-custom-tokens-item-btn",title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Custom Tokens")),end:F.createElement(F.Fragment,null,F.createElement(ut,{variant:"body",size:"medium"},`${m.length}`),F.createElement(Xr,{direction:"horizontal",size:8}),F.createElement(Ga,{color:"black"})),start:F.createElement(mN,{color:"gray",size:16}),onClick:()=>t(O.customTokens)},_={id:"widget-setting-language-item-btn",title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Language")),start:F.createElement(iN,{color:"gray",size:16}),end:F.createElement(F.Fragment,null,F.createElement(ut,{variant:"body",size:"medium"},s),F.createElement(Xr,{direction:"horizontal",size:8}),F.createElement(Ga,{color:"black"})),onClick:()=>t(O.languages)},Q={id:"widget-setting-infinite-approval-item-btn",title:F.createElement(F.Fragment,null,F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Infinite approval")),F.createElement(Xr,{direction:"horizontal",size:4}),F.createElement(fN,{side:"top",sideOffset:4,container:W(),content:F.createElement(qa,null,F.createElement(ut,{variant:"label",size:"medium",color:"neutral700"},F.createElement("b",null,xt.t("Warning")),":\xA0",xt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},F.createElement(rN,{color:"gray"}))),start:F.createElement(nN,{color:"gray",size:16}),end:F.createElement(uN,{checked:y}),onClick:()=>{ee({type:"settingsChanged",payload:{settingName:"infinite_approval",previousValue:String(y),newValue:String(!y)}}),S()}},V={id:"widget-setting-theme-item-btn",type:F.createElement(sN,null),title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Theme")),end:F.createElement(hN,null,F.createElement(dN,{container:W(),items:yN,value:n,className:"widget-setting-theme-item-tabs-container",onChange:P=>o(P.id),type:"primary",borderRadius:"small"})),start:SN(n)},Y=h?[]:[v,N];return d||Y.push(B),g||Y.push(_),Y.push(Q),!e?.singleTheme&&!f&&Y.push(V),F.createElement(aN,{type:F.createElement(lN,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Y})}i(cS,"SettingsLists");var EN=kN("div",{paddingLeft:"$8"});function pS(){let{isInCampaignMode:t,updateCampaignMode:e}=T(),o=t(),[,n]=wN(),r=vN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return en.createElement(se,{header:{title:Cp.t("Settings")}},en.createElement(pe,null,o&&en.createElement(CN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:Cp.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:en.createElement(EN,null,en.createElement(TN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Cp.t("Reset")))}),en.createElement(Sp,null),en.createElement(cS,null)))}i(pS,"SettingsPage");import{i18n as _0}from"@lingui/core";import{cancelSwap as M0}from"@rango-dev/queue-manager-rango-preset";import{useManager as D0}from"@rango-dev/queue-manager-react";import{Alert as $0}from"@rango-dev/ui";import Dp from"react";import{useParams as F0}from"react-router-dom";import{i18n as Qt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as T0,getCurrentStep as k0,getRelatedWalletOrNull as v0}from"@rango-dev/queue-manager-rango-preset";import{Button as rC,Divider as w0,QuoteCost as E0,StepDetails as b0,Typography as Wp}from"@rango-dev/ui";import{useWallets as x0}from"@rango-dev/wallets-react";import iC from"bignumber.js";import{PendingSwapNetworkStatus as Qn}from"rango-types";import we,{useEffect as Pp,useRef as Bp,useState as es}from"react";import{useNavigate as I0}from"react-router-dom";import{i18n as xo}from"@lingui/core";var bN=[xo.t("Sunday"),xo.t("Monday"),xo.t("Tuesday"),xo.t("Wednesday"),xo.t("Thursday"),xo.t("Friday"),xo.t("Saturday")];function uS(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?xo.t("Today"):`${bN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(uS,"timeSince");function dS(t){return t.finishTime?uS(parseInt(t.finishTime)):uS(parseInt(t.creationTime))}i(dS,"getSwapDate");import Yr from"react";import{i18n as Va}from"@lingui/core";import{Button as mS,Divider as Tp,MessageBox as xN}from"@rango-dev/ui";import Io from"react";var fS=i(({onCancel:t,onClose:e})=>Io.createElement(Io.Fragment,null,Io.createElement(Tp,{size:20}),Io.createElement(xN,{type:"error",title:Va.t("Cancel Swap"),description:Va.t("Are you sure you want to cancel this swap?")}),Io.createElement(Tp,{size:32}),Io.createElement(mS,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Va.t("Yes, Cancel it")),Io.createElement(Tp,{size:12}),Io.createElement(mS,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Va.t("No, Continue"))),"CancelContent");import{i18n as Ka}from"@lingui/core";import{Button as gS,Divider as kp,MessageBox as IN,Typography as AN}from"@rango-dev/ui";import so from"react";var hS=i(({onDelete:t,onClose:e})=>so.createElement(so.Fragment,null,so.createElement(kp,{size:20}),so.createElement(IN,{type:"error",title:Ka.t("Delete Transaction"),description:Ka.t("Are you sure you want to delete this swap?")}),so.createElement(kp,{size:32}),so.createElement(gS,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Ka.t("Yes, Delete it")),so.createElement(kp,{size:12}),so.createElement(gS,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},so.createElement(AN,{variant:"title",size:"medium",color:"primary"},Ka.t("No, Cancel")))),"DeleteContent");import{i18n as NN}from"@lingui/core";import{Button as WN,Divider as PN,MessageBox as BN}from"@rango-dev/ui";import tn from"react";var yS=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return tn.createElement(tn.Fragment,null,tn.createElement(BN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&tn.createElement(tn.Fragment,null,tn.createElement(PN,{size:"30"}),tn.createElement(WN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},NN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as YN,getCurrentStep as ZN,getRelatedWalletOrNull as JN}from"@rango-dev/queue-manager-rango-preset";import{WalletState as RN}from"@rango-dev/ui";import{useWallets as e0}from"@rango-dev/wallets-react";import ES from"react";import{i18n as zn}from"@lingui/core";import{Alert as TS,Button as MN,Checkbox as DN,Divider as Ya,Image as $N,MessageBox as FN,Spinner as ON,WarningIcon as UN}from"@rango-dev/ui";import{useWallets as zN}from"@rango-dev/wallets-react";import Ce,{useState as HN}from"react";import{css as LN,darkTheme as _N,styled as vp}from"@rango-dev/ui";var SS=LN({wordWrap:"break-word",display:"block"}),CS=vp("img",{width:"100%"}),ja=vp("div",{position:"relative"}),Xa=vp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${_N} &`]:{$$color:"$warning600"}});var kS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=HN(null),{list:s}=It(),c=oe.use.isActiveTab(),{state:l,connect:p}=zN(),u=s.find(w=>w.type===e.walletType),m=u?.needsNamespace?.data.find(w=>w.value===o?.namespace);if(!u)return null;let f=l(e.walletType),h=u.isHub&&o?.namespace?f.namespaces?.get(o.namespace):null,g=f.connecting||h?.connecting,d=u.isHub?h?.connected:f.connected,y=i(()=>d?zn.t("Done"):r?zn.t("Try again"):zn.t("Connect"),"getButtonTitle"),S=i(()=>g?Ce.createElement(ON,{color:"info"}):r||d?null:Ce.createElement(DN,{checked:!0,disabled:!0}),"getNamespaceSuffix"),C=i(async()=>{try{a(null),await p(u.type,o?.namespace?[{namespace:o?.namespace,network:void 0,derivationPath:e.derivationPath}]:void 0)}catch(w){a(w)}},"handleConnect"),k=i(async()=>{if(d){n();return}C()},"handleClickButton"),E=i(()=>{if(!d)return null;let w=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),I=w?.[w?.length-1];return I?po(I):null},"getAddress");return Ce.createElement(Ce.Fragment,null,Ce.createElement(FN,{type:"warning",title:zn.t("Connect {wallet}",{wallet:u.title}),description:zn.t("The connection of your wallet or some networks has been disconnected. Connect to continue the swap"),icon:Ce.createElement(ja,null,Ce.createElement($N,{src:u.image,size:45}),Ce.createElement(Xa,null,Ce.createElement(UN,{color:"warning",size:10})))}),d&&!m&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ya,{size:10}),Ce.createElement(TS,{type:"success",variant:"alarm",title:zn.t("Wallet connected successfully.")})),r&&!m&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ya,{size:10}),Ce.createElement(TS,{type:"error",title:r?.message,variant:"alarm"})),m&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ya,{size:30}),Ce.createElement(Oo,{namespace:m,suffix:S(),error:r?.message,connected:d,address:E()})),Ce.createElement(Ya,{size:"40"}),Ce.createElement(MN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:k,disabled:!c},y()))},"ConnectWalletContent");import{i18n as vS}from"@lingui/core";import{Button as QN,Divider as qN,Image as GN,MessageBox as VN,WarningIcon as KN}from"@rango-dev/ui";import{useWallets as jN}from"@rango-dev/wallets-react";import{detectInstallLink as XN}from"@rango-dev/wallets-shared";import lo from"react";var wS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=jN(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(XN(n.installLink),"_blank"),"handleButtonClick");return lo.createElement(lo.Fragment,null,lo.createElement(VN,{type:"warning",title:vS.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:lo.createElement(ja,null,lo.createElement(GN,{src:n.img,size:45}),lo.createElement(Xa,null,lo.createElement(KN,{color:"warning",size:10})))}),lo.createElement(qN,{size:"40"}),lo.createElement(QN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},vS.t("Install")))},"InstallWalletContent");var bS=i(t=>{let{swap:e,onClose:o}=t,{state:n,getWalletInfo:r}=e0(),a=ZN(e),s=a?JN(e,a):null,c=s?.walletType,l=c?Jn(r(c),n(c)):null,p=a?YN(e,a):null;return c?l===RN.NOT_INSTALLED?ES.createElement(wS,{walletType:c}):ES.createElement(kS,{wallet:s,namespace:p,onClose:o}):null},"WalletStateContent");function wp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return Yr.createElement(R,{open:e,onClose:r,container:W()},o==="connectWallet"&&Yr.createElement(bS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&Yr.createElement(yS,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&Yr.createElement(hS,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&Yr.createElement(fS,{onClose:r,onCancel:()=>{r(),s()}}))}i(wp,"SwapDetailsModal");import{i18n as Zr}from"@lingui/core";import{Button as Ep,Divider as Jr,MessageBox as AS,TokenAmount as t0,Typography as NS}from"@rango-dev/ui";import ve from"react";import{Link as o0,useNavigate as n0}from"react-router-dom";var xS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",IS="/profile";function bp(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:c,token:l,chain:p,percentageChange:u,description:m,diagnosisUrl:f}=t,h=n0(),{showProfileBanner:g}=oe();return ve.createElement(R,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(rt.SWAP_BOX_ID)||document.body},n==="success"?ve.createElement(AS,{type:"success",title:Zr.t("Swap Successful")},ve.createElement(t0,{direction:"vertical",tooltipContainer:W(),id:"widget-swap-details-complete-modal-success-token-amount-container",type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:c},token:l,chain:p,percentageChange:u}),ve.createElement(Jr,{size:12}),ve.createElement(NS,{className:SS(),variant:"body",size:"medium",color:"neutral700",align:"center"},m)):ve.createElement(AS,{type:"error",title:Zr.t("Transaction Failed"),description:m}),ve.createElement(Jr,{size:30}),n==="success"&&ve.createElement(ve.Fragment,null,g&&ve.createElement(ve.Fragment,null,ve.createElement(o0,{to:IS},ve.createElement(CS,{src:xS,alt:"Profile Banner"})),ve.createElement(Jr,{size:30})),ve.createElement(Ep,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},Zr.t("Done"))),ve.createElement(Jr,{size:12}),f&&ve.createElement(ve.Fragment,null,ve.createElement(Ep,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},Zr.t("Diagnosis")),ve.createElement(Jr,{size:12})),ve.createElement(Ep,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},ve.createElement(NS,{variant:"title",size:"medium",color:"primary"},Zr.t("See Details"))))}i(bp,"SwapDetailsCompleteModal");import{i18n as Ra}from"@lingui/core";import{CopyIcon as g0,DoneIcon as h0,IconButton as y0,RangoExplorerIcon as S0,Tooltip as JS,Typography as RS,useCopyToClipboard as C0}from"@rango-dev/ui";import _t from"react";import f0 from"react";import{i18n as p0}from"@lingui/core";import{Alert as jS,IconButton as u0,LinkIcon as d0}from"@rango-dev/ui";import Ao,{Fragment as m0}from"react";import{Alert as i0,ChevronDownIcon as a0,IconButton as s0}from"@rango-dev/ui";import Hn,{useState as l0}from"react";import{css as Rr,darkTheme as WS,styled as Ht,Typography as r0}from"@rango-dev/ui";var PS=Ht(pe,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${WS} &`]:{color:"$secondary500"}}}}}),BS=Ht("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),LS=Ht("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),_S=Ht("div",{padding:"$0 $20 $20 $20"}),C7=Ht("div",{display:"flex",flexDirection:"column",gap:"$10"}),MS=Ht("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),T7=Ht("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),on=Rr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${WS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),DS=Rr({padding:"$5 0"}),Za=Rr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),$S=Rr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),FS=Rr({width:"100%",padding:"0 $20 $10"}),OS=Ht("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),US=Ht("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ja=Ht(r0,{wordBreak:"break-word"});import{styled as xp}from"@rango-dev/ui";var zS=xp("div",{display:"flex",flexDirection:"column",gap:"$10"}),HS=xp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),QS=xp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function qS(t){let{message:e}=t,[o,n]=l0(!1);return Hn.createElement(i0,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&Hn.createElement(s0,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},Hn.createElement(HS,{rotated:o},Hn.createElement(a0,{size:12,color:"gray"}))),footer:Hn.createElement(QS,{open:o},Hn.createElement(Ja,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(qS,"FailedAlert");import{i18n as GS}from"@lingui/core";import{Alert as Ip,Button as VS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as c0}from"rango-types";import ei from"react";function KS(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?ei.createElement(Ip,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:ei.createElement(VS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},GS.t("Change"))}):a===c0.WaitingForConnectingWallet?ei.createElement(Ip,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:ei.createElement(VS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},GS.t("Connect"))}):ei.createElement(Ip,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(KS,"WarningAlert");function Ap(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a,step:s,hasAlreadyProceededToSign:c}=t,l=hr(s),p=s.status==="waitingForApproval"&&!l,u=s.status==="running"&&!l,m=u&&!c||p&&!s.explorerUrl?.length;return Ao.createElement(zS,null,s.explorerUrl?.map((f,h,g)=>{let d=h+f.url,y=h===g.length-1,S=(y&&u||p)&&!m,C=y&&s.status==="failed";return Ao.createElement(m0,{key:d},Ao.createElement(jS,{id:"widget-swap-details-tx-alert",type:y&&(S&&"loading"||C&&"error")||"success",title:f.description?`${f.description} Tx`:p0.t("View transaction"),action:f.url&&Ao.createElement(u0,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Ao.createElement(d0,{size:12}))}))}),m&&Ao.createElement(jS,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Ao.createElement(KS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Ao.createElement(qS,{message:a}))}i(Ap,"SwapDetailsAlerts");var XS=2e3;var YS=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let c=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:vt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:D(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:vt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:D(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:jn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(l=>({from:{chain:{displayName:vt(l.fromBlockchain,e)??"",image:l.fromBlockchainLogo??""}},to:{chain:{displayName:vt(l.toBlockchain,e)??"",image:l.toBlockchainLogo??""}},swapper:{displayName:jn(l.swapperId,o)??"",image:l.swapperLogo??"",type:l.swapperType}})):[],alerts:f0.createElement(Ap,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function ZS(t){if(hr(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(ZS,"getStepState");function eC(t){let{requestId:e}=t,[o,n]=C0(XS);return _t.createElement(LS,{className:on()},_t.createElement(RS,{variant:"label",size:"large",color:"neutral700"},Ra.t("Request ID")),_t.createElement("div",{className:Za()},_t.createElement(RS,{variant:"label",size:"small",color:"neutral700"},e),_t.createElement(JS,{container:W(),content:o?Ra.t("Copied To Clipboard"):Ra.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},_t.createElement(y0,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?_t.createElement(h0,{size:16,color:"secondary"}):_t.createElement(g0,{size:16,color:"gray"}))),_t.createElement(OS,{target:"_blank",href:`${du}/swap/${e}`},_t.createElement(JS,{container:W(),content:Ra.t("View on Rango Explorer"),side:"bottom"},_t.createElement(S0,{size:20})))))}i(eC,"RequestIdRow");import{i18n as tC}from"@lingui/core";import{Typography as oC}from"@rango-dev/ui";import Np from"react";function nC(t){let{date:e,isFinished:o}=t;return Np.createElement("div",{className:on()},Np.createElement(oC,{variant:"label",size:"large",color:"neutral700"},o?tC.t("Finished at"):tC.t("Created at")),Np.createElement(oC,{variant:"label",size:"small",color:"neutral700"},e))}i(nC,"SwapDateRow");var A0=3e3;function Lp(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=x0(),l=T().blockchains(),p=T().swappers(),{findToken:u}=T(),m=G().use.retry(),f=I0(),h=Bp(null),[g,d]=es(!1),[y,S]=es(null),[C,k]=es(null),[E,w]=es(null),I=Bp(y),A=Bp(C),x=We.use.getNotifications(),b=We.use.removeNotification(),v=x(),N=k0(e),B=N?.networkStatus,_=i(Le=>{d(!0),S(Le)},"handleChangeModalState"),Q=i(()=>{d(!1)},"handleCloseModal"),V=i(()=>{k({type:"loading",title:Qt.t("Change Network"),description:`We\u2019re switching the connected network to ${X?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),Y=i(()=>{k({type:"success",title:Qt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),P=i(Le=>{k({type:"error",title:Qt.t("Network Switch Failed"),description:Le?.message||q.detailedMessage.content})},"handleShowSwitchNetworkFailed"),Z=um(e),X=N?T0(e,N):null,ie=N?v0(e,N):null,Te=dS(e),dt=dm(e),me=i(Le=>!!c(Le)?.mobileWallet,"checkIsMobileWallet"),Oe=!!B&&[Qn.WaitingForNetworkChange,Qn.NetworkChangeFailed].includes(B),Qe=!!ie?.walletType&&me(ie.walletType),kt=!!ie&&!!X&&a(ie.walletType,X.network,X),ot=!!X&&Oe&&(Qe||kt),Ee=i(()=>{ot&&(V(),s(ie.walletType,[{namespace:X.namespace,network:X.network}]).then(()=>{Y()}).catch(Le=>{P(Le)}))},"handleSwitchNetwork"),z=i(()=>{_("switchNetwork"),Ee()},"handleSwitchNetworkClick"),q=pm(e,N,c),$=YS({swap:e,switchNetworkIsAvailable:ot,handleSwitchNetworkClick:z,showNetworkModal:B,setNetworkModal:_,message:q,blockchains:l,swappers:p}),M=$.length,[ce,H]=[e.steps[0],e.steps[M-1]],ae=H?.outputAmount||H?.expectedOutputAmountHumanReadable,qe=e.steps.reduce((Le,Mt)=>Le+parseFloat(Mt.feeInUsd||""),0),nt=e.steps.find(Le=>Le.diagnosisUrl)?.diagnosisUrl,co=D(parseFloat(ae||"0")*(H?.toUsdPrice||0),4,4),Vn=D(parseFloat(e.inputAmount)*(ce?.fromUsdPrice||0),4,4),No=ae?new iC(ae).multipliedBy(H.toUsdPrice||0).toString():"",ni=new iC(e.inputAmount).multipliedBy(ce?.fromUsdPrice||0).toString(),rn=Yt(Vn,co),us=q.detailedMessage.content||q.shortMessage,FC=e.status==="success"?Qt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:D(ae,6,6),token:$[M-1]?.to.token.displayName,conciseAddress:po(e.wallets[$[M-1]?.to.chain.displayName||""]?.address||""),chain:$[M-1]?.to.chain.displayName}}):we.createElement(US,null,we.createElement(Wp,{variant:"body",size:"medium",color:"neutral700",align:"center"},us?"":Qt.t("Transaction was not sent."),Z?`${Qt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:Z.outputAmount,symbol:Z.symbol,blockchain:Z.blockchain}})}`:""),us&&we.createElement(Ja,{align:"center",variant:"body",size:"medium",color:"neutral700"},we.createElement("b",null,"Reason:")," ",us));return Pp(()=>{v.find(Mt=>Mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),b(e.requestId),Q()):E&&w(null))},[e.status,e.requestId]),Pp(()=>{if(ot){if(_("switchNetwork"),B===Qn.WaitingForNetworkChange){V();return}if(B===Qn.NetworkChangeFailed){P();return}return}if(B===Qn.WaitingForConnectingWallet){_("connectWallet");return}if(B===Qn.NetworkChanged){_("switchNetwork"),Y();return}y&&["connectWallet","switchNetwork"].includes(y)&&Q()},[B]),Pp(()=>{if(I.current=y,A.current=C,y==="switchNetwork"&&C?.type==="success"){let Le=setTimeout(()=>{I.current==="switchNetwork"&&A.current?.type==="success"&&Q()},A0);return()=>clearTimeout(Le)}},[y,C]),we.createElement(se,{header:{title:Qt.t("Swap Details"),onCancel:e.status==="running"?()=>_("cancel"):void 0,suffix:e.status!=="running"&&we.createElement(ho,null,we.createElement(rC,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>_("delete")},we.createElement(Wp,{size:"medium",variant:"label",color:"error"},Qt.t("Delete"))))},footer:dt&&!E&&we.createElement(rC,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{ee({type:"swapRetried",payload:{routeId:e.requestId}});let Le=Di(e,l,u);m(Le),setTimeout(()=>{f("../../")},0)}},Qt.t("Try again"))},we.createElement(PS,{compact:!0,ref:h},we.createElement(eC,{requestId:o}),we.createElement(nC,{date:Te,isFinished:!!e.finishTime}),we.createElement("div",{className:$S()},we.createElement(E0,{fee:D(String(qe),2,2),time:Yn(di(e.steps)),steps:M}),we.createElement(br,{from:{price:{value:D(e.inputAmount,6,6),usdValue:Vn,realUsdValue:ni,realValue:e.inputAmount},token:{displayName:$[0]?.from.token.displayName||"",image:$[0]?.from.token.image},chain:{image:$[0]?.from.chain.image,displayName:$[0]?.from.chain.displayName||""}},to:{price:{value:D(ae,6,6),usdValue:co,realUsdValue:No,realValue:ae||""},token:{displayName:$[M-1]?.to.token.displayName||"",image:$[M-1]?.to.token.image},chain:{image:$[M-1]?.to.chain.image,displayName:$[M-1]?.to.chain.displayName||""}},percentageChange:D(rn,2,2),warningLevel:Zt(rn??0)})),we.createElement("div",{className:FS()},we.createElement(Wp,{variant:"title",size:"small"},Qt.t("Swaps steps"))),we.createElement(w0,{size:8}),we.createElement(_S,null,$.map((Le,Mt)=>{let Vp=Mt,Kn=e.steps[Mt]&&ZS(e.steps[Mt]),OC=Kn==="error"||Kn==="in-progress"||Kn==="warning"||Kn==="completed"&&Mt===$.length-1;return we.createElement(b0,{className:"widget-swap-details-step-item-container",key:Vp,step:Le,type:"swap-progress",ref:h,state:Kn,hasSeparator:Mt!==0,tabIndex:Vp,isFocused:OC,tooltipContainer:W()})}))),we.createElement(wp,{isOpen:g,state:y,switchNetworkModalState:C,onClose:Q,onCancel:r,onDelete:n,message:q.detailedMessage.content,swap:e,handleSwitchNetwork:z}),we.createElement(bp,{open:!!E,diagnosisUrl:nt,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:D(ae,6,6),usdValue:co,realUsdValue:No,realValue:ae||"",percentageChange:D(rn,2,2),token:{displayName:$[M-1]?.to.token.displayName||"",image:$[M-1]?.to.token.image},chain:{image:$[M-1]?.to.chain.image},description:FC}))}i(Lp,"SwapDetails");import{i18n as os}from"@lingui/core";import{Divider as lC,NotFound as L0,Skeleton as oi,Typography as ns}from"@rango-dev/ui";import Ae from"react";import{i18n as N0}from"@lingui/core";import{Divider as W0,Skeleton as P0,Typography as B0}from"@rango-dev/ui";import Ie from"react";import{css as qt,styled as _p}from"@rango-dev/ui";var aC=_p("div",{width:"100%",height:"100%",padding:"$10 $20"}),ti=_p("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),ts=_p("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),X9=qt({display:"flex",justifyContent:"space-between",alignItems:"center"}),Y9=qt({paddingTop:"$15",display:"flex"}),Z9=qt({padding:"$15 $0"}),J9=qt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),R9=qt({paddingBottom:"$10"}),eZ=qt({display:"flex",justifyContent:"start",alignItems:"center"}),tZ=qt({paddingTop:"$5",display:"flex",alignItems:"center"}),oZ=qt({display:"flex",alignItems:"center"}),nZ=qt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),sC=qt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Mp(){return Ie.createElement(aC,null,Ie.createElement(Ar,{type:"swap-preview"}),Ie.createElement("div",{className:"swaps-steps"},Ie.createElement(B0,{variant:"title",size:"small"},N0.t("Swaps steps"))),Ie.createElement(Ie.Fragment,null,Ie.createElement(ti,null,Ie.createElement(Ut,{separator:!1}),Ie.createElement("div",{className:sC()},Ie.createElement(W0,{direction:"horizontal",size:20}),Ie.createElement(P0,{height:22,variant:"rectangular"}))),Ie.createElement(ts,null),Ie.createElement(ti,null,Ie.createElement(Ut,{separator:!1})),Ie.createElement(ts,null),Ie.createElement(ti,null,Ie.createElement(Ut,{separator:!1})),Ie.createElement(ts,null),Ie.createElement(ti,null,Ie.createElement(Ut,{separator:!1}))))}i(Mp,"LoadingSwapDetails");function cC(t){let{requestId:e,showSkeleton:o}=t;return Ae.createElement(se,{header:{title:os.t("Swap Details"),suffix:Ae.createElement(ho,null)}},o&&Ae.createElement(BS,null,Ae.createElement("div",{className:on()},Ae.createElement(ns,{variant:"label",size:"large",color:"neutral700"},`${os.t("Request ID")}`),Ae.createElement("div",{className:Za()},Ae.createElement(ns,{variant:"label",size:"small",color:"neutral700"},Ae.createElement(oi,{width:60,height:10,variant:"rounded"})),Ae.createElement(lC,{direction:"horizontal",size:4}),Ae.createElement(oi,{width:16,height:16,variant:"rectangular"}),Ae.createElement(lC,{direction:"horizontal",size:4}),Ae.createElement(oi,{width:16,height:16,variant:"rectangular"}))),Ae.createElement("div",{className:on()},Ae.createElement(ns,{className:DS(),variant:"label",size:"large",color:"neutral700"},Ae.createElement(oi,{width:60,height:10,variant:"rounded"})),Ae.createElement(ns,{variant:"label",size:"small",color:"neutral700"},Ae.createElement(oi,{width:60,height:10,variant:"rounded"}))),Ae.createElement(Mp,null)),!o&&Ae.createElement(MS,null,Ae.createElement(L0,{title:os.t("Not found"),description:os.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(cC,"SwapDetailsPlaceholder");function pC(){let{manager:t,state:e}=D0(),o=!e.loadedFromPersistor,n=bt(t),{requestId:r}=F0(),a=Ke(),{fetchStatus:s}=T();if(!r)return Dp.createElement($0,{containerStyles:{margin:"20px"},type:"error",title:_0.t("The request ID is necessary to display the swap details.")});let c=o||s==="loading",l=r?n.find(({swap:f})=>f.requestId===r):void 0,p=i(()=>{if(l?.id){let f=t?.get(l.id);f&&(ee({type:"swapCancelled",payload:{routeId:r}}),M0(f))}},"onCancel"),u=i(async()=>{if(l?.id)try{t?.deleteQueue(l.id),a()}catch(f){console.log(f)}},"onDelete"),m=l?.swap;return!m||c?Dp.createElement(cC,{requestId:r,showSkeleton:c}):Dp.createElement(Lp,{swap:m,requestId:r,onCancel:p,onDelete:u})}i(pC,"SwapDetailsPage");import{i18n as uC}from"@lingui/core";import{Divider as O0,getCategoriesCount as U0,SelectableCategoryList as z0,styled as mC,Typography as H0,Wallet as Q0}from"@rango-dev/ui";import Gt,{useState as dC}from"react";var q0=mC("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),G0=mC(pe,{textAlign:"center"});function fC(){let{fetchStatus:t}=T(),[e,o]=dC("ALL"),n=T().blockchains(),{config:r}=T(),[a,s]=dC(),c=oe.use.isActiveTab(),{list:l}=It(),p=zu(l,n),m=U0(p)!==1,f=Hu(l,e),h=i(g=>{ku(l,r.multiWallets)||s(g)},"handleWalletItemClick");return Gt.createElement(se,{header:{title:uC.t("Connect Wallets")}},Gt.createElement(G0,null,m&&Gt.createElement(Gt.Fragment,null,Gt.createElement(z0,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Gt.createElement(O0,{size:24})),Gt.createElement(H0,{variant:"title",size:"xmedium",align:"center"},uC.t("Choose a wallet to connect.")),Gt.createElement(q0,null,f.map((g,d)=>{let y=`wallet-${d}-${g.type}`;return Gt.createElement(Q0,{key:y,...g,state:g.state,container:W(),onClick:()=>h(g),isLoading:t==="loading",disabled:!c})}),Gt.createElement(fr,{id:"widget-state-full-connect-modal",wallet:a,onClose:()=>{s(void 0)}}))))}i(fC,"WalletsPage");function gC(){return wm(),al(),V0([{path:O.home,element:He.createElement(Py,null)},{path:O.routes,element:He.createElement(Dy,null)},{path:O.fromSwap,children:[{index:!0,element:He.createElement(Qa,{type:"source"})},{path:O.blockchains,element:He.createElement(Oa,{type:"source"})}]},{path:O.toSwap,children:[{index:!0,element:He.createElement(Qa,{type:"destination"})},{path:O.blockchains,element:He.createElement(Oa,{type:"destination"})}]},{path:O.settings,children:[{index:!0,element:He.createElement(pS,null)},{path:O.languages,element:He.createElement(Ly,null)},{path:O.exchanges,element:He.createElement(ap,{sourceType:"Exchanges"})},{path:O.bridges,element:He.createElement(ap,{sourceType:"Bridges"})},{path:O.customTokens,children:[{index:!0,element:He.createElement(Lh,null)},{path:O.addCustomTokens,children:[{index:!0,element:He.createElement(vf,null)},{path:O.blockchains,element:He.createElement(Oa,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:O.swaps,children:[{index:!0,element:He.createElement(Rh,null)},{path:O.swapDetails,element:He.createElement(pC,null)}]},{path:O.wallets,element:He.createElement(fC,null)},{path:O.confirmSwap,element:He.createElement(yh,null)}])}i(gC,"AppRoutes");import{useQueueManager as uW}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as dW}from"rango-sdk";import{useContext as mW,useEffect as Up,useState as IC}from"react";import{Provider as J0}from"@rango-dev/wallets-react";import{WalletTypes as R0}from"@rango-dev/wallets-shared";import rs,{createContext as eW,useEffect as TC,useMemo as tW,useRef as kC}from"react";import{useEffect as j0}from"react";import{Provider as K0}from"@rango-dev/wallets-core";function hC(t){return t.map(e=>typeof e=="string"?e:e instanceof K0?e.id:e.config.type).join("-")}i(hC,"hashProviders");function $p(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=T(),a=n();return j0(()=>{o(),r()},[hC(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i($p,"useWalletProviders");import{legacyFormatAddressWithNetwork as X0,legacyReadAccountAddress as yC}from"@rango-dev/wallets-core/legacy";import{Events as qn}from"@rango-dev/wallets-react";import{isEvmBlockchain as Y0}from"rango-sdk";function SC(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=T(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(Y0).map(d=>d.name),u=i((d,y)=>{let[S,,C,k,E]=d,w={walletType:S,network:k.network??void 0,accounts:C};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?");let I=ks(S,C,p,y.supportedChainNames,E.isContractWallet);I.length&&e(I,E.namespace,k.derivationPath,{walletName:S})},"onAccountsEvent"),m=i((d,y,S,C,k)=>{if(y===qn.ACCOUNTS){let E=Rn(k.supportedBlockchains);S&&u([d,y,S,C,k],{supportedChainNames:E})}y===qn.PROVIDER_DISCONNECTED&&(o(d),l.current?l.current(d):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),y===qn.NAMESPACE_DISCONNECTED&&n(d,S)},"handleUpdatesForHub"),f=i((d,y,S,C,k)=>{if(y===qn.ACCOUNTS){let E=Rn(k.supportedBlockchains),w=[],I=[];if(S?.forEach(x=>{let{network:b}=yC(x);p.includes(b)?w.push(x):I.push(x)}),r.filter(x=>x.walletType===d).map(x=>X0(x.address,x.chain)).length>0){if(w.length>0){let x=ks(d,w,p,E,k.isContractWallet);a(d,{chains:x.map(b=>b.chain)})}I.length>0&&a(d,{chains:I.map(x=>{let{network:b}=yC(x);return b})})}S?u([d,y,S,C,k],{supportedChainNames:E}):(o(d),l.current?l.current(d):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((d,y,S,C,k)=>{if(y===qn.CONNECTED&&S){let E={walletType:d,network:C.network??void 0,accounts:C.accounts??void 0};c.current?c.current(E):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(y===qn.NETWORK&&S){let E={walletType:d,network:S,accounts:C.accounts??void 0};c.current?c.current(E):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((d,y,S,C,k)=>{k.isHub?m(d,y,S,C,k):f(d,y,S,C,k),h(d,y,S,C,k)},"handler")}}i(SC,"useUpdates");import{LegacyEvents as Z0}from"@rango-dev/wallets-core/legacy";function CC(t,e){let[o,n,r,a,s]=e;n!==Z0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(CC,"propagateEvents");var is=eW({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function oW(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=T(),a=T().blockchains(),s=T().config,c={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:l}=$p(s.wallets,c),p=kC(),u=kC(),{handler:m}=SC({onConnectWalletHandler:p,onDisconnectWalletHandler:u});TC(()=>{n().catch(console.log)},[]),TC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=oe.use.isActiveTab(),h=tW(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return rs.createElement(is.Provider,{value:h},rs.createElement(J0,{allBlockChains:a,providers:l,onUpdateState:(g,d,y,S,C)=>{let k=[g,d,y,S,C];m(...k),t.onUpdateState&&CC(t.onUpdateState,k)},autoConnect:!!f,configs:{wallets:s.wallets,walletOptions:{[R0.TON_CONNECT]:{provider:{manifestUrl:s.tonConnect?.manifestUrl}}}}},t.children))}i(oW,"Main");function as(t){let{config:e,...o}=t;return rs.createElement(pd,{config:e},rs.createElement(oW,{...o,config:e}))}i(as,"WidgetWallets");import{globalCss as nW}from"@rango-dev/ui";var vC=i(()=>nW({"@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");import{useWallets as rW}from"@rango-dev/wallets-react";import{useEffect as iW,useRef as aW}from"react";function wC(){let{connect:t,state:e}=rW(),o=aW({}),{fetchStatus:n}=T(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);iW(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(wC,"useForceAutoConnect");import{isApprovalTX as sW,RouteEventType as EC,StepEventType as bC,StepExecutionEventStatus as lW,WidgetEvents as ss}from"@rango-dev/queue-manager-rango-preset";import{useEffect as xC}from"react";function Fp(){let t=We.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=T();xC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===bC.TX_EXECUTION&&s.status===lW.TX_SENT&&!sW(c)||s.type===bC.SUCCEEDED){let u=[],m=l.wallets[c?.fromBlockchain];if(m){let f=e.find(h=>h.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&h.walletType===m.walletType&&h.chain===c?.fromBlockchain);f&&u.push(f)}if(c?.fromBlockchain!==c?.toBlockchain){let f=l.wallets[c?.toBlockchain];if(f){let h=e.find(g=>g.address?.toLocaleLowerCase()===f.address?.toLocaleLowerCase()&&g.walletType===f.walletType&&g.chain===c?.toBlockchain);h&&u.push(h)}}if(u.length>0){let f=n(),g=[{blockchain:c.fromBlockchain,address:c.fromSymbolAddress,symbol:c.fromSymbol},{blockchain:c.toBlockchain,address:c.toSymbolAddress,symbol:c.toSymbol}].filter(d=>f.some(y=>y.blockchain===d.blockchain&&y.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&y.symbol?.toLocaleLowerCase()===d.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return de.on(ss.StepEvent,r),()=>de.off(ss.StepEvent,r)},[de,e]),xC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===EC.FAILED||s.type===EC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return de.on(ss.RouteEvent,r),()=>de.off(ss.RouteEvent,r)},[de])}i(Fp,"useSubscribeToWidgetEvents");import{useManager as cW}from"@rango-dev/queue-manager-react";import{useEffect as pW}from"react";function Op(){let{isSynced:t,syncNotifications:e}=We(),{manager:o,state:n}=cW();pW(()=>{if(We.persist.hasHydrated()&&n.loadedFromPersistor&&!t){let a=bt(o);e(a),a.forEach(({swap:s})=>{if(!(s.status==="running"&&s.steps.length>1))return;let l=s.steps.findIndex(p=>p.status!=="success");ee({type:"swapResumed",payload:{routeId:s.requestId,stepCount:s.steps.length,stepNumber:l===-1?s.steps.length:l+1}})})}},[We.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Op,"useSyncNotifications");function zp(){wC(),vC(),Fp(),Op();let t=T().blockchains(),{canSwitchNetworkTo:e}=ra(),[o,n]=IC(null),[r,a]=IC(),s=mW(is),c=t.filter(dW);Up(()=>()=>km(),[]),Up(()=>()=>vm(),[]),uW({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Up(()=>(Fo.init(),We.persist.hasHydrated()||We.persist.rehydrate(),s.onConnectWallet(l=>{n(p=>{if(!p||p.walletType!==l.walletType)return l;let u={...p};return l.network&&(u.network=l.network),l.accounts&&(u.accounts=l.accounts),u})}),s.onDisconnectWallet(l=>{a(l),n(p=>l===p?.walletType?null:p)}),Fo.destroy),[])}i(zp,"useBootstrap");import{styled as fW}from"@rango-dev/ui";var AC=fW("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left",height:"100%","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function nn(){zp();let{config:t}=T(),{activeTheme:e}=go(t?.theme||{}),{activeLanguage:o}=Eo();return Hp.createElement(gW,{language:o},Hp.createElement(AC,{id:"swap-container",className:e()},Hp.createElement(gC,null)))}i(nn,"Main");import{setSolanaSignerConfig as MW}from"@rango-dev/signer-solana";import qp,{useEffect as Gp,useMemo as DW}from"react";function NC(){let{setWatermark:t,setShowProfileBanner:e}=oe();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Kt("BASE_URL")}/meta/dapp/config?apiKey=${Kt("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(NC,"useFetchApiConfig");import{useState as hW}from"react";var yW=i(()=>{let[t,e]=hW(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=Tu(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),WC=yW;import{checkWaitingForNetworkChange as SW,makeQueueDefinition as CW}from"@rango-dev/queue-manager-rango-preset";import{Provider as TW}from"@rango-dev/queue-manager-react";import{useWallets as kW}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as vW}from"@rango-dev/wallets-shared";import{isEvmBlockchain as wW}from"rango-types";import EW,{useMemo as bW}from"react";function xW(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s,hubProvider:c}=kW(),l=bW(()=>CW({API_KEY:t.apiKey||Kt("API_KEY"),BASE_URL:Kt("BASE_URL"),emitter:{emit:de.emit}}),[t.apiKey]),{blockchains:p,connectedWallets:u}=T(),m=p(),f={blockchains:u.map(w=>({accounts:[w],name:w.chain}))},h=i(async(w,I)=>a(w,I.network,I)?await r(w,[I]):void 0,"switchNetwork"),g=i(w=>!!s(w).mobileWallet,"isMobileWallet"),d=m.filter(w=>w.enabled).reduce((w,I)=>(w[I.name]=I,w),{}),y=m.filter(wW),S=i(w=>{let{supportedChains:I}=s(w);return Rn(I)},"getSupportedChainNames"),C=e(),k={meta:{blockchains:d,evmBasedChains:y,evmNetworkChainInfo:vW(y),getSupportedChainNames:S},getSigners:o,wallets:f,providers:C,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g,hubProvider:c},E=oe.use.isActiveTab();return EW.createElement(TW,{queuesDefs:[l],context:k,onPersistedDataLoaded:w=>{SW(w)},isPaused:!E},t.children)}i(xW,"QueueManager");var PC=xW;import{useManager as PW}from"@rango-dev/queue-manager-react";import BW,{createContext as LW,useContext as _W}from"react";function BC(){let{findToken:t}=T(),e=T().blockchains(),o=T().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:c}=G()();return i(p=>{let{fromBlockchain:u,fromToken:m,toBlockchain:f,toToken:h,requestAmount:g}=p,d={blockchains:e,tokens:o};if(u!==void 0){let y=e.find(S=>S.name===u)??null;n(y)}if(m!==void 0){let y=m?t(m)??null:null;r({meta:d,token:y})}if(f!==void 0){let y=e.find(S=>S.name===f)??null;a(y)}if(h!==void 0){let y=h?t(h)??null:null;s({meta:d,token:y})}g!==void 0&&c(g)},"updateQuoteInputs")}i(BC,"useUpdateQuoteInputs");import{cancelSwap as IW,getCurrentNamespaceOfOrNull as AW,getCurrentStep as NW,getRelatedWalletOrNull as WW}from"@rango-dev/queue-manager-rango-preset";var ls=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return bt(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=Di(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&IW(o)}getCurrentStepInfo(e){let o=NW(e);return{step:o,wallet:o?WW(e,o):null,network:o?AW(e,o)?.network:null}}};var LC=LW(void 0);function Qp(t){let{manager:e}=PW(),o=oe.use.isActiveTab(),n=G().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=T(),l=new ls(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=T(),u=Du(a()),m=T().blockchains(),f=T().tokens(),h=T().swappers(),g=T().fetchStatus,d=Eo().resetLanguage,y=We().getNotifications(),S=We().clearNotifications,C=BC(),{fromBlockchain:k,toBlockchain:E,fromToken:w,toToken:I,inputAmount:A}=G()(),x={isActiveTab:o,setCurrentTabAsActive:Fo.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async b=>c(b)},meta:{blockchains:m,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:d,notifications:{list:y,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:E?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:A},updateQuoteInputs:C}};return BW.createElement(LC.Provider,{value:x},t.children)}i(Qp,"WidgetInfo");function _C(){let t=_W(LC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(_C,"useWidget");function Gn(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=NC(),{handleLoadCustomFont:a}=WC();return Gp(()=>{r().catch(console.log)},[]),Gp(()=>{n&&a(n)},[n]),DW(()=>{Qu({API_KEY:o?.apiKey||lu(),BASE_URL:o?.apiUrl||uu})},[o.apiKey,o.apiUrl]),Gp(()=>{t.config?.signers?.customSolanaRPC&&MW("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),qp.createElement(as,{config:o,onUpdateState:e},qp.createElement(PC,{apiKey:o.apiKey},qp.createElement(Qp,null,t.children)))}i(Gn,"WidgetProvider");function MC(t){let e=t.config?.externalWallets;return cs.createElement(_i,null,e?cs.createElement(nn,null):cs.createElement(Gn,{config:t.config??ln},cs.createElement(nn,null)))}i(MC,"Refuel");import ps from"react";function DC(t){let e=t.config?.externalWallets;return console.log("Widget props",t),ps.createElement(_i,null,e?ps.createElement(nn,null):ps.createElement(Gn,{config:t.config??ln},ps.createElement(nn,null)))}i(DC,"Widget");function $C(){let{on:t,off:e}=de;return{on:t,off:e}}i($C,"useWidgetEvents");var roe={DerivationPath:ur,Namespaces:lr,Detached:pr,isOnDerivationPath:mr,isOnNamespace:dr,isOnDetached:Wo};export{Ite as EventSeverity,dn as MainEvents,$te as Networks,Ute as PendingSwapNetworkStatus,or as QuoteEventTypes,MC as Refuel,Ate as RouteEventType,hs as SUPPORTED_FONTS,roe as StatefulConnect,Nte as StepEventType,Wte as StepExecutionBlockedEventStatus,Pte as StepExecutionEventStatus,$d as SwapModeContext,rt as UI_ID,Re as UiEventTypes,vi as WalletEventTypes,Mte as WalletEvents,Fte as WalletTypes,DC as Widget,dn as WidgetEvents,Gn as WidgetProvider,as as WidgetWallets,Tl as customizedThemeTokens,fs as pickProviderVersionWithFallbackToLegacy,Lte as readAccountAddress,an as useStatefulConnect,It as useWalletList,ra as useWallets,_C as useWidget,$C as useWidgetEvents,QT as widgetEventEmitter};
1
+ var HC=Object.defineProperty;var i=(t,e)=>HC(t,"name",{value:e,configurable:!0});import{EventSeverity as Nte,RouteEventType as Wte,StepEventType as Pte,StepExecutionBlockedEventStatus as Bte,StepExecutionEventStatus as Lte}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Mte}from"@rango-dev/wallets-core/legacy";import{useWallets as ra,Events as $te}from"@rango-dev/wallets-react";import{Networks as Ote,WalletTypes as Ute}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Hte}from"rango-types";import{Divider as lv}from"@rango-dev/ui";import mo,{useEffect as cv,useRef as pv,useState as $d}from"react";import{WalletState as QC}from"@rango-dev/ui";import{useWallets as qC}from"@rango-dev/wallets-react";import{useReducer as GC}from"react";function Kp(t){return!!t.derivationPath}i(Kp,"isStateOnDerivationPathStep");function jp(t){return!!t.namespace}i(jp,"isStateOnNamespace");var ri={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function Xp(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"detached":return{...t,status:"detached",namespace:{targetWallet:e.payload.targetWallet},selectedNamespaces:e.payload.selectedNamespaces};case"reset":return ri;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ri;default:throw new Error("Action hasn't been defined.")}}i(Xp,"reducer");function sn(){let{state:t,disconnect:e,connect:o}=qC(),[n,r]=GC(Xp,ri),a=i(async(m,f,h)=>{r({type:"reset"});try{let g=f?.map(d=>({...d,network:void 0}));return await o(m.type,g),{status:"connected"}}catch(g){let d=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";if(h?.disconnectOnError)try{await u(m)}catch{console.warn("An error happened during disconnecting wallet after error on connecting.")}throw new Error(d,{cause:g})}},"runConnect"),s=i(async(m,f)=>{let h=m.state===QC.DISCONNECTED,g=f?.forceConnectToNamespaces;if(h){let d=!!m.isHub,y=d?m.properties?.find(C=>C.name==="namespaces")?.value:m.needsNamespace,S=d?m.properties?.find(C=>C.name==="derivationPath")?.value:m.needsDerivationPath;if(g){let C=g.find(k=>!y?.data?.map(E=>E.value).includes(k));if(C)throw new Error(`One of the forced namespaces is not available in the wallet. Forced namespace: ${C}`);if(g.length>1&&S)throw new Error("Derivation path is not supported when multiple namespaces are selected.");return g.length===1&&g[0]&&S?(r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:g[0]}}),{status:"derivation-path"}):await a(m,g.map(k=>({namespace:k})),{...f,disconnectOnError:!0})}if(!y?.data?.length)return await a(m,void 0,f);if(y?.data.length&&y.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:m,defaultSelectedChains:f?.defaultSelectedChains}}),{status:"namespace"};if(y?.data.length===1&&y.data[0]){if(S){let C=y.data[0];return r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:C.value}}),{status:"derivation-path"}}return await a(m,y?.data?.map(C=>({namespace:C.value})),f)}}if(m.isHub&&!f?.forceConnectToNamespaces){let d=m.properties?.find(y=>y.name==="namespaces")?.value;if(d?.data.length&&d.data.length>1)return r({type:"detached",payload:{targetWallet:m,selectedNamespaces:null}}),{status:"Detached"}}return f?.disconnectIfConnected?(await u(m),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),c=i(async(m,f)=>{let h=!!m.isHub,g=h?m.properties?.find(k=>k.name==="namespaces")?.value:m.needsNamespace,d=h?m.properties?.find(k=>k.name==="derivationPath")?.value:m.needsDerivationPath,y=g?.selection==="single",S=f[0];if(!S)throw new Error("To confirm a namespace, you should select at least one namespace.");if(y&&d)return r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:S}}),{status:"derivation-path"};if(!jp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let C=f.map(k=>({namespace:k}));return r({type:"detached",payload:{targetWallet:m,selectedNamespaces:C??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(m,f,h)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!Kp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=[{namespace:n.derivationPath.namespace,derivationPath:f}],S=!!m.isHub?m.properties?.find(E=>E.name==="namespaces")?.value:m.needsNamespace,C=!!S?.data&&S.data.length>1,k=!!h?.forceConnectToNamespaces;return C&&!k?(r({type:"detached",payload:{targetWallet:m,selectedNamespaces:d??null,derivationPath:f}}),{status:"Detached"}):await a(m,d)},"handleDerivationPath"),p=i(()=>n,"getState"),u=i(async m=>{let f=t(m.type);return f.connected||f.connecting?(await e(m.type),Wo(p)?(r({type:"needsNamespace",payload:{targetWallet:m}}),{status:"namespace"}):{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:c,handleDerivationPath:l,getState:p,resetState:m=>{r(m==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(sn,"useStatefulConnect");import{WalletState as rr}from"@rango-dev/ui";import{useWallets as ok}from"@rango-dev/wallets-react";import{detectMobileScreens as nk,KEPLR_COMPATIBLE_WALLETS as rk,WalletTypes as ir}from"@rango-dev/wallets-shared";import{useCallback as ik,useEffect as _s}from"react";import ZT,{createContext as JT,useContext as RT,useEffect as ek,useRef as tk}from"react";import{create as XT}from"zustand";import{persist as YT}from"zustand/middleware";import{allProviders as VC}from"@rango-dev/provider-all";var ds=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()}},ln=new ds;import{defineVersions as Zp,pickVersion as Jp,Provider as ms}from"@rango-dev/wallets-core";function Rp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=fs(a);return s instanceof ms?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 ms?o.push(Zp().version("1.0.0",n).build()):o.push(Zp().version("0.0.0",n).build())}),o}return t}i(Rp,"matchAndGenerateProviders");function fs(t){try{return Jp(t,"1.0.0")[1]}catch{return Jp(t,"0.0.0")[1]}}i(fs,"pickProviderVersionWithFallbackToLegacy");function eu(t){return t.map(o=>fs(o)).map(o=>o instanceof ms?o.id:o.config.type)}i(eu,"configWalletsToWalletName");function ii(t,e){return e.find(o=>o.name===t)?.displayName}i(ii,"getBlockchainDisplayNameFor");function vt(t,e){return e.find(o=>o.name===t)?.shortName}i(vt,"getBlockchainShortNameFor");function tu(t,e){return e.find(o=>o.name===t)?.logo}i(tu,"getBlockchainImage");function jn(t,e){return e.find(o=>o.id===t)?.title}i(jn,"getSwapperDisplayName");function Po(t,e){return e.find(o=>o.name===t)??null}i(Po,"findBlockchain");function gs(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(gs,"isTokenNative");function wt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(wt,"createTokenHash");function Bo(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Bo,"isValidTokenAddress");function Xn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(c=>{c.forEach(l=>{typeof l!="string"&&(l=wt(l));let p=o.tokensMapByTokenHash.get(l);p&&(n[l]=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 c=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(l=>{let p=o.tokensMapByBlockchainName[l];!c.has(l)&&p&&a(p)})}return s.forEach(c=>{let l=r[c];if(!l&&o.tokensMapByBlockchainName?.[c]){a(o.tokensMapByBlockchainName[c]);return}l&&(l.isExcluded&&o.tokensMapByBlockchainName[c]?(a(o.tokensMapByBlockchainName[c]),l.tokens.forEach(p=>{let u=wt(p);delete n[u]})):a(l.tokens))}),Object.values(n)}i(Xn,"matchTokensFromConfigWithMeta");function ai(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(ai,"getSupportedBlockchainsFromConfig");function nu(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(nu,"makeProvidersOptionsFromConfig");var cn={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/assets/refs/heads/main/manifests/tonconnect/manifest.json"}},KC={clientUrl:void 0},jC={liquiditySources:void 0};function ou(t){let e=nu(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 VC(o).map(a=>a())}i(ou,"generateProviders");var ru=i((t,e,o)=>{let n=ou({...cn,...t});return{config:{...cn,...t},iframe:KC,campaignMode:jC,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:c}=o(),l=Xn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}}),p=Xn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}});ln.set("supportedSourceTokens",l),ln.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=ou(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=nu(a);return Rp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as iu}from"rango-types";var au=[iu.EVM,iu.SOLANA],si="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as pT}from"rango-sdk";function su(){return process.env.REACT_APP_RANGO_API_KEY}i(su,"getApiKeyFromEnv");function lu(){let t=su();if(t)return t;throw new Error("Ensure you have set REACT_APP_RANGO_API_KEY in your env variables.")}i(lu,"getApiKeyFromEnvOrThrow");function cu(){return su()||"NOT_SET"}i(cu,"getApiKeyFromEnvOrNotSet");import{BlockchainCategories as oT,WalletState as ft}from"@rango-dev/ui";import{legacyReadAccountAddress as nT}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as rT,getCosmosExperimentalChainInfo as iT,isEvmAddress as aT,KEPLR_COMPATIBLE_WALLETS as RP,Networks as _u}from"@rango-dev/wallets-shared";import un from"bignumber.js";import{isCosmosBlockchain as sT}from"rango-types";import XC from"bignumber.js";var ue=new XC(0);import{WalletTypes as YC}from"@rango-dev/wallets-shared";var Lo="~",pu=[YC.LEAP];import{BlockchainCategories as ys,WalletState as tT}from"@rango-dev/ui";import{TransactionType as li}from"rango-sdk";import{UI_ID as ZC}from"@rango-dev/ui";var uu="https://api.rango.exchange",du="https://explorer.rango.exchange",rt={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...ZC};var mu="Roboto",hs=[{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 pn(t){return Array.from(new Set(t))}i(pn,"removeDuplicateFrom");function ci(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ci,"debounce");function mt(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(mt,"containsText");function hu(t,e){return t.toLowerCase()===e.toLowerCase()}i(hu,"exactText");function yu(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(yu,"startWithText");var W=i(()=>document.getElementById(rt.SWAP_BOX_ID),"getContainer"),_o=i(()=>document.getElementById(rt.EXPANDED_BOX_ID),"getExpanded");function Su(t,e,o){let n=!!e&&hu(e,t),r=!!o&&hu(o,t);return n!==r?n?-1:1:0}i(Su,"compareExactMatchText");function Ss(t,e,o){let n=!!e&&mt(e,t),r=!!o&&mt(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(Ss,"compareContainsText");function Cs(t,e,o){let n=!!e&&yu(e,t),r=!!o&&yu(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(Cs,"compareStartWithText");function Cu(t,e,o){if(!o)return 0;let n=Su(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Su(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=Cs(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=Ss(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=Cs(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=Ss(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=Cs(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=Ss(o,t.address,e.address);if(r!==0)return r}return 0}i(Cu,"compareWithSearchFor");var pi=i((t,e)=>{switch(e){case ys.ALL:return!0;case ys.UTXO:return t===li.TRANSFER;case ys.OTHER:return t!==li.TRANSFER&&t!==li.COSMOS&&t!==li.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Tu=i(t=>hs.find(o=>o.value===t)?.url,"getFontUrlByName");function ku(t,e){let o=!!t.find(n=>n.state===tT.CONNECTED);return e===!1&&o}i(ku,"isSingleWalletActive");function vu(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(vu,"memoizedResult");function wu(t,e){let o=new Set;return e.forEach(n=>{o.add(n.blockchain)}),t.filter(n=>o.has(n.name))}i(wu,"filterBlockchainsWithAtLeastOneToken");import{BigNumber as Bu}from"bignumber.js";function Eu(t){return t.replace(/^0+(?=\d)/g,"")}i(Eu,"removeLeadingZeros");function bu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(bu,"ensureLeadingZeroForDecimal");function xu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(xu,"formatThousandsWithCommas");function Iu(t){return t.replace(/\s+/g,"-")}i(Iu,"replaceSpacesWithDash");function Au(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(Au,"stripTrailingZeros");function Nu(t){return t=t.replace(/[^\d.]/g,"").replace(/\./g,(e,o,n)=>n.indexOf(".")===o?".":""),t}i(Nu,"parseNumericValue");function ui(t){return/^0+(?:\.0+)?$/.test(t)}i(ui,"isZeroValue");function Wu(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(Wu,"isValidCurrencyFormat");function Pu(t){return/\d+$/.test(t)}i(Pu,"isColorKeyOverridden");var Yn=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"),D=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Bu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Bu(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 di=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var Dt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),Zn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function Lu(t){return ui(t)?"0":t.endsWith(".")?t.slice(0,-1):Au(t)}i(Lu,"sanitizeInputAmount");function Jn(t,e){return cT(t,e)?ft.PARTIALLY_CONNECTED:e.connected?ft.CONNECTED:e.connecting?ft.CONNECTING:e.installed?ft.DISCONNECTED:ft.NOT_INSTALLED}i(Jn,"getWalletConnectionStatus");function Mu(t,e,o,n){return o.filter(r=>!pu.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:c,network:l}=t(r);return s&&(!c||!!n&&l!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:c,showOnMobile:l,needsNamespace:p,supportedChains:u,needsDerivationPath:m,properties:f,isHub:h}=e(r),g=pn(u.map(y=>y.type)),d=Jn(e(r),t(r));return{title:a,image:s,link:rT(c),state:d,type:r,showOnMobile:l,needsNamespace:p,blockchainTypes:g,needsDerivationPath:m,properties:f,isHub:h}})}i(Mu,"mapWalletTypesToWalletInfo");function Rn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(Rn,"walletAndSupportedChainsNames");function ks(t,e,o,n,r){let a=[];function s(l,p,u){if(!!!a.find(f=>f.chain===l)){let f={address:p,chain:l,walletType:t,isContractWallet:u??!1};a.push(f)}}i(s,"addAccount");let c=n||[];return e.forEach(l=>{let{address:p,network:u}=nT(l),m=c.length>0,f=c.includes(u),h=u===_u.Unknown;if(m&&!f&&!h)return;let d=u===_u.Unknown&&aT(p);if(h&&!d)return;o.includes(u)||d?r?s(u,p.toLowerCase(),r):c.filter(C=>o.includes(C)).forEach(C=>{s(C,p.toLowerCase())}):s(u,p)}),a}i(ks,"prepareAccountsForWalletStore");function Mo(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,c=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:l}=r;l.forEach((p,u)=>{let m=p.from.blockchain,f=p.to.blockchain,h=a===o.swaps.length-1,g=u===l.length-1;(!h&&!g||h&&c!==m||e==="all")&&n.add(m),e==="all"&&n.add(f)})}e==="all"&&n.add(c)}),Array.from(n)}i(Mo,"getQuoteChains");function er(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(er,"isAccountAndWalletMatched");var Du=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?Ts(n.usdValue,n.decimals):ue.toFixed();return o.plus(r)},new un(ue));return lT(e.toString())},"calculateWalletUsdValue");function lT(t){let e=t.toString().split(".");return e[0]&&(e[0]=xu(e[0])),e.join(".")}i(lT,"numberWithThousandSeparator");var gi=i((t,e)=>{let o=iT(Object.entries(t).map(([,n])=>n).filter(sT));return o&&!!o[e]?.experimental},"isExperimentalChain");function Ts(t,e){return new un(t).shiftedBy(-e).toFixed()}i(Ts,"representAmountInNumber");function hi(t){if(!t)return null;let e=Ts(t.amount,t.decimals),o=t.usdValue?Ts(t.usdValue,t.decimals):null,n=D(e,8,8),r=o?D(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(hi,"formatBalance");function $u(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new un(t.usdValue).shiftedBy(-t.decimals):ue,n=e&&e.usdValue?new un(e.usdValue).shiftedBy(-e.decimals):ue;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new un(t.amount).shiftedBy(-t.decimals):ue,n=e&&e.amount?new un(e.amount).shiftedBy(-e.decimals):ue;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i($u,"compareTokenBalance");function Vt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Vt,"areTokensEqual");function Fu(t){return t.sort((e,o)=>+(o.state===ft.CONNECTED)-+(e.state===ft.CONNECTED)||+(o.state===ft.PARTIALLY_CONNECTED)-+(e.state===ft.PARTIALLY_CONNECTED)||+(o.state===ft.DISCONNECTED||o.state===ft.CONNECTING)-+(e.state===ft.DISCONNECTED||e.state===ft.CONNECTING))}i(Fu,"sortWalletsBasedOnConnectionState");function po(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(po,"getConciseAddress");function Ou({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Ou,"getAddress");var Uu=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function yi(t){return t.map(e=>e.state).join("-")}i(yi,"hashWalletsState");function zu(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(zu,"filterBlockchainsByWalletTypes");function Hu(t,e){return e===oT.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(pi(n,e))return!0;return!1})}i(Hu,"filterWalletsByCategory");function cT(t,e){if(!t.isHub||!t.needsNamespace||!e.connected)return!1;let n=t.needsNamespace.data.filter(r=>!r.unsupported);return t.needsNamespace.selection==="multiple"&&n.some(r=>!e.namespaces?.get(r.value)?.connected)}i(cT,"checkIsWalletPartiallyConnected");var vs={API_KEY:cu()};function Kt(t){return vs[t]||""}i(Kt,"getConfig");function Qu(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),vs=e,vs}i(Qu,"initConfig");var qu=20,Gu=25,ws="theme-widget",Es=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Vt(n,t));else if(!Array.isArray(e)){let n=e[t.blockchain];if(n){o=!!n.tokens.some(a=>Vt(a,t));let r=n.isExcluded;return!r&&!o||r&&o}}}return o},"isTokenExcludedInConfig"),bs=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Vu=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Si,gt=i(()=>Si||(Si=new pT(Kt("API_KEY"),Kt("BASE_URL")),Si),"httpService");import{i18n as Ku}from"@lingui/core";var Ci=[.5,1,3],Ti=1,dn=5,tr=30,ki=0;var Je=(a=>(a[a.NO_RESULT=0]="NO_RESULT",a[a.REQUEST_FAILED=1]="REQUEST_FAILED",a[a.REQUEST_CANCELED=2]="REQUEST_CANCELED",a[a.BRIDGE_LIMIT=3]="BRIDGE_LIMIT",a[a.INSUFFICIENT_SLIPPAGE=4]="INSUFFICIENT_SLIPPAGE",a))(Je||{});var or=(s=>(s.QUOTE_INPUT_UPDATE="quoteInputUpdate",s.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",s.ROUTE_REQUESTED="routeRequested",s.ROUTE_NOT_FOUND="routeNotFound",s.ROUTE_FETCH_FAILED="routeFetchFailed",s.ROUTE_CHANGED="routeChanged",s))(or||{}),vi=(r=>(r.CONNECT="connect",r.DISCONNECT="disconnect",r.CONNECT_INITIATED="connectInitiated",r.DETECTED="detected",r))(vi||{}),Re=(d=>(d.CLICK_CONNECT_WALLET="clickConnectWallet",d.TOKEN_SELECTED="tokenSelected",d.CHAIN_FILTER_APPLIED="chainFilterApplied",d.SETTINGS_CHANGED="settingsChanged",d.ROUTE_FEE_VIEWED="routeFeeViewed",d.DESTINATION_ADDRESS_SET="destinationAddressSet",d.GAS_WARNING_SHOWN="gasWarningShown",d.GAS_WARNING_BYPASSED="gasWarningBypassed",d.SWAP_INITIATED="swapInitiated",d.SWAP_WALLETS_MODAL_SHOWN="swapWalletsModalShown",d.SWAP_WALLETS_CONFIRMED="swapWalletsConfirmed",d.SWAP_STARTED="swapStarted",d.SWAP_RESUMED="swapResumed",d.SWAP_RETRIED="swapRetried",d.SWAP_CANCELLED="swapCancelled",d))(Re||{}),mn=(a=>(a.RouteEvent="routeEvent",a.StepEvent="stepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(mn||{});function wi(t,e){let o=t.map(a=>a.swapperGroup),n=[];return pn(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(c=>c.swapperGroup===a);if(s){let c=!0;o&&(c=o.some(l=>l===s.swapperGroup)),c&&s.types.map(l=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:l,selected:!e.includes(s.swapperGroup)})})}}),n}i(wi,"getUniqueSwappersGroups");function ju(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(ju,"sortLiquiditySourcesByGroupTitle");function it(t,e){return e?.[t]==="hidden"}i(it,"isFeatureHidden");function fn(t,e){return e?.[t]==="enabled"}i(fn,"isRoutingEnabled");var Xu=i((t,e,o)=>it("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function gn(t){return t==ki?{type:"error",message:Ku.t("Slippage must be greater than or equal to 0.01")}:t>dn&&t<=tr?{type:"warning",message:Ku.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(gn,"getSlippageValidation");var Yu=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 l=ai({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>au.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(l=>!(s.length>0&&!s.includes(l.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),c=Array.from(n.values()),l=e()._blockchainsMapByName;if(!o||!o.type)return c;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=ln.get(u);m?.length||(m=Xn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),ln.set(u,m)),m=Xu(m,s,a.features);let f=e().blockchains({type:o.type});return m.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!f.some(d=>d.name===g.blockchain)?!1:o.searchFor?!!(mt(g.symbol,o.searchFor)||mt(g.address||"",o.searchFor)||mt(g.name||"",o.searchFor)):!0).sort((g,d)=>{let y=e().isTokenPinned(g,o.type),S=e().isTokenPinned(d,o.type);if(y!==S)return y?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(g),A=o.getBalanceFor(d),x=$u(I,A);if(x!==0)return x}let C=l.get(g.blockchain),k=l.get(d.blockchain),E=gs(g,C),w=gs(d,k);if(E!==w)return E?-1:1;if(g.isPopular!==d.isPopular)return g.isPopular?-1:1;if(o.searchFor){let I=Cu(g,d,o.searchFor);if(I)return I}return g.isSecondaryCoin!==d.isSecondaryCoin?g.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=wt(o),s=n.get(a);return s||(s=r.find(c=>wt(c)===a)),s},findNativeToken:o=>{let n=o.feeAssets[0];return e().findToken({blockchain:o.name,address:n.address,symbol:n.symbol})},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Vt(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(ju)},fetch:async()=>{try{let{routing:o}=e().config,n=fn("enableCentralizedSwappers",o),r=await gt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=r.popularTokens,p=r.swappers.filter(m=>m.enabled);r.blockchains.sort((m,f)=>m.sort-f.sort).forEach(m=>{m.enabled&&a.set(m.name,m)}),r.tokens.forEach(m=>{let f=wt(m);c[m.blockchain]||(c[m.blockchain]=[]),s.set(f,m),c[m.blockchain]?.push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c,_popularTokens:l,_swappers:p})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as uT,Catalonia as dT,Chinese as Zu,Denmark as mT,English as fT,Finland as gT,French as hT,German as yT,Greece as ST,Hungary as CT,India as TT,Indonesian as kT,Italian as vT,Japanese as wT,Korea as ET,Lithuania as bT,Malay as xT,Netherlands as IT,Pakistan as AT,Philippines as NT,Poland as WT,Portuguese as PT,Russian as BT,SaudiArabia as LT,Serbia as _T,Slovakia as MT,SouthAfrica as DT,Spanish as $T,Swahili as FT,Swedish as OT,Thai as UT,Turkish as zT,Ukrainian as HT,Vietnamese as QT}from"@rango-dev/ui";var Ju=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:DT},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:LT},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:uT},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:dT},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Zu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Zu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:mT},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:IT},{title:"English",label:"English",local:"en",SVGFlag:fT},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:NT},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:gT},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:hT},{title:"German",label:"Deutsch",local:"de",SVGFlag:yT},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:ST},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:TT},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:CT},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:kT},{title:"Italian",label:"Italiana",local:"it",SVGFlag:vT},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:wT},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:ET},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:bT},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:xT},{title:"Polish",label:"Polski",local:"pl",SVGFlag:WT},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:PT},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:BT},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:_T},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:MT},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:$T},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:FT},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:OT},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:UT},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:zT},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:HT},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:AT},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:QT}],hn="en";var Ru=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Ti,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],quoteTokensRate:"default",changeQuoteTokensRate:()=>t(o=>({quoteTokensRate:o.quoteTokensRate==="default"?"reversed":"default"})),addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,c)=>{let l=s===o,p=c<=9;return l&&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=pn(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=it("theme",n),s=it("language",n),c=it("liquiditySource",n),l=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...l&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||hn},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||hn}})},setCustomToken:o=>{e().fetchCustomTokensBalances({tokens:[o],connectedWallets:e().connectedWallets}),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=ai({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import Ps from"bignumber.js";import qT from"mitt";var de=qT(),GT={on:de.on,off:de.off};var ed=null,td=new Map;function od(t){ed=t}i(od,"setPendingWalletConnectionSource");function nd(t){td.set(t,ed)}i(nd,"markWalletConnecting");function rd(t){return td.get(t)??null}i(rd,"getWalletConnectionSource");var id=i(t=>(e,o,n)=>t(i((...a)=>{let[s,...c]=a;e(l=>({...typeof s=="function"?s(l):s,lastUpdatedAt:+new Date}),...c)},"modifedSet"),o,n),"keepLastUpdated");import ad from"bignumber.js";function jt(t){return`${t.blockchain}${Lo}${t.address}${Lo}${t.symbol}`}i(jt,"createAssetKey");function sd(t,e){return`${jt(e)}${Lo}${t}`}i(sd,"createBalanceKey");function nr(t){let[e,o,n]=t.split(Lo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(nr,"extractAssetFromBalanceKey");function Is(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[jt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new ad(r??ue).multipliedBy(o[s].amount).toString():""})})}),o}i(Is,"computeNextBalancesWithNewPrices");function As(t,e){let o={};return t.balances?.forEach(n=>{let r=sd(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new ad(c??ue).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(As,"createBalanceStateForNewAccount");function Ns(t,e){for(let o in e){let n=nr(o);if(n){let r=jt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}}return t}i(Ns,"updateAggregatedBalanceStateForNewAccount");function VT(t,e){let o=nr(e);if(!o)return t;let n=jt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(VT,"removeBalanceFromAggregatedBalance");function Ws(t,e,o){let n=t.connectedWallets.filter(l=>e.includes(l.walletType));t.connectedWallets.forEach(l=>{e.includes(l.walletType)||(n=n.filter(p=>!(p.chain===l.chain&&p.address===l.address)))}),o?.chains&&o.chains.length>0&&(n=n.filter(l=>o.chains?.includes(l.chain))),o?.namespaces&&o.namespaces.length>0&&(n=n.filter(l=>l.namespace?o.namespaces?.includes(l.namespace):!1));let r={},a=t._aggregatedBalances,s=t._balances;return Object.keys(s).forEach(l=>{let p=nr(l);if(!p)return;!!n.find(m=>sd(m.address,{address:p.address,blockchain:m.chain,symbol:p.symbol})===l)?a=VT(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(Ws,"computeNextStateAfterWalletBalanceRemoval");function KT(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(KT,"matchWalletDetailsWithConnectedWallet");var jT=vu(),ld=id((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>er(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>er(s,a))?{...a,loading:!1,error:!1,explorerUrl:KT(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>er(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n,r)=>{let a=e().connectedWallets,s=o.filter(c=>!a.some(l=>er(c,l)));if(s.length>0){let c=s.map(l=>{let p=!a.some(u=>u.chain===l.chain&&u.selected&&u.walletType!==l.walletType);return{address:l.address,chain:l.chain,isContractWallet:l.isContractWallet,explorerUrl:null,walletType:l.walletType,selected:p,namespace:n,derivationPath:r,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(u=>!c.some(m=>m.walletType===u.walletType&&m.chain===u.chain)),...c]}))}},fetchCustomTokensBalances:async o=>{let{tokens:n,connectedWallets:r}=o,a=n.reduce((l,p)=>((l[p.blockchain]||=[]).push(p),l),{}),s=new Set,c=r.reduce((l,p)=>{let u=`${p.address}-${p.chain}`;return s.has(u)||(s.add(u),a[p.chain]&&(l[p.address]||(l[p.address]=[]),l[p.address]?.push(...a[p.chain]||[]))),l},{});Object.entries(c).forEach(async([l,p])=>{try{let{balances:u}=await gt().getMultipleTokenBalance({assets:p.map(({symbol:m,address:f,blockchain:h})=>({symbol:m,address:f,blockchain:h})),walletAddress:l});if(u){let m=e()._balances,f=e()._aggregatedBalances;u.forEach(h=>{if(parseFloat(h.amount.amount)===0)return;let g={blockChain:h.asset.blockchain,balances:[h],address:l},d={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};Is(d,g,m);let y=As(g,e);f=Ns(f,y),m={...m,...y}}),t(h=>({_balances:{...h._balances,...m},_aggregatedBalances:f}))}}catch(u){console.error(u)}})},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(c=>c.chain===r.chain&&c.walletType!==r.walletType&&r.selected),s=!!o.find(c=>c.chain===r.chain&&c.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n,r,a)=>{let s=o[0];s&&(de.emit("walletEvent",{type:"connect",payload:{walletType:s.walletType,accounts:o,chain:s.chain??null,walletName:a?.walletName??s.walletType,source:rd(s.walletType)}}),e().addConnectedWallet(o,n,r),e().fetchBalances(o))},removeBalancesForWallet:(o,n)=>{let r={_balances:e()._balances,_aggregatedBalances:e()._aggregatedBalances,connectedWallets:e().connectedWallets},{_balances:a,_aggregatedBalances:s}=Ws(r,[o],n);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(de.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(c=>a.includes(c.chain)?(a=a.filter(l=>l!==c.chain),{...c,selected:!0}):c);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let{shouldFetchCustomTokens:r=!0,selectedCustomTokens:a}=n||{};await e().fetchMainTokensBalances(o),r&&e().fetchCustomTokensBalances({tokens:a??e().customTokens(),connectedWallets:o})},fetchMainTokensBalances:async(o,n)=>{if(o.length===0||!o[0])return;let r=[...new Set(o.map(l=>l.walletType))];e().setConnectedWalletAsRefetching(o);let a=o.map(l=>({address:l.address,blockchain:l.chain})),s;try{s=await gt().getWalletsDetails(a)}catch(l){e().setConnectedWalletHasError(o),console.error(`Request for fetching balances failed. cause: ${l}`);return}let c=s.wallets;if(c){let l=e()._balances,p=e()._aggregatedBalances;c.forEach(m=>{if(m.failed)return;let f={_balances:l,_aggregatedBalances:p,connectedWallets:e().connectedWallets,findToken:e().findToken};Is(f,m,l);let{_balances:h,_aggregatedBalances:g}=Ws(f,r,{chains:[m.blockChain]});if(p=g,l=h,!e().connectedWallets.find(y=>r.includes(y.walletType)&&y.address===m.address&&y.chain===m.blockChain))return;let d=As(m,e);p=Ns(p,d),l={...l,...d}}),t(m=>({_balances:{...m._balances,...l},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(o,c);let{retryOnFailedBalances:u=!0}=n||{};if(u){let m=c.filter(f=>f.failed).map(f=>{let h=e().connectedWallets.find(g=>g.chain===f.blockChain&&g.address)?.walletType;return h?{chain:f.blockChain,walletType:h,address:f.address}:null}).filter(f=>!!f);m.length>0&&await e().fetchMainTokensBalances(m,{retryOnFailedBalances:!1})}}else e().setConnectedWalletHasError(o),console.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=jt(o),a=e()._aggregatedBalances[r]||[];if(a.length===0||!a[0])return null;let s=a[0];if(a.length===1&&n[s])return n[s];let c=n[a[0]];if(!c)return null;let l=c;return a.forEach(p=>{let u=n[p];if(!u)return;let m=new Ps(u.amount),f=new Ps(l.amount);m.isGreaterThan(f)&&(l=u)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,c)=>{let l=n[c],[,,,p]=c.split(Lo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>jT(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,c)=>{let l=r[c],p=nr(c);if(p&&p.blockchain===n.chain&&l){let u=e().findToken(p),m=l?.amount?new Ps(l.amount).shiftedBy(-l.decimals):ue;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:l.amount,decimal:l.decimals,amount:m.toString(),isSupported:!!u,logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function cd(t){return XT()(YT((...e)=>({...ld(...e),...Yu(...e),...Ru(...e),...ru(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,quoteTokensRate:e.quoteTokensRate}),version:1,migrate:(e,o)=>{let n=e;return o===0&&(n._customTokens=n._customTokens.map(r=>({...r,warning:!0}))),n}}))}i(cd,"createAppStore");var pd=JT(null);function T(){let t=RT(pd);if(ek(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(T,"useAppStore");function ud(t){let e=tk();return e.current||(e.current=cd(t.config)),ZT.createElement(pd.Provider,{value:e.current},t.children)}i(ud,"AppStoreProvider");function dd(t,e){let o=!1,n={...t.payload,preventDefault(){o=!0}};de.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(dd,"emitPreventableEvent");function ee(t){de.emit("uiEvent",t)}i(ee,"emitUiEvent");function Bs(t){od(t),de.emit("walletEvent",{type:"connectInitiated",payload:{source:t}})}i(Bs,"emitWalletConnectInitiated");function $o(t){de.emit("quoteEvent",t)}i($o,"emitQuoteEvent");function Ls(t){de.emit("walletEvent",{type:"detected",payload:t})}i(Ls,"emitWalletDetected");var Ei=new Set;function It(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=T(),{state:r,getWalletInfo:a}=ok(),s=T().blockchains(),{handleDisconnect:c}=sn(),l=eu(n()),p=Mu(r,a,l,e);p=nk()?p.filter(d=>d.showOnMobile!==!1&&r(d.type).installed):p;let u=Fu(p);_s(()=>{p.forEach(d=>{d.state!==rr.NOT_INSTALLED&&!Ei.has(d.type)&&(Ei.add(d.type),Ls({walletType:d.type,walletName:d.title}))})},[yi(p)]),_s(()=>{p.forEach(d=>{d.state!==rr.NOT_INSTALLED&&!Ei.has(d.type)&&(Ei.add(d.type),Ls({walletType:d.type,walletName:d.title}))})},[yi(p)]);let m=i(d=>!o.find(y=>y.walletType===d&&y.chain===e),"isExperimentalChainNotAdded"),f=ik(()=>{let d=p?.filter(y=>y.state===rr.CONNECTING)||[];for(let y of d)c(y)},[yi(p)]);_s(()=>()=>{f()},[]);let h=i(d=>{let y=d.find(C=>C.type===ir.DEFAULT);return!y||y.state===rr.NOT_INSTALLED?!1:d.filter(C=>C.state!=rr.NOT_INSTALLED&&![ir.DEFAULT,ir.WALLET_CONNECT_2,ir.LEDGER].includes(C.type)&&a(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((d,y,S)=>gi(S,y)&&m(d)&&!rk.includes(d)||d==ir.DEFAULT&&!h(p),"shouldExcludeWallet");return{list:u.filter(d=>!g(d.type,e??"",s)),terminateConnectingWallets:f}}i(It,"useWalletList");import{Modal as ck}from"@rango-dev/ui";import pk from"react";import{create as lk}from"zustand";var md="rango-widget";var ar=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(md),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 sk=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"),uo=sk;var oe=uo(lk()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!1,showCompactTokenSelector:!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})},setShowCompactTokenSelector:o=>{t({showCompactTokenSelector:o})}}))),Fo=new ar({onInit:()=>oe.setState({tabManagerInitiated:!0}),onClaim:()=>oe.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>oe.setState({isActiveTab:!1})});function R(t){let{watermark:e}=oe();return pk.createElement(ck,{hasWatermark:e==="FULL",...t},t.children)}i(R,"WatermarkedModal");import{i18n as Cn}from"@lingui/core";import{Alert as Ek,Button as bk,Divider as Tn,Image as xk,MessageBox as Ik,RadioRoot as Ak,WalletImageContainer as Nk}from"@rango-dev/ui";import le,{useEffect as Wk,useMemo as Pk,useState as Bk}from"react";import{i18n as fk}from"@lingui/core";import{Typography as kd}from"@rango-dev/ui";import yn from"react";function bi(t,e){return t.find(o=>o.name===e)?.logo}i(bi,"getBlockchainLogo");import{darkTheme as uk,Image as dk,styled as Xt,Typography as mk}from"@rango-dev/ui";var xi=Xt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${uk} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Ii=Xt("div",{display:"flex",gap:"$8",alignItems:"center"}),gd=Xt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),hd=Xt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),yd=Xt("div",{display:"flex",gap:"$6",alignItems:"center"}),Sd=Xt("div",{paddingLeft:"48px"}),Cd=Xt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),Td=Xt(mk,{maxWidth:"100px"}),Ai=Xt(dk,{variants:{disabled:{true:{opacity:"0.5"}}}});function Ni(t){let{namespace:e}=t,o=T().blockchains();return yn.createElement(xi,{unsupported:!0},yn.createElement(Ii,null,yn.createElement(Ai,{src:bi(o,e.id),size:40,disabled:!0}),yn.createElement(hd,null,yn.createElement(kd,{variant:"label",size:"large"},e.label),yn.createElement(kd,{variant:"body",size:"xsmall"},fk.t("(Currently not supported)")))))}i(Ni,"NamespaceUnsupportedItem");import{Checkbox as kk,Radio as vk}from"@rango-dev/ui";import Fs from"react";import{i18n as $s}from"@lingui/core";import{ChevronDownIcon as hk,ChevronUpIcon as yk,Divider as Sk,Typography as sr}from"@rango-dev/ui";import Ne,{useEffect as Ck,useState as Tk}from"react";import{Image as wd,Tooltip as Ed,Typography as gk}from"@rango-dev/ui";import $t from"react";import{styled as vd}from"@rango-dev/ui";var Ms=vd("div",{display:"flex",alignItems:"center",padding:0,margin:0}),Wi=vd("div",{marginLeft:"-5px",listStyleType:"none",backgroundColor:"$background",borderRadius:"$lg",minWidth:"15px",height:"15px",variants:{firstItem:{true:{marginLeft:0}}},display:"flex",alignItems:"center",justifyContent:"center"});var Ds=3;function bd(t){let{chains:e}=t;return $t.createElement(Ms,{id:"widget-supported-chains-container"},e.slice(0,Ds).map((o,n)=>$t.createElement(Ed,{key:o.name,container:W(),side:"bottom",align:"start",content:o.name,sideOffset:4},$t.createElement(Wi,{firstItem:n===0},$t.createElement(wd,{src:o.logo,size:15})))),e.length>Ds&&$t.createElement(Ed,{container:W(),side:"bottom",align:"start",sideOffset:4,content:$t.createElement(Ms,null,e.map((o,n)=>$t.createElement(Wi,{key:o.name,firstItem:n===0},$t.createElement(wd,{src:o.logo,size:15}))))},$t.createElement(Wi,null,$t.createElement(gk,{variant:"body",size:"xsmall"},"+",e.length-Ds))))}i(bd,"SupportedChainsList");function Oo(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=Tk(!1),p=T().blockchains();Ck(()=>l(!1),[o]);let u=e.getSupportedChains(p),m=!o&&!r&&u.length>1;return Ne.createElement(xi,{hasError:!!o,clickable:!!s,onClick:s},Ne.createElement(Ii,null,Ne.createElement(Ai,{src:bi(p,e.id),size:40}),Ne.createElement(gd,{showSupportedChains:m||r||!!o},Ne.createElement(yd,null,Ne.createElement(sr,{variant:"label",size:"large"},e.label),r&&Ne.createElement(sr,{variant:"body",size:"small",color:"success500"},$s.t("Connected")),!!o&&Ne.createElement(sr,{variant:"body",size:"small",color:"error500"},$s.t("Connection failed"))),m&&Ne.createElement(bd,{chains:u}),r&&Ne.createElement(Td,{variant:"body",size:"small",color:"neutral700"},a),o&&Ne.createElement(Cd,{onClick:()=>l(f=>!f)},Ne.createElement(sr,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},$s.t("See why")),c?Ne.createElement(yk,{size:12,color:"gray"}):Ne.createElement(hk,{size:12,color:"gray"}))),n),!!o&&c&&Ne.createElement(Ne.Fragment,null,Ne.createElement(Sk,{size:4}),Ne.createElement(Sd,null,Ne.createElement(sr,{variant:"body",size:"small",color:"neutral700"},o))))}i(Oo,"NamespaceItem");function xd(t){let{onClick:e,type:o,namespace:n}=t;return Fs.createElement(Oo,{namespace:n,onClick:e,suffix:o==="radio"?Fs.createElement(vk,{value:n.value}):Fs.createElement(kk,{checked:t.value})})}i(xd,"NamespaceListItem");import{Button as wk,styled as Id}from"@rango-dev/ui";var Pi=Id("ul",{padding:0,paddingBottom:"$20",margin:0}),Sn=Id(wk,{minHeight:"$40"});function lr(t){let{targetWallet:e}=t.value,o=e.properties?.find(d=>d.name==="namespaces"),n=e.isHub,r=e.isHub?o?.value.selection==="single":e.needsNamespace?.selection==="single",a=n?o?.value:e.needsNamespace,s=e.image,c=T().blockchains(),[l,p]=Bk([]),u=Pk(()=>a?.data.filter(d=>!d.unsupported),[e?.type]),m=i(d=>{p(r?[d]:y=>y.includes(d)?y.filter(S=>S!==d):y.concat(d))},"onSelect"),f=u?.length===l.length,h=i(()=>{if(r)throw new Error("onSelectAll should not be called on single selection mode.");f?p([]):u&&p(u.map(d=>d.value))},"onSelectAll"),g=i(d=>r?le.createElement(Ak,{value:l?.[0]},d):le.createElement(le.Fragment,null,d),"wrapRadioRoot");return Wk(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let d=u.filter(y=>y.getSupportedChains(c).some(S=>t.value.defaultSelectedChains?.includes(S.name)));p(d.map(y=>y.value))}else p(u.map(d=>d.value))},[]),le.createElement(le.Fragment,null,le.createElement(Ik,{type:"info",title:Cn.t("Connect {wallet}",{wallet:e.title}),description:Cn.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect."),icon:le.createElement(Nk,null,le.createElement(xk,{src:s,size:45}))}),r?le.createElement(le.Fragment,null,le.createElement(Tn,{size:20,className:"_initial_namespace_list_header_alert_top_divider"}),le.createElement(Ek,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:Cn.t("This wallet can only connect to one chain at a time. ")}),le.createElement(Tn,{size:30,className:"_initial_namespace_list_header_alert_bottom_divider"})):le.createElement(le.Fragment,null,le.createElement(Tn,{size:30,className:"_initial_namespace_list_header_button_top_divider"}),le.createElement(bk,{style:{marginLeft:"auto"},id:"widget-name-space-select-all-btn",size:"xsmall",variant:"ghost",type:"primary",onClick:h},f?Cn.t("Deselect all"):Cn.t("Select all")),le.createElement(Tn,{size:10,className:"_initial_namespace_list_header_button_bottom_divider"})),le.createElement(Pi,null,g(le.createElement(le.Fragment,null,a?.data.map((d,y,S)=>le.createElement(le.Fragment,{key:d.id},d.unsupported?le.createElement(Ni,{namespace:d}):le.createElement(xd,{value:l.includes(d.value),namespace:d,type:r?"radio":"checkbox",onClick:()=>m(d.value)}),y!==S.length-1&&le.createElement(Tn,{size:10})))))),le.createElement(Tn,{size:20}),le.createElement(Sn,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!l.length,onClick:()=>t.onConfirm(l)},Cn.t("Connect")))}i(lr,"Namespaces");import{i18n as cr}from"@lingui/core";import{Alert as Ok,Button as Uk,Divider as kn,Image as zk,MessageBox as Hk,WalletImageContainer as Qk}from"@rango-dev/ui";import{useWallets as qk}from"@rango-dev/wallets-react";import fe from"react";import{styled as Lk}from"@rango-dev/ui";var Ad=Lk("div",{display:"flex",justifyContent:"end"});import{i18n as Os}from"@lingui/core";import{Button as _k,Spinner as Mk}from"@rango-dev/ui";import Us,{useLayoutEffect as Dk,useRef as $k,useState as Fk}from"react";function Nd(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=Fk(null),p=$k(!1);Dk(()=>{o&&!p.current&&u()},[]);let u=i(async g=>{try{p.current=!0,await a(g)}catch(d){l(d)}finally{p.current=!1}},"handleConnectNamespace"),m=i(async()=>{l(null),r.connected?await s():u({shouldAskForDerivationPath:!0})},"handleButtonClick"),f=i(()=>{let g=r.accounts?.[0]?.split(":"),d=g?.[g.length-1];return!r.connected||!d?null:po(d)},"getConnectedAddress"),h=i(()=>r.connected?Os.t("Disconnect"):c?Os.t("Try again"):Os.t("Connect"),"getButtonText");return Us.createElement(Oo,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?Us.createElement(Mk,{color:"info"}):Us.createElement(_k,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>m(),disabled:n},h())})}i(Nd,"NamespaceDetachedItem");function pr(t){let{value:e,selectedNamespaces:o,onConfirm:n,confirmText:r=cr.t("Done"),onDisconnectWallet:a,navigateToDerivationPath:s}=t,{targetWallet:c}=e,{connect:l,disconnect:p,state:u}=qk(),m=c.type,f=u(m),h=c.properties?.find(E=>E.name==="namespaces"),g=c.properties?.find(E=>E.name==="derivationPath"),d=h?.value.selection==="single",y=i(async(E,w)=>{d&&await p(m),g&&w?.shouldAskForDerivationPath?s(E):await l(m,[{namespace:E,network:"",derivationPath:w?.derivationPath??void 0}])},"handleConnectNamespace"),S=i(async E=>{await p(m,[E])},"handleDisconnectNamespace"),C=i(()=>d?fe.createElement(fe.Fragment,null,fe.createElement(kn,{size:20,className:"_detached_namespace_list_header_alert_top_divider"}),fe.createElement(Ok,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:cr.t("This wallet can only connect to one chain at a time.")}),fe.createElement(kn,{size:30,className:"_detached_namespace_list_header_alert_bottom_divider"})):fe.createElement(fe.Fragment,null,fe.createElement(kn,{size:30,className:"_detached_namespace_list_header_button_top_divider"}),fe.createElement(Ad,null,fe.createElement(Uk,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:f.connecting||!f.connected,onClick:a},cr.t("Disconnect wallet"))),fe.createElement(kn,{size:16,className:"_detached_namespace_list_header_button_bottom_divider"})),"renderNamespaceListHeader"),k=i(E=>{if(E.unsupported)return fe.createElement(Ni,{namespace:E});let w=o?.find(x=>x.namespace===E.value),I=f.namespaces?.get(E.value);if(!I)throw new Error(`State for ${E.value} was not found!`);let A=d&&f.connecting;return fe.createElement(Nd,{namespace:E,initialConnect:!!w,disabled:A,state:I,handleConnect:async x=>y(E.value,{derivationPath:w?.derivationPath,shouldAskForDerivationPath:x?.shouldAskForDerivationPath}),handleDisconnect:async()=>S(E.value)})},"renderNamespaceItem");return fe.createElement(fe.Fragment,null,fe.createElement(Hk,{type:"info",title:cr.t("Connect {wallet}",{wallet:c.type}),description:cr.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:fe.createElement(Qk,null,fe.createElement(zk,{src:c.image,size:45}))}),C(),fe.createElement(Pi,{id:"widget-detached-namespace-list"},c.needsNamespace?.data.map((E,w,I)=>fe.createElement(fe.Fragment,{key:E.id},k(E),w!==I.length-1&&fe.createElement(kn,{size:10})))),fe.createElement(kn,{size:20}),fe.createElement(Sn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},r))}i(pr,"Detached");import{i18n as vn}from"@lingui/core";import{Divider as jk,Image as Xk,MessageBox as Yk,Select as Zk,TextField as Jk}from"@rango-dev/ui";import At,{useEffect as Rk,useState as Pd}from"react";import{namespaces as Gk}from"@rango-dev/wallets-shared";var Bi={id:"custom",label:"Custom",generateDerivationPath:t=>t};function zs(t){let e=t?Gk[t]?.derivationPaths:null;return e?[...e,Bi]:[]}i(zs,"getDerivationPaths");import{Button as Vk,styled as Hs,Typography as Kk}from"@rango-dev/ui";var Wd=Hs("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Qs=Hs(Kk,{paddingLeft:"$10"}),qs={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},LM=Hs(Vk,{minHeight:"$40"});var Bd="0";function ur(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Pd(null),[c,l]=Pd(Bd),p=a===Bi.id,u=zs(o),m=i(({value:h})=>{let g=u?.find(d=>d.id===h);g&&(a===Bi.id&&Number.isNaN(Number(c))&&l(Bd),s(g.id))},"handleDerivationPathItemClick"),f=i(()=>{let h=u.find(g=>g.id===a);if(h)e(h.generateDerivationPath(c));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return Rk(()=>{s(zs(o)[0]?.id||null)},[o]),At.createElement(At.Fragment,null,At.createElement(Yk,{type:"info",title:vn.t("Select Derivation Path"),description:vn.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:At.createElement(Xk,{src:n,size:45})}),At.createElement(Wd,{className:"_derivation_path_inputs_container"},At.createElement(Qs,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},vn.t("Choose Derivation Path Template")),At.createElement(Zk,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:m,styles:{trigger:qs}}),At.createElement(jk,{size:20}),At.createElement(Qs,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?vn.t("Enter Path"):vn.t("Enter Index")),At.createElement(Jk,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:qs})),At.createElement(Sn,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!u||!a||!c},vn.t("Confirm")))}i(ur,"DerivationPath");import{i18n as wn}from"@lingui/core";import{Image as ov,MessageBox as Vs,WalletImageContainer as nv,WalletState as rv}from"@rango-dev/ui";import{useWallets as iv}from"@rango-dev/wallets-react";import Uo from"react";import{keyframes as ev,styled as Gs}from"@rango-dev/ui";var qM=Gs("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Ld=Gs("div",{position:"relative"}),tv=ev({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),_d=Gs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${tv} 1s linear infinite`,top:0,bottom:0,right:0,left:0});function Ks(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a,getWalletInfo:s}=iv();return Jn(s(n),a(n))===rv.CONNECTED?Uo.createElement(Vs,{type:"success",title:wn.t("Wallet Connected"),description:wn.t("Your wallet is connected, you can use it to swap.")}):o?Uo.createElement(Vs,{type:"error",title:wn.t("Failed to Connect"),description:o||wn.t("Your wallet is not connected. Please try again.")}):Uo.createElement(Vs,{type:"loading",title:wn.t("Connecting to your wallet"),description:wn.t("Click connect in your wallet popup."),icon:Uo.createElement(Ld,null,Uo.createElement(nv,null,Uo.createElement(ov,{src:r,size:45})),Uo.createElement(_d,null))})}i(Ks,"ConnectStatus");import{i18n as js}from"@lingui/core";import{Button as av,Divider as Md,MessageBox as sv}from"@rango-dev/ui";import Li from"react";function Xs(t){let{displayName:e,onConfirm:o,id:n}=t;return Li.createElement(sv,{id:n,title:js.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:js.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Li.createElement(Md,{size:18}),Li.createElement(Md,{size:32}),Li.createElement(av,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},js.t("Confirm")))}i(Xs,"ExperimentalChain");function Dd(t,e){return t().status==="init"&&!!e}i(Dd,"isOnStatus");function dr(t){return t().status==="namespace"}i(dr,"isOnNamespace");function mr(t){return t().status==="derivationPath"}i(mr,"isOnDerivationPath");function Wo(t){return t().status==="detached"}i(Wo,"isOnDetached");var uv=3e3,dv=300;function fr(t){let e=pv(),[o,n]=$d(!1),[r,a]=$d(),s=i(w=>{a(w.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=It(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:m,resetState:f,handleDisconnect:h}=sn(),g=i(w=>{u(t.wallet,w).then(k).catch(s)},"handleConfirmNamespaces"),d=i(()=>{S()},"handleDetachedConfirm"),y=i(w=>{if(!w)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(t.wallet,w).then(k).catch(s)},"handleDerivationPathConfirm"),S=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),k=i((w,I)=>{let A=w.status==="connected",x=["disconnected","disconnected-unhandled"].includes(w.status);A?(t.onConnect?.(),I||(e.current=setTimeout(S,uv))):x&&S()},"afterConnected"),E=i(w=>{t.wallet?.needsDerivationPath&&u(t.wallet,[w])},"handleNavigateToDerivationPath");return cv(()=>{if(t.wallet){C();let w=!1,I=!0;i(()=>{setTimeout(()=>{I=!1,w||n(!0)},dv)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(x=>{["namespace","Detached","derivation-path"].includes(x.status)||(w=!0),k(x,I)}).catch(s)}},[t.wallet]),mo.createElement(R,{id:t.id,open:o,onClose:S,onExit:()=>{C(),c(),t.onClose&&t.onClose()},container:W()},Dd(m,t.wallet)&&mo.createElement(mo.Fragment,null,mo.createElement(Ks,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),mo.createElement(lv,{direction:"vertical",size:32})),dr(m)&&mo.createElement(lr,{onConfirm:g,value:m().namespace}),mr(m)&&mo.createElement(ur,{onConfirm:y,value:m().derivationPath}),Wo(m)&&mo.createElement(pr,{onConfirm:d,onDisconnectWallet:()=>void h(m().namespace.targetWallet),value:m().namespace,selectedNamespaces:m().selectedNamespaces,navigateToDerivationPath:E}))}i(fr,"StatefulConnectModal");import cs from"react";import mv,{Fragment as fv}from"react";import{MemoryRouter as gv,useInRouterContext as hv}from"react-router";function _i({children:t}){let o=hv()?fv:gv;return mv.createElement(o,null,t)}i(_i,"AppRouter");import{I18nManager as yW}from"@rango-dev/ui";import Hp from"react";import He from"react";import{useRoutes as j0}from"react-router-dom";var O={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 bn,useRef as zi}from"react";import lt from"bignumber.js";import{create as hm}from"zustand";import{subscribeWithSelector as ym}from"zustand/middleware";import{createContext as yv,useContext as Sv}from"react";var Fd=yv({swapMode:"swap",isMultiMode:!1});function at(){let{swapMode:t,isMultiMode:e}=Sv(Fd);return{swapMode:t,isMultiMode:e}}i(at,"useSwapMode");import{i18n as Et}from"@lingui/core";import{getRelatedWalletOrNull as kv,RouteEventType as s$}from"@rango-dev/queue-manager-rango-preset";import Ve from"bignumber.js";import{PendingSwapNetworkStatus as gr}from"rango-types";import{i18n as Ge}from"@lingui/core";var ne=i(()=>({genericServerError:Ge.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Ge.t("Please reset your liquidity sources."),description:Ge.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Ge.t("No Routes Found."),description:Ge.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:Ge.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Ge.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Ge.t("High Price Impact"),title:Ge.t("Price impact is too high!"),description:Ge.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Ge.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Ge.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Ge.t("USD Price Unknown"),title:Ge.t("USD Price Unknown, Cannot calculate Price Impact."),description:Ge.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Ge.t("Confirm USD Price Unknown")}}),"errorMessages");function Od(t){return t.type===0?t.diagnosisMessage??ne().noResultError.title:t.type===1?t.diagnosisMessage??ne().genericServerError:""}i(Od,"getQuoteErrorMessage");import{i18n as Mi}from"@lingui/core";var zo=i(()=>({connectWallet:Mi.t("Connect Wallet"),swap:Mi.t("Swap"),swapAnyway:Mi.t("Swap anyway"),ethWarning:Mi.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Ys(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(Ys,"getFeeLabel");var Zs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Ud=100,zd=30,Hd=15,Qd=60;var qd=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Gd=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as Tv}from"@rango-dev/queue-manager-rango-preset";import KD from"bignumber.js";function Kd(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(Kd,"getRequiredBalanceOfWallet");function Zt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Zt,"getPriceImpactLevel");function Di(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=Tv(t.steps);if(!r||!n)return{fromBlockchain:null,fromToken:void 0,toBlockchain:null,toToken:void 0,inputAmount:""};let s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},c=Po(a?a.toBlockchain:n.fromBlockchain,e),l=Po(r.toBlockchain,e),p=o(a?{blockchain:c?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:c?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:c,fromToken:p,toBlockchain:l,toToken:u,inputAmount:m}}i(Di,"createRetryQuote");function En(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=Ho(o),s=st(o);if(o&&a&&s){let p=Yt(a.toString(),s.toString());if(!!p&&Jd(a,p)){let m=Fi(o?.swaps,n),f=Zt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:m,warningLevel:f}}}if(e&&tm(e,o))return{type:4,usdValueChange:D(st(o)?.minus(st(e)??0).toString()??"0",null,2),percentageChange:D(Yt(st(e)??"1",st(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Oi(o.swaps),l=r>dn;if(em(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Rd(o,r),minRequiredSlippage:c};return null}i(En,"generateQuoteWarnings");function jd(t){return![4].includes(t.type)}i(jd,"isQuoteWarningConfirmationRequired");function Yt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Js(t.toString(),e.toString());return n&&n<0?n:null}i(Yt,"getPriceImpact");var Xd=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"),$i=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 c=o.requestId.toLowerCase(),l=n.requestId.toLowerCase();return c.localeCompare(l)}),"sortQuotesBy"),Yd=i((t,e,o)=>{let n=e[0];if(!e.length||!n)return null;if(!t)return{requestAmount:o,validationStatus:null,...n};let r=new Set(t.swaps.map(s=>s.swapperId)),a=e.find(s=>{let c=new Set(s.swaps.map(l=>l.swapperId));return Array.from(r).every(l=>c.has(l))});return{requestAmount:o,validationStatus:null,...a||n}},"getDefaultQuote"),Zd=i(t=>{let e=i((o,n)=>{let r=Zs.indexOf(o.value),a=Zs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Jd(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return qd.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ve(r)))}i(Jd,"hasHighValueLoss");function om(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ve(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ve(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(om,"hasLimitError");function nm(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new Ve(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new Ve(c.fromAmountMaxValue):null;return c.fromAmountRestrictionType==="EXCLUSIVE"?l?.gte(c.fromAmount)||p?.lte(c.fromAmount):l?.gt(c.fromAmount)||p?.lt(c.fromAmount)})[0];if(!e)return{swap:void 0,fromAmountRangeError:"",recommendation:""};let o=e.fromAmountMinValue?new Ve(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ve(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=Et.t({id:"Required: >= {min} {symbol}",values:{min:D(o,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=Et.t({id:"Required: > {min} {symbol}",values:{min:D(o,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=Et.t({id:"Required: <= {max} {symbol}",values:{max:D(n,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=Et.t({id:"Required: < {max} {symbol}",values:{max:D(n,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(nm,"getLimitErrorMessage");function rm(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:c,needsToWarnEthOnPath:l}=t;return e!=="success"?{title:zo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||c||!r||r==="0"?{title:zo().swap,action:"confirm-swap",disabled:!0}:s?{title:zo().swapAnyway,action:"confirm-warning",disabled:!1}:l?{title:zo().ethWarning,action:"confirm-warning",disabled:!1}:{title:zo().swap,action:"confirm-swap",disabled:!1}:{title:zo().connectWallet,action:"connect-wallet",disabled:!1}}i(rm,"getSwapButtonState");function Rs(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ue))&&e&&e!=="0"&&n!==0)}i(Rs,"canComputePriceImpact");function el(t,e){let o=ue;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(!r||r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Ve(r.amount).multipliedBy(a||0))}return o}i(el,"getUsdFeeOfStep");function Fi(t,e){return t.reduce((o,n)=>o.plus(el(n,e)),ue)}i(Fi,"getTotalFeeInUsd");function tl(t){let e=ue,o=new Ve(t.price||0);return e=e.plus(new Ve(t.amount).multipliedBy(o)),e}i(tl,"getUsdFee");function im(t){return t.reduce((e,o)=>e.plus(tl(o)),ue)}i(im,"getTotalFeesInUsd");function am(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(am,"getFeesGroup");function sm(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?Object.fromEntries(e):null}i(sm,"checkSlippageErrors");function Rd(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?Object.fromEntries(o):null}i(Rd,"checkSlippageWarnings");function Oi(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(Oi,"getMinRequiredSlippage");function em(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(em,"hasProperSlippage");function lm(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:c,excludeLiquiditySources:l,slippage:p,affiliateRef:u,affiliatePercent:m,affiliateWallets:f,destination:h,contractCall:g}=t,d=a?.reduce((C,k)=>(C[k.chain]=k.address,C),{}),y=[];return r?.forEach(C=>{y.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:m??void 0,affiliateWallets:f??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:y,selectedWallets:d??{},slippage:p.toString(),contractCall:g,...h&&{destination:h},...l&&{swapperGroups:s.concat(c??[]),swappersGroupsExclude:!0},...!l&&{swapperGroups:c?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1}}}i(lm,"createQuoteRequestBody");function cm(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(cm,"getWalletsForNewSwap");function Ho(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new Ve(e).multipliedBy(o)}i(Ho,"getUsdInputFrom");function st(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1]?.to.usdPrice;if(!(!e||!o))return new Ve(e).multipliedBy(o)}i(st,"getUsdOutputFrom");function Js(t,e){return new Ve(e).div(new Ve(t)).minus(1).multipliedBy(Ud).toNumber()}i(Js,"getPercentageChange");function tm(t,e){let o=Ho(t),n=st(t),r=st(e);if(!o||!n||!r)return!1;let a=Js(n.toString(),r.toString());return Gd.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(tm,"isOutputAmountChangedExcessively");function pm(t,e,o){let n=t.validationStatus,r=Mo({filter:"required",quote:t});return e.sort((s,c)=>r.indexOf(s.chain)-r.indexOf(c.chain)).flatMap(s=>Kd(s,n)||[]).filter(s=>!s.ok).map(s=>{let c=s.asset.symbol,l=D(new Ve(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=D(new Ve(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=Et.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=Et.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=Et.t(" for input and network fee")),Et.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:p,symbol:c,reason:u,currentAmount:l,blockchain:vt(s.asset.blockchain,o)}})})}i(pm,"generateBalanceWarnings");function hr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==gr.NetworkChanged}i(hr,"isNetworkStatusInWarningState");function um(t,e,o){let n="bellow button or",r=t.extraMessage,a=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(n)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(n,"")),hr(e)){r=t.networkStatusExtraMessage||"",a=t.networkStatusExtraMessageDetail||"";let p=(e?kv(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case gr.WaitingForConnectingWallet:r=u?Et.t("Connect {wallet}",{wallet:u}):r;break;case gr.WaitingForQueue:r=r||Et.t("Waiting for other running tasks to be finished");break;case gr.WaitingForNetworkChange:r=r||Et.t("Waiting for changing wallet network");break;case gr.NetworkChangeFailed:r=r||Et.t("The network switch could not be completed. Please try again, or switch the network manually in your wallet.");break;default:r=r||"";break}}a=a||"",r=r||"";let c=r?.indexOf("code")!==-1&&r?.indexOf("reason")!==-1;return{shortMessage:r,detailedMessage:{content:a,long:c}}}i(um,"getSwapMessages");function dm(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(dm,"getLastConvertedTokenInFailedSwap");function mm(t){return t.status==="failed"}i(mm,"shouldRetrySwap");function fm(t,e,o,n,r,a){if(!n||t)return!0;let s=Mo({filter:"all",quote:n}),c=Mo({filter:"required",quote:n}),l=s.every(m=>r.some(f=>f.chain===m)),p=c.every(m=>r.some(f=>f.chain===m)),u=o&&a?Bo(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(fm,"isConfirmSwapDisabled");function gm(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(gm,"isTokensIdentical");var Ui=i((t,e)=>t?.usdPrice?new lt(e||ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),Sm=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new lt(0),outputUsdValue:new lt(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=ue,a=o.inputUsdValue;return Zn(o.inputAmount)?(e&&(n=e?.outputAmount?new lt(e?.outputAmount):null,a=Ho(e)??ue,r=st(e)??ue),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new lt(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new lt(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new lt(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:Ui(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 lt(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),sanitizeInputAmount:e=>{let o=Lu(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=Nu(e);ui(e)||(o=Eu(o),o=bu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new lt(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:Ui(n.fromToken,o)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Ui(n??null,s),outputUsdValue:new lt(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?Ui(e.toToken,e.outputAmount?.toString()||""):new lt(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new lt(0),inputUsdValue:new lt(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new lt(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})}),"initializer"),Cm=hm()(ym(Sm)),Tm=hm()(ym(Sm)),vv=uo(Cm),wv=uo(Tm);function G(){let{swapMode:t}=at();return uo(t==="refuel"?Tm:Cm)}i(G,"useQuoteStore");var km=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&de.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&&de.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})},"subscribeCallback"),vm=vv.subscribe(km),wm=wv.subscribe(km);function Em(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=G()(),u=T().config,m=T().fetchStatus,f=T().blockchains(),{findToken:h}=T(),{setAffiliateRef:g,setAffiliatePercent:d,setAffiliateWallets:y}=T(),S=u?.from?.tokens,C=u?.from?.blockchains,k=u?.to?.tokens,E=u?.to?.blockchains,w=zi(void 0),I=zi(void 0),A=zi(void 0),x=zi(void 0);bn(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),bn(()=>{if(m==="success"){r();let b=f.find(B=>B.name===u?.from?.blockchain),v=u?.from?.token,N=v&&h(v);(b||!b&&A.current)&&n(b??null),N?a({token:N,meta:{blockchains:f}}):!N&&w.current&&a({token:null}),A.current=u?.from?.blockchain,w.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,m]),bn(()=>{Es(s,S)&&a({token:null}),bs(l,C)&&n(null)},[S,C]),bn(()=>{Es(c,k)&&a({token:null}),bs(p,E)&&o(null)},[k,E]),bn(()=>{if(m==="success"){r();let b=f.find(B=>B.name===u?.to?.blockchain),v=u?.to?.token,N=v&&h(v);(b||!b&&x.current)&&o(b??null),N?e({token:N,meta:{blockchains:f}}):!N&&I.current&&e({token:null}),x.current=u?.to?.blockchain,I.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,m]),bn(()=>{g(u?.affiliate?.ref??null),d(u?.affiliate?.percent??null),y(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(Em,"useSyncStoresWithConfig");import{useEffect as rl,useRef as Ev}from"react";import{useInRouterContext as bv,useLocation as xv,useSearchParams as Iv}from"react-router-dom";function ol(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(ol,"convertTokenSearchParamToAsset");function nl(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(nl,"tokenToSearchParam");function al(){let t=xv(),[e,o]=Iv(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:m,setInputAmount:f}=G()(),h=T().fetchStatus,g=T().blockchains(),d=bv(),{updateIframe:y,updateCampaignMode:S}=T(),C=T().isInCampaignMode(),k=Ev(),{findToken:E}=T(),w=i(()=>{let A={};for(let[P,Z]of e.entries())(P.startsWith("utm_")||P.startsWith("privy_"))&&(A[P]=Z);let x=e.get("fromAmount"),b=e.get("fromBlockchain"),v=e.get("fromToken"),N=e.get("toBlockchain"),B=e.get("toToken"),_=e.get("autoConnect"),Q=e.get("clientUrl"),V=e.get("liquiditySources"),Y=e.get("blockchain");return{fromAmount:x,fromBlockchain:b,fromToken:v,toBlockchain:N,toToken:B,autoConnect:_,clientUrl:Q,liquiditySources:V,extraQueryParams:A,blockchain:Y}},"getUrlSearchParams"),I=i(A=>{for(let x in A)A[x]||delete A[x];o(A,{replace:!0})},"updateUrlSearchParams");rl(()=>{let{autoConnect:A,clientUrl:x,extraQueryParams:b,blockchain:v}=w();d&&h==="success"&&I({fromBlockchain:n?.name,fromToken:nl(a),toBlockchain:r?.name,toToken:nl(s),fromAmount:c,autoConnect:A??void 0,clientUrl:x??void 0,blockchain:v??void 0,liquiditySources:C?k.current:void 0,...b})},[t.pathname,c,n,a,r,s,C,h]),rl(()=>{if(!d)return;let A=w();if(!k.current&&A.liquiditySources&&(k.current=A.liquiditySources),A.fromAmount&&f(A.fromAmount),h==="success"){let x=g.find(Q=>Q.name===A.fromBlockchain),b=A.fromToken&&x&&ol(A.fromToken,x),v=b?E(b):void 0,N=g.find(Q=>Q.name===A.toBlockchain),B=A.toToken&&N&&ol(A.toToken,N),_=B?E(B):void 0;x&&(l(x),v&&u({token:v,meta:{blockchains:g}})),N&&(p(N),_&&m({token:_,meta:{blockchains:g}}))}},[h]),rl(()=>{let{clientUrl:A,liquiditySources:x}=w();y("clientUrl",A||void 0),S("liquiditySources",x?.split(",")??void 0)},[])}i(al,"useSyncUrlAndStore");import{i18n as An}from"@lingui/core";import{Alert as jw,Button as Xw,darkTheme as Yw,Divider as Dl,DoneIcon as Zw,styled as Jw,TextField as Rw,Typography as eE}from"@rango-dev/ui";import je,{useState as tE}from"react";import{useNavigate as oE,useSearchParams as nE}from"react-router-dom";import{ChevronRightIcon as Av,Divider as Nm,Image as Nv,Typography as Wm}from"@rango-dev/ui";import Nt from"react";import{darkTheme as bm,styled as sl}from"@rango-dev/ui";var xm=sl("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${bm} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${bm} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),Im=sl("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),Am=sl("div",{display:"flex"});function ll(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return Nt.createElement(Im,null,Nt.createElement(Wm,{size:"large",variant:"label"},n),Nt.createElement(Nm,{size:10}),Nt.createElement(xm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},Nt.createElement(Am,null,r&&Nt.createElement(Nt.Fragment,null,Nt.createElement(Nv,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),Nt.createElement(Nm,{size:4,direction:"horizontal"})),Nt.createElement(Wm,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),Nt.createElement(Av,{size:12,color:"black"})))}i(ll,"BlockchainSelectorButton");import{i18n as dl}from"@lingui/core";import{Button as $v,Divider as Dm,MessageBox as Fv}from"@rango-dev/ui";import fo,{useEffect as $m,useState as ml}from"react";import{i18n as Hi}from"@lingui/core";import{Divider as Qo,ExternalLinkIcon as Bv,Image as Lv,InfoIcon as _v,Tooltip as Mv,Typography as Sr}from"@rango-dev/ui";import ge from"react";var Pm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function Bm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Bm,"generateExplorerLink");import{Button as Wv,darkTheme as xn,styled as yr,Typography as Pv}from"@rango-dev/ui";var cl=yr("a",{textDecoration:"none",color:"$colors$neutral700",[`.${xn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${xn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${xn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${xn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Lm=yr("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${xn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${xn} &`]:{color:"$colors$neutral900"}}}),pl=yr(Wv,{minHeight:"$40"}),_m=yr(Pv,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),Mm=yr("div",{display:"flex",justifyContent:"center",alignItems:"center"});var Dv=9;function ul(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=Bm(n.address,s),l=i(()=>window.open(Pm,"_blank"),"onClickLearnMore");return ge.createElement(R,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:W()},ge.createElement(Lm,null,ge.createElement(Lv,{src:n.image===""?si:n.image,size:45,type:"circular"}),ge.createElement(Qo,{size:4}),ge.createElement(Mm,null,ge.createElement(_m,{variant:"title",size:"medium"},n.symbol),n.symbol.length>Dv&&ge.createElement(Mv,{content:n.symbol,container:W()},ge.createElement(_v,{size:12,color:"gray"}))),ge.createElement(Sr,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),ge.createElement(Qo,{size:4}),ge.createElement(Sr,{variant:"body",size:"medium"},c?ge.createElement(cl,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,ge.createElement(Bv,{size:12,color:"gray"})):ge.createElement(cl,null,n.address)),ge.createElement(Qo,{size:4}),n.coinSource&&ge.createElement(Sr,{className:"_coin-source",variant:"body",size:"xsmall"},Hi.t("via")," ",ge.createElement(Sr,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),ge.createElement(Qo,{size:"32"}),ge.createElement(Sr,{size:"medium",variant:"body",className:"_custom-token-description"},Hi.t("This token is not part of our verified token list. please verify its source and make sure to understand all associated risks before proceeding."))),ge.createElement(Qo,{size:40}),ge.createElement(Qo,{size:10}),ge.createElement(pl,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Hi.t("Import Anyway")),ge.createElement(Qo,{size:10}),ge.createElement(pl,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},Hi.t("Learn More")))}i(ul,"CustomTokenModal");function Cr(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:c,onExitErrorModal:l,onExitImportModal:p}=t,{setCustomToken:u}=T(),[m,f]=ml(!1),[h,g]=ml(!1),[d,y]=ml(!1),S=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),C=i(()=>{n?.type!=="network-error"&&s?.(),f(!1)},"closeErrorModal"),k=i(()=>{y(!0),C()},"handleErrorModalButtonClick"),E=i(()=>{d&&n?.type==="network-error"&&(y(!1),S()),l()},"handleExit"),w=i(()=>{e&&(u(e),c())},"handleSubmit");return $m(()=>{n&&f(!0)},[n]),$m(()=>{o&&e&&g(!0)},[o,e]),fo.createElement(fo.Fragment,null,fo.createElement(R,{open:m,dismissible:!0,id:"widget-add-custom-token-modal",onClose:C,onExit:E,container:W()},fo.createElement(Fv,{title:n?.title??"",type:"error",description:n?.message||dl.t("Failed Network, Please retry.")},fo.createElement(Dm,{size:40}),fo.createElement(Dm,{size:10}),fo.createElement($v,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:k},n?.type==="network-error"?dl.t("Retry"):dl.t("Add another custom token")))),o&&e&&fo.createElement(ul,{blockchain:o,token:e,onSubmitClick:w,onClose:()=>g(!1),open:h,onExit:p}))}i(Cr,"ImportCustomToken");import{useManager as Hw}from"@rango-dev/queue-manager-react";import{BottomLogo as Qw,Divider as Sf,Header as qw}from"@rango-dev/ui";import Pe,{useEffect as Ji,useLayoutEffect as Gw,useRef as Cf,useState as Tf}from"react";import{useRef as Ov}from"react";function Qi(){return window.self!==window.top}i(Qi,"isAppLoadedIntoIframe");function fl(){let t=Ov(null),{iframe:e}=T(),o=Qi()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(c=>{for(let l of c)n({type:"widget_height",data:{height:l.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(fl,"useIframe");import{useNavigate as Uv}from"react-router-dom";function Ke(){let t=Uv();return()=>t(-1)}i(Ke,"useNavigateBack");import{createTheme as kl,darkTheme as Rv,lightTheme as ew}from"@rango-dev/ui";import{useEffect as tw,useState as ow}from"react";import{theme as Zv,darkColors as Jv}from"@rango-dev/ui";import Cl from"react";var qi=16,Gi=255,Fm=.11;function zv(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(zv,"expandShortHexColor");function Hv(t,e){return t.padStart(e,"0")}i(Hv,"pad");function gl(t){let e=Math.min(Math.max(Math.round(t),0),Gi);return Hv(e.toString(qi),2)}i(gl,"intToHex");function Qv(t){return`#${gl(t.red)}${gl(t.green)}${gl(t.blue)}`}i(Qv,"rgbToHex");function qv(t){let e=parseInt(t.slice(1,3),qi),o=parseInt(t.slice(3,5),qi),n=parseInt(t.slice(5,7),qi);return{red:e,green:o,blue:n}}i(qv,"hexToRGB");function Gv(t,e){let o=1-Fm*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(Gv,"generateShade");function Vv(t,e){let o=Fm*e;return{red:t.red+(Gi-t.red)*o,green:t.green+(Gi-t.green)*o,blue:t.blue+(Gi-t.blue)*o}}i(Vv,"generateTint");function Kv(t){return Om(t,Gv)}i(Kv,"calculateShades");function jv(t){return Om(t,Vv)}i(jv,"calculateTints");function Om(t,e){let o=qv(t),n=[];for(let r=1;r<9;r++)n.push(Qv(e(o,r)));return n}i(Om,"calculateColors");function hl(t,e,o){let a=jv(t).reverse().concat(t),s=Kv(t),c=a.concat(s),l={},p=c.length;for(let u=0;u<p;u++){let m=100+(o?p-1-u:u)*50,f=c[u];f&&(l[`${e}${m}`]=f)}return l}i(hl,"createTintsAndShades");function yl(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)&&!Pu(r)){let l=zv(a);Object.assign(n,hl(l,r,s))}}return{...n,...e}}i(yl,"expandToGenerateThemeColors");var Um=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),Xv=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Um(o%52)+e;return Um(o%52)+e},"toAlphabeticName"),Yv=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Sl=i(t=>Xv(Yv(5381,JSON.stringify(t))>>>0),"toHash");function Tl(t){let e=Zv.colors,o={...e,...Jv},n,r;if(t?.light){let s={colors:yl(e,t.light)};n={id:`${ws}-light-${Sl(s)}`,tokens:s}}if(t?.dark){let s={colors:yl(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ws}-dark-${Sl(s)}`,tokens:s}}return{light:n,dark:r}}i(Tl,"customizedThemeTokens");function zm(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Cl.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Cl.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(Cl.cloneElement(e,{key:c}))}}),o}i(zm,"joinList");function Hm(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Hm,"doesWindowPreferDarkColorScheme");function go(t){let{colors:e,fontFamily:o=mu,borderRadius:n=qu,secondaryBorderRadius:r=Gu}=t,[a,s]=ow(Hm()?"dark":"light"),{theme:c}=T(),{dark:l,light:p}=Tl(e),u=kl({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[u.className,ew.className],f=[u.className,Rv.className];if(p){let g=kl(p.id,p.tokens);m.push(g.className)}if(l){let g=kl(l.id,l.tokens);f.push(g.className)}return tw(()=>{let g=i(d=>{d.matches?s("dark"):s("light")},"switchThemeListener");return Hm()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=m.join(" "),d=f.join(" ");return c==="auto"?a==="dark"?d:g:c==="dark"?d:g},"getActiveTheme"),mode:c==="auto"?a:c}}i(go,"useTheme");var bt=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 Qm}from"@lingui/core";import{Alert as nw,Button as rw}from"@rango-dev/ui";import qm from"react";function vl(t){return qm.createElement(nw,{action:qm.createElement(rw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Qm.t("Activate this tab")),type:"warning",variant:"alarm",title:Qm.t("Another tab is open and handles transactions.")})}i(vl,"ActivateTabAlert");import{i18n as wl}from"@lingui/core";import{Button as iw,Divider as aw,MessageBox as sw}from"@rango-dev/ui";import Vi from"react";function El(t){let{open:e,onClose:o,onConfirm:n}=t;return Vi.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:W()},Vi.createElement(sw,{title:wl.t("Activate current tab"),type:"warning",description:wl.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.")},Vi.createElement(aw,{size:20}),Vi.createElement(iw,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},wl.t("Confirm"))))}i(El,"ActivateTabModal");import{ChevronLeftIcon as pw}from"@rango-dev/ui";import Jm from"react";import{css as lw,darkTheme as Gm,IconButton as cw,styled as qo}from"@rango-dev/ui";var Ft=qo(cw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Gm} &`]:{backgroundColor:"$neutral"}}}),Vm=qo("div",{position:"absolute",background:"$secondary500",[`.${Gm} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),ho=qo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Km=qo("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"}}}}),jm=qo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Xm=qo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Ym=lw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Zm=qo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function bl(t){return Jm.createElement(Ft,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Jm.createElement(pw,{color:"black",size:16}))}i(bl,"BackButton");import{i18n as uw}from"@lingui/core";import{Button as dw,Typography as mw}from"@rango-dev/ui";import xl from"react";function Il(t){return xl.createElement(ho,null,xl.createElement(dw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},xl.createElement(mw,{variant:"label",size:"medium",color:"error500"},uw.t("Cancel"))))}i(Il,"CancelButton");import{i18n as fw}from"@lingui/core";import{Image as gw,Tooltip as hw,WalletIcon as yw,WalletState as Rm}from"@rango-dev/ui";import Go from"react";function Al(t){let{list:e}=It(),o=e.filter(r=>r.state===Rm.CONNECTED||r.state===Rm.PARTIALLY_CONNECTED),n=o.length?Go.createElement("div",{className:Ym()},o.map(r=>Go.createElement(Zm,{key:r.title},Go.createElement(gw,{src:r.image,size:14})))):fw.t("Connect Wallet");return Go.createElement(hw,{container:t.container,side:"bottom",content:n},Go.createElement(Ft,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&Go.createElement(Vm,null),Go.createElement(yw,{size:18,color:"black"})))}i(Al,"WalletButton");import{i18n as ji}from"@lingui/core";import{NotificationsIcon as Lw,Popover as _w,SettingsIcon as Mw,Tooltip as Xi,TransactionIcon as Dw}from"@rango-dev/ui";import _e from"react";import{Notifications as kw}from"@rango-dev/ui";import vw from"react";import{useNavigate as ww}from"react-router-dom";import{create as Sw}from"zustand";import{persist as Cw,subscribeWithSelector as Tw}from"zustand/middleware";var We=uo(Sw()(Cw(Tw((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1];if(!r||!a)return;let 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}}},c=e().notifications.filter(l=>l.requestId!==n.requestId);t(()=>({notifications:[...c,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(l=>l.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 Nl(){let t=ww(),{getNotifications:e,clearNotifications:o}=We(),n=e(),r=T().blockchains(),{findToken:a}=T();return vw.createElement(kw,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>tu(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${O.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(Nl,"NotificationContent");import{useManager as Ew}from"@rango-dev/queue-manager-react";import{InProgressIcon as bw}from"@rango-dev/ui";import ef from"react";var xw=i(()=>{let{manager:t}=Ew();return bt(t).map(({swap:o})=>o).find(o=>o.status==="running")?ef.createElement(Xm,{id:"widget-header-history-badge-container"},ef.createElement(bw,{color:"info",size:6})):null},"InProgressTransactionBadge"),tf=xw;import{EventSeverity as Iw}from"@rango-dev/queue-manager-rango-preset";import{Typography as Aw}from"@rango-dev/ui";import of from"react";function nf(){let{getNotifications:t}=We(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===Iw.WARNING);return o?of.createElement(Km,{isSever:n},of.createElement(Aw,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(nf,"NotificationsBadge");import{RefreshProgressButton as Nw}from"@rango-dev/ui";import Wl,{useEffect as Ww,useState as rf}from"react";var Pw=1e3,af=60,Bw=100;function Ki({onClick:t}){let[e,o]=rf(0),[n,r]=rf(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");Ww(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===af&&c()},Pw):s(l),document.addEventListener("visibilitychange",()=>a(l)),()=>{document.removeEventListener("visibilitychange",()=>a(l)),l&&clearInterval(l)}},[e,t]);let s=i(l=>{l&&clearInterval(l),o(0)},"clearTimeout"),c=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return Wl.createElement(Ft,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},Wl.createElement(jm,{onTransitionEnd:()=>r(!1),isRefetched:n},Wl.createElement(Nw,{size:22,color:t?"black":"gray",progress:e/af*Bw})))}i(Ki,"RefreshButton");function Vo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=T(),c=it("notification",s)||r.includes("notifications");return _e.createElement(_e.Fragment,null,!r.includes("refresh")&&_e.createElement(Xi,{container:a||W(),side:"top",content:ji.t("Refresh")},_e.createElement(Ki,{onClick:e})),!c&&_e.createElement(_w,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:W(),content:_e.createElement(Nl,null)},_e.createElement("div",null,_e.createElement(Xi,{container:W(),side:"top",content:ji.t("Notifications")},_e.createElement(Ft,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},_e.createElement(Lw,{size:18,color:"black"}),_e.createElement(nf,null))))),!r.includes("settings")&&_e.createElement(Xi,{container:W(),side:"top",content:ji.t("Settings")},_e.createElement(Ft,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},_e.createElement(Mw,{size:18,color:"black"}))),!r.includes("history")&&_e.createElement(Xi,{container:W(),side:"top",content:ji.t("History")},_e.createElement(Ft,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},_e.createElement(Dw,{size:18,color:"black"}),_e.createElement(tf,null))))}i(Vo,"HeaderButtons");import{i18n as Pl}from"@lingui/core";import{Divider as lf,MessageBox as Ow,RefreshIcon as Uw}from"@rango-dev/ui";import In from"react";import{Button as $w,styled as Fw}from"@rango-dev/ui";var sf=Fw($w,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function Bl(t){let{open:e,onClose:o}=t;return In.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:W()},In.createElement(Ow,{title:Pl.t("Something went wrong"),type:"error",description:Pl.t("Something went wrong. Please refresh the app.")},In.createElement(lf,{size:30}),In.createElement(sf,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},In.createElement(Uw,{size:20,color:"primary"}),In.createElement(lf,{size:4,direction:"horizontal"}),Pl.t("Refresh"))))}i(Bl,"RefreshModal");var cf="700px",pf="425px",uf="550px",df="640px",mf="800px";function Ll(t){let e=t.target;if(e){let o=e.scrollTop,n=W();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(Ll,"onScrollContentAttachStatusToContainer");import{css as zw,styled as Yi}from"@rango-dev/ui";var Zi=zw({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),ff=Yi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",maxHeight:cf,variants:{height:{auto:{height:"auto"},fixed:{height:"100%",minHeight:pf,[`@media screen and (min-height: ${mf})`]:{minHeight:uf}}},showBanner:{true:{overflow:"visible"}}}}),gf=Yi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),hf=Yi("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"}}}),yf=Yi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function se(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=fl(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=T(),[u,m]=Tf(!1),{config:{features:f,theme:h}}=T(),{watermark:g}=oe(),d=g==="FULL",{activeTheme:y}=go(h||{}),[S,C]=Tf(!1),k=it("connectWalletButton",f),{isActiveTab:E,tabManagerInitiated:w,showActivateTabModal:I,setShowActivateTabModal:A,activateCurrentTab:x,setShowCompactTokenSelector:b}=oe(),v=Ke(),{manager:N}=Hw(),_=bt(N).map(({swap:X})=>X).some(X=>X.status==="running"),Q=i(()=>x(Fo.forceClaim,_),"onActivateTab"),V=i(()=>{r.onWallet?.()},"onConnectWallet"),Y=typeof r.hasBackButton>"u"||r.hasBackButton,P=Cf(null),Z=Cf(null);return Ji(()=>{let X=(p?.swapBoxBanner?.routes?.length??0)===0,ie=!!p?.swapBoxBanner?.routes?.some(Te=>location.pathname.endsWith(Te));C(!!p?.swapBoxBanner&&(X||ie))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Ji(()=>(Qi()&&Z.current&&e(Z.current),()=>{o()}),[]),Ji(()=>(P.current?.addEventListener("scroll",Ll),()=>{P.current?.removeEventListener("scroll",Ll)}),[]),Ji(()=>{m(c==="failed")},[c]),Gw(()=>{if(!Z.current)return;let X=new ResizeObserver(ie=>{for(let Te of ie)Te.contentRect&&b(Te.contentRect.height<parseInt(df))});return X.observe(Z.current),()=>X.disconnect()},[]),Pe.createElement(ff,{height:s,id:rt.SWAP_BOX_ID,className:`${y()} ${Zi()}`,ref:Z,showBanner:S},Pe.createElement(qw,{prefix:Y?Pe.createElement(bl,{onClick:()=>{v(),r.onBack?.()}}):null,title:r.title,suffix:Pe.createElement(Pe.Fragment,null,r.suffix,r.onWallet&&!k&&Pe.createElement(Al,{container:W(),onClick:V,isConnected:!!l?.length}),r.onCancel&&Pe.createElement(Il,{onClick:r.onCancel}))}),Pe.createElement(gf,{ref:P},n),Pe.createElement(El,{open:I,onClose:()=>A(!1),onConfirm:Q}),Pe.createElement(hf,null,Pe.createElement("div",{className:"footer__content"},w&&!E&&Pe.createElement("div",{className:"footer__alert"},Pe.createElement(vl,{onActivateTab:Q}),Pe.createElement(Sf,{size:10})),a),Pe.createElement(Sf,{size:12}),Pe.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},Pe.createElement(Qw,null))),S&&Pe.createElement(yf,null,p?.swapBoxBanner?.element),Pe.createElement(Bl,{open:u,onClose:()=>m(!1)}))}i(se,"Layout");import{styled as Vw}from"@rango-dev/ui";var kf="$20 $20 $10 $20",_l=Vw("div",{padding:kf,overflowY:"auto",flexGrow:1});import{styled as Kw}from"@rango-dev/ui";var pe=Kw("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 yo}from"@lingui/core";import{useState as Ml}from"react";function vf(){let[t,e]=Ml(!1),[o,n]=Ml(null),[r,a]=Ml(null),{findToken:s}=T(),c=T().customTokens(),l=i(()=>{a(null),e(!1),n(null)},"resetState");function p(m,f){switch(m){case"duplicated":return{type:m,title:yo.t("Duplicate Token"),message:yo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:m,title:yo.t("Token Already Exists"),message:yo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{type:m,title:yo.t("Token Not Found"),message:yo.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:f}})};case"network-error":return{type:m,title:yo.t("Network error"),message:yo.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:m,tokenAddress:f})=>{e(!0);try{if(c.some(S=>S.address?.toLowerCase()===f.toLowerCase())){let S=p("duplicated");n(S);return}let g=await gt().getCustomToken({blockchain:m,address:f});if(!g||!g.token||g.error){let S=p("not-found",m);n(S);return}let d=g.token;if(s({blockchain:d.blockchain,address:d.address,symbol:d.symbol})){let S=p("token-exist");n(S);return}return a({...d,warning:!0})}catch(h){if(h.code==="ERR_BAD_REQUEST"){let g=p("not-found",m);n(g);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:l}}i(vf,"useFetchCustomToken");var rE=Jw("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $12",backgroundColor:"$neutral300","& input":{padding:"0"},[`.${Yw} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function wf(){let t=oE(),[e]=nE(),o=Ke(),n=T().blockchains(),r=e.get("blockchain")||"",a=Po(r,n),[s,c]=tE(""),{fetchCustomToken:l,token:p,loading:u,error:m,resetState:f}=vf(),h=!!a&&Bo(a,s),g=!a||!s||!h,d=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return je.createElement(se,{header:{title:An.t("Add Custom Token")}},je.createElement(pe,null,je.createElement(rE,null,je.createElement("div",null,je.createElement(ll,{onClick:()=>t(O.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:An.t("Select chain"),placeholder:An.t("Select chain")}),je.createElement(Dl,{size:"24"}),je.createElement(eE,{size:"large",variant:"label"},An.t("Enter Address")),je.createElement(Dl,{size:10}),je.createElement(Rw,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:An.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&je.createElement(Zw,{color:"success",size:12}),onChange:y=>c(y.target.value)}),!h&&!!s&&je.createElement(je.Fragment,null,je.createElement(Dl,{size:4}),je.createElement(jw,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),je.createElement(Xw,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:d},An.t("Import"))),je.createElement(Cr,{token:p,blockchain:a??void 0,address:s,error:m??void 0,fetchCustomToken:l,onCloseErrorModal:()=>{m?.type!=="network-error"&&c("")},onImport:o,onExitErrorModal:f,onExitImportModal:f})))}i(wf,"AddCustomTokenPage");import{i18n as yc}from"@lingui/core";import{useManager as Kb}from"@rango-dev/queue-manager-react";import{Alert as jb,Button as Xb,css as Cc,Divider as Sc,IconButton as yh,styled as Yb,Typography as Zb,WalletIcon as Jb}from"@rango-dev/ui";import $e,{useEffect as Ia,useLayoutEffect as Rb,useRef as ex,useState as Pr}from"react";import{useNavigate as tx}from"react-router-dom";import{i18n as Ko}from"@lingui/core";import{Alert as AE,BalanceErrors as NE,Button as Zf,ChevronLeftIcon as WE,Divider as ql,MessageBox as PE,Typography as Gl}from"@rango-dev/ui";import re,{useCallback as BE,useEffect as ia,useMemo as LE,useRef as _E,useState as Bn}from"react";import{useNavigate as ME}from"react-router-dom";import{i18n as Ul}from"@lingui/core";import{Alert as cE,ChevronDownIcon as pE,CloseIcon as uE,Divider as Wf,IconButton as Pf,PasteIcon as dE,Typography as mE,WalletIcon as fE}from"@rango-dev/ui";import Me,{useEffect as Bf,useRef as Lf}from"react";import oa,{useRef as sE}from"react";import*as Nn from"@radix-ui/react-collapsible";import{keyframes as Ef,styled as Ri}from"@rango-dev/ui";var $l=300,iE=Ef({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),aE=Ef({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),bf=Ri(Nn.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Fl=Ri(Nn.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),ea=Ri(Nn.Content,{overflow:"hidden",variants:{open:{true:{animation:`${iE} ${$l}ms ease-out`},false:{animation:`${aE} ${$l}ms ease-out`}}}}),ta=Ri("div",{transition:`all ${$l}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function na(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=sE(null);return oa.createElement(bf,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&oa.createElement(Fl,{className:"collapsible_trigger",onClick:a},s),oa.createElement(ea,{className:"collapsible_content",open:e},r),c==="bottom"&&oa.createElement(Fl,{className:"collapsible_trigger",onClick:a},s))}i(na,"CustomCollapsible");import{darkTheme as xf,styled as Ol,TextField as lE}from"@rango-dev/ui";var If=Ol("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"},"& input":{padding:"$15"}}),Af=Ol(lE,{backgroundColor:"$neutral100"}),Nf=Ol("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${xf} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${xf} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function _f(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=G()(),{config:s}=T(),c=T().blockchains(),l=ii(e.name,c),p=Lf(null),u=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!Bo(e,r),g=i(()=>{a("")},"handleClear"),d=i(async C=>{if(C.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),p?.current?.focus()}},"handlePaste"),y=i(()=>r?Me.createElement(Pf,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Me.createElement(uE,{size:12,color:"gray"})):m?null:Me.createElement(Pf,{id:"widget-custom-destination-paste-icon-btn",onClick:d,variant:"ghost"},Me.createElement(dE,{size:16})),"renderSuffix");Bf(()=>{!!u&&r===null&&(a(u),o(!0))},[u]);let S=Lf(null);return Bf(()=>{if(!r){S.current=null;return}n&&Bo(e,r)&&S.current!==r&&(S.current=r,ee({type:"destinationAddressSet",payload:{destinationChain:e.name}}))},[r,n,e]),Me.createElement(If,null,Me.createElement(na,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(Nf,{id:"widget-custom-destination-collapsible-btn"},Me.createElement("div",{className:"button__content"},Me.createElement(fE,{size:18,color:"info"}),Me.createElement(Wf,{size:4,direction:"horizontal"}),Me.createElement(mE,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ul.t("Send to a different address"))),Me.createElement(ta,{orientation:n?"up":"down"},Me.createElement(pE,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(Af,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ul.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:y(),onChange:C=>{let k=C.target.value;a(k)}})),h&&Me.createElement(Me.Fragment,null,Me.createElement(Wf,{size:4}),Me.createElement(cE,{variant:"alarm",type:"error",title:Ul.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(_f,"CustomDestination");import{css as gE,IconButton as hE,SelectableWalletButton as yE,styled as So}from"@rango-dev/ui";var Mf=So("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Df=So("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),$f=So(yE,{justifyContent:"center"}),Ff=So("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),Of=So(hE,{position:"absolute",left:"$20"}),Uf=So("div",{paddingTop:"$20"}),zf=gE({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Hf=So("div",{display:"flex"}),Qf=So("div",{overflow:"visible",width:"100%"});import{i18n as Hl}from"@lingui/core";import{warn as vE}from"@rango-dev/logging-core";import{Divider as wE,makeInfo as EE,SelectableWallet as bE,Typography as Xf,WalletState as Pn}from"@rango-dev/ui";import ct,{useEffect as Yf,useState as kr}from"react";import{Image as TE,MessageBox as kE}from"@rango-dev/ui";import Tr from"react";import{keyframes as SE,styled as zl}from"@rango-dev/ui";var qf=zl("div",{position:"relative"}),CE=SE({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Gf=zl("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${CE} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Vf=zl("div",{"& img":{borderRadius:"50%"}});import{i18n as Wn}from"@lingui/core";function Kf(t,e){switch(t){case"in-progress":return{type:"loading",title:Wn.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Wn.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Wn.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Wn.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Wn.t("Request Rejected"),description:Wn.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(Kf,"generateMessageByStatus");function jf(t){let{status:e,displayName:o,image:n}=t,r=Kf(e,o),a=e=="in-progress";return Tr.createElement(kE,{type:r.type,title:r.title,description:r.description,icon:a?Tr.createElement(qf,null,Tr.createElement(Vf,null,Tr.createElement(TE,{src:n,size:45})),Tr.createElement(Gf,null)):void 0})}i(jf,"ExperimentalChainStatus");var xE=7,IE=3e3;function Ql(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=oe.use.isActiveTab(),{blockchains:l,connectedWallets:p}=T(),[u,m]=kr(),[f,h]=kr(null),[g,d]=kr(!1),[y,S]=kr(null),{suggestAndConnect:C}=ra(),{list:k}=It({chain:e}),[E,w]=kr(k),I=k.length,A=a&&I-a>0,x=i(async v=>{d(!1),S("in-progress");try{let N=k.find(V=>V.type===V.type),B=N?.isHub?N.properties?.find(V=>V.name==="namespaces")?.value:N?.needsNamespace,_=l(),Q=B?.data.find(V=>V.getSupportedChains(_).some(Y=>Y.name===v.chain));if(!Q)throw new Error("Requested chain is not supported");await C(v.walletType,{namespace:Q.value,network:v.chain}),S("completed")}catch{S("rejected")}},"addExperimentalChain");Yf(()=>{w(v=>{let N=k.findIndex(B=>n(B.type,e));return A&&N>1?[k[N]].concat(k.filter((B,_)=>_!==N)):v.map(B=>k.find(_=>_.type===B.type)??B)})},[JSON.stringify(k)]);let b=document.getElementById(rt.SWAP_BOX_ID);return Yf(()=>{let v=null;return(y==="completed"||y==="rejected")&&(v=setTimeout(()=>S(null),IE)),()=>{v&&clearTimeout(v)}},[y]),ct.createElement(ct.Fragment,null,E.slice(0,a).map(v=>{let N=Ou({connectedWallets:p,walletType:v.type,chain:e}),B=v.state===Pn.CONNECTED||v.state===Pn.PARTIALLY_CONNECTED,_=N?po(N,xE):"",Q=B&&!!v.needsNamespace&&!_,V=gi(l(),e),Y=!p.find(me=>me.walletType===v.type&&me.chain===e),P=V&&Y&&v.state===Pn.CONNECTED,Z=i(async()=>{v.state===Pn.DISCONNECTED||Q&&!P?m(v):P?(h({walletType:v.type,chain:e,address:N??""}),d(!0)):r({walletType:v.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=EE(v.state),ie=i(()=>P?Hl.t({id:"Add {chain} chain",values:{chain:e}}):Q?Hl.t("Chain not connected"):_||X.description,"getWalletDescription"),Te=i(()=>v.state===Pn.CONNECTED||v.state===Pn.PARTIALLY_CONNECTED?Q?"neutral600":"neutral700":X.color,"getWalletDescriptionColor"),dt=f?.chain?ii(f.chain,l()):void 0;return ct.createElement(ct.Fragment,{key:`${v.title}_${dt}`},!!f&&ct.createElement(R,{id:"widget-wallets-list-watermarked-modal",open:!!f&&g,container:b,onClose:()=>{h(null)}},ct.createElement(Xs,{id:"widget-wallets-list-experimental-chain-container",displayName:dt,onConfirm:()=>{x(f)}})),y&&ct.createElement(R,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!y,onClose:S.bind(null,null),container:b},ct.createElement(jf,{status:y,displayName:dt,image:v.image}),ct.createElement(wE,{direction:"vertical",size:32})),ct.createElement(bE,{key:v.type,id:"widget-wallets-list-selectable-wallet-btn",description:ie(),descriptionColor:Te(),onClick:Z,selected:n(v.type,e),disabled:!c,...v}))}),ct.createElement(fr,{id:"widget-wallets-list-stateful-connect-modal",wallet:u,options:{defaultSelectedChains:o||[e]},onClose:()=>{m(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):vE(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),A&&ct.createElement($f,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},ct.createElement(Xf,{variant:"label",size:"medium"},Hl.t("Show more wallets"),ct.createElement(Xf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(a??0)))))}i(Ql,"WalletList");var DE=2;function Jf(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=ME(),c=T().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:m,customDestination:f,setCustomDestination:h}=G()(),{config:g,connectedWallets:d,setWalletsAsSelected:y}=T(),[S,C]=Bn(""),[k,E]=Bn([]),[w,I]=Bn(""),[A,x]=Bn(!!f),b=LE(()=>Mo({filter:"all",quote:l}),[l]),v=Mo({filter:"required",quote:l}),N=c.find(z=>z.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),B=i(z=>v.includes(z),"isWalletRequiredFor"),_=BE(()=>d.filter(z=>z.selected&&b.includes(z.chain)),[d,b]),[Q,V]=Bn(_()),[Y,P]=Bn([]),Z=i((z,q)=>P($=>$.concat({blockchain:z,walletType:q})),"addNextSelectedWallets"),X=k.length>0,ie=i((z,q)=>!!Q.find($=>$.walletType===z&&$.chain===q&&$.selected&&(B(q)||!B(q)&&!f)),"isSelected"),Te=i((z,q,$)=>{let M=!1;return z.map(ce=>{if(ce.chain===q){let H=ce.selected;return!M&&$?(M=!0,H=!0):$||(H=!1),{...ce,selected:H}}return ce})},"updateSelectableWallets"),dt=i(z=>{x(z),z?B(N?.name??"")||V(q=>Te(q,N?.name||"",!1)):(h(""),V(q=>Te(q,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),me=i(z=>{if(S&&C(""),ie(z.walletType,z.chain))return;let $=d.find(M=>M.walletType===z.walletType&&M.chain===z.chain);$&&(n(),z.chain===N?.name&&A&&!B(N.name)&&(x(!1),h(null)),V(M=>M.filter(ce=>ce.chain!==z.chain).concat({...$,selected:!0})))},"onChange"),Oe=i(()=>{let z=Q.filter(q=>q.selected);ee({type:"swapWalletsConfirmed",payload:{routeId:l?.requestId??""}}),y(z),p(z),m(!0),o()},"onConfirmBalance"),Qe=i(async()=>{E([]),I("");let z=await r?.({selectedWallets:Q.filter($=>$.selected),customDestination:f}),q=z.warnings;q?.balance?.messages&&E(q.balance.messages),z.error&&I(Od(z.error)),!z.error&&!q?.balance?.messages.length?Oe():E(q?.balance?.messages??[])},"onConfirmWallets");ia(()=>{V(z=>{let q=[];return z.forEach($=>{!d.some(ce=>ce.chain===$.chain&&ce.walletType===$.walletType&&ce.address===$.address)||q.push($)}),q=q.concat(d.filter($=>!!!q.find(ce=>ce.chain===$.chain)&&$.selected&&b.includes($.chain))),q})},[d,b]),ia(()=>{let z=[];Y.length>0&&(Y.forEach(q=>{let $=d.find(M=>M.chain===q.blockchain&&M.walletType===q.walletType);$?me($):z.push(q)}),P(z))},[d,Y]);let kt=l?.requestId??"",ot=_E(!1);ia(()=>{if(e&&!ot.current){ot.current=!0;let z=v.filter(q=>!d.some($=>$.chain===q));ee({type:"swapWalletsModalShown",payload:{chainsRequired:v.length,chainsPending:z.length}})}else e||(ot.current=!1)},[e,v,d]),ia(()=>{X&&ee({type:"gasWarningShown",payload:{routeId:kt}})},[X,kt]);let Ee=document.getElementById(rt.SWAP_BOX_ID);return re.createElement(R,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:Ee,...!S&&{styles:{container:{height:"100%"}},footer:re.createElement(Hf,null,re.createElement(Zf,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:fm(a,A,f,l,Q,N),onClick:Qe,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ko.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:re.createElement(Ff,null,re.createElement(Of,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},re.createElement(WE,{size:16})),re.createElement(Gl,{variant:"headline",size:"small"},Ko.t({id:"Your {blockchainName} wallets",values:{blockchainName:vt(S,c)}})))},anchor:"center"},re.createElement(R,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:X,onClose:E.bind(null,[]),container:Ee},re.createElement(PE,{title:Ko.t("Insufficient account balance"),type:"error",description:re.createElement(NE,{messages:k??[]})},re.createElement(Zf,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>{ee({type:"gasWarningBypassed",payload:{routeId:kt}}),Oe()}},Ko.t("Proceed anyway")))),S&&re.createElement(Uf,null,re.createElement("div",{className:zf()},re.createElement(Ql,{chain:S,quoteChains:b,isSelected:ie,selectWallet:me,onShowMore:()=>C(S),onConnect:z=>{Z(S,z)}}))),!S&&re.createElement(re.Fragment,null,w&&re.createElement(re.Fragment,null,re.createElement(AE,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ko.t(w)}),re.createElement(ql,{size:12})),re.createElement(Qf,null,b.map((z,q)=>{let $=c.find(ae=>ae.name===z),M=`wallet-${q}`,ce=q===b.length-1,H=ce&&N&&g?.customDestination!==!1;return re.createElement("div",{key:M},re.createElement(Mf,null,re.createElement(Gl,{variant:"title",size:"xmedium"},Ko.t({id:"Your {blockchainName} wallets",values:{blockchainName:$?.shortName}})),re.createElement(Gl,{variant:"label",color:"$neutral700",size:"medium"},Ko.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:$?.shortName}}))),re.createElement(ql,{size:24}),re.createElement(Df,null,re.createElement(Ql,{chain:z,quoteChains:b,isSelected:ie,selectWallet:me,limit:DE,onShowMore:()=>C($?.name??""),onConnect:ae=>{Z(z,ae)}})),!ce&&re.createElement(ql,{size:32}),H&&re.createElement(_f,{blockchain:N,open:A,handleOpenChange:dt}))}))))}i(Jf,"ConfirmWalletsModal");import{i18n as lb}from"@lingui/core";import{Alert as cb,Button as pb,Divider as Sg,InfoIcon as ub}from"@rango-dev/ui";import Ue from"react";import{Alert as OE,Button as UE,Divider as jl,NoRouteIcon as zE,RefreshIcon as HE,Typography as ig}from"@rango-dev/ui";import ht from"react";import{i18n as Rf}from"@lingui/core";var $E=24,FE=60;function eg(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:ne().genericServerError,action:{onClick:n,title:Rf.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:ne().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Rf.t("Reset")}},description:ne().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:ne().noResultError.description}}i(eg,"makeInfo");var Vl=(o=>(o[o.small=$E]="small",o[o.large=FE]="large",o))(Vl||{}),Kl=(o=>(o.small="small",o.large="medium",o))(Kl||{});import{styled as aa}from"@rango-dev/ui";var tg=aa("div",{display:"flex",flexDirection:"column",alignItems:"center"}),og=aa("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),ng=aa("div",{variants:{size:{small:{width:"100%"},large:{}}}}),rg=aa("div",{padding:"$6 $0"});function vr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=T().getDisabledLiquiditySources(),s=T().toggleAllLiquiditySources,c=T().swappers(),l=eg(o,a,()=>s(c,!0),e);return r&&(l.alert=null),ht.createElement(tg,{id:"widget-no-result-container"},ht.createElement(zE,{size:Vl[n],color:"gray"}),ht.createElement(jl,{size:4}),ht.createElement(ig,{variant:"title",size:Kl[n]},ne().noResultError.title),n==="large"&&ht.createElement(jl,{size:4}),!!l.description&&ht.createElement(og,{size:n},ht.createElement(ig,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),ht.createElement(jl,{size:n==="large"?"24":"4"}),!!l.alert&&ht.createElement(ng,{size:n},ht.createElement(OE,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&ht.createElement(UE,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:ht.createElement(rg,null,ht.createElement(HE,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(vr,"NoResult");import{i18n as wr}from"@lingui/core";import{Button as YE,Divider as ZE,MessageBox as JE,Typography as RE,WarningIcon as eb}from"@rango-dev/ui";import Jt from"react";import{InfoIcon as VE,Tooltip as KE,Typography as jE}from"@rango-dev/ui";import Ln from"react";import{Button as QE,darkTheme as qE,styled as jo,Typography as GE}from"@rango-dev/ui";var ag=jo("div",{width:"100%"}),Xl=jo("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),sg=jo("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${qE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),lg=jo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),cg=jo(GE,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),pg=jo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),ug=jo(QE,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var XE=35;function dg(t){let{title:e,value:o,valueColor:n}=t,r=W();return Ln.createElement(sg,null,Ln.createElement(jE,{size:"medium",variant:"label",className:"_title"},e),Ln.createElement(lg,null,Ln.createElement(cg,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`),o.length>XE&&Ln.createElement(KE,{content:o,container:r},Ln.createElement(VE,{size:12,color:"gray"}))))}i(dg,"QuoteErrorsModalItem");function mg(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",c=[{title:wr.t("Swapping"),value:D(r.inputUsdValue)},{title:wr.t("Gas cost"),value:D(r.totalFee,2,2)},{title:wr.t("Receiving"),value:D(r.outputUsdValue)},{title:wr.t("Price impact"),value:D(r.priceImpact,2,2),valueColor:`${s}500`}];return Jt.createElement(R,{id:"widget-high-value-loss-warning-modal",footer:Jt.createElement(YE,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Jt.createElement(eb,null),fullWidth:!0,disabled:a,onClick:n},ne().highValueLossError.confirmMessage),open:e,onClose:o,container:W()},Jt.createElement(JE,{type:s,title:ne().highValueLossError.impactTitle,description:ne().highValueLossError.description}),Jt.createElement(Xl,null,Jt.createElement(ZE,{size:"4"}),Jt.createElement(RE,{size:"small",variant:"title"},wr.t("Details")),Jt.createElement(Xl,null,c.map((l,p)=>Jt.createElement(dg,{key:p,...l})))))}i(mg,"HighValueLossWarningModal");import{i18n as _n}from"@lingui/core";function fg(t,e){let o={alertType:"warning",title:"",action:null,actionButtonTitle:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=_n.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=_n.t("Increase")),o;if(t){switch(t.type){case 0:{Zt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=ne().highValueLossError.title;break}case 4:{o.title=_n.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=ne().unknownPriceError.title;break}case 2:{o.title=_n.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=_n.t("Increase");break}case 3:{o.title=_n.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(fg,"makeAlerts");function gg(t,e){return e?.type===4?Number(e.minRequiredSlippage):t?.type===2?Number(t.minRequiredSlippage):null}i(gg,"getRequiredSlippage");import{i18n as Mn}from"@lingui/core";import{Button as tb,Divider as Yl,MessageBox as ob,WarningIcon as nb}from"@rango-dev/ui";import ko from"react";import{useNavigate as rb}from"react-router-dom";function hg(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=rb();return ko.createElement(R,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:W(),onClose:o},ko.createElement(ob,{type:"warning",title:r.type===3?Mn.t("High slippage"):Mn.t("Low slippage"),description:r.type===3?Mn.t("Caution, your slippage is high. Your trade may be front run."):Mn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},ko.createElement(Yl,{size:18}),ko.createElement(Yl,{size:32}),ko.createElement(ug,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:a,onClick:n},ko.createElement(nb,{color:"white",size:16}),Mn.t("Swap anyway")),ko.createElement(Yl,{size:10}),ko.createElement(tb,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+O.settings)},Mn.t("Change Slippage"))))}i(hg,"SlippageWarningModal");import{Button as ib,MessageBox as ab,WarningIcon as sb}from"@rango-dev/ui";import sa from"react";function yg(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return sa.createElement(R,{id:"widget-unknown-price-warning-modal",footer:sa.createElement(ib,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:sa.createElement(sb,null),fullWidth:!0,disabled:r,onClick:n},ne().unknownPriceError.confirmMessage),open:e,onClose:o,container:W()},sa.createElement(ab,{type:"warning",title:ne().unknownPriceError.impactTitle,description:ne().unknownPriceError.description}))}i(yg,"UnknownPriceWarningModal");function Er(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,skipAlerts:s,refetchQuote:c,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:m,onChangeSlippage:f}=t,h={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,d=fg(e,o?.type===3||o?.type===4?o:null);d&&!n&&(d.action=null);let y=!!d&&!s,S=i(C=>{if(C==="change-slippage"){let k=o?.type===3||o?.type===4?o:null,E=gg(e,k);f?.(E)}else C==="change-settings"&&m()},"onclickActionButton");return Ue.createElement(Ue.Fragment,null,g&&Ue.createElement(Ue.Fragment,null,Ue.createElement(Sg,{size:10}),Ue.createElement(vr,{skipAlerts:s,error:o,fetch:c})),y&&Ue.createElement(ag,null,Ue.createElement(Sg,{size:10}),Ue.createElement(cb,{id:"widget-quote-warning-and-errors-alert",title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:Ue.createElement(pg,{onClick:l},Ue.createElement(ub,{size:12,color:"gray"}))},...(d.action==="change-settings"||d.action==="change-slippage")&&{action:Ue.createElement(pb,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:d.alertType,onClick:()=>S(d.action)},d.actionButtonTitle||lb.t("Change"))}})),e&&Ue.createElement(Ue.Fragment,null,e.type===0&&Ue.createElement(mg,{...h,warning:e}),(e.type===3||e.type===2)&&Ue.createElement(hg,{...h,warning:e}),e.type===1&&Ue.createElement(yg,{...h,warning:e})))}i(Er,"QuoteWarningsAndErrors");import Ub from"bignumber.js";import wa from"react";import{i18n as Xo}from"@lingui/core";import{Alert as Ab,CampaignQuoteTag as Nb,Divider as $n,FullExpandedQuote as Wb,InfoIcon as sc,NumericTooltip as lc,QuoteTag as Pb,StepDetails as Bb,TokenAmount as Lb,Typography as Fn,useIsTruncated as cc}from"@rango-dev/ui";import pc from"bignumber.js";import U,{useRef as Ta,useState as _b}from"react";import{styled as Zl}from"@rango-dev/ui";var Jl=Zl("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Cg=Zl("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),Tg=Zl("div",{width:"100%",display:"flex"});import*as la from"@radix-ui/react-collapsible";import{Button as db,css as ca,darkTheme as De,Image as kg,styled as Xe,Typography as Rl}from"@rango-dev/ui";var mb=300,vg=Xe(la.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),wg=ca({padding:"$10 $15"}),Eg=Xe(db,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${De} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${De} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${De} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),bg=Xe("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",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${De} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}}}}]}),xg=ca({width:"100%",padding:"$15 $15 $10 $15"}),Ig=ca({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Dn=ca({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Ag=Xe(la.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:{[`& ${kg}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${kg}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),Ng=Xe("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"}}}}),Wg=Xe(ea,{width:"100%",background:"inherit"}),ec=Xe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${mb}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),oq=Xe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),Pg=Xe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${De} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Bg=Xe("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),tc=Xe(Rl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),oc=Xe(Rl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),nc=Xe("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"}}}}),Lg=Xe("div",{display:"flex"}),pa=Xe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${De} &`]:{borderTopColor:"$neutral800"}}),_g=Xe(Rl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as Ot}from"@lingui/core";import{ChevronDownIcon as gb,CloseIcon as hb,Divider as ma,IconButton as yb,NumericTooltip as Sb,QuoteCost as Cb,Typography as Wt}from"@rango-dev/ui";import J,{useState as Fg}from"react";import{css as fb,styled as ua}from"@rango-dev/ui";var da=ua("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),rc=ua("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Mg=ua("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Dg=ua("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),$g=fb({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var Tb=i(t=>t.fee.isZero()?null:J.createElement(da,null,J.createElement(Wt,{variant:"label",size:"medium",color:"neutral600"},t.label),J.createElement(Wt,{variant:"label",size:"medium"},"$",D(t.fee,4,4))),"NonPayableFee");function ic(t){let[e,o]=Fg(!1),[n,r]=Fg(!1),{steps:a,quote:s,fee:c,time:l,feeWarning:p,timeWarning:u,showModalFee:m,fullExpandedMode:f=!1}=t,h=s?.swaps??[],g=f?_o():W(),d=am(h),y=D(c,2,2);return J.createElement(J.Fragment,null,J.createElement(Cb,{onClickFee:m?S=>{S.stopPropagation(),!e&&s&&ee({type:"routeFeeViewed",payload:{routeId:s.requestId}}),o(!e)}:void 0,fee:y,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:m?Ot.t("View more info"):void 0,tooltipContainer:g}),J.createElement(R,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:J.createElement(Dg,{style:{textAlign:f?"left":"center"}},J.createElement(Wt,{variant:"title",size:"medium"},Ot.t("Gas & Fee Explanation")),J.createElement(yb,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},J.createElement(hb,{color:"gray",size:14}))),onClose:()=>{o(!1)}},J.createElement(Mg,null,J.createElement(Wt,{variant:"title",size:"small"},Ot.t("Details")),J.createElement(ma,{size:10}),Object.entries(d.payable).flatMap(([S,C])=>C.map((k,E)=>{let w=`payable-fee-${E}`,I=tl(k);return J.createElement(da,{key:w},J.createElement(Wt,{variant:"label",size:"medium",color:"neutral600"},Ys(S,Ot.t)),J.createElement(Sb,{content:k.amount,container:g},J.createElement(Wt,{variant:"label",size:"medium"},D(k.amount,2,2),k.asset.symbol," ($",D(I,4,4),")")))})),J.createElement(da,{className:"total_payable_fee"},J.createElement(Wt,{variant:"label",size:"medium"},Ot.t("Total Payable Fee")),J.createElement(Wt,{variant:"label",size:"medium"},"$",D(c,4,4))),J.createElement(rc,null),!!Object.keys(d.nonePayable).length&&J.createElement(na,{triggerAnchor:"bottom",onClickTrigger:()=>r(S=>!S),trigger:J.createElement("div",{className:$g()},J.createElement(Wt,{size:"small",variant:"body",color:"neutral700"},n?Ot.t("Hide non-payable fees"):Ot.t("Show non-payable fees")),J.createElement(ma,{size:4,direction:"horizontal"}),J.createElement(ta,{orientation:n?"up":"down"},J.createElement(gb,{size:12,color:"gray"}))),open:n},J.createElement(Wt,{size:"small",variant:"title"},Ot.t("Description")),J.createElement(ma,{size:4}),J.createElement(Wt,{size:"small",variant:"body",color:"neutral700"},Ot.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),J.createElement(ma,{size:10}),Object.entries(d.nonePayable).map(([S,C],k)=>{let E=im(C),w=Ys(S,Ot.t),I=`non-payable-fee-${k}`;return J.createElement(Tb,{key:I,fee:E,label:w})}),J.createElement(rc,null)))))}i(ic,"QuoteCostDetails");import{i18n as zg}from"@lingui/core";import{TokenAmount as Hg}from"@rango-dev/ui";import fa from"react";import{css as kb,styled as vb}from"@rango-dev/ui";var Og=vb("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),Ug=kb({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function br(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return fa.createElement(Og,null,fa.createElement(Hg,{direction:"horizontal",label:zg.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:W(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),fa.createElement("div",{className:Ug()}),fa.createElement(Hg,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:W(),label:zg.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(br,"QuoteSummary");import{i18n as Kg}from"@lingui/core";import{ChevronDownIcon as bb,ChevronRightIcon as xb,Divider as ac,Image as Ib,Tooltip as Ca,Typography as ha}from"@rango-dev/ui";import K from"react";import{useLayoutEffect as wb,useState as xr}from"react";var Qg=480,qg=768,Gg=1024,Vg=1200,Eb=i(()=>{let[t,e]=xr(!1),[o,n]=xr(!1),[r,a]=xr(!1),[s,c]=xr(!1),[l,p]=xr(!1),u=i(()=>{e(window.innerWidth<=Qg),n(window.innerWidth>Qg&&window.innerWidth<=qg),a(window.innerWidth>qg&&window.innerWidth<=Gg),c(window.innerWidth>Gg&&window.innerWidth<=Vg),p(window.innerWidth>Vg)},"handleResize");return wb(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),ga=Eb;var ya=4,Sa=6,Ir=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||W();return K.createElement(Ca,{container:c,side:"bottom",sideOffset:4,open:r,content:e},K.createElement(Ng,{className:n,state:a},K.createElement(Ib,{src:o,size:16})))},"ImageComponent");function jg(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||W(),p=r.length,u=Xd(r),{isTablet:m,isMobile:f}=ga();return K.createElement(Ag,{className:"widget-quote-trigger-btn",listItem:s==="list-item",ref:h=>e.current=h,selected:o,onClick:h=>{h.stopPropagation(),n(g=>!g)}},K.createElement("div",{className:Dn()},K.createElement(ha,{variant:"body",size:"xsmall"},Kg.t("Via:")),K.createElement(ac,{direction:"horizontal",size:4}),r.map((h,g)=>{let d=`item-${g}`,y=K.createElement(ec,null,K.createElement(xb,{size:12,color:"black"}));return f||m?K.createElement(K.Fragment,{key:d},K.createElement(Ir,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&K.createElement(K.Fragment,null,y)):K.createElement(K.Fragment,{key:d},p<=ya||p>ya&&g<ya-1?K.createElement(K.Fragment,null,K.createElement(Ir,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&K.createElement(K.Fragment,null,y)):g===ya-1&&K.createElement(Ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:K.createElement("div",{className:Dn()},y,r.map((S,C)=>{let k=`image-${C}`;return C>=g&&K.createElement(K.Fragment,{key:k},K.createElement(Ir,{content:S.swapper.displayName,src:S.swapper.image??"",state:S.state,open:!1}),C!==p-1&&K.createElement(K.Fragment,null,y))}))},K.createElement(nc,{state:r.find((S,C)=>C>=g&&(S.state==="error"||S.state==="warning"))?.state},K.createElement(ha,{size:"xsmall",variant:"body"},"+",p-g))))})),K.createElement("div",{className:Dn()},K.createElement("div",{className:"blockchains_section"},K.createElement("div",{className:Dn()},K.createElement(ha,{variant:"body",size:"xsmall"},Kg.t("Chains:")),K.createElement(ac,{direction:"horizontal",size:4}),u.map((h,g)=>K.createElement(K.Fragment,{key:h.displayName},u.length<=Sa||u.length>Sa&&g<Sa-1?K.createElement(Ca,{container:l,side:"bottom",content:h.displayName,sideOffset:4},K.createElement(Ir,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===Sa-1&&K.createElement(Ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:K.createElement("div",{className:Dn()},u.map((d,y)=>y>=g&&K.createElement(Ir,{key:d.displayName,content:"",src:d.image??"",open:!1,className:y>g?"blockchainImage":"",container:c})))},K.createElement(nc,{className:"blockchainImage"},K.createElement(ha,{size:"xsmall",variant:"body"},"+",u.length-g))))),K.createElement(ac,{direction:"horizontal",size:32}))),K.createElement(ec,{orientation:a?"up":"down"},K.createElement(bb,{size:12,color:"black"}))))}i(jg,"QuoteTrigger");function uc(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:c=!1,tagHidden:l=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:m=!1,container:f}=t,h=T().blockchains(),{findToken:g}=T(),d=T().swappers(),{customSlippage:y,slippage:S}=T(),C=y||S,[k,E]=_b(t.expanded),w=Ta(null),I=D(n.value,6,6),A=n.usdValue?D(n.usdValue,4,4):"",{config:{__UNSTABLE_OR_INTERNAL__:x}}=T(),b=Yt(o.usdValue,n.usdValue??null),v=D(b,2,2),N=Zt(b??0),B=i((M,ce)=>M.map((H,ae)=>{let qe,nt=r?.type===3&&r.swap.swapperId===H.swapperId,co=r?.type===4&&!!r.recommendedSlippages?.[ae],Vn=a?.type===2&&!!a.recommendedSlippages?.[ae],No=nt||co,ni=Vn;No?qe="error":ni&&(qe="warning");let an=No?Xo.t("Slippage Error"):Xo.t("Slippage Warning");return nt&&(an=Xo.t("Bridge Limit Error")),{swapper:{displayName:jn(H.swapperId,d)??"",image:H.swapperLogo},from:{token:{displayName:H.from.symbol,image:H.from.logo},chain:{displayName:vt(H.from.blockchain,h)??"",image:H.from.blockchainLogo},price:{value:ae===0&&!ce?D(o.value,6,6):D(H.fromAmount,6,6),usdValue:D((H.from.usdPrice??0)*parseFloat(H.fromAmount),4,4),realValue:ae===0?o.value:H.fromAmount,realUsdValue:new pc(H.from.usdPrice??0).multipliedBy(H.fromAmount).toString()}},to:{token:{displayName:H.to.symbol,image:H.to.logo},chain:{displayName:vt(H.to.blockchain,h)||"",image:H.to.blockchainLogo},price:{value:D(H.toAmount,6,6),usdValue:D((H.to.usdPrice??0)*parseFloat(H.toAmount),4,4),realValue:H.toAmount,realUsdValue:new pc(H.to.usdPrice??0).multipliedBy(H.toAmount).toString()}},state:qe,alerts:No||ni?U.createElement(Cg,{dense:m},U.createElement(Ab,{variant:"alarm",type:No?"error":"warning",title:an,id:"widget-quote-footer-step-alarm-alert",footer:U.createElement(Tg,null,nt&&U.createElement("div",null,U.createElement(Fn,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),U.createElement($n,{direction:"vertical",size:2}),U.createElement(Fn,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},Xo.t({id:"Yours: {amount} {symbol}",values:{amount:D(H.fromAmount,6,6),symbol:H?.from.symbol}}))),(co||Vn)&&!nt&&U.createElement("div",null,U.createElement(Fn,{size:"xsmall",variant:"body",color:"neutral900"},Xo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[ae]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[ae]}}})),U.createElement($n,{direction:"vertical",size:2}),U.createElement(Fn,{size:"xsmall",variant:"body",color:"neutral900"},Xo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:Yn(H.estimatedTimeInSeconds),fee:D(el(H,g),2,2),internalSwaps:H.internalSwaps?B(H.internalSwaps):void 0}}),"getQuoteSteps"),_=B(e?.swaps??[]),Q=_.length,V=f||W(),Y=Zd(t.quote.tags||[]),P=!!u,Z=di(e?.swaps),X=Yn(Z),ie=Fi(e?.swaps??[],g),Te=D(ie,2,2),dt=ie.gte(new pc(zd)),me=Z/Qd>=Hd,Oe=Ta(null),Qe=cc(o.value,Oe),kt=Ta(null),ot=cc(n.value,kt),Ee=Ta(null),z=cc(A,Ee),q=_[Q-1],$=_[0];return!$||!q?null:m?U.createElement(Wb,{selected:c,fee:Te,time:X,tooltipContainer:_o(),steps:_,tags:Y,campaignTag:x?.campaignTag,id:"widget-quote-full-expanded-quote-container",quoteCost:U.createElement(ic,{quote:e,fullExpandedMode:!0,time:X,fee:ie,feeWarning:dt,timeWarning:me,showModalFee:p,steps:Q}),percentageChange:v,warningLevel:N,outputPrice:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue}}):U.createElement(bg,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},U.createElement("div",{className:xg()},!l&&Y.length?U.createElement(U.Fragment,null,U.createElement(Lg,null,Y.map((M,ce)=>{let H=`${M.value}_${ce}`;return U.createElement(U.Fragment,{key:H},M.value=="CAMPAIGN"&&x?.campaignTag?U.createElement(Nb,{routeTag:M,...x.campaignTag}):U.createElement(Pb,{label:M.label,value:M.value}),U.createElement($n,{size:4,direction:"horizontal"}))})),U.createElement(pa,null),!P&&U.createElement($n,{size:4})):null,U.createElement("div",{id:"portal-root",className:Ig()},U.createElement(ic,{quote:e,time:X,fee:ie,feeWarning:dt,timeWarning:me,showModalFee:p,steps:Q}),P&&U.createElement(Eg,{onClick:M=>{M.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},U.createElement(Fn,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},Xo.t("See All Routes")))),s==="basic"&&U.createElement(Bg,null,U.createElement(oc,{ref:Oe,size:"small",variant:"body"},o.value),Qe&&U.createElement(lc,{content:o.value,container:V,open:o.value?void 0:!1},U.createElement(sc,{size:12,color:"gray"})),U.createElement(tc,{size:"small",variant:"body"},_[0]?.from.token.displayName),U.createElement(Fn,{size:"small",variant:"body"},"="),U.createElement(oc,{ref:kt,size:"small",variant:"body"},n.value),ot&&U.createElement(lc,{content:n.value,container:V,open:n.value?void 0:!1},U.createElement(sc,{size:12,color:"gray"})),U.createElement(tc,{size:"small",variant:"body"},q?.to.token.displayName),U.createElement($n,{size:2,direction:"horizontal"}),U.createElement(_g,{ref:Ee,color:"$neutral600",size:"xsmall",variant:"body"},`($${A})`),z&&U.createElement(lc,{content:n.usdValue,container:V},U.createElement(sc,{size:12,color:"gray"}))),s==="list-item"&&U.createElement(Lb,{id:"widget-quote-token-amount-container",tooltipContainer:V,type:"output",direction:"vertical",price:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:q.to.token.displayName,image:q.to.token.image},chain:{image:q.to.chain.image},percentageChange:v,warningLevel:N}),s==="swap-preview"&&U.createElement(U.Fragment,null,U.createElement(br,{from:$.from,to:q.to,percentageChange:v,warningLevel:N}),U.createElement($n,{size:4}))),U.createElement(vg,{selected:c,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:E},U.createElement(jg,{type:s,quoteRef:w,selected:c,setExpanded:E,container:V,expanded:k,steps:_}),U.createElement(Wg,{open:k},U.createElement(Pg,null),U.createElement("div",{className:wg()},_.map((M,ce)=>{let H=`item-${ce}`;return U.createElement(Bb,{type:"quote-details",className:"widget-quote-step-details-container",key:H,tooltipContainer:V,step:M,hasSeparator:ce!==_.length-1,state:M.state})})))))}i(uc,"Quote");import{Divider as Fb,Skeleton as Ob}from"@rango-dev/ui";import oo from"react";import{darkTheme as Mb,styled as ka}from"@rango-dev/ui";var Xg=ka("div",{$$color:"$colors$neutral100",[`.${Mb} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Yg=ka("div",{paddingTop:"$2"}),Zg=ka("div",{paddingLeft:"$8"}),Jg=ka("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as lh,Divider as Pt,Skeleton as yt}from"@rango-dev/ui";import j from"react";import{css as Db,styled as to}from"@rango-dev/ui";var dc=to("div",{display:"flex"}),Rg=to("div",{padding:"$10 $0 $20"}),eh=to("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),th=to("div",{display:"flex",justifyContent:"start",alignItems:"center"}),oh=to("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),nh=to("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),rh=to("div",{width:"65%",display:"flex",justifyContent:"start"}),ih=to("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),ah=to("div",{padding:"$15 $0 $15 $0"}),sh=Db({display:"flex",justifyContent:"space-between",alignItems:"center"});function Ar(t){let{type:e,tagHidden:o=!0}=t,n=j.createElement(oh,null,j.createElement(rh,null,j.createElement(lh,{loading:!0,size:"medium"}),j.createElement(Pt,{size:8,direction:"horizontal"}),j.createElement(ih,null,j.createElement(yt,{height:10,width:60,variant:"rounded"}),j.createElement(Pt,{size:4}),j.createElement(yt,{height:15,variant:"rounded"}))),j.createElement(yt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return j.createElement("div",null,!o&&j.createElement(j.Fragment,null,j.createElement(dc,null,j.createElement(yt,{width:65,height:20,variant:"rounded"}),j.createElement(Pt,{size:4,direction:"horizontal"}),j.createElement(yt,{width:65,height:20,variant:"rounded"}),j.createElement(Pt,{size:4,direction:"horizontal"}),j.createElement(yt,{width:65,height:20,variant:"rounded"})),j.createElement(pa,null),!r&&j.createElement(Pt,{size:4})),j.createElement("div",{className:sh()},j.createElement(dc,null,j.createElement(yt,{width:60,height:10,variant:"rounded"}),j.createElement(Pt,{size:4,direction:"horizontal"}),j.createElement(yt,{width:60,height:10,variant:"rounded"}),j.createElement(Pt,{size:4,direction:"horizontal"}),j.createElement(yt,{width:60,height:10,variant:"rounded"})),r&&j.createElement(yt,{width:85,height:24,variant:"rounded"})),e==="basic"&&j.createElement(Rg,null,j.createElement(yt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&j.createElement(eh,null,j.createElement(th,null,j.createElement(lh,{loading:!0,size:"medium"}),j.createElement(Pt,{direction:"horizontal",size:4}),j.createElement(yt,{height:15,width:150,variant:"rounded"})),j.createElement(Pt,{size:10}),j.createElement(yt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&j.createElement(j.Fragment,null,j.createElement(Pt,{size:4}),j.createElement(ah,null,n,j.createElement(nh,null),n),j.createElement(Pt,{size:12})))}i(Ar,"QuoteSummarySkeleton");import{ChainToken as mh,Divider as fc,NextIcon as $b,Skeleton as va}from"@rango-dev/ui";import Be from"react";import{styled as Nr}from"@rango-dev/ui";var ch=Nr("div",{display:"flex",alignItems:"start"}),ph=Nr("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),mc=Nr("div",{display:"flex",alignItems:"center",flexGrow:1}),uh=Nr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),dh=Nr("div",{display:"flex",alignItems:"center"});function Ut(t){let{separator:e=!0}=t;return Be.createElement(Be.Fragment,null,Be.createElement(dh,null,Be.createElement(va,{height:22,width:22,variant:"circular"}),Be.createElement(fc,{direction:"horizontal",size:8}),Be.createElement(va,{height:15,width:148,variant:"rounded"})),Be.createElement(ch,null,Be.createElement(Jg,{hideSeparator:!e}),Be.createElement(ph,{extraSpace:e},Be.createElement(mc,null,Be.createElement(mh,{size:"small",loading:!0}),Be.createElement(fc,{direction:"horizontal",size:8}),Be.createElement(va,{height:12,variant:"rounded"})),Be.createElement(uh,null,Be.createElement($b,{color:"gray",size:16})),Be.createElement(mc,null,Be.createElement(mh,{size:"small",loading:!0}),Be.createElement(fc,{direction:"horizontal",size:8}),Be.createElement(va,{height:12,variant:"rounded"})))))}i(Ut,"StepSkeleton");function Wr(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return oo.createElement(Xg,{expanded:o,rounded:e!=="basic"},oo.createElement(Ar,{type:e,tagHidden:n}),oo.createElement(Yg,null,oo.createElement(Ob,{height:15,variant:"rounded"})),o&&oo.createElement(Zg,null,oo.createElement(Fb,{size:24}),oo.createElement(Ut,null),oo.createElement(Ut,null),oo.createElement(Ut,{separator:!1})))}i(Wr,"QuoteSkeleton");function Yo(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:c,onClick:l,showModalFee:p,selected:u,id:m,onClickAllRoutes:f,fullExpandedMode:h=!1,container:g}=t,{inputAmount:d,inputUsdValue:y}=G()(),S=e?.outputAmount?new Ub(e?.outputAmount):null,C=e?st(e):null,E=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?wa.createElement(Jl,null,wa.createElement(Wr,{tagHidden:c,type:o,expanded:s})):E?wa.createElement(Jl,{onClick:()=>l?.(e),id:m},wa.createElement(uc,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:c,selected:u,type:o,expanded:s,onClickAllRoutes:f,fullExpandedMode:h,input:{value:d,usdValue:y?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(Yo,"QuoteInfo");import{warn as qb}from"@rango-dev/logging-core";import{calculatePendingSwap as Gb}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Vb}from"react";import{useRef as zb,useState as Hb}from"react";var Qb=2e3;function Ea({request:t}){let[e,o]=Hb(!1),n=zb(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,Qb)),await s(c,!1)),"retryFetch"),s=i(async(c,l=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(c,{signal:n.current.signal});return n.current=null,p}catch(p){if(l)return await a(c);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(Ea,"useFetch");function fh(){let{fetch:t,loading:e,cancelFetch:o}=Ea({request:async(n,r)=>await gt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(fh,"useFetchConfirmQuote");function ba(t){if(!t.swaps)throw new Error(ne().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=gc(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ba,"throwErrorIfResponseIsNotValid");function gc(t){if(om(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=nm(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=sm(t);if(o){let n=Oi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(gc,"getQuoteError");function gh(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,c={quote:null,balance:null},l=En({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});l&&(c.quote=l);let p=pm(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(gh,"generateWarnings");function xa(t){return t?.code==="ERR_CANCELED"?{type:2}:t.cause?t.cause:t?.code==="ERR_BAD_REQUEST"?{type:0,diagnosisMessage:t.response.data.error}:{type:1,diagnosisMessage:t.message}}i(xa,"handleQuoteErrors");function hc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=G()(),{slippage:l,customSlippage:p}=T(),u=T().getDisabledLiquiditySources(),m=T().blockchains(),f=T().tokens(),{findToken:h}=T(),{swapMode:g}=at(),d=p||l,{fetch:y,cancelFetch:S,loading:C}=fh();return Vb(()=>S,[]),{loading:C,fetch:i(async E=>{let w=E.selectedWallets,I=E?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=w.reduce((b,v)=>(b[v.chain]=v.address,b),{}),x={requestId:a?.requestId||"",selectedWallets:A,destination:I||void 0};try{return await y(x,!0).then(b=>{let{result:v}=b;if(!v)throw new Error(b.error??"Error fetching updated quote");ba({diagnosisMessages:v.diagnosisMessages,requestId:v.requestId,swaps:v.result?.swaps});let N={outputAmount:v.result?.outputAmount,requestId:v.requestId,resultType:v.result?.resultType,swaps:v.result?.swaps||[],validationStatus:v.validationStatus,requestAmount:v.requestAmount};r(N);let B={slippage:d.toString(),disabledSwappersGroups:u},_=gh({previousQuote:a??void 0,currentQuote:N,meta:{blockchains:m},selectedWallets:w,userSlippage:d,inputUsdValue:n,findToken:h});c();let Q=!!_.balance,V=Gb({inputAmount:o.toString(),bestRoute:v,wallets:cm(w),settings:B,validateBalanceOrFee:!Q,meta:{blockchains:m,tokens:f},swapMode:g});return{quote:N,swap:V,error:null,warnings:_}})}catch(b){let v=xa(b);return v.type!==2&&qb(new Error("confirm swap error"),{tags:{...v,type:Je[v.type],initialQuote:a,requestBody:x}}),{swap:null,error:v,warnings:null}}},"fetch"),cancelFetch:S}}i(hc,"useConfirmSwap");function hh(t){if(t==null||t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}i(hh,"toNumberOrNull");function On(t){let e=t.swaps[0],o=t.swaps[t.swaps.length-1],n=Ho(t),r=st(t);return{routeId:t.requestId,sourceChain:e?.from.blockchain??"",destinationChain:o?.to.blockchain??"",sourceToken:e?.from.symbol??"",destinationToken:o?.to.symbol??"",sourceTokenAmount:hh(t.requestAmount),destinationTokenAmount:hh(t.outputAmount),inputAmountUsd:n?n.toNumber():null,outputAmountUsd:r?r.toNumber():null}}i(On,"buildSwapEstimatePayload");var ox=Yb("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${yh}`]:{width:"$48",height:"$48"}}),nx=Cc({flexGrow:1,paddingRight:"$10"}),rx=Cc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),ix=Cc({display:"flex",justifyContent:"space-between",alignItems:"center"});function Sh(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=G()(),s=tx(),[c,l]=Pr(""),p=!n,[u,m]=Pr(!1),[f,h]=Pr(!1),{isActiveTab:g}=oe(),d=T().getDisabledLiquiditySources(),y=ex(d),{manager:S}=Kb(),{fetch:C,loading:k,cancelFetch:E}=hc(),[w,I]=Pr({swap:null,error:null,warnings:null}),[A,x]=Pr(!1),b=i(async({selectedWallets:P,customDestination:Z})=>{let X=await C?.({selectedWallets:P,customDestination:Z});return I(X),X},"onConfirmSwap"),v=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let P=`../${O.swaps}/${w.swap.requestId}`;s(P,{replace:!0}),setTimeout(()=>{e("")},0)}catch(P){l("Error: "+P?.message)}},"addNewSwap"),N=i(async()=>{h(!0),await v(),h(!1)},"onConfirm"),B=i(async()=>{w.warnings?.quote&&jd(w.warnings.quote)&&!a?x(!0):(t&&ee({type:"swapStarted",payload:{...On(t),stepCount:t.swaps.length}}),await N())},"onStartConfirmSwap"),_=i(async()=>{I({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(P=>{I(P)}).catch(P=>console.error(P))},"onRefresh");Ia(()=>{!!y.current.length&&!d.length&&_(),y.current=d},[d.length]),Ia(()=>{p&&E()},[p]),Ia(()=>{p&&m(p)},[p]),Ia(()=>{p||C({selectedWallets:o,customDestination:r}).then(P=>I(P)).catch(P=>console.error(P))},[]),Rb(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let Q=w.warnings?.quote??null,V=w.error,Y=[];if(c&&Y.push($e.createElement(jb,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),Q||V){let P=`../${O.settings}`;Y.push($e.createElement(Er,{warning:Q,error:V,couldChangeSettings:!1,refetchQuote:_,skipAlerts:V?.type===4||Q?.type===2,showWarningModal:A,confirmationDisabled:!g,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await v()},onChangeSettings:()=>s(P)}))}return $e.createElement(se,{header:{title:yc.t("Confirm Swap"),onWallet:()=>{let P=`../${O.wallets}`;s(P)}},footer:$e.createElement(ox,null,$e.createElement("div",{className:nx()},$e.createElement(Xb,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||f,disabled:!!w.error||!g,onClick:B},yc.t("Start Swap"))),$e.createElement(yh,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||f,disabled:!g,onClick:m.bind(null,!0)},$e.createElement(Jb,{size:24})))},u&&$e.createElement(Jf,{open:u,onClose:()=>m(!1),onCancel:E,loading:k,onCheckBalance:b}),$e.createElement(pe,null,$e.createElement("div",{className:ix()},$e.createElement(Zb,{variant:"title",size:"small"},yc.t("You get")),$e.createElement("div",{className:rx()},$e.createElement(Ki,{onClick:!k&&!u&&!A?_:void 0}))),$e.createElement(Sc,{size:"12"}),zm(Y.map((P,Z)=>({element:P,key:`alert-${Z}`})),$e.createElement(Sc,{size:10})),Y.length>0?$e.createElement(Sc,{size:10}):null,$e.createElement(Yo,{quote:t,type:"swap-preview",id:"widget-confirm-swap-quote-container",expanded:!0,tagHidden:!0,error:w.error,loading:k,warning:w.warnings?.quote??null})))}i(Sh,"ConfirmSwapPage");import{i18n as ro}from"@lingui/core";import{Button as Pc,CustomTokensZeroStateDarkIcon as bx,CustomTokensZeroStateIcon as xx,DeleteIcon as Ix,Divider as Dr,IconButton as Ax,MessageBox as Nx,NotFound as Wx,styled as Lc}from"@rango-dev/ui";import Se,{useState as Bc}from"react";import{useNavigate as Px}from"react-router-dom";import{CloseIcon as ax,IconButton as sx,SearchIcon as lx,TextField as cx}from"@rango-dev/ui";import Un from"react";import{styled as Ch}from"@rango-dev/ui";var Th=Ch("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),kh=Ch("div",{width:"100%","& ._text-field":{paddingLeft:"$10","& input":{paddingLeft:"$2",paddingTop:"$12",paddingBottom:"$12"}}});function Bt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:c,setValue:l,suffix:p,id:u,...m}=t,f=s.length?Un.createElement(sx,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Un.createElement(ax,{color:"gray",size:10})):null;return p&&(f=p),Un.createElement(kh,null,Un.createElement(cx,{prefix:Un.createElement(Th,null,Un.createElement(lx,{color:"black"})),id:u,suffix:f,fullWidth:o,color:n,variant:e,style:{borderRadius:25,alignItems:"center",...c},size:r,value:s,onChange:a,...m}))}i(Bt,"SearchInput");import{i18n as Wc}from"@lingui/core";import{Button as mx,CustomTokenWarning as fx,darkTheme as Lh,Divider as no,ExternalLinkIcon as gx,Image as hx,ListItem as yx,NotFound as Sx,PinIcon as Cx,Skeleton as Zo,Typography as _r,VirtualizedList as Tx}from"@rango-dev/ui";import L,{useState as kx}from"react";import{useTranslation as vx}from"react-i18next";import{Divider as Ph,ListItem as dx,Skeleton as Lr}from"@rango-dev/ui";import Lt from"react";import{css as zn,darkTheme as Tc,ImageContainer as px,ListItemButton as ux,styled as pt,Typography as vh}from"@rango-dev/ui";var kc=zn({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),vc=zn({position:"relative",height:12,width:"30%",maxWidth:"150px"}),wc=zn({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Ec=zn({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Tc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),bc=zn({}),xc=zn(),wh=pt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Ic=pt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Aa=pt("ul",{flexGrow:1,height:"100%",padding:0,margin:0,display:"flex",flexDirection:"column",listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${vc}`]:{[`& .${Ec}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${bc}`]:{bottom:"-15px"},[`& .${kc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${wc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Eh=pt(ux,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),Ac=pt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Nc=pt(vh,{}),bh=pt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${xc}`]:{$$color:"$colors$neutral600",[`.${Tc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Br=pt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),s2=pt("div",{display:"flex",alignItems:"center"}),xh=pt("div",{position:"relative",[`& ${px}`]:{borderRadius:"$xm",overflow:"hidden"}}),Ih=pt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Ah=pt(vh,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Nh=pt("a",{"& svg:hover":{color:"$colors$info"}}),Wh=pt("div",{paddingRight:"$5","& .widget-token-list-item-btn":{width:"100%",overflow:"hidden",height:"60px"},"& .widget-token-list-item-import-btn":{height:"$20",padding:"0 $10","& ._text":{display:"flex",justifyContent:"center",alignItems:"center"},"& ._typography":{[`.${Tc} &`]:{color:"$foreground"}}}});function Bh(t){return Lt.createElement(Aa,null,Array.from(Array(t.size),e=>Lt.createElement(dx,{key:e,hasDivider:!0,start:Lt.createElement(Lr,{variant:"circular",width:35,height:35}),end:Lt.createElement(Br,null,Lt.createElement(Lr,{variant:"text",size:"large",width:70}),Lt.createElement(Ph,{size:4}),Lt.createElement(Lr,{variant:"text",size:"medium",width:50})),title:Lt.createElement("div",null,Lt.createElement(Lr,{variant:"text",size:"large",width:90}),Lt.createElement(Ph,{size:4}),Lt.createElement(Lr,{variant:"text",size:"medium",width:90}))})))}i(Bh,"LoadingTokenList");var wx=20,Ex=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return L.createElement("div",{className:vc()},o?L.createElement("div",{className:kc()},o):L.createElement(Ic,{className:wc()},L.createElement(_r,{variant:"title",size:"xmedium"},r.symbol),L.createElement(no,{direction:"horizontal",size:4}),L.createElement(Ac,{css:a},L.createElement(Nc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&L.createElement("div",{className:`${Ec()} ${!o&&bc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",L.createElement(no,{size:4,direction:"horizontal"}),L.createElement(Nh,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},L.createElement(gx,{size:12}))))},"renderDesc");function Mr(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:c,showWarning:l=!0}=t,p=T().fetchStatus,u=T().blockchains(),{getBalanceFor:m,fetchingWallets:f}=T(),{isTokenPinned:h}=T(),{setFromToken:g,setToToken:d}=G()(),{t:y}=vx(),S=Ke(),[C,k]=kx(null),E=i(()=>{c==="source"?g({token:C,meta:{blockchains:u}}):d({token:C,meta:{blockchains:u}})},"updateToken"),w=i(()=>{E(),S()},"handleImportToken"),I=i(b=>{if(b.customToken){let{customToken:N,...B}=b;return L.createElement(mx,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(Q=>{Q.stopPropagation(),k({...B,warning:!0})},"handleClick")},L.createElement(_r,{variant:"body",size:"xsmall",color:"background"},y("import")))}let v=hi(m(b));return s?s(b):f?L.createElement(Br,null,L.createElement(Zo,{variant:"text",size:"large",width:70}),L.createElement(no,{size:4}),L.createElement(Zo,{variant:"text",size:"medium",width:50})):v&&L.createElement(bh,null,L.createElement(Ah,{variant:"title",size:"small"},v.amount),L.createElement("div",null),v.usdValue&&L.createElement(_r,{variant:"body",className:xc(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),A=i(()=>L.createElement(Tx,{style:{flexGrow:1,minHeight:0},itemContent:b=>{let v=e[b];if(v==="skeleton")return L.createElement(yx,{hasDivider:!0,start:L.createElement(Zo,{variant:"circular",width:35,height:35}),end:L.createElement(Br,null,L.createElement(Zo,{variant:"text",size:"large",width:70}),L.createElement(no,{size:4}),L.createElement(Zo,{variant:"text",size:"medium",width:50})),title:L.createElement("div",null,L.createElement(Zo,{variant:"text",size:"large",width:90}),L.createElement(no,{size:4}),L.createElement(Zo,{variant:"text",size:"medium",width:90}))});let N=u.find(P=>P.name===v?.blockchain);if(!N||!v)return null;let B=v.address,_=hl(N.color,"main"),Q={$$color:_.main150,[`.${Lh} &`]:{$$color:_.main750},backgroundColor:"$$color"},V={$$color:_.main750,[`.${Lh} &`]:{$$color:_.main150},color:"$$color"},Y=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return L.createElement(Wh,null,L.createElement(Eh,{"tab-index":b,key:`${v.symbol}${B}`,id:`${v.symbol}${B}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v?.customToken,onClick:Y,start:L.createElement(xh,null,L.createElement(hx,{src:v.image===""?si:v.image,size:30}),t.type!=="custom-token"&&v&&h(v,t.type)&&L.createElement(Ih,null,L.createElement(Cx,{size:12,color:"gray"}))),title:N.type==="COSMOS"||v.name||!v.name&&!B?L.createElement(Ic,null,L.createElement(_r,{variant:"title",size:"xmedium"},v.symbol),L.createElement(no,{direction:"horizontal",size:4}),L.createElement(Ac,{css:Q},L.createElement(Nc,{variant:"body",size:"xsmall",css:V},v.blockchain)),l&&v.warning&&L.createElement(L.Fragment,null,L.createElement(no,{direction:"horizontal",size:4}),L.createElement(fx,{container:W()}))):void 0,description:typeof v!="string"&&N.info&&B&&N.type!=="COSMOS"?Ex({address:B,token:v,customCssForTag:Q,customCssForTagTitle:V,name:v.name,url:N.info.addressUrl.split("{wallet}").join(B)}):v.name||void 0,end:I(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),x=C?Po(C?.blockchain,u):null;return L.createElement(L.Fragment,null,a&&L.createElement(L.Fragment,null,L.createElement(_r,{variant:"label",size:"large"},Wc.t("Select Token")),L.createElement(no,{size:4})),L.createElement(wh,null,L.createElement(no,{size:4}),p==="loading"&&L.createElement(Bh,{size:wx}),p==="success"&&(e.length?L.createElement(L.Fragment,null,L.createElement(Cr,{token:C,address:C?.address??"",blockchain:x??void 0,onImport:w,onExitErrorModal:()=>k(null),onExitImportModal:()=>k(null)}),L.createElement(Aa,{as:"ul"},A())):!!o&&L.createElement(Sx,{title:Wc.t("No results found"),description:Wc.t("Try using different keywords")}))))}i(Mr,"TokenList");var Bx=Lc("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Lx=Lc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),_x=Lc(Ax,{"&:hover":{"& svg":{color:"$secondary550"}}});function _h(){let[t,e]=Bc(""),{deleteCustomToken:o}=T(),n=T().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=G()(),{mode:l}=go({}),p=Px(),[u,m]=Bc(!1),[f,h]=Bc(),g=i(C=>{let k=C.target.value;e(k)},"handleSearch"),d=l==="dark",y=n.filter(C=>mt(C.symbol,t)||mt(C.address||"",t)||mt(C.name||"",t)),S=i(()=>{if(f){let C=a?wt(a):null,k=r?wt(r):null,E=wt(f);C===E?c({token:null}):k===E&&s({token:null}),o(f)}m(!1)},"handleDeleteCustomToken");return Se.createElement(se,{header:{title:ro.t("Custom Tokens")}},Se.createElement(pe,null,Se.createElement(Bx,null,n.length?Se.createElement(Se.Fragment,null,Se.createElement(Bt,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:ro.t("Search Token"),onChange:g}),Se.createElement(Dr,{size:16}),Se.createElement(Mr,{list:y,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:C=>Se.createElement(_x,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),h(C)}},Se.createElement(Ix,{size:12,color:"gray"}))})):Se.createElement(Lx,null,Se.createElement(Wx,{icon:d?Se.createElement(bx,{size:200}):Se.createElement(xx,{size:200}),title:ro.t("No custom tokens"),description:ro.t("press the button to add your custom token")})),Se.createElement(Dr,{size:20}),Se.createElement(Pc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p(O.addCustomTokens)},ro.t("Add Custom Token"))),Se.createElement(R,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>m(!1),container:W()},Se.createElement(Nx,{title:ro.t("Delete Custom Token"),type:"error",description:ro.t("Are you sure you want to Delete this Token?")},Se.createElement(Dr,{size:40}),Se.createElement(Dr,{size:10}),Se.createElement(Pc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},ro.t("Yes, Delete it")),Se.createElement(Dr,{size:12}),Se.createElement(Pc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},ro.t("No, Continue"))))))}i(_h,"CustomTokensPage");import{i18n as Fe}from"@lingui/core";import{useManager as eI}from"@rango-dev/queue-manager-react";import{Button as Uc,darkTheme as tI,Divider as vo,MessageBox as oI,NotFound as nI,styled as zc,Tabs as rI,Typography as Pa}from"@rango-dev/ui";import{TransactionStatus as Or}from"rango-types";import te,{useMemo as Rh,useState as Ur}from"react";import{useNavigate as iI}from"react-router-dom";import{FilterIcon as zx,Popover as Hx}from"@rango-dev/ui";import Jo from"react";import{css as Mx,darkTheme as Na,IconButton as Dx,styled as $r}from"@rango-dev/ui";var _c=$r("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Na} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),Mh=$r(Dx,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Na} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Na} &`]:{backgroundColor:"$neutral"},[`& ${_c}::before`]:{backgroundColor:"$secondary100",[`.${Na} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),Dh=$r("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),$h=$r("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),Fh=Mx({display:"flex",justifyContent:"space-between",alignItems:"center"}),Oh=$r("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as Uh}from"@lingui/core";import{Button as $x,Divider as zh,ListItemButton as Fx,Radio as Ox,RadioRoot as Ux,Typography as Hh}from"@rango-dev/ui";import St from"react";function Qh(t){let{filterBy:e,onClickItem:o}=t;return St.createElement($h,null,St.createElement("div",{className:Fh()},St.createElement(Hh,{size:"small",variant:"body"},Uh.t("Status")),St.createElement($x,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},Uh.t("Reset"))),St.createElement(zh,{size:10}),St.createElement(Ux,{value:e},St.createElement(Oh,null,t.list.map((n,r)=>St.createElement(Fx,{key:n.id,className:"widget-filter-selector-list-item-btn",style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:St.createElement(St.Fragment,null,St.createElement(zh,{direction:"horizontal",size:4}),St.createElement(Hh,{size:"medium",variant:"body"},n.title)),start:St.createElement(Ox,{value:n.id}),onClick:o})))))}i(Qh,"FilterSelectorContent");function Mc(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Jo.createElement("div",null,Jo.createElement(Hx,{open:a,align:"end",onOpenChange:o,container:W(),content:Jo.createElement(Qh,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Jo.createElement(Mh,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Jo.createElement(_c,{isSelect:!!n},Jo.createElement(zx,{size:16,color:"black"}),!!n&&Jo.createElement(Dh,null)))))}i(Mc,"FilterSelector");import{i18n as Gx}from"@lingui/core";import{getCurrentStep as Vx}from"@rango-dev/queue-manager-rango-preset";import{Divider as jh,GroupedVirtualizedList as Kx,Skeleton as jx,SwapListItem as Xh,Typography as Xx}from"@rango-dev/ui";import et,{useCallback as Yh,useEffect as Yx,useRef as Zx,useState as Jx}from"react";function qh(t,e){let o=[],n=0;do{let r=t[n];r&&(o.push(Math.min(r,e)),e-=r),n++}while(e>0&&n<=t.length);return o}i(qh,"calculateGroupsSoFar");import{css as Qx,darkTheme as qx,styled as Fr}from"@rango-dev/ui";var Dc=Qx(),Gh=Fr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),$c=Fr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Dc}`]:{$$color:"$colors$neutral600",[`.${qx} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Fc=Fr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Vh=Fr("div",{gap:"$10",display:"flex",flexDirection:"column"}),Kh=Fr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var Rx=10;function Oc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Jx([]),c=Zx(0),{swaps:l,groupCounts:p,groups:u}=n(e),m=Yh(qh,[]),f=Yh(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,Rx),s(m(p,c.current)))},[e.length]);if(Yx(()=>{r||f()},[r,f]),r){let h=[1,2];return et.createElement(et.Fragment,null,[h,h].map((d,y)=>et.createElement($c,{key:y},et.createElement(Fc,null,et.createElement(jx,{variant:"text",width:60,size:"small"}),et.createElement(jh,{size:16})),et.createElement(jh,{size:4}),et.createElement(Vh,null,d.map((C,k)=>et.createElement(Xh,{isLoading:!0,key:k}))))))}return et.createElement(Kx,{style:{flexGrow:1,minHeight:0},endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>et.createElement($c,null,et.createElement(Fc,null,et.createElement(Xx,{variant:"label",size:"medium",className:Dc()},u[h]))),itemContent:(h,g)=>{let d=l[h];if(!d)return null;let y=Vx(d),S=d.steps[0],C=d.steps[d.steps.length-1];return!S||!C?null:et.createElement(Gh,{key:d.requestId},et.createElement(Xh,{className:"widget-history-group-list-swap-item-btn",requestId:d.requestId,creationTime:d.creationTime,status:d.status,onClick:o,currentStep:y,tooltipContainer:W(),onlyShowTime:u[g]===Gx.t("Today"),swapTokenData:{from:{token:{image:S.fromLogo,displayName:S.fromSymbol},blockchain:{image:S.fromBlockchainLogo||""},amount:D(d.inputAmount,6,6),realAmount:d.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:D(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(Oc,"HistoryGroupedList");import{i18n as Wa}from"@lingui/core";import Zh from"dayjs";var Jh=i(t=>{let e=new Map([["today",{title:Wa.t("Today"),swaps:[]}],["week",{title:Wa.t("This week"),swaps:[]}],["month",{title:Wa.t("This month"),swaps:[]}],["year",{title:Wa.t("This year"),swaps:[]}]]);function o(l,p){e.has(l)||e.set(l,{title:l,swaps:[]}),e.get(l)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Zh();t.forEach(l=>{let p=Number(l.creationTime),u=Zh(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(l);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(l);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(l);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(l);else{let m=new Date(p).getFullYear().toString();o(m,l)}});let r=Array.from(e.values()).filter(l=>l.swaps.length>0),a=r.flatMap(l=>l.swaps),s=r.map(l=>l.swaps.length),c=r.map(l=>l.title);return{swaps:a,groupCounts:s,groups:c}},"groupSwapsByDate");var aI=zc("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%",minHeight:0,flexGrow:1}),sI=zc("div",{display:"flex",justifyContent:"center",alignItems:"center"}),lI=zc("div",{"._typography":{color:"$neutral700",[`.${tI}&`]:{color:"$neutral900"}}}),cI=i((t,e)=>t?.length?t.filter(o=>Dt(o.fromBlockchain,e)||Dt(o.toBlockchain,e)||Dt(o.toSymbol,e)||Dt(o.fromSymbol,e)).length:!1,"isStepContainsText");function ey(){let t=iI(),{manager:e,state:o}=eI(),n=bt(e).map(({swap:x})=>x),[r,a]=Ur(""),[s,c]=Ur(!1),l=!o.loadedFromPersistor,[p,u]=Ur(""),[m,f]=Ur(!1),[h,g]=Ur("all"),d=i(x=>{let b=x.target.value;a(b)},"handleSearch"),{isMultiMode:y}=at(),S=[{id:Or.SUCCESS,title:Fe.t("Complete")},{id:Or.RUNNING,title:Fe.t("Running")},{id:Or.FAILED,title:Fe.t("Failed")}],C=[{id:"all",title:Fe.t("All")},{id:"swap",title:Fe.t("Swap")},{id:"refuel",title:Fe.t("Refuel")}],k=Rh(()=>!r&&!p&&h==="all"?n:n.filter(x=>{let{inputAmount:b,status:v,steps:N,requestId:B,mode:_}=x;return(!r||Dt(b,r)||Dt(v,r)||cI(N,r)||Dt(B,r))&&(!p||p===v)&&(h==="all"?!0:h==="swap"?!_||_==="swap":h==="refuel"?_==="refuel":!1)}),[n,r,p,h]),E=!k?.length&&!l,w=i(()=>f(!1),"onCloseModal"),I=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(x){console.log(x)}},"onClear"),A=Rh(()=>!n.some(x=>x.status===Or.SUCCESS||x.status===Or.FAILED),[n]);return te.createElement(se,{header:{title:Fe.t("History"),suffix:te.createElement(ho,null,te.createElement(Uc,{id:"widget-history-clear-btn",disabled:A,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},te.createElement(Pa,{size:"medium",variant:"label",color:"error"},Fe.t("Clear"))))}},te.createElement(pe,null,te.createElement(sI,null,te.createElement(Bt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Fe.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:d,style:{height:36},value:r}),te.createElement(vo,{size:10,direction:"horizontal"}),te.createElement(Mc,{filterBy:p,open:s,onOpenChange:x=>c(x),onClickItem:x=>u(x),list:S})),te.createElement(vo,{size:"16"}),y&&!l&&te.createElement(te.Fragment,null,te.createElement(rI,{items:C,onChange:x=>g(x.id),value:h,type:"secondary"}),te.createElement(vo,{size:"12"})),te.createElement(aI,null,E&&te.createElement(Kh,null,te.createElement(vo,{size:32}),te.createElement(nI,{title:r?Fe.t("No results found"):Fe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Fe.t("Try using different keywords"):Fe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!E&&te.createElement(Oc,{list:k,onSwapClick:t,groupBy:Jh,isLoading:l}))),te.createElement(R,{open:m,onClose:w,id:"widget-history-clear-modal",container:W()},te.createElement(vo,{size:20}),te.createElement(oI,{type:"warning",title:Fe.t("Clear Transaction History"),description:te.createElement(lI,null,te.createElement(Pa,{variant:"body",size:"medium"},Fe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),te.createElement(vo,{size:"24"}),te.createElement(Pa,{variant:"body",size:"small"},Fe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),te.createElement(vo,{size:30}),te.createElement(Uc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:I},Fe.t("Yes, Clear the history")),te.createElement(vo,{size:10}),te.createElement(Uc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:w},te.createElement(Pa,{variant:"title",size:"medium",color:"primary"},Fe.t("No, Cancel")))))}i(ey,"HistoryPage");import{i18n as Ny}from"@lingui/core";import{Button as GI,Divider as tp,styled as VI,WarningIcon as KI}from"@rango-dev/ui";import jI from"bignumber.js";import ke,{useEffect as Wy,useState as Py}from"react";import{useNavigate as XI}from"react-router-dom";import{i18n as oy}from"@lingui/core";import{Alert as uI,Divider as Hc,NoRouteIcon as dI,Typography as mI}from"@rango-dev/ui";import Ro from"react";import{styled as pI}from"@rango-dev/ui";var ty=pI("div",{display:"flex",flexDirection:"column",alignItems:"center"});function Qc(){let{fromToken:t,toToken:e}=G()();return!!t&&!!e&&Vt(t,e)?Ro.createElement(ty,null,Ro.createElement(Hc,{size:10}),Ro.createElement(dI,{size:24,color:"gray"}),Ro.createElement(Hc,{size:4}),Ro.createElement(mI,{variant:"title",size:"small"},oy.t("No Routes Found")),Ro.createElement(Hc,{size:4}),Ro.createElement(uI,{title:oy.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(Qc,"SameTokensWarning");import{Alert as fI,Button as gI}from"@rango-dev/ui";import ry from"react";import{i18n as Ba}from"@lingui/core";function ny(t){let e=null;return t===ki?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:Ba.t("Reset"),title:Ba.t("Slippage cannot be set lower than 0.01%.")},e):t>dn?(e={alertType:"warning",action:"change-settings",actionButtonTitle:Ba.t("Change"),title:Ba.t("Caution, your slippage is high!")},e):null}i(ny,"makeAlerts");function iy(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=T(),{onChangeSettings:a}=t,c=ny(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(Ti),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?ry.createElement(fI,{title:c.title,type:c.alertType,variant:"alarm",action:ry.createElement(gI,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(iy,"SlippageWarningsAndErrors");import{i18n as TI}from"@lingui/core";import{IconButton as kI,ReverseIcon as vI,Skeleton as wI,Tooltip as EI,Typography as zr}from"@rango-dev/ui";import Ct from"react";import La from"bignumber.js";function sy(t){let{error:e,isDarkTheme:o,warning:n}=t,{quoteError:r,slippageError:a}=e,{quoteWarning:s,slippageWarning:c}=n,l=!!a||r?.type===4,p=!!c||s?.type===2;return l?"$error500":p?"$warning500":o?"$neutral600":"$neutral700"}i(sy,"getSlippageColor");function ly(t){let{toTokenUsdPrice:e,fromTokenUsdPrice:o}=t;if(!e||!o)return{rawValue:"0",displayValue:"0"};let n=new La(e),r=new La(o),a=n.dividedBy(r),s;return a.isLessThan(1)?s=a.toFixed(14).replace(/\.?0+$/,""):a.toFixed(0).length>10?s=a.toFixed(0).slice(0,10):s=a.toFixed(2),{displayValue:s,rawValue:a.toFixed()}}i(ly,"getUsdExchangeRate");function cy(t,e){let o=new La(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,La.ROUND_DOWN).toFormat(2)}`}i(cy,"formatTokenValueInUsd");import{darkTheme as SI,styled as Gc,Typography as CI}from"@rango-dev/ui";var py=Gc("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),uy=Gc("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${SI} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),Vc=Gc(CI,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function Kc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=T(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,m=o!==null?o:e,{mode:f}=go({}),h=gn(m),g=f==="dark",d=n==="default",y={quoteError:a,slippageError:h?.type==="error"?h.message:null},S={quoteWarning:s,slippageWarning:h?.type==="warning"?h.message:null},C=p?.swaps[0]?.from||c,k=p?.swaps[p?.swaps.length-1]?.to||l,E=d?C:k,w=d?k:C,I=Number(d?p?.outputAmount:p?.requestAmount),A=Number(d?p?.requestAmount:p?.outputAmount),x=I||E.usdPrice,b=A||w.usdPrice,{rawValue:v,displayValue:N}=ly({toTokenUsdPrice:b,fromTokenUsdPrice:x});return Ct.createElement(py,null,Ct.createElement(zr,{variant:y||S?"label":"body",size:y||S?"medium":"small",color:sy({error:y,warning:S,isDarkTheme:g})},TI.t("Slippage:")," ",m,"%"),u?Ct.createElement(wI,{height:16,width:104,variant:"rounded"}):x&&b&&Ct.createElement(uy,null,Ct.createElement(zr,{className:"rate-text",variant:"body",size:"small"},"1"),Ct.createElement(Vc,{className:"rate-text",variant:"body",size:"small"},w.symbol),Ct.createElement(kI,{id:"widget-home-page-change-rate-button",onClick:r},Ct.createElement(vI,{size:14,color:"secondary"})),Ct.createElement(EI,{container:W(),side:"top",sideOffset:4,content:Ct.createElement(zr,{className:"rate-text",variant:"body",size:"small"},v)},Ct.createElement(zr,{className:"rate-text",variant:"body",size:"small"},N)),Ct.createElement(Vc,{className:"rate-text",variant:"body",size:"small"},E.symbol),E.usdPrice&&Ct.createElement(zr,{color:"neutral600",variant:"body",size:"small"},"~",cy(Number(v),E.usdPrice))))}i(Kc,"SwapMetrics");import{i18n as WI}from"@lingui/core";import{Header as PI}from"@rango-dev/ui";import wo,{useEffect as BI,useState as LI}from"react";import{i18n as xI}from"@lingui/core";import{Divider as Xc,FullExpandedQuote as II,Typography as AI}from"@rango-dev/ui";import be from"react";import{styled as jc}from"@rango-dev/ui";var dy=jc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),my=jc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),fy=jc("div",{width:"146px"});import{i18n as Hr}from"@lingui/core";import{Select as bI}from"@rango-dev/ui";import gy from"react";function _a(t){let{updateQuotePartialState:e,sortStrategy:o}=G()(),n=[{value:"SMART",label:Hr.t("Smart Routing")},{value:"FEE",label:Hr.t("Lowest Fee")},{value:"SPEED",label:Hr.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Hr.t("Maximum Return")},{value:"PRICE",label:Hr.t("Maximum Output")}];return gy.createElement(fy,null,gy.createElement(bI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(_a,"SelectStrategy");var hy=3;function Qr(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:c}=t,{selectedQuote:l,quotes:p,updateQuotePartialState:u,fromToken:m,toToken:f,sortStrategy:h,error:g}=G()(),{slippage:d,customSlippage:y}=T(),{findToken:S}=T(),C=c||W(),k=!!p&&p.results.length,E=y??d,{config:{__UNSTABLE_OR_INTERNAL__:w}}=T(),I=i(b=>{if(!m||!f||!p)return null;let v={requestAmount:p.requestAmount,validationStatus:null,...b};return En({currentQuote:v,userSlippage:E,findToken:S})},"getQuoteWarning"),A=g?.type===0||g?.type===1,x=p?.results?$i(h,p?.results):[];return be.createElement(be.Fragment,null,a&&be.createElement(be.Fragment,null,be.createElement(my,null,be.createElement(AI,{size:"xmedium",variant:"title"},xI.t("Sort by")),be.createElement(_a,{container:C})),be.createElement(Xc,{size:"10"})),e&&Array.from({length:hy},(b,v)=>be.createElement(be.Fragment,{key:v},s?be.createElement(II,{campaignTag:w?.campaignTag,loading:!0}):be.createElement(Wr,{tagHidden:!1,type:"list-item",expanded:!1}),v!==hy-1&&be.createElement(Xc,{size:16}))),!e&&be.createElement(be.Fragment,null,k?x.map((b,v)=>{let N=I(b),B=gc(b.swaps),_=x.length-1===v;return be.createElement(be.Fragment,{key:b.requestId},be.createElement(Yo,{id:"widget-quotes-quote-info-container",showModalFee:r,container:C,selected:l?.requestId===b.requestId,tagHidden:!1,quote:{...b,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:B?.options||null,warning:N,fullExpandedMode:s,onClick:Q=>{B||u("warning",N),u("error",B?.options||null),o(Q)},type:"list-item"}),!_&&be.createElement(Xc,{size:16}))}):A&&be.createElement(dy,null,be.createElement(vr,{size:s?"large":"small",error:g,fetch:n}))))}i(Qr,"Quotes");import{darkTheme as NI,styled as yy}from"@rango-dev/ui";var Sy=yy("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${NI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Cy=yy("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var _I=100;function Yc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=LI(!1),l=s?"":"is-hidden",{config:p}=T(),u=p?.variant==="full-expanded",m=_o();return BI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},_I):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),wo.createElement(Sy,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${Zi()} widget-expanded-quotes-container`,id:rt.EXPANDED_BOX_ID},wo.createElement(PI,{title:WI.t("Routes"),suffix:wo.createElement(wo.Fragment,null,wo.createElement(_a,{container:m}),wo.createElement(Vo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),wo.createElement(Cy,null,wo.createElement(Qr,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:_o(),onClickOnQuote:n,fullExpandedMode:u})))}i(Yc,"ExpandedQuotes");import{i18n as xy}from"@lingui/core";import{SwapInput as Iy}from"@rango-dev/ui";import FI from"bignumber.js";import qr from"react";import{ReverseIcon as $I}from"@rango-dev/ui";import Jc from"react";import{keyframes as MI,styled as Ty}from"@rango-dev/ui";var Zc=450,DI=MI({"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)"}}),ky=Ty("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),vy=Ty("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${DI} ${Zc}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 Rc(){let t=G().use.switchFromAndTo();return Jc.createElement(ky,null,Jc.createElement(vy,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Zc),t()}},Jc.createElement($I,{size:12})))}i(Rc,"SwitchFromAndToButton");import{styled as wy}from"@rango-dev/ui";var Ey=wy("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),by=wy("div",{position:"relative"});function ep(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:c,toBlockchain:l,setInputAmount:p,sanitizeInputAmount:u,inputAmount:m,inputUsdValue:f,outputAmount:h,outputUsdValue:g,selectedQuote:d}=G()(),{swapMode:y}=at(),{connectedWallets:S,getBalanceFor:C}=T(),k=a?C(a):null,E=hi(k)?.amount??"0",w=k?new FI(k.amount).shiftedBy(-k.decimals):ue,I=!!s&&Uu(S,s.name),A=!Rs(d,m,f),x=!Rs(d,m,g),b=!f||!g||!g.gt(0)?null:Yt(f.toString(),g.toString());return qr.createElement(Ey,null,qr.createElement(by,null,qr.createElement(Iy,{label:xy.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:E,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:m,usdValue:A?void 0:D(f,4,4),realUsdValue:A?void 0:f?.toString(),error:A?ne().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:I,tooltipContainer:W(),onSelectMaxBalance:()=>{let v=w.isGreaterThan(ue)?w.toFixed():"";p(v)},anyWalletConnected:S.length>0}),y==="swap"&&qr.createElement(Rc,null)),qr.createElement(Iy,{selectionType:y==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!d||e),label:xy.t("To"),mode:"To",id:"widget-swap-to-input",fetchingQuote:e,chain:{displayName:l?.displayName||"",image:l?.logo},token:{displayName:c?.symbol||"",image:c?.image,securityWarning:!!c?.warning},percentageChange:D(Yt(f,g),2,2),warningLevel:Zt(b??0),price:{value:D(h,6,6),usdValue:x?void 0:D(g,4,4),realValue:h?.toString(),realUsdValue:x?void 0:g?.toString(),error:x?ne().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:W()}))}i(ep,"Inputs");import{warn as OI}from"@rango-dev/logging-core";import{useCallback as UI,useEffect as zI,useRef as HI,useState as QI}from"react";function Ay(){let{fetch:t,loading:e,cancelFetch:o}=Ea({request:async(n,r)=>await gt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Ay,"useFetchAllQuotes");var qI=600;function Ma({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Ay(),{excludeLiquiditySources:n,routing:r}=T().config,{connectedWallets:a}=T(),c=a.some(me=>me.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:m,selectedQuote:f,sortStrategy:h,resetQuote:g,error:d,warning:y,setSelectedQuote:S,updateQuotePartialState:C}=G()(),{slippage:k,customSlippage:E,affiliatePercent:w,affiliateRef:I,affiliateWallets:A,fetchStatus:x}=T(),b=T().getLiquiditySources(),v=T().getDisabledLiquiditySources(),N=T().excludeLiquiditySources(),{findToken:B}=T(),{swapMode:_}=at(),[Q,V]=QI(!0),Y=HI(u),P=E??k,X=!l||!p||Vt(l,p)||!Zn(u),ie=i(me=>{V(me)},"resetState"),Te=i(me=>{let{fromToken:Oe,toToken:Qe,inputAmount:kt,liquiditySources:ot,excludeLiquiditySources:Ee,disabledLiquiditySources:z,slippage:q,affiliateRef:$,affiliatePercent:M,affiliateWallets:ce}=me;if(Q||ie(!0),!X&&Oe&&Qe){g();let H=lm({fromToken:Oe,toToken:Qe,inputAmount:kt,liquiditySources:ot,excludeLiquiditySources:Ee,disabledLiquiditySources:z,wallets:a,slippage:q,affiliateRef:$,affiliatePercent:M,affiliateWallets:ce,contractCall:c});fn("experimental",r)&&(H.experimental=!0),fn("avoidNativeFee",r)&&(H.avoidNativeFee=!0),fn("enableCentralizedSwappers",r)&&(H.enableCentralizedSwappers=!0),r?.maxLength&&(H.maxLength=r.maxLength),_==="refuel"&&(H.maxLength=1),e(H).then(ae=>{let qe=$i(h,ae.results),nt=Yd(f,qe,ae.requestAmount);V(!1),C("quotes",ae),S(nt),!ae.results?.length||!nt?$o({type:"routeNotFound",payload:{sourceChain:Oe.blockchain,destinationChain:Qe.blockchain,sourceToken:Oe.symbol,destinationToken:Qe.symbol,inputAmountUsd:m?m.toNumber():null}}):$o({type:"routeRequested",payload:{...On(nt),routeCount:ae.results.length}}),ba({diagnosisMessages:ae.diagnosisMessages,requestId:nt?.requestId||"",swaps:nt?.swaps});let co=nt&&En({currentQuote:nt,userSlippage:P,findToken:B});C("warning",co)}).catch(ae=>{let qe=xa(ae);qe.type===0?$o({type:"routeNotFound",payload:{sourceChain:Oe.blockchain,destinationChain:Qe.blockchain,sourceToken:Oe.symbol,destinationToken:Qe.symbol,inputAmountUsd:m?m.toNumber():null}}):qe.type===1&&$o({type:"routeFetchFailed",payload:{sourceChain:Oe.blockchain,destinationChain:Qe.blockchain,errorCode:String(ae?.response?.status??"")}}),(qe.type===0||qe.type===1)&&g(),qe.type!==2&&(C("error",qe),V(!1),OI(new Error("quote error"),{tags:{...qe,type:Je[qe.type],requestBody:H}}))})}},"fetch"),dt=UI(ci(me=>{Te(me)},qI),[X]);return zI(()=>{if(!t){V(!1);return}if(x!=="success")return;if(X){V(!1),(f||d||y)&&g();return}if(!Zn(u)&&m?.eq(0)){ie(!1),o();return}g(),ie(!0);let me=Te;return Y.current&&Y.current!=u&&(me=dt),Y.current=u,me({inputAmount:u,fromToken:l,toToken:p,liquiditySources:b,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:P,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),o},[x,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,X,b?.length,n,v.length,P,I,w,c,JSON.stringify(A)]),{fetch:()=>Te({inputAmount:u,fromToken:l,toToken:p,liquiditySources:b,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:P,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),loading:Q}}i(Ma,"useSwapInput");var YI=VI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),ZI=300;function By(){let t=XI(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:c,quotes:l,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:m,updateQuotePartialState:f}=G()(),[h,g]=Py(!1),{isLargeScreen:d,isExtraLargeScreen:y}=ga(),{fetch:S,loading:C}=Ma({refetchQuote:a}),{config:k,fetchStatus:E,connectedWallets:w,customSlippage:I,slippage:A,setSlippage:x,setCustomSlippage:b}=T(),{isActiveTab:v}=oe(),[N,B]=Py(!1),_=I!==null?I:A,{swapMode:Q}=at(),V=gn(_),P=rm({fetchMetaStatus:E,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),Z=Vu(d,y,k?.variant),X=!!n&&!!e&&!!o&&new jI(n).gt(0)&&!gm(e,o),ie=X&&E==="success"&&C,Te=V?.quoteValidation||c,Oe=(!Z||Z&&l?.results.length)&&(Te||s),Qe=!!e&&!!o,kt=Qe&&!!V,ot=(r||s)&&!N?S:void 0,Ee=i(M=>{Z&&h?(g(!1),setTimeout(()=>{t(M)},ZI)):t(M)},"onHandleNavigation"),z=i(M=>{r?.requestId!==M.requestId&&(r&&$o({type:"routeChanged",payload:{sourceChain:M.swaps[0]?.from.blockchain??"",destinationChain:M.swaps[M.swaps.length-1]?.to.blockchain??"",fromRouteId:r.requestId,toRouteId:M.requestId}}),B(!1),p(M))},"onClickOnQuote"),q=i(M=>{if(M){if(Ci.includes(M)){x(M),b(null);return}b(M)}},"onChangeSlippage"),$=i(M=>{Ee(M==="from"?O.fromSwap:Q==="swap"?O.toSwap:O.toSwap+"/"+O.blockchains)},"handleInputTokenClick");return Wy(()=>{u(),f("refetchQuote",!0)},[]),Wy(()=>{g(X)},[X]),ke.createElement(YI,null,ke.createElement(se,{height:"auto",footer:ke.createElement(GI,{id:`widget-swap-${P.action}-btn`,type:"primary",size:"large",disabled:P.disabled||!v,prefix:P.action==="confirm-warning"&&ke.createElement(KI,null),fullWidth:!0,onClick:()=>{P.action==="connect-wallet"?dd({type:"clickConnectWallet"},()=>{Bs("swap_button"),Ee(O.wallets)}):P.action==="confirm-warning"?B(!0):r&&(ee({type:"swapInitiated",payload:{...On(r),walletConnected:w.length>0}}),Ee(O.confirmSwap))}},P.title),header:{onWallet:()=>{Bs("nav"),Ee(O.wallets)},hasBackButton:!1,title:k.title||(Q==="swap"?Ny.t("Swap"):Ny.t("Refuel")),suffix:ke.createElement(Vo,{hidden:Z?["refresh"]:void 0,onClickRefresh:ot,onClickHistory:()=>Ee(O.swaps),onClickSettings:()=>{Ee(O.settings)}})}},ke.createElement(pe,null,ke.createElement(ep,{fetchingQuote:ie,fetchMetaStatus:E,isExpandable:Z,onClickToken:$}),ke.createElement(tp,{size:"2"}),Z?null:ke.createElement(Yo,{quote:r,loading:ie,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:Te,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),Ee(O.routes)}:void 0}),Qe&&ke.createElement(ke.Fragment,null,ke.createElement(tp,{size:8}),ke.createElement(Kc,{quoteError:s,quoteWarning:Te,fromToken:e,toToken:o,quote:r,loading:ie})),Oe?ke.createElement(ke.Fragment,null,ke.createElement(Er,{warning:Te,error:s,skipAlerts:!!V,couldChangeSettings:!0,refetchQuote:S,showWarningModal:N,confirmationDisabled:!v,onOpenWarningModal:()=>B(!0),onCloseWarningModal:()=>B(!1),onChangeSlippage:q,onConfirmWarningModal:()=>{B(!1),m(!0),Ee(O.confirmSwap)},onChangeSettings:()=>Ee(O.settings)})):null,kt&&ke.createElement(ke.Fragment,null,ke.createElement(tp,{size:"10"}),ke.createElement(iy,{onChangeSettings:()=>Ee(O.settings)})),ke.createElement(Qc,null))),Z?ke.createElement(Yc,{loading:ie,onClickOnQuote:z,fetch:S,onClickRefresh:ot,isVisible:h}):null)}i(By,"Home");import{i18n as Ly}from"@lingui/core";import{Alert as JI,Divider as RI,List as eA,ListItemButton as tA,Radio as oA,RadioRoot as nA,Typography as rA}from"@rango-dev/ui";import zt from"react";function Eo(){let{setLanguage:t,language:e,config:o}=T(),n=Ju,r=o?.language||hn;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||hn),resetLanguage:()=>t(null)}}i(Eo,"useLanguage");function _y(){let{activeLanguage:t,changeLanguage:e,languages:o}=Eo(),n=Ke(),r=o.map(a=>{let{local:s,label:c,SVGFlag:l}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:zt.createElement(rA,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:zt.createElement(oA,{value:s}),start:zt.createElement(l,null)}});return zt.createElement(se,{header:{title:Ly.t("Language")}},zt.createElement(pe,null,zt.createElement(JI,{type:"warning",id:"widget-language-machine-translation-alarm-alert",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),zt.createElement(RI,{size:"8"}),zt.createElement(nA,{value:t},zt.createElement(eA,{type:zt.createElement(tA,{title:Ly.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(_y,"LanguagePage");import{i18n as io}from"@lingui/core";import{Button as cA,Checkbox as pA,Image as uA,ListItemButton as dA,NotFound as mA,Typography as fA}from"@rango-dev/ui";import tt,{useState as gA}from"react";import{Checkbox as sA,Skeleton as Dy}from"@rango-dev/ui";import Vr from"react";import{styled as op}from"@rango-dev/ui";var Gr=op("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),np=op("div",{width:80,display:"flex",justifyContent:"flex-end"}),rp=op("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as iA,styled as aA}from"@rango-dev/ui";var My=aA(iA,{height:61});var lA=30;function ip(){return Vr.createElement(Gr,null,Array.from(Array(lA),(t,e)=>Vr.createElement(My,{hasDivider:!0,key:e,start:Vr.createElement(Dy,{variant:"circular",width:35,height:35}),title:Vr.createElement(Dy,{variant:"text",size:"large",width:90}),end:Vr.createElement(sA,{checked:!1})})))}i(ip,"LoadingLiquiditySourceList");function ap({sourceType:t}){let e=T().fetchStatus,o=T().swappers(),n=T().getDisabledLiquiditySources(),[r,a]=gA(""),s=T().toggleLiquiditySource,c=T().isInCampaignMode(),l=wi(o,n),p={Exchanges:io.t("Exchanges"),Bridges:io.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=l.filter(S=>u.includes(S.type)),f=m.length===m.filter(S=>S.selected).length,h=i(()=>{ee({type:"settingsChanged",payload:{settingName:"bridge_exclusion",previousValue:`${t}:${f?"all_enabled":"some_disabled"}`,newValue:`${t}:${f?"all_disabled":"all_enabled"}`}}),m.forEach(S=>{f?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),g=m.map(S=>{let{selected:C,groupTitle:k,logo:E,id:w,...I}=S;return{id:`widget-setting-liquidity-source-${Iu(w.toLowerCase())}-item-btn`,start:tt.createElement(uA,{src:E,size:22,type:"circular"}),onClick:()=>{c||(ee({type:"settingsChanged",payload:{settingName:"bridge_exclusion",previousValue:`${k}:${C?"enabled":"disabled"}`,newValue:`${k}:${C?"disabled":"enabled"}`}}),s(k))},end:tt.createElement(pA,{checked:C,disabled:c}),title:tt.createElement(fA,{variant:"title",size:"xmedium"},io.t(k)),selected:C,groupTitle:k,logo:E,...I}}),d=i(S=>{let C=S.target.value;a(C)},"handleSearch"),y=g;return r&&(y=g.filter(S=>Dt(S.groupTitle,r))),tt.createElement(se,{header:{title:io.t(t),suffix:tt.createElement(np,null,tt.createElement(cA,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:h},f?io.t("Deselect all"):io.t("Select all")))}},tt.createElement(pe,{view:!0},tt.createElement(Bt,{value:r,setValue:a,id:"widget-liquidity-source-search-input",fullWidth:!0,color:"light",variant:"contained",placeholder:io.t("Search {sourceType}",{sourceType:p[t]}),onChange:d}),e==="loading"&&tt.createElement(ip,null),!y.length&&r?tt.createElement(rp,null,tt.createElement(mA,{title:io.t("No results found"),description:io.t("Try using different keywords")})):e==="success"&&tt.createElement(Gr,{disabled:c,className:"widget-liquidity-source-list"},y.map(S=>{let{groupTitle:C,...k}=S;return tt.createElement(tt.Fragment,{key:S.id},tt.createElement(dA,{style:{height:"61px"},...k,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(ap,"LiquiditySourcePage");import{i18n as hA}from"@lingui/core";import Da from"react";import{useNavigate as yA}from"react-router-dom";function $y(){let t=yA(),e=Ke(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=G()(),{fetch:c,loading:l}=Ma({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${O.settings}`,m=`../${O.wallets}`;return Da.createElement(se,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:hA.t("Routes"),suffix:Da.createElement(Vo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Da.createElement(pe,null,Da.createElement(Qr,{fetch:c,loading:l,onClickOnQuote:p})))}i($y,"RoutesPage");import{i18n as qy}from"@lingui/core";import{Divider as Gy,getCategoriesCount as IA,SelectableCategoryList as AA}from"@rango-dev/ui";import ao,{useMemo as NA,useState as Vy}from"react";import{useNavigate as WA}from"react-router-dom";import{i18n as sp}from"@lingui/core";import{Divider as kA,Image as vA,ListItemButton as wA,NotFound as EA,Typography as Qy}from"@rango-dev/ui";import Tt,{useEffect as bA,useState as xA}from"react";var Fy=i((t,e,o)=>t.filter(n=>pi(n.type,o)).filter(n=>mt(n.name,e)||mt(n.displayName,e)),"filterBlockchains");import{ImageContainer as SA,styled as Oy}from"@rango-dev/ui";var Uy=Oy("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),$a=Oy(_l,{padding:0,margin:0,listStyle:"none",[`& ${SA}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as CA,Skeleton as zy}from"@rango-dev/ui";import Fa from"react";var TA=20;function Hy(){return Fa.createElement($a,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(TA),t=>Fa.createElement(CA,{key:t,hasDivider:!0,start:Fa.createElement(zy,{variant:"circular",width:35,height:35}),title:Fa.createElement(zy,{variant:"text",size:"large",width:90})})))}i(Hy,"LoadingBlockchainList");function lp(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=xA(e),{fetchStatus:l}=T();bA(()=>{c([...Fy(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?Tt.createElement(EA,{title:sp.t("No results found"),description:sp.t("Try using different keywords")}):Tt.createElement($a,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>Tt.createElement(wA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:Tt.createElement(vA,{src:u.logo,size:30}),title:Tt.createElement(Qy,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return Tt.createElement(Tt.Fragment,null,a&&Tt.createElement(Tt.Fragment,null,Tt.createElement(Qy,{variant:"label",size:"large"},sp.t("Select Chain")),Tt.createElement(kA,{size:4})),Tt.createElement(Uy,null,l==="loading"&&Tt.createElement(Hy,null),l==="success"&&p()))}i(lp,"BlockchainList");function Oa(t){let{type:e}=t,o=Ke(),[n,r]=Vy(""),[a,s]=Vy("ALL"),c=G().use.setToBlockchain(),l=G().use.setFromBlockchain(),p=G().use.setToToken(),{fetchStatus:u,findNativeToken:m}=T(),f=WA(),{swapMode:h}=at(),g=T().blockchains({type:e}),d=T().tokens(),y=NA(()=>wu(g,d),[g.length,d.length]),S=IA(y),C=!t.hideCategory&&S!==1,k=i(E=>{if(e==="custom-token")f(`..?blockchain=${E.name}`,{replace:!0});else{if(ee({type:"chainFilterApplied",payload:{side:e==="source"?"from":"to",chain:E.name,filterSource:"expanded"}}),e==="source")l(E);else if(h==="swap")c(E);else{let w=m(E);w&&p({token:w,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ao.createElement(se,{header:{title:qy.t("Select Chain")}},ao.createElement(pe,{view:!0},C&&ao.createElement(ao.Fragment,null,ao.createElement(AA,{setCategory:s,category:a,blockchains:y,isLoading:u==="loading"}),ao.createElement(Gy,{size:24})),ao.createElement(Bt,{value:n,autoFocus:!0,placeholder:qy.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:E=>r(E.target.value)}),ao.createElement(Gy,{size:16}),ao.createElement(lp,{list:y,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:k})))}i(Oa,"SelectBlockchainPage");import{i18n as Ha}from"@lingui/core";import{Divider as eS,Spinner as GA}from"@rango-dev/ui";import bo,{useEffect as VA,useState as KA}from"react";import{useNavigate as jA}from"react-router-dom";import{i18n as up}from"@lingui/core";import{BlockchainsChip as Ua,Divider as Yy,Image as Zy,Skeleton as DA,Tooltip as $A,Typography as dp}from"@rango-dev/ui";import xe from"react";import{useEffect as LA}from"react";var Ky=["ETH","COSMOS","OSMOSIS"];function cp(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(PA),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let c=o.limit-e.length;for(let l=0;l<=c;l++){let p=n[l];s=s.filter(u=>p?.name!==u)}}n.sort(BA(s)),r=n.splice(a)}return{list:n,more:r}}i(cp,"prepare");function PA(t,e){let o=Ky,n=o.findIndex(c=>c===t.name),r=o.findIndex(c=>c===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(PA,"sortByMostUsedBlockchains");function BA(t){return i(function(o,n){let r=t.findIndex(l=>l===o.name),a=t.findIndex(l=>l===n.name),s=r>-1,c=a>-1;return s&&c?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(BA,"generateSortByPreferredBlockchainsFor");function jy(t,e){return!!e.list.find(o=>o.name===t)}i(jy,"isInVisibleList");function pp(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=T();LA(()=>{if(e?.selected){let a=cp(t,o,e);jy(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=cp(t,o,e);return{list:r.list,more:r.more,history:[]}}i(pp,"usePrepareBlockchainList");import{styled as _A}from"@rango-dev/ui";var Xy=_A("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var FA=6,OA=12;function mp(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=oe(),c=pp(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=T(),p=G().use.resetToBlockchain(),u=G().use.resetFromBlockchain(),m=c.more.length>0,f=c.more[0],h=c.more.length===1&&f,g=!h&&m;return xe.createElement(xe.Fragment,null,!s&&xe.createElement(xe.Fragment,null,xe.createElement(Yy,{size:12}),xe.createElement(dp,{variant:"label",size:"large"},up.t("Select Chain"))),xe.createElement(Yy,{size:12}),xe.createElement(Xy,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?FA:OA),(d,y)=>xe.createElement(DA,{key:y,variant:"rounded",height:50})),l==="success"&&xe.createElement(xe.Fragment,null,xe.createElement(Ua,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},xe.createElement(dp,{variant:"body",size:"xsmall",color:"secondary500"},up.t("All"))),c.list.map(d=>xe.createElement($A,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:W()},xe.createElement(Ua,{className:"widget-blockchains-section-item-btn",key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},xe.createElement(Zy,{src:d.logo,size:30})))),h?xe.createElement(Ua,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},xe.createElement(Zy,{src:f.logo,size:30})):null,g?xe.createElement(Ua,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},xe.createElement(dp,{variant:"body",size:"xsmall",color:"secondary500"},up._("More +{count}",{count:c.more.length}))):null)))}i(mp,"BlockchainsSection");import{useCallback as zA,useRef as HA,useState as fp}from"react";function gp(){let t=T().blockchains(),e=HA(null),{customTokens:o}=T(),[n,r]=fp(!1),[a,s]=fp([]),[c,l]=fp(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await gt().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),d=new Set(o().map(C=>jt(C))),y=new Set(t.map(C=>C.name)),S=g.tokens.filter(C=>y.has(C.blockchain)&&!d.has(jt(C)));s(S),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=zA(ci((f,h)=>{e.current?.signal.aborted||p(f,h)},600),[t.length]);return{fetch:(f,h)=>{e.current=new AbortController,s([]),r(!0),u(f,h)},cancel:i(()=>{e.current?.abort()},"cancel"),loading:n,tokens:a,error:c}}i(gp,"useSearchCustomTokens");function Jy(t,e){return t.trim()?"search":e?"popular":"recent"}i(Jy,"getTokenSelectionMethod");function za(t,e,o){return o&&t.length===1&&t[0]?.address===e?!1:t.length<20&&e.trim().length>=3}i(za,"shouldSearchForCustomTokens");function Ry(t,e,o,n,r){let a=[...t];return za(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(Ry,"prepareTokensList");function Qa(t){let{type:e}=t,o=jA(),n=Ke(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=G()(),{getBalanceFor:u}=T(),{fetch:m,loading:f,tokens:h,cancel:g}=gp(),[d,y]=KA(""),S=e==="source"?r:a,C=S?.name??"",k=T().blockchains({type:e}),E=T().tokens({type:e,blockchain:C,searchFor:d,getBalanceFor:u}),w=Ry(E,h,d,f,S?.name),I=i(b=>{e==="source"?l(b):p(b)},"updateBlockchain"),A=i(b=>{e==="source"?s({token:b,meta:{blockchains:k}}):c({token:b,meta:{blockchains:k}})},"updateToken"),x={source:Ha.t("Source"),destination:Ha.t("Destination")};return VA(()=>(za(E,d,S?.name)&&m(d,S?.name??void 0),()=>{g()}),[E.length,d,S?.name]),bo.createElement(se,{header:{title:Ha.t("Swap {type}",{type:x[e]})}},bo.createElement(pe,null,bo.createElement(mp,{blockchains:k,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(O.blockchains),onChange:b=>{ee({type:"chainFilterApplied",payload:{side:e==="source"?"from":"to",chain:b.name,filterSource:"featured"}}),I(b)}}),bo.createElement(eS,{size:24}),bo.createElement(Bt,{value:d,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:Ha.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>y(""),onChange:b=>y(b.target.value),suffix:za(E,d,S?.name)&&f?bo.createElement(GA,{size:12,color:"secondary"}):void 0}),bo.createElement(eS,{size:16}),bo.createElement(Mr,{list:w,selectedBlockchain:C,searchedFor:d,type:e,onChange:b=>{ee({type:"tokenSelected",payload:{side:e==="source"?"from":"to",tokenName:b.name,tokenSymbol:b.symbol,tokenAddress:b.address,chain:b.blockchain,selectionMethod:Jy(d,b.isPopular),activeChainFilter:C||"all"}}),A(b);let v=k.find(N=>b.blockchain===N.name);v&&I(v),n()}})))}i(Qa,"SelectSwapItemsPage");import{i18n as Cp}from"@lingui/core";import{Alert as kN,Button as vN,styled as wN}from"@rango-dev/ui";import en from"react";import{useInRouterContext as EN,useSearchParams as bN}from"react-router-dom";import{i18n as aS}from"@lingui/core";import{Alert as JA,Divider as yp,InfoIcon as RA,SlippageIcon as eN,TextField as tN,Tooltip as oN,Typography as sS}from"@rango-dev/ui";import ze from"react";import{Chip as XA,styled as Kr,TextField as YA}from"@rango-dev/ui";var tS=Kr("div",{paddingTop:"$5",padding:"$10 $5"}),oS=Kr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${YA}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),nS=Kr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),qa=Kr("div",{maxWidth:"280px",padding:"$10"}),rS=Kr(XA,{width:"61px",flexShrink:0});import{i18n as hp}from"@lingui/core";import{Typography as ZA}from"@rango-dev/ui";import jr from"react";function iS(){return jr.createElement(qa,null,jr.createElement(ZA,{variant:"label",size:"medium",color:"neutral700"},hp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),jr.createElement("br",null),jr.createElement("br",null),jr.createElement("b",null,hp.t("Warning")),":\xA0",hp.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(iS,"SlippageTooltipContent");function Sp(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=T(),r=o!==null?gn(o):null,a=o??t,s=i((u,m)=>{u!==m&&ee({type:"settingsChanged",payload:{settingName:"slippage",previousValue:String(u),newValue:String(m)}})},"emitSlippageChanged"),c=i(u=>{let m=u.target.value,f=parseFloat(m);if(isNaN(f))return n(null);let h=f;f>tr&&(h=tr),s(a,h),n(h)},"onSlippageValueChange"),l=i(u=>{s(a,u),o!==null&&n(null),e(u)},"onClickSlippageChip"),p=i(u=>{let m=u.target,f=m.value;Wu(f)||(m.value=f.slice(0,-1))},"onInput");return ze.createElement(tS,null,ze.createElement(nS,null,ze.createElement(eN,{size:16,color:"gray"}),ze.createElement(yp,{direction:"horizontal",size:4}),ze.createElement(sS,{variant:"title",size:"xmedium"},aS.t("Slippage tolerance per swap")),ze.createElement(yp,{direction:"horizontal",size:4}),ze.createElement(oN,{container:W(),side:"top",sideOffset:4,content:ze.createElement(iS,null)},ze.createElement(RA,{color:"gray"}))),ze.createElement(oS,null,Ci.map((u,m)=>{let f=`slippage-${m}`;return ze.createElement(rS,{id:`widget-slippage-chip-${u.toString()}%-btn`,key:f,onClick:()=>l(u),selected:o===null&&u===t,label:`${u.toString()}%`})}),ze.createElement(tN,{type:"number",min:"0.01",max:"30",step:"0.01",status:r?.type||(o?"success":"default"),id:"widget-slippage-chip-text-input",onInput:p,fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:c,suffix:o&&ze.createElement(sS,{variant:"body",size:"small"},"%"),placeholder:aS.t("Custom")})),r&&ze.createElement(ze.Fragment,null,ze.createElement(yp,{size:10}),ze.createElement(JA,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(Sp,"Slippage");import{i18n as xt}from"@lingui/core";import{AutoThemeIcon as lS,BridgesIcon as nN,ChevronRightIcon as Ga,DarkModeIcon as cS,Divider as Xr,ExchangeIcon as rN,InfinityIcon as iN,InfoIcon as aN,LanguageIcon as sN,LightModeIcon as pS,List as lN,ListItem as cN,ListItemButton as pN,Skeleton as uN,styled as dN,Switch as mN,Tabs as fN,TargetIcon as gN,Tooltip as hN,Typography as ut}from"@rango-dev/ui";import F from"react";import{useNavigate as yN}from"react-router-dom";var SN=dN("div",{width:"202px",height:"$40"}),CN=[{id:"light",icon:F.createElement(pS,{color:"black",size:24}),tooltip:F.createElement(ut,{size:"xsmall",variant:"body"},xt.t("Light"))},{id:"dark",icon:F.createElement(cS,{color:"black",size:24}),tooltip:F.createElement(ut,{size:"xsmall",variant:"body"},xt.t("Dark"))},{id:"auto",icon:F.createElement(lS,{color:"black",size:24}),tooltip:F.createElement(ut,{size:"xsmall",variant:"body"},xt.t("Auto"))}],TN=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return F.createElement(lS,{...e});case"dark":return F.createElement(cS,{...e});default:return F.createElement(pS,{...e})}},"getThemeIcon");function uS(){let t=yN(),{theme:e}=T().config,{setTheme:o,theme:n}=T(),{activeLanguage:r,languages:a}=Eo(),s=a.find(P=>P.local===r)?.label,c=T().fetchStatus,l=T().swappers(),p=T().getDisabledLiquiditySources(),{config:{features:u}}=T(),m=T().customTokens(),f=it("theme",u),h=it("liquiditySource",u),g=it("language",u),d=it("customTokens",u),y=T().infiniteApprove,S=T().toggleInfiniteApprove,C=wi(l,p),k=C.filter(P=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(P.type)),E=k.length,w=k.filter(P=>P.selected).length,I=C.filter(P=>P.type==="DEX"),A=I.length,x=I.filter(P=>P.selected).length,b=i((P,Z)=>{switch(c){case"loading":return F.createElement(uN,{variant:"text",size:"medium",width:50});case"failed":return F.createElement(ut,{variant:"body",size:"medium",color:"$error500"},xt.t("Loading failed"));default:return F.createElement(ut,{variant:"body",size:"medium"},`${P} / ${Z}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Bridges")),end:F.createElement(F.Fragment,null,b(w,E),F.createElement(Xr,{direction:"horizontal",size:8}),F.createElement(Ga,{color:"black"})),onClick:()=>t(O.bridges),start:F.createElement(nN,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Exchanges")),end:F.createElement(F.Fragment,null,b(x,A),F.createElement(Xr,{direction:"horizontal",size:8}),F.createElement(Ga,{color:"black"})),start:F.createElement(rN,{color:"gray",size:16}),onClick:()=>t(O.exchanges)},B={id:"widget-setting-custom-tokens-item-btn",title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Custom Tokens")),end:F.createElement(F.Fragment,null,F.createElement(ut,{variant:"body",size:"medium"},`${m.length}`),F.createElement(Xr,{direction:"horizontal",size:8}),F.createElement(Ga,{color:"black"})),start:F.createElement(gN,{color:"gray",size:16}),onClick:()=>t(O.customTokens)},_={id:"widget-setting-language-item-btn",title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Language")),start:F.createElement(sN,{color:"gray",size:16}),end:F.createElement(F.Fragment,null,F.createElement(ut,{variant:"body",size:"medium"},s),F.createElement(Xr,{direction:"horizontal",size:8}),F.createElement(Ga,{color:"black"})),onClick:()=>t(O.languages)},Q={id:"widget-setting-infinite-approval-item-btn",title:F.createElement(F.Fragment,null,F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Infinite approval")),F.createElement(Xr,{direction:"horizontal",size:4}),F.createElement(hN,{side:"top",sideOffset:4,container:W(),content:F.createElement(qa,null,F.createElement(ut,{variant:"label",size:"medium",color:"neutral700"},F.createElement("b",null,xt.t("Warning")),":\xA0",xt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},F.createElement(aN,{color:"gray"}))),start:F.createElement(iN,{color:"gray",size:16}),end:F.createElement(mN,{checked:y}),onClick:()=>{ee({type:"settingsChanged",payload:{settingName:"infinite_approval",previousValue:String(y),newValue:String(!y)}}),S()}},V={id:"widget-setting-theme-item-btn",type:F.createElement(cN,null),title:F.createElement(ut,{variant:"title",size:"xmedium"},xt.t("Theme")),end:F.createElement(SN,null,F.createElement(fN,{container:W(),items:CN,value:n,className:"widget-setting-theme-item-tabs-container",onChange:P=>o(P.id),type:"primary",borderRadius:"small"})),start:TN(n)},Y=h?[]:[v,N];return d||Y.push(B),g||Y.push(_),Y.push(Q),!e?.singleTheme&&!f&&Y.push(V),F.createElement(lN,{type:F.createElement(pN,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Y})}i(uS,"SettingsLists");var xN=wN("div",{paddingLeft:"$8"});function dS(){let{isInCampaignMode:t,updateCampaignMode:e}=T(),o=t(),[,n]=bN(),r=EN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return en.createElement(se,{header:{title:Cp.t("Settings")}},en.createElement(pe,null,o&&en.createElement(kN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:Cp.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:en.createElement(xN,null,en.createElement(vN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Cp.t("Reset")))}),en.createElement(Sp,null),en.createElement(uS,null)))}i(dS,"SettingsPage");import{i18n as D0}from"@lingui/core";import{cancelSwap as $0}from"@rango-dev/queue-manager-rango-preset";import{useManager as F0}from"@rango-dev/queue-manager-react";import{Alert as O0}from"@rango-dev/ui";import Dp from"react";import{useParams as U0}from"react-router-dom";import{i18n as Qt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as v0,getCurrentStep as w0,getRelatedWalletOrNull as E0}from"@rango-dev/queue-manager-rango-preset";import{Button as aC,Divider as b0,QuoteCost as x0,StepDetails as I0,Typography as Wp}from"@rango-dev/ui";import{useWallets as A0}from"@rango-dev/wallets-react";import sC from"bignumber.js";import{PendingSwapNetworkStatus as qn}from"rango-types";import we,{useEffect as Pp,useRef as Bp,useState as es}from"react";import{useNavigate as N0}from"react-router-dom";import{i18n as xo}from"@lingui/core";var IN=[xo.t("Sunday"),xo.t("Monday"),xo.t("Tuesday"),xo.t("Wednesday"),xo.t("Thursday"),xo.t("Friday"),xo.t("Saturday")];function mS(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?xo.t("Today"):`${IN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(mS,"timeSince");function fS(t){return t.finishTime?mS(parseInt(t.finishTime)):mS(parseInt(t.creationTime))}i(fS,"getSwapDate");import Yr from"react";import{i18n as Va}from"@lingui/core";import{Button as gS,Divider as Tp,MessageBox as AN}from"@rango-dev/ui";import Io from"react";var hS=i(({onCancel:t,onClose:e})=>Io.createElement(Io.Fragment,null,Io.createElement(Tp,{size:20}),Io.createElement(AN,{type:"error",title:Va.t("Cancel Swap"),description:Va.t("Are you sure you want to cancel this swap?")}),Io.createElement(Tp,{size:32}),Io.createElement(gS,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Va.t("Yes, Cancel it")),Io.createElement(Tp,{size:12}),Io.createElement(gS,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Va.t("No, Continue"))),"CancelContent");import{i18n as Ka}from"@lingui/core";import{Button as yS,Divider as kp,MessageBox as NN,Typography as WN}from"@rango-dev/ui";import so from"react";var SS=i(({onDelete:t,onClose:e})=>so.createElement(so.Fragment,null,so.createElement(kp,{size:20}),so.createElement(NN,{type:"error",title:Ka.t("Delete Transaction"),description:Ka.t("Are you sure you want to delete this swap?")}),so.createElement(kp,{size:32}),so.createElement(yS,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Ka.t("Yes, Delete it")),so.createElement(kp,{size:12}),so.createElement(yS,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},so.createElement(WN,{variant:"title",size:"medium",color:"primary"},Ka.t("No, Cancel")))),"DeleteContent");import{i18n as PN}from"@lingui/core";import{Button as BN,Divider as LN,MessageBox as _N}from"@rango-dev/ui";import tn from"react";var CS=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return tn.createElement(tn.Fragment,null,tn.createElement(_N,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&tn.createElement(tn.Fragment,null,tn.createElement(LN,{size:"30"}),tn.createElement(BN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},PN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as JN,getCurrentStep as RN,getRelatedWalletOrNull as e0}from"@rango-dev/queue-manager-rango-preset";import{WalletState as t0}from"@rango-dev/ui";import{useWallets as o0}from"@rango-dev/wallets-react";import xS from"react";import{i18n as Hn}from"@lingui/core";import{Alert as vS,Button as $N,Checkbox as FN,Divider as Ya,Image as ON,MessageBox as UN,Spinner as zN,WarningIcon as HN}from"@rango-dev/ui";import{useWallets as QN}from"@rango-dev/wallets-react";import Ce,{useState as qN}from"react";import{css as MN,darkTheme as DN,styled as vp}from"@rango-dev/ui";var TS=MN({wordWrap:"break-word",display:"block"}),kS=vp("img",{width:"100%"}),ja=vp("div",{position:"relative"}),Xa=vp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${DN} &`]:{$$color:"$warning600"}});var wS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=qN(null),{list:s}=It(),c=oe.use.isActiveTab(),{state:l,connect:p}=QN(),u=s.find(w=>w.type===e.walletType),m=u?.needsNamespace?.data.find(w=>w.value===o?.namespace);if(!u)return null;let f=l(e.walletType),h=u.isHub&&o?.namespace?f.namespaces?.get(o.namespace):null,g=f.connecting||h?.connecting,d=u.isHub?h?.connected:f.connected,y=i(()=>d?Hn.t("Done"):r?Hn.t("Try again"):Hn.t("Connect"),"getButtonTitle"),S=i(()=>g?Ce.createElement(zN,{color:"info"}):r||d?null:Ce.createElement(FN,{checked:!0,disabled:!0}),"getNamespaceSuffix"),C=i(async()=>{try{a(null),await p(u.type,o?.namespace?[{namespace:o?.namespace,network:void 0,derivationPath:e.derivationPath}]:void 0)}catch(w){a(w)}},"handleConnect"),k=i(async()=>{if(d){n();return}C()},"handleClickButton"),E=i(()=>{if(!d)return null;let w=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),I=w?.[w?.length-1];return I?po(I):null},"getAddress");return Ce.createElement(Ce.Fragment,null,Ce.createElement(UN,{type:"warning",title:Hn.t("Connect {wallet}",{wallet:u.title}),description:Hn.t("The connection of your wallet or some networks has been disconnected. Connect to continue the swap"),icon:Ce.createElement(ja,null,Ce.createElement(ON,{src:u.image,size:45}),Ce.createElement(Xa,null,Ce.createElement(HN,{color:"warning",size:10})))}),d&&!m&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ya,{size:10}),Ce.createElement(vS,{type:"success",variant:"alarm",title:Hn.t("Wallet connected successfully.")})),r&&!m&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ya,{size:10}),Ce.createElement(vS,{type:"error",title:r?.message,variant:"alarm"})),m&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ya,{size:30}),Ce.createElement(Oo,{namespace:m,suffix:S(),error:r?.message,connected:d,address:E()})),Ce.createElement(Ya,{size:"40"}),Ce.createElement($N,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:k,disabled:!c},y()))},"ConnectWalletContent");import{i18n as ES}from"@lingui/core";import{Button as GN,Divider as VN,Image as KN,MessageBox as jN,WarningIcon as XN}from"@rango-dev/ui";import{useWallets as YN}from"@rango-dev/wallets-react";import{detectInstallLink as ZN}from"@rango-dev/wallets-shared";import lo from"react";var bS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=YN(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(ZN(n.installLink),"_blank"),"handleButtonClick");return lo.createElement(lo.Fragment,null,lo.createElement(jN,{type:"warning",title:ES.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:lo.createElement(ja,null,lo.createElement(KN,{src:n.img,size:45}),lo.createElement(Xa,null,lo.createElement(XN,{color:"warning",size:10})))}),lo.createElement(VN,{size:"40"}),lo.createElement(GN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},ES.t("Install")))},"InstallWalletContent");var IS=i(t=>{let{swap:e,onClose:o}=t,{state:n,getWalletInfo:r}=o0(),a=RN(e),s=a?e0(e,a):null,c=s?.walletType,l=c?Jn(r(c),n(c)):null,p=a?JN(e,a):null;return c?l===t0.NOT_INSTALLED?xS.createElement(bS,{walletType:c}):xS.createElement(wS,{wallet:s,namespace:p,onClose:o}):null},"WalletStateContent");function wp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return Yr.createElement(R,{open:e,onClose:r,container:W()},o==="connectWallet"&&Yr.createElement(IS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&Yr.createElement(CS,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&Yr.createElement(SS,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&Yr.createElement(hS,{onClose:r,onCancel:()=>{r(),s()}}))}i(wp,"SwapDetailsModal");import{i18n as Zr}from"@lingui/core";import{Button as Ep,Divider as Jr,MessageBox as WS,TokenAmount as n0,Typography as PS}from"@rango-dev/ui";import ve from"react";import{Link as r0,useNavigate as i0}from"react-router-dom";var AS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",NS="/profile";function bp(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:c,token:l,chain:p,percentageChange:u,description:m,diagnosisUrl:f}=t,h=i0(),{showProfileBanner:g}=oe();return ve.createElement(R,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(rt.SWAP_BOX_ID)||document.body},n==="success"?ve.createElement(WS,{type:"success",title:Zr.t("Swap Successful")},ve.createElement(n0,{direction:"vertical",tooltipContainer:W(),id:"widget-swap-details-complete-modal-success-token-amount-container",type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:c},token:l,chain:p,percentageChange:u}),ve.createElement(Jr,{size:12}),ve.createElement(PS,{className:TS(),variant:"body",size:"medium",color:"neutral700",align:"center"},m)):ve.createElement(WS,{type:"error",title:Zr.t("Transaction Failed"),description:m}),ve.createElement(Jr,{size:30}),n==="success"&&ve.createElement(ve.Fragment,null,g&&ve.createElement(ve.Fragment,null,ve.createElement(r0,{to:NS},ve.createElement(kS,{src:AS,alt:"Profile Banner"})),ve.createElement(Jr,{size:30})),ve.createElement(Ep,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},Zr.t("Done"))),ve.createElement(Jr,{size:12}),f&&ve.createElement(ve.Fragment,null,ve.createElement(Ep,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},Zr.t("Diagnosis")),ve.createElement(Jr,{size:12})),ve.createElement(Ep,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},ve.createElement(PS,{variant:"title",size:"medium",color:"primary"},Zr.t("See Details"))))}i(bp,"SwapDetailsCompleteModal");import{i18n as Ra}from"@lingui/core";import{CopyIcon as y0,DoneIcon as S0,IconButton as C0,RangoExplorerIcon as T0,Tooltip as eC,Typography as tC,useCopyToClipboard as k0}from"@rango-dev/ui";import _t from"react";import h0 from"react";import{i18n as d0}from"@lingui/core";import{Alert as YS,IconButton as m0,LinkIcon as f0}from"@rango-dev/ui";import Ao,{Fragment as g0}from"react";import{Alert as s0,ChevronDownIcon as l0,IconButton as c0}from"@rango-dev/ui";import Qn,{useState as p0}from"react";import{css as Rr,darkTheme as BS,styled as Ht,Typography as a0}from"@rango-dev/ui";var LS=Ht(pe,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${BS} &`]:{color:"$secondary500"}}}}}),_S=Ht("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),MS=Ht("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),DS=Ht("div",{padding:"$0 $20 $20 $20"}),T7=Ht("div",{display:"flex",flexDirection:"column",gap:"$10"}),$S=Ht("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),k7=Ht("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),on=Rr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${BS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),FS=Rr({padding:"$5 0"}),Za=Rr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),OS=Rr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),US=Rr({width:"100%",padding:"0 $20 $10"}),zS=Ht("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),HS=Ht("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ja=Ht(a0,{wordBreak:"break-word"});import{styled as xp}from"@rango-dev/ui";var QS=xp("div",{display:"flex",flexDirection:"column",gap:"$10"}),qS=xp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),GS=xp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function VS(t){let{message:e}=t,[o,n]=p0(!1);return Qn.createElement(s0,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&Qn.createElement(c0,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},Qn.createElement(qS,{rotated:o},Qn.createElement(l0,{size:12,color:"gray"}))),footer:Qn.createElement(GS,{open:o},Qn.createElement(Ja,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(VS,"FailedAlert");import{i18n as KS}from"@lingui/core";import{Alert as Ip,Button as jS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as u0}from"rango-types";import ei from"react";function XS(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?ei.createElement(Ip,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:ei.createElement(jS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},KS.t("Change"))}):a===u0.WaitingForConnectingWallet?ei.createElement(Ip,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:ei.createElement(jS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},KS.t("Connect"))}):ei.createElement(Ip,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(XS,"WarningAlert");function Ap(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a,step:s,hasAlreadyProceededToSign:c}=t,l=hr(s),p=s.status==="waitingForApproval"&&!l,u=s.status==="running"&&!l,m=u&&!c||p&&!s.explorerUrl?.length;return Ao.createElement(QS,null,s.explorerUrl?.map((f,h,g)=>{let d=h+f.url,y=h===g.length-1,S=(y&&u||p)&&!m,C=y&&s.status==="failed";return Ao.createElement(g0,{key:d},Ao.createElement(YS,{id:"widget-swap-details-tx-alert",type:y&&(S&&"loading"||C&&"error")||"success",title:f.description?`${f.description} Tx`:d0.t("View transaction"),action:f.url&&Ao.createElement(m0,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Ao.createElement(f0,{size:12}))}))}),m&&Ao.createElement(YS,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Ao.createElement(XS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Ao.createElement(VS,{message:a}))}i(Ap,"SwapDetailsAlerts");var ZS=2e3;var JS=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let c=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:vt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:D(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:vt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:D(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:jn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(l=>({from:{chain:{displayName:vt(l.fromBlockchain,e)??"",image:l.fromBlockchainLogo??""}},to:{chain:{displayName:vt(l.toBlockchain,e)??"",image:l.toBlockchainLogo??""}},swapper:{displayName:jn(l.swapperId,o)??"",image:l.swapperLogo??"",type:l.swapperType}})):[],alerts:h0.createElement(Ap,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function RS(t){if(hr(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(RS,"getStepState");function oC(t){let{requestId:e}=t,[o,n]=k0(ZS);return _t.createElement(MS,{className:on()},_t.createElement(tC,{variant:"label",size:"large",color:"neutral700"},Ra.t("Request ID")),_t.createElement("div",{className:Za()},_t.createElement(tC,{variant:"label",size:"small",color:"neutral700"},e),_t.createElement(eC,{container:W(),content:o?Ra.t("Copied To Clipboard"):Ra.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},_t.createElement(C0,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?_t.createElement(S0,{size:16,color:"secondary"}):_t.createElement(y0,{size:16,color:"gray"}))),_t.createElement(zS,{target:"_blank",href:`${du}/swap/${e}`},_t.createElement(eC,{container:W(),content:Ra.t("View on Rango Explorer"),side:"bottom"},_t.createElement(T0,{size:20})))))}i(oC,"RequestIdRow");import{i18n as nC}from"@lingui/core";import{Typography as rC}from"@rango-dev/ui";import Np from"react";function iC(t){let{date:e,isFinished:o}=t;return Np.createElement("div",{className:on()},Np.createElement(rC,{variant:"label",size:"large",color:"neutral700"},o?nC.t("Finished at"):nC.t("Created at")),Np.createElement(rC,{variant:"label",size:"small",color:"neutral700"},e))}i(iC,"SwapDateRow");var W0=3e3;function Lp(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=A0(),l=T().blockchains(),p=T().swappers(),{findToken:u}=T(),m=G().use.retry(),f=N0(),h=Bp(null),[g,d]=es(!1),[y,S]=es(null),[C,k]=es(null),[E,w]=es(null),I=Bp(y),A=Bp(C),x=We.use.getNotifications(),b=We.use.removeNotification(),v=x(),N=w0(e),B=N?.networkStatus,_=i(Le=>{d(!0),S(Le)},"handleChangeModalState"),Q=i(()=>{d(!1)},"handleCloseModal"),V=i(()=>{k({type:"loading",title:Qt.t("Change Network"),description:`We\u2019re switching the connected network to ${X?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),Y=i(()=>{k({type:"success",title:Qt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),P=i(Le=>{k({type:"error",title:Qt.t("Network Switch Failed"),description:Le?.message||q.detailedMessage.content})},"handleShowSwitchNetworkFailed"),Z=dm(e),X=N?v0(e,N):null,ie=N?E0(e,N):null,Te=fS(e),dt=mm(e),me=i(Le=>!!c(Le)?.mobileWallet,"checkIsMobileWallet"),Oe=!!B&&[qn.WaitingForNetworkChange,qn.NetworkChangeFailed].includes(B),Qe=!!ie?.walletType&&me(ie.walletType),kt=!!ie&&!!X&&a(ie.walletType,X.network,X),ot=!!X&&Oe&&(Qe||kt),Ee=i(()=>{ot&&(V(),s(ie.walletType,[{namespace:X.namespace,network:X.network}]).then(()=>{Y()}).catch(Le=>{P(Le)}))},"handleSwitchNetwork"),z=i(()=>{_("switchNetwork"),Ee()},"handleSwitchNetworkClick"),q=um(e,N,c),$=JS({swap:e,switchNetworkIsAvailable:ot,handleSwitchNetworkClick:z,showNetworkModal:B,setNetworkModal:_,message:q,blockchains:l,swappers:p}),M=$.length,[ce,H]=[e.steps[0],e.steps[M-1]],ae=H?.outputAmount||H?.expectedOutputAmountHumanReadable,qe=e.steps.reduce((Le,Mt)=>Le+parseFloat(Mt.feeInUsd||""),0),nt=e.steps.find(Le=>Le.diagnosisUrl)?.diagnosisUrl,co=D(parseFloat(ae||"0")*(H?.toUsdPrice||0),4,4),Vn=D(parseFloat(e.inputAmount)*(ce?.fromUsdPrice||0),4,4),No=ae?new sC(ae).multipliedBy(H.toUsdPrice||0).toString():"",ni=new sC(e.inputAmount).multipliedBy(ce?.fromUsdPrice||0).toString(),an=Yt(Vn,co),us=q.detailedMessage.content||q.shortMessage,UC=e.status==="success"?Qt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:D(ae,6,6),token:$[M-1]?.to.token.displayName,conciseAddress:po(e.wallets[$[M-1]?.to.chain.displayName||""]?.address||""),chain:$[M-1]?.to.chain.displayName}}):we.createElement(HS,null,we.createElement(Wp,{variant:"body",size:"medium",color:"neutral700",align:"center"},us?"":Qt.t("Transaction was not sent."),Z?`${Qt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:Z.outputAmount,symbol:Z.symbol,blockchain:Z.blockchain}})}`:""),us&&we.createElement(Ja,{align:"center",variant:"body",size:"medium",color:"neutral700"},we.createElement("b",null,"Reason:")," ",us));return Pp(()=>{v.find(Mt=>Mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),b(e.requestId),Q()):E&&w(null))},[e.status,e.requestId]),Pp(()=>{if(ot){if(_("switchNetwork"),B===qn.WaitingForNetworkChange){V();return}if(B===qn.NetworkChangeFailed){P();return}return}if(B===qn.WaitingForConnectingWallet){_("connectWallet");return}if(B===qn.NetworkChanged){_("switchNetwork"),Y();return}y&&["connectWallet","switchNetwork"].includes(y)&&Q()},[B]),Pp(()=>{if(I.current=y,A.current=C,y==="switchNetwork"&&C?.type==="success"){let Le=setTimeout(()=>{I.current==="switchNetwork"&&A.current?.type==="success"&&Q()},W0);return()=>clearTimeout(Le)}},[y,C]),we.createElement(se,{header:{title:Qt.t("Swap Details"),onCancel:e.status==="running"?()=>_("cancel"):void 0,suffix:e.status!=="running"&&we.createElement(ho,null,we.createElement(aC,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>_("delete")},we.createElement(Wp,{size:"medium",variant:"label",color:"error"},Qt.t("Delete"))))},footer:dt&&!E&&we.createElement(aC,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{ee({type:"swapRetried",payload:{routeId:e.requestId}});let Le=Di(e,l,u);m(Le),setTimeout(()=>{f("../../")},0)}},Qt.t("Try again"))},we.createElement(LS,{compact:!0,ref:h},we.createElement(oC,{requestId:o}),we.createElement(iC,{date:Te,isFinished:!!e.finishTime}),we.createElement("div",{className:OS()},we.createElement(x0,{fee:D(String(qe),2,2),time:Yn(di(e.steps)),steps:M}),we.createElement(br,{from:{price:{value:D(e.inputAmount,6,6),usdValue:Vn,realUsdValue:ni,realValue:e.inputAmount},token:{displayName:$[0]?.from.token.displayName||"",image:$[0]?.from.token.image},chain:{image:$[0]?.from.chain.image,displayName:$[0]?.from.chain.displayName||""}},to:{price:{value:D(ae,6,6),usdValue:co,realUsdValue:No,realValue:ae||""},token:{displayName:$[M-1]?.to.token.displayName||"",image:$[M-1]?.to.token.image},chain:{image:$[M-1]?.to.chain.image,displayName:$[M-1]?.to.chain.displayName||""}},percentageChange:D(an,2,2),warningLevel:Zt(an??0)})),we.createElement("div",{className:US()},we.createElement(Wp,{variant:"title",size:"small"},Qt.t("Swaps steps"))),we.createElement(b0,{size:8}),we.createElement(DS,null,$.map((Le,Mt)=>{let Vp=Mt,Kn=e.steps[Mt]&&RS(e.steps[Mt]),zC=Kn==="error"||Kn==="in-progress"||Kn==="warning"||Kn==="completed"&&Mt===$.length-1;return we.createElement(I0,{className:"widget-swap-details-step-item-container",key:Vp,step:Le,type:"swap-progress",ref:h,state:Kn,hasSeparator:Mt!==0,tabIndex:Vp,isFocused:zC,tooltipContainer:W()})}))),we.createElement(wp,{isOpen:g,state:y,switchNetworkModalState:C,onClose:Q,onCancel:r,onDelete:n,message:q.detailedMessage.content,swap:e,handleSwitchNetwork:z}),we.createElement(bp,{open:!!E,diagnosisUrl:nt,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:D(ae,6,6),usdValue:co,realUsdValue:No,realValue:ae||"",percentageChange:D(an,2,2),token:{displayName:$[M-1]?.to.token.displayName||"",image:$[M-1]?.to.token.image},chain:{image:$[M-1]?.to.chain.image},description:UC}))}i(Lp,"SwapDetails");import{i18n as os}from"@lingui/core";import{Divider as pC,NotFound as M0,Skeleton as oi,Typography as ns}from"@rango-dev/ui";import Ae from"react";import{i18n as P0}from"@lingui/core";import{Divider as B0,Skeleton as L0,Typography as _0}from"@rango-dev/ui";import Ie from"react";import{css as qt,styled as _p}from"@rango-dev/ui";var lC=_p("div",{width:"100%",height:"100%",padding:"$10 $20"}),ti=_p("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),ts=_p("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),Y9=qt({display:"flex",justifyContent:"space-between",alignItems:"center"}),Z9=qt({paddingTop:"$15",display:"flex"}),J9=qt({padding:"$15 $0"}),R9=qt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),eZ=qt({paddingBottom:"$10"}),tZ=qt({display:"flex",justifyContent:"start",alignItems:"center"}),oZ=qt({paddingTop:"$5",display:"flex",alignItems:"center"}),nZ=qt({display:"flex",alignItems:"center"}),rZ=qt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),cC=qt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Mp(){return Ie.createElement(lC,null,Ie.createElement(Ar,{type:"swap-preview"}),Ie.createElement("div",{className:"swaps-steps"},Ie.createElement(_0,{variant:"title",size:"small"},P0.t("Swaps steps"))),Ie.createElement(Ie.Fragment,null,Ie.createElement(ti,null,Ie.createElement(Ut,{separator:!1}),Ie.createElement("div",{className:cC()},Ie.createElement(B0,{direction:"horizontal",size:20}),Ie.createElement(L0,{height:22,variant:"rectangular"}))),Ie.createElement(ts,null),Ie.createElement(ti,null,Ie.createElement(Ut,{separator:!1})),Ie.createElement(ts,null),Ie.createElement(ti,null,Ie.createElement(Ut,{separator:!1})),Ie.createElement(ts,null),Ie.createElement(ti,null,Ie.createElement(Ut,{separator:!1}))))}i(Mp,"LoadingSwapDetails");function uC(t){let{requestId:e,showSkeleton:o}=t;return Ae.createElement(se,{header:{title:os.t("Swap Details"),suffix:Ae.createElement(ho,null)}},o&&Ae.createElement(_S,null,Ae.createElement("div",{className:on()},Ae.createElement(ns,{variant:"label",size:"large",color:"neutral700"},`${os.t("Request ID")}`),Ae.createElement("div",{className:Za()},Ae.createElement(ns,{variant:"label",size:"small",color:"neutral700"},Ae.createElement(oi,{width:60,height:10,variant:"rounded"})),Ae.createElement(pC,{direction:"horizontal",size:4}),Ae.createElement(oi,{width:16,height:16,variant:"rectangular"}),Ae.createElement(pC,{direction:"horizontal",size:4}),Ae.createElement(oi,{width:16,height:16,variant:"rectangular"}))),Ae.createElement("div",{className:on()},Ae.createElement(ns,{className:FS(),variant:"label",size:"large",color:"neutral700"},Ae.createElement(oi,{width:60,height:10,variant:"rounded"})),Ae.createElement(ns,{variant:"label",size:"small",color:"neutral700"},Ae.createElement(oi,{width:60,height:10,variant:"rounded"}))),Ae.createElement(Mp,null)),!o&&Ae.createElement($S,null,Ae.createElement(M0,{title:os.t("Not found"),description:os.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(uC,"SwapDetailsPlaceholder");function dC(){let{manager:t,state:e}=F0(),o=!e.loadedFromPersistor,n=bt(t),{requestId:r}=U0(),a=Ke(),{fetchStatus:s}=T();if(!r)return Dp.createElement(O0,{containerStyles:{margin:"20px"},type:"error",title:D0.t("The request ID is necessary to display the swap details.")});let c=o||s==="loading",l=r?n.find(({swap:f})=>f.requestId===r):void 0,p=i(()=>{if(l?.id){let f=t?.get(l.id);f&&(ee({type:"swapCancelled",payload:{routeId:r}}),$0(f))}},"onCancel"),u=i(async()=>{if(l?.id)try{t?.deleteQueue(l.id),a()}catch(f){console.log(f)}},"onDelete"),m=l?.swap;return!m||c?Dp.createElement(uC,{requestId:r,showSkeleton:c}):Dp.createElement(Lp,{swap:m,requestId:r,onCancel:p,onDelete:u})}i(dC,"SwapDetailsPage");import{i18n as mC}from"@lingui/core";import{Divider as z0,getCategoriesCount as H0,SelectableCategoryList as Q0,styled as gC,Typography as q0,Wallet as G0}from"@rango-dev/ui";import Gt,{useState as fC}from"react";var V0=gC("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),K0=gC(pe,{textAlign:"center"});function hC(){let{fetchStatus:t}=T(),[e,o]=fC("ALL"),n=T().blockchains(),{config:r}=T(),[a,s]=fC(),c=oe.use.isActiveTab(),{list:l}=It(),p=zu(l,n),m=H0(p)!==1,f=Hu(l,e),h=i(g=>{ku(l,r.multiWallets)||s(g)},"handleWalletItemClick");return Gt.createElement(se,{header:{title:mC.t("Connect Wallets")}},Gt.createElement(K0,null,m&&Gt.createElement(Gt.Fragment,null,Gt.createElement(Q0,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Gt.createElement(z0,{size:24})),Gt.createElement(q0,{variant:"title",size:"xmedium",align:"center"},mC.t("Choose a wallet to connect.")),Gt.createElement(V0,null,f.map((g,d)=>{let y=`wallet-${d}-${g.type}`;return Gt.createElement(G0,{key:y,...g,state:g.state,container:W(),onClick:()=>h(g),isLoading:t==="loading",disabled:!c})}),Gt.createElement(fr,{id:"widget-state-full-connect-modal",wallet:a,onClose:()=>{s(void 0)}}))))}i(hC,"WalletsPage");function yC(){return Em(),al(),j0([{path:O.home,element:He.createElement(By,null)},{path:O.routes,element:He.createElement($y,null)},{path:O.fromSwap,children:[{index:!0,element:He.createElement(Qa,{type:"source"})},{path:O.blockchains,element:He.createElement(Oa,{type:"source"})}]},{path:O.toSwap,children:[{index:!0,element:He.createElement(Qa,{type:"destination"})},{path:O.blockchains,element:He.createElement(Oa,{type:"destination"})}]},{path:O.settings,children:[{index:!0,element:He.createElement(dS,null)},{path:O.languages,element:He.createElement(_y,null)},{path:O.exchanges,element:He.createElement(ap,{sourceType:"Exchanges"})},{path:O.bridges,element:He.createElement(ap,{sourceType:"Bridges"})},{path:O.customTokens,children:[{index:!0,element:He.createElement(_h,null)},{path:O.addCustomTokens,children:[{index:!0,element:He.createElement(wf,null)},{path:O.blockchains,element:He.createElement(Oa,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:O.swaps,children:[{index:!0,element:He.createElement(ey,null)},{path:O.swapDetails,element:He.createElement(dC,null)}]},{path:O.wallets,element:He.createElement(hC,null)},{path:O.confirmSwap,element:He.createElement(Sh,null)}])}i(yC,"AppRoutes");import{useQueueManager as mW}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as fW}from"rango-sdk";import{useContext as gW,useEffect as Up,useState as NC}from"react";import{Provider as eW}from"@rango-dev/wallets-react";import{WalletTypes as tW}from"@rango-dev/wallets-shared";import rs,{createContext as oW,useEffect as vC,useMemo as nW,useRef as wC}from"react";import{useEffect as Y0}from"react";import{Provider as X0}from"@rango-dev/wallets-core";function SC(t){return t.map(e=>typeof e=="string"?e:e instanceof X0?e.id:e.config.type).join("-")}i(SC,"hashProviders");function $p(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=T(),a=n();return Y0(()=>{o(),r()},[SC(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i($p,"useWalletProviders");import{legacyFormatAddressWithNetwork as Z0,legacyReadAccountAddress as CC}from"@rango-dev/wallets-core/legacy";import{Events as nn}from"@rango-dev/wallets-react";import{isEvmBlockchain as J0}from"rango-sdk";function TC(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=T(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(J0).map(d=>d.name),u=i((d,y)=>{let[S,,C,k,E]=d,w={walletType:S,network:k.network??void 0,accounts:C};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?");let I=ks(S,C,p,y.supportedChainNames,E.isContractWallet);I.length&&e(I,E.namespace,k.derivationPath,{walletName:S})},"onAccountsEvent"),m=i((d,y,S,C,k)=>{if(y===nn.ACCOUNTS){let E=Rn(k.supportedBlockchains);S&&u([d,y,S,C,k],{supportedChainNames:E})}y===nn.PROVIDER_DISCONNECTED&&(o(d),l.current?l.current(d):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),y===nn.NAMESPACE_DISCONNECTED&&n(d,S)},"handleUpdatesForHub"),f=i((d,y,S,C,k)=>{if(y===nn.ACCOUNTS){let E=Rn(k.supportedBlockchains),w=[],I=[];if(S?.forEach(x=>{let{network:b}=CC(x);p.includes(b)?w.push(x):I.push(x)}),r.filter(x=>x.walletType===d).map(x=>Z0(x.address,x.chain)).length>0){if(w.length>0){let x=ks(d,w,p,E,k.isContractWallet);a(d,{chains:x.map(b=>b.chain)})}I.length>0&&a(d,{chains:I.map(x=>{let{network:b}=CC(x);return b})})}S?u([d,y,S,C,k],{supportedChainNames:E}):(o(d),l.current?l.current(d):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((d,y,S,C,k)=>{if(y===nn.CONNECTED&&S){let E={walletType:d,network:C.network??void 0,accounts:C.accounts??void 0};c.current?c.current(E):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(y===nn.NETWORK&&S){let E={walletType:d,network:S,accounts:C.accounts??void 0};c.current?c.current(E):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((d,y,S,C,k)=>{y===nn.CONNECTING&&nd(d),k.isHub?m(d,y,S,C,k):f(d,y,S,C,k),h(d,y,S,C,k)},"handler")}}i(TC,"useUpdates");import{LegacyEvents as R0}from"@rango-dev/wallets-core/legacy";function kC(t,e){let[o,n,r,a,s]=e;n!==R0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(kC,"propagateEvents");var is=oW({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function rW(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=T(),a=T().blockchains(),s=T().config,c={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:l}=$p(s.wallets,c),p=wC(),u=wC(),{handler:m}=TC({onConnectWalletHandler:p,onDisconnectWalletHandler:u});vC(()=>{n().catch(console.log)},[]),vC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=oe.use.isActiveTab(),h=nW(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return rs.createElement(is.Provider,{value:h},rs.createElement(eW,{allBlockChains:a,providers:l,onUpdateState:(g,d,y,S,C)=>{let k=[g,d,y,S,C];m(...k),t.onUpdateState&&kC(t.onUpdateState,k)},autoConnect:!!f,configs:{wallets:s.wallets,walletOptions:{[tW.TON_CONNECT]:{provider:{manifestUrl:s.tonConnect?.manifestUrl}}}}},t.children))}i(rW,"Main");function as(t){let{config:e,...o}=t;return rs.createElement(ud,{config:e},rs.createElement(rW,{...o,config:e}))}i(as,"WidgetWallets");import{globalCss as iW}from"@rango-dev/ui";var EC=i(()=>iW({"@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");import{useWallets as aW}from"@rango-dev/wallets-react";import{useEffect as sW,useRef as lW}from"react";function bC(){let{connect:t,state:e}=aW(),o=lW({}),{fetchStatus:n}=T(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);sW(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(bC,"useForceAutoConnect");import{isApprovalTX as cW,RouteEventType as xC,StepEventType as IC,StepExecutionEventStatus as pW,WidgetEvents as ss}from"@rango-dev/queue-manager-rango-preset";import{useEffect as AC}from"react";function Fp(){let t=We.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=T();AC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===IC.TX_EXECUTION&&s.status===pW.TX_SENT&&!cW(c)||s.type===IC.SUCCEEDED){let u=[],m=l.wallets[c?.fromBlockchain];if(m){let f=e.find(h=>h.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&h.walletType===m.walletType&&h.chain===c?.fromBlockchain);f&&u.push(f)}if(c?.fromBlockchain!==c?.toBlockchain){let f=l.wallets[c?.toBlockchain];if(f){let h=e.find(g=>g.address?.toLocaleLowerCase()===f.address?.toLocaleLowerCase()&&g.walletType===f.walletType&&g.chain===c?.toBlockchain);h&&u.push(h)}}if(u.length>0){let f=n(),g=[{blockchain:c.fromBlockchain,address:c.fromSymbolAddress,symbol:c.fromSymbol},{blockchain:c.toBlockchain,address:c.toSymbolAddress,symbol:c.toSymbol}].filter(d=>f.some(y=>y.blockchain===d.blockchain&&y.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&y.symbol?.toLocaleLowerCase()===d.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return de.on(ss.StepEvent,r),()=>de.off(ss.StepEvent,r)},[de,e]),AC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===xC.FAILED||s.type===xC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return de.on(ss.RouteEvent,r),()=>de.off(ss.RouteEvent,r)},[de])}i(Fp,"useSubscribeToWidgetEvents");import{useManager as uW}from"@rango-dev/queue-manager-react";import{useEffect as dW}from"react";function Op(){let{isSynced:t,syncNotifications:e}=We(),{manager:o,state:n}=uW();dW(()=>{if(We.persist.hasHydrated()&&n.loadedFromPersistor&&!t){let a=bt(o);e(a),a.forEach(({swap:s})=>{if(!(s.status==="running"&&s.steps.length>1))return;let l=s.steps.findIndex(p=>p.status!=="success");ee({type:"swapResumed",payload:{routeId:s.requestId,stepCount:s.steps.length,stepNumber:l===-1?s.steps.length:l+1}})})}},[We.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Op,"useSyncNotifications");function zp(){bC(),EC(),Fp(),Op();let t=T().blockchains(),{canSwitchNetworkTo:e}=ra(),[o,n]=NC(null),[r,a]=NC(),s=gW(is),c=t.filter(fW);Up(()=>()=>vm(),[]),Up(()=>()=>wm(),[]),mW({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Up(()=>(Fo.init(),We.persist.hasHydrated()||We.persist.rehydrate(),s.onConnectWallet(l=>{n(p=>{if(!p||p.walletType!==l.walletType)return l;let u={...p};return l.network&&(u.network=l.network),l.accounts&&(u.accounts=l.accounts),u})}),s.onDisconnectWallet(l=>{a(l),n(p=>l===p?.walletType?null:p)}),Fo.destroy),[])}i(zp,"useBootstrap");import{styled as hW}from"@rango-dev/ui";var WC=hW("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left",height:"100%","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function rn(){zp();let{config:t}=T(),{activeTheme:e}=go(t?.theme||{}),{activeLanguage:o}=Eo();return Hp.createElement(yW,{language:o},Hp.createElement(WC,{id:"swap-container",className:e()},Hp.createElement(yC,null)))}i(rn,"Main");import{setSolanaSignerConfig as $W}from"@rango-dev/signer-solana";import qp,{useEffect as Gp,useMemo as FW}from"react";function PC(){let{setWatermark:t,setShowProfileBanner:e}=oe();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Kt("BASE_URL")}/meta/dapp/config?apiKey=${Kt("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(PC,"useFetchApiConfig");import{useState as SW}from"react";var CW=i(()=>{let[t,e]=SW(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=Tu(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),BC=CW;import{checkWaitingForNetworkChange as TW,makeQueueDefinition as kW}from"@rango-dev/queue-manager-rango-preset";import{Provider as vW}from"@rango-dev/queue-manager-react";import{useWallets as wW}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as EW}from"@rango-dev/wallets-shared";import{isEvmBlockchain as bW}from"rango-types";import xW,{useMemo as IW}from"react";function AW(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s,hubProvider:c}=wW(),l=IW(()=>kW({API_KEY:t.apiKey||Kt("API_KEY"),BASE_URL:Kt("BASE_URL"),emitter:{emit:de.emit}}),[t.apiKey]),{blockchains:p,connectedWallets:u}=T(),m=p(),f={blockchains:u.map(w=>({accounts:[w],name:w.chain}))},h=i(async(w,I)=>a(w,I.network,I)?await r(w,[I]):void 0,"switchNetwork"),g=i(w=>!!s(w).mobileWallet,"isMobileWallet"),d=m.filter(w=>w.enabled).reduce((w,I)=>(w[I.name]=I,w),{}),y=m.filter(bW),S=i(w=>{let{supportedChains:I}=s(w);return Rn(I)},"getSupportedChainNames"),C=e(),k={meta:{blockchains:d,evmBasedChains:y,evmNetworkChainInfo:EW(y),getSupportedChainNames:S},getSigners:o,wallets:f,providers:C,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g,hubProvider:c},E=oe.use.isActiveTab();return xW.createElement(vW,{queuesDefs:[l],context:k,onPersistedDataLoaded:w=>{TW(w)},isPaused:!E},t.children)}i(AW,"QueueManager");var LC=AW;import{useManager as LW}from"@rango-dev/queue-manager-react";import _W,{createContext as MW,useContext as DW}from"react";function _C(){let{findToken:t}=T(),e=T().blockchains(),o=T().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:c}=G()();return i(p=>{let{fromBlockchain:u,fromToken:m,toBlockchain:f,toToken:h,requestAmount:g}=p,d={blockchains:e,tokens:o};if(u!==void 0){let y=e.find(S=>S.name===u)??null;n(y)}if(m!==void 0){let y=m?t(m)??null:null;r({meta:d,token:y})}if(f!==void 0){let y=e.find(S=>S.name===f)??null;a(y)}if(h!==void 0){let y=h?t(h)??null:null;s({meta:d,token:y})}g!==void 0&&c(g)},"updateQuoteInputs")}i(_C,"useUpdateQuoteInputs");import{cancelSwap as NW,getCurrentNamespaceOfOrNull as WW,getCurrentStep as PW,getRelatedWalletOrNull as BW}from"@rango-dev/queue-manager-rango-preset";var ls=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return bt(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=Di(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&NW(o)}getCurrentStepInfo(e){let o=PW(e);return{step:o,wallet:o?BW(e,o):null,network:o?WW(e,o)?.network:null}}};var MC=MW(void 0);function Qp(t){let{manager:e}=LW(),o=oe.use.isActiveTab(),n=G().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=T(),l=new ls(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=T(),u=Du(a()),m=T().blockchains(),f=T().tokens(),h=T().swappers(),g=T().fetchStatus,d=Eo().resetLanguage,y=We().getNotifications(),S=We().clearNotifications,C=_C(),{fromBlockchain:k,toBlockchain:E,fromToken:w,toToken:I,inputAmount:A}=G()(),x={isActiveTab:o,setCurrentTabAsActive:Fo.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async b=>c(b)},meta:{blockchains:m,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:d,notifications:{list:y,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:E?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:A},updateQuoteInputs:C}};return _W.createElement(MC.Provider,{value:x},t.children)}i(Qp,"WidgetInfo");function DC(){let t=DW(MC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(DC,"useWidget");function Gn(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=PC(),{handleLoadCustomFont:a}=BC();return Gp(()=>{r().catch(console.log)},[]),Gp(()=>{n&&a(n)},[n]),FW(()=>{Qu({API_KEY:o?.apiKey||lu(),BASE_URL:o?.apiUrl||uu})},[o.apiKey,o.apiUrl]),Gp(()=>{t.config?.signers?.customSolanaRPC&&$W("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),qp.createElement(as,{config:o,onUpdateState:e},qp.createElement(LC,{apiKey:o.apiKey},qp.createElement(Qp,null,t.children)))}i(Gn,"WidgetProvider");function $C(t){let e=t.config?.externalWallets;return cs.createElement(_i,null,e?cs.createElement(rn,null):cs.createElement(Gn,{config:t.config??cn},cs.createElement(rn,null)))}i($C,"Refuel");import ps from"react";function FC(t){let e=t.config?.externalWallets;return ps.createElement(_i,null,e?ps.createElement(rn,null):ps.createElement(Gn,{config:t.config??cn},ps.createElement(rn,null)))}i(FC,"Widget");function OC(){let{on:t,off:e}=de;return{on:t,off:e}}i(OC,"useWidgetEvents");var aoe={DerivationPath:ur,Namespaces:lr,Detached:pr,isOnDerivationPath:mr,isOnNamespace:dr,isOnDetached:Wo};export{Nte as EventSeverity,mn as MainEvents,Ote as Networks,Hte as PendingSwapNetworkStatus,or as QuoteEventTypes,$C as Refuel,Wte as RouteEventType,hs as SUPPORTED_FONTS,aoe as StatefulConnect,Pte as StepEventType,Bte as StepExecutionBlockedEventStatus,Lte as StepExecutionEventStatus,Fd as SwapModeContext,rt as UI_ID,Re as UiEventTypes,vi as WalletEventTypes,$te as WalletEvents,Ute as WalletTypes,FC as Widget,mn as WidgetEvents,Gn as WidgetProvider,as as WidgetWallets,Tl as customizedThemeTokens,fs as pickProviderVersionWithFallbackToLegacy,Mte as readAccountAddress,sn as useStatefulConnect,It as useWalletList,ra as useWallets,DC as useWidget,OC as useWidgetEvents,GT as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map